<?php

defined('WikyBlog') or die("Not an entry point...");

function showError2($errno, $errmsg, $filename, $linenum, $vars){
	global $page,$jsNum,$dbObject;
	
	// for "Undefined variable"
	if( $errno === 2048 ){
		return;
	}
	
	// for functions prepended with @ symbol to suppress errors
	if($errno === 0){
		return;
	}	

	
	if( !isset($page->contentA['Debug Error Message']) ){
		//$page->regLink('/include/errorlocal','Debug Error Message');
		$page->contentA['Debug Error Message'] = '';
	}
	
	
	 $errortype = array (
				E_ERROR				=> "Error",
				E_WARNING			=> "Warning",
				E_PARSE				=> "Parsing Error",
				E_NOTICE 			=> "Notice",
				E_CORE_ERROR		=> "Core Error",
				E_CORE_WARNING 		=> "Core Warning",
				E_COMPILE_ERROR		=> "Compile Error",
				E_COMPILE_WARNING 	=> "Compile Warning",
				E_USER_ERROR		=> "User Error",
				E_USER_WARNING 		=> "User Warning",
				E_USER_NOTICE		=> "User Notice",
				E_STRICT			=> "Runtime Notice"
			 );

	$mess = '';
	$mess .= '<fieldset style="padding:1em">';
	$mess .= '<legend>'.$errortype[$errno].' ('.$errno.')</legend> '.$errmsg;
	$mess .= '<br/> &nbsp; &nbsp; <b>in:</b> '.$filename;
	$mess .= '<br/> &nbsp; &nbsp; <b>on line:</b> '.$linenum;
	
	if( mysql_errno() ){
		$mess .= '<br/> &nbsp; &nbsp; Mysql Error ('.mysql_errno().')'. mysql_error();
	}
	if( ($errno !== E_NOTICE) &&($errno != E_STRICT)){
		$page->scripts['local'] = '/include/js/local.js?'.$jsNum;
		$mess .= '<div><a href="javascript:void(0)" onclick="showBacktrace(this);return false;">Show/Hide Backtrace</a>';
		$mess .= '<div style="display:none">';
		
		$temp = debug_backtrace();
		@array_shift($temp); //showError2()
		@array_shift($temp); //showError()
		$mess .= showArray($temp);
		
		$mess .= '</div>';
		$mess .= '</div>';
	}
	$mess .= '</p>';
	$mess .= '</fieldset>';

	$page->contentA['Debug Error Message'] .= $mess;
}


function debugVariables(){
	global $pageOwner;

	$text = '<div style="background-color:white;padding:10px">';
	$text .= '<h2>PageOwner</h2>';
	$text .= showArray($pageOwner);
	$text .= '</div><p>';
	
	$text .= '<div style="background-color:white;padding:10px">';
	$text .= '<h2>SESSION</h2>';
	$text .= showArray($_SESSION);
	$text .= '</div><p>';
	
	return $text;
}
/*
if( $localHost == true && false ){
	$text .= '<div style="background-color:white;padding:10px">';
	$text .= '<h2>Headers</h2>';
	$headers = getallheaders();
	$text .= showArray($headers);
	$text .= '</div><p>';
	
	echo '<div style="background-color:white;padding:10px">';
	echo '<h2>Event</h2>';
	unset($dbObject->content);
	echo showArray($dbObject);
	echo '</div>';
	
	echo '<div style="background-color:white;padding:10px">';
	echo '<h2>Session</h2>';
	echo showArray($_SESSION);
	echo '</div><p>';	
	
	echo '<div style="background-color:white;padding:10px">';
	echo '<h2>Owner</h2>';
	echo showArray($pageOwner);
	echo '</div><p>';	
		
	echo '<div style="background-color:white;padding:10px">';
	echo '<h2>Cookie</h2>';
	echo showArray($_COOKIE);
	echo '</div><p>';
	
	ob_start();
	print_r($_POST);
	return nl2br(wb::get_clean());
	
}
*/