public static function mobile_show_error($type, $errormsg, $phpmsg) { global $_G; ob_end_clean(); ob_start(); $host = $_SERVER['HTTP_HOST']; $phpmsg = trim($phpmsg); $title = 'Mobile ' . ($type == 'db' ? 'Database' : 'System'); //出错处理 改为记日志而不是直接输出到页面 $endmsg = lang('error', 'mobile_error_end_message', array('host' => $host)); $messagesave = $host . '\\r' . $title . '\\r\\n' . $errormsg . '\\r\\n' . $type . '\\r\\n' . $endmsg; !empty($phpmsg) && ($messagesave = $messagesave . '\\r\\n' . var_export($phpmsg, true)); discuz_error::write_error_log($messagesave); header("Location: /"); exit; echo <<<EOT <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html> <head> \t<title>{$host} - {$title} Error</title> \t<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \t<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" /> \t<style type="text/css"> \t<!-- \tbody { background-color: white; color: black; } \tUL, LI { margin: 0; padding: 2px; list-style: none; } \t#message { color: black; background-color: #FFFFCC; } \t#bodytitle { font: 11pt/13pt verdana, arial, sans-serif; height: 20px; vertical-align: top; } \t.bodytext { font: 8pt/11pt verdana, arial, sans-serif; } \t.help { font: 12px verdana, arial, sans-serif; color: red;} \t.red {color: red;} \ta:link { font: 8pt/11pt verdana, arial, sans-serif; color: red; } \ta:visited { font: 8pt/11pt verdana, arial, sans-serif; color: #4e4e4e; } \t--> \t</style> </head> <body> <table cellpadding="1" cellspacing="1" id="container"> <tr> \t<td id="bodytitle" width="100%">Discuz! {$title} Error </td> </tr> EOT; echo <<<EOT <tr><td><hr size="1"/></td></tr> <tr><td class="bodytext">Error messages: </td></tr> <tr> \t<td class="bodytext" id="message"> \t\t<ul> {$errormsg}</ul> \t</td> </tr> EOT; if (!empty($phpmsg) && $type == 'db') { echo <<<EOT <tr><td class="bodytext"> </td></tr> <tr><td class="bodytext">Program messages: </td></tr> <tr> \t<td class="bodytext"> \t\t<ul> {$phpmsg} </ul> \t</td> </tr> EOT; } $endmsg = lang('error', 'mobile_error_end_message', array('host' => $host)); echo <<<EOT <tr> \t<td class="help"><br />{$endmsg}</td> </tr> </table> </body> </html> EOT; $exit && exit; }
function db_error($message, $sql) { global $_G; list($showtrace, $logtrace) = discuz_error::debug_backtrace(); $title = lang('error', 'db_' . $message); $title_msg = lang('error', 'db_error_message'); $title_sql = lang('error', 'db_query_sql'); $title_backtrace = lang('error', 'backtrace'); $title_help = lang('error', 'db_help_link'); $db =& DB::object(); $dberrno = $db->errno(); $dberror = str_replace($db->tablepre, '', $db->error()); $sql = htmlspecialchars(str_replace($db->tablepre, '', $sql)); $msg = '<li>[Type] ' . $title . '</li>'; $msg .= $dberrno ? '<li>[' . $dberrno . '] ' . $dberror . '</li>' : ''; $msg .= $sql ? '<li>[Query] ' . $sql . '</li>' : ''; discuz_error::show_error('db', $msg, $showtrace, false); unset($msg, $phperror); $errormsg = '<b>' . $title . '</b>'; $errormsg .= "[{$dberrno}]<br /><b>ERR:</b> {$dberror}<br />"; if ($sql) { $errormsg .= '<b>SQL:</b> ' . $sql; } $errormsg .= "<br />"; $errormsg .= '<b>PHP:</b> ' . $logtrace; discuz_error::write_error_log($errormsg); exit; }