public static function db_error($message, $sql) { global $_G; list($showtrace, $logtrace) = error::debug_backtrace(); $db =& DB::object(); $dberrno = $db->errno(); $dberror = str_replace($db->tablepre, '', $db->error()); $sql = htmlspecialchars(str_replace($db->tablepre, '', $sql)); $msg = '<li>' . $message . '</li>'; $msg .= $dberrno ? '<li>[' . $dberrno . '] ' . $dberror . '</li>' : ''; $msg .= $sql ? '<li>[Query] ' . $sql . '</li>' : ''; error::show_error('db', $msg, $showtrace, false); exit; }
public static function db_error($message) { global $_G; $db = DB::object(); if (method_exists($db, 'errorInfo')) { $dberrno = $db->errorInfo(); $sql = $db->currentSql; $dberror = str_replace(DB::table(), '', $db->errorInfo()); } else { $dberror = $message; } if (stristr($dberror, '** BEGIN NESTED EXCEPTION **')) { $dberror = '<br/>' . $dberror; $dberror = nl2br($dberror); } $sql = dhtmlspecialchars(str_replace(DB::table(), '', $sql)); $msg = ''; $msg .= '<li>[Message] 数据库执行错误,请检查错误日志</li>'; $msg .= $dberrno ? '<li>[info] ' . $dberror . '</li>' : ''; //if($_GET[debug]==$_G[setting][debug_str]){ $msg .= $sql ? '<li>[Query] ' . $sql . '</li>' : ''; $msg .= $message ? "<li>[msg] " . $message . "</li>" : ''; //} $msg .= "\r\n"; $write_msg = '错误信息:' . $msg . "\r\n\r\n,--错误sql:" . $sql . ",\r\n--错误提示:" . $message . "\r\n\r\n"; L($write_msg, 1); if ($_G[mobile] && $_G[inajax] || (defined('FETCH') || defined('API'))) { if ($_GET[debug] == $_G[setting][debug_str]) { msg('数据库执行错误:' . $write_msg, 'error'); } else { msg('数据库执行错误:' . $dberror, 'error'); } } $_G['error_msg'] = $sql; error::show_error('db', $msg); }
function show_tpl($tpl, $arr) { global $_G, $app; if (!defined('TPLNAME')) { if ($_G['setting']['template']) { define('TPLNAME', $_G['setting']['template']); } else { if (ERROR) { if (!class_exists('error')) { include_once libfile('class/error'); } error::show_error('system', $msg); } else { define('TPLNAME', 'common'); } } } include_once ROOT_PATH . 'web/smarty/Smarty.class.php'; $smarty = new Smarty(); /*include ROOT_PATH.'web/smarty/SimpleSmarty.php'; $smarty = new SimpleSmarty(); $smarty->compile_dir = ROOT_PATH.'web/templates_c';*/ $ass = array('TPLNAME' => TPLNAME ? TPLNAME : 'common', "IMGDIR" => IMGDIR, "TPLDIR" => TPLDIR, "ASSDIR" => '/assets/' . TPLNAME . '/' . CURMODULE, "TPLDIR" => '/assets/' . TPLNAME . '/', "CSSDIR" => CSSDIR, "JSDIR" => JSDIR, "CM" => CURMODULE, "CA" => CURACTION, "TAE" => TAE ? 1 : 0, "URL" => URL, "SYSTEM_TYPE" => SYSTEM_TYPE); $_G['version'] = TTAE_VERSION; $_G['update_time'] = TTAE_UPDATE_TIME; if (!$_G['cpmsg']) { $tae = TAE ? 1 : 0; $data = array(); $data[] = $tae; $data[] = CURSCRIPT; $data[] = CURMODULE; $data[] = CURACTION; $data[] = $_G[uid]; $data[] = $_G[username]; $global_str = implode('|', $data); $smarty->assign("global_str", $global_str); $safe_get = safe_output($_GET); $query_text = http_build_query($safe_get); $smarty->assign("query_text", $query_text); } if ($arr && is_array($arr)) { $ass = array_merge($ass, $arr); } $unset = array('table', '_config', 'goods_sql', 'memory_list', 'cache_list'); $tmp = array(); foreach ($_G as $k => $v) { if (!in_array($k, $unset)) { $tmp[$k] = $v; } } $smarty->assign("_G", $tmp); if (defined('IN_ADMIN')) { $smarty->assign("menu", $_G['menu']); } else { $ap = new app(); $data = $ap->data_api(); if ($data && is_array($data)) { $ass = array_merge($data, $ass); } } foreach ($ass as $k => $v) { $smarty->assign($k, $v); } $show_tpl = ROOT_PATH . $tpl; try { $smarty->display($show_tpl); } catch (Exception $e) { //$e->trace = ''; $file = end(explode('\\', $e->getFile())); $msg = '<br/> File : ' . $file . ' On line ' . $e->getLine() . ' Code ' . $e->getCode(); $msg = $e->getMessage() . $msg; $msg = str_replace(ROOT_PATH . 'view/', '', $msg); system_error('system', $msg); //msg($msg); exit; } }