"; //echo $output."\n"; $message = $output; $title = "Debug message:"; include BASE_PATH."/system/templates/message.tpl.php"; } } //--- //------------------------------------------------- // Simple key/value debug to save a small // amount of time. function df($value,$key="output:"){ $db = new DB; if (has_perm($db,"perm_debug") ){ echo $key.":".$value."
"; } } //--- //------------------------------------------------- // debugs an array function debugr($output,$permOverride = false){ debug_textarea(print_r($output,true),$permOverride); } //--- //------------------------------------------------- // debug inside a textbox, for html debugging function debug_textarea($output,$permOverride = false){ $db = new DB; if (has_perm($db,"perm_debug") || $permOverride == true){ $output = "\n"; $message = $output; $title = "Debug message:"; include BASE_PATH."/system/templates/message.tpl.php"; } } //--- //------------------------------------------------- // send a message to the screen, but only if the // user is logged in as an admin function admin_message($output){ $message = $output; $title = "Admin message:"; include BASE_PATH."/system/templates/message.tpl.php"; } //--- //------------------------------------------------- // Error handling function error($message,$fatal=false,$silent = false){ global $page_data,$db; if ($fatal) $title = "Fatal system error:"; else $title = "System error:"; $message .= "

This error has been logged and a technician has been notified.
Please click here to return to the website"; //include BASE_PATH."/system/templates/message.tpl.php"; if ($silent == false) { include BASE_PATH."/system/templates/message.tpl.php"; } // email the error to admin $page_id = isset($_REQUEST['page_id']) ? $_REQUEST['page_id'] : ""; audit($db,"system_error","".$page_id."".$message.""); if ($fatal){ if (EMAIL_ERRORS){ //audit($db,"error_emailed","".$errline."".$errfile.""); email_error($title,$message); } } //perform error notification here if ($fatal){ ob_end_flush(); echo $page_data; exit(1); } } //--- //-------------------------------------------------- // Error handler function errorHandler ($errno, $errstr, $errfile, $errline, $errcontext){ global $db; // only manage the error if the error type wants to be reported // by the current error settings -as set by error_reporting() if (!($errno & error_reporting())) return; switch ($errno) { case E_ERROR: $type = "ERROR"; break; case E_WARNING: $type = "WARNING"; break; case E_NOTICE: $type = "NOTICE"; break; case E_PARSE: $type = "PARSE ERROR"; break; case E_USER_ERROR: $type = "ERROR"; break; case E_USER_WARNING: $type = "WARNING"; break; case E_USER_NOTICE: $type = "NOTICE"; break; default: $type = "Unkown error type: [$errno] $errstr
\n"; break; } $title = "Base Error:"; $message = ""; $message .= "

".$type.": $errstr (# $errno).

\n"; $message .= "

Error in line $errline of file '$errfile'.

\n"; $message .= "

Script: '{$_SERVER['PHP_SELF']}'.

\n"; $message .= "This error has been logged and a technician has been notified.
Please click here to return to the website"; include BASE_PATH."/system/templates/message.tpl.php"; if (isset($errcontext['this'])) { if (is_object($errcontext['this'])) { $classname = get_class($errcontext['this']); $parentclass = get_parent_class($errcontext['this']); $message .= "

Object/Class: '$classname', Parent Class: '$parentclass'.

\n"; } } if (EMAIL_ERRORS){ //audit($db,"error_emailed","".$errline."".$errfile.""); email_error($title,$message); } audit($db,"error","".(isset($_REQUEST['page_id']) ? $_REQUEST['page_id'] : "")."".$errno."".$errstr."".$errline."".$errfile.""); //ob_end_flush(); //echo $page_data; } //--- //-------------------------------------------------- // Error emailer function email_error($subject,$message){ global $db; // if we've spammed EMAIL_ERRORS_TO in the last five minutes then dont send another email $ts_five_mins_ago = mktime( date("H"), // hours date("i")-5, // mins date("s"), // seconds date("m"), // months date("d"), // days date("Y") // year ); // get the request data if (isset($_REQUEST)){ $req = print_r($_REQUEST,true); $req = nl2br($req); $message .= "

_REQUEST Data

".$req.""; } // get the server data if (isset($_SERVER)){ $ser = print_r($_SERVER,true); $ser = nl2br($ser); $message .= "

_SERVER Data

".$ser."

"; } $five_mins_ago = date("Y-m-d H:i:s",$ts_five_mins_ago); $db->query("SELECT * FROM audit WHERE name='error_emailed' AND date > '".$five_mins_ago."'"); if ($db->num_rows() == 0){ html_email(EMAIL_ERRORS_TO,SITE_CONTACT,BASE_URL."::".$subject,$message,$message); audit($db,"error_emailed","".EMAIL_ERRORS_TO.""); } } //--- ?>",$page['name'],$source); $source = str_replace("",$page['label'],$source); $source = str_replace("",$page['index_id'],$source); // generate the title based on what has been set explitally, // otherwise generate it based on the page name if (isset($page['page_title']) && $page['page_title'] != ""){ $source = str_replace("",$page['page_title'],$source); }else{ $source = str_replace("",$page['name']." - ".$site_title,$source); } $source = str_replace("",$site_title,$source); // either use the keywords specific to this page, or the site default $page_description = get_option($db,"admin_settings","site_description"); if ($page['page_description'] !="") $page_description = $page['page_description']; $page_keywords = get_option($db,"admin_settings","site_keywords"); if ($page['page_keywords'] !="") $page_keywords = $page['page_keywords']; $source = str_replace("",$page_keywords,$source); $source = str_replace("",$page_description,$source); // replace all request. tags preg_match_all ("//", $source, $matches); for ($i=0; $i< count($matches[0]); $i++) { if (isset($matches[1][$i])){ $tag = trim($matches[1][$i]); //debugr("found request:".$tag); $source = str_replace("",assign_if_set($tag),$source); } } preg_match_all ("//", $source, $matches); //debug_textarea(print_r($matches,true)); //debug ("