page: '.array_pop(explode('/', $array['file'])).' function: '.$array['function'].' line: '.$array['line'].'
'; return get_functions($trace).$str; } } //Query function, all MySQL query's run though this, //$var, raw query string. //$print, output this for viewing purposes. function query($var, $print = false){ global $mysql_query_info, $config; if ($config['QUERY_OUTPUT'])//if in "development" show all query's. $print = true; $time = microtime(true);//store current time for timing purposes. $data = mysql_query($var);// run query $time = round(microtime(true)-$time, 6);//get the time the query ran. if ($time > 0.5){//if the time is longer then half a second... trigger_error($time.' - '.$var);//notify me thoguh a php error. } if ($print){//if print, store information to a structured array to be outputted at the end of file execution. $rows = mysql_affected_rows(); $str = ''; if (mysql_errno() == 0 && strpos($var, 'SELECT') === 0){// see if this a select query that has not errored and if it is run a mysql EXPLAIN to check for database optimizations. $dat = mysql_query('EXPLAIN '.$var); $outarr = array(); while($exp = mysql_fetch_assoc($dat)){// for each table find, format, and save the output. $str1 = array(); $str2 = array(); foreach($exp as $key => $val){ $str1[] = $key; $str2[] = $val; } if (empty($outarr)) $outarr[] = ''.implode('', $str1).''; $outarr[] = ''.implode('', $str2).''; } $str = '
'.implode('', $outarr).'
'; } $mysql_query_info[] = array('time' => $time, 'query' => $var.$str, 'affected' => $rows, 'trace' => get_functions(debug_backtrace())); } if (mysql_errno() != 0){// if there is a MySQL error, append output to display error, and log error in database. $mysql_query_info[count($mysql_query_info)-1]['query'] .= '
Query failed: error# '.mysql_errno().' -- '.mysql_error().'
'.get_functions(debug_backtrace()).'
'; mysql_query('INSERT INTO error (log_id, info, error_no, error) VALUES ('.$config['LOG_ID'].', \''.mysql_real_escape_string($var).'\', '.mysql_errno().', \''.mysql_real_escape_string(mysql_error()).'\')'); } return $data; } function error_handle($code, $msg, $file, $line, $var_dump) { global $error_info, $config; $error_info[] = $code.' : '.$msg.' : '.$file.' : '.$line; query('INSERT INTO error_php (log_id, code, msg, file, line, var_dump) VALUES ('.$config['LOG_ID'].', '.$code.', \''.mysql_real_escape_string($msg).'\', \''.mysql_real_escape_string($file).'\', '.$line.', \'\')');//\''.mysql_real_escape_string(serialize($var_dump)).'\')'); } ?>