mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-27 17:00:52 +01:00
Erorr handling update
This commit is contained in:
parent
784c3ffadb
commit
056a6001ac
@ -121,14 +121,14 @@ function query($query) {
|
|||||||
return $pdo->query($query);
|
return $pdo->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_error($PDOStatement=null) {
|
function db_error($PDOStatement = null) {
|
||||||
global $pdo;
|
global $pdo, $db_error;
|
||||||
|
|
||||||
if (isset($PDOStatement)) {
|
if (isset($PDOStatement)) {
|
||||||
$err = $PDOStatement->errorInfo();
|
$db_error = $PDOStatement->errorInfo();
|
||||||
return $err[2];
|
return $db_error[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
$err = $pdo->errorInfo();
|
$db_error = $pdo->errorInfo();
|
||||||
return $err[2];
|
return $db_error[2];
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ function createBoardlist($mod=false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function error($message, $priority = true, $debug_stuff = false) {
|
function error($message, $priority = true, $debug_stuff = false) {
|
||||||
global $board, $mod, $config;
|
global $board, $mod, $config, $db_error;
|
||||||
|
|
||||||
if ($config['syslog'] && $priority !== false) {
|
if ($config['syslog'] && $priority !== false) {
|
||||||
// Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant.
|
// Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant.
|
||||||
@ -70,6 +70,10 @@ function error($message, $priority = true, $debug_stuff = false) {
|
|||||||
die('Error: ' . $message . "\n");
|
die('Error: ' . $message . "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($config['debug'] && isset($db_error)) {
|
||||||
|
$debug_stuff = array_combine(array('SQLSTATE', 'Error code', 'Error message'), $db_error);
|
||||||
|
}
|
||||||
|
|
||||||
die(Element('page.html', array(
|
die(Element('page.html', array(
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'title' => _('Error'),
|
'title' => _('Error'),
|
||||||
|
@ -155,19 +155,9 @@ function loadConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($config['verbose_errors']) {
|
if ($config['verbose_errors']) {
|
||||||
set_error_handler(function($errno, $errstr, $errfile, $errline) {
|
set_error_handler('verbose_error_handler');
|
||||||
if (error_reporting() == 0)
|
|
||||||
return false; // Looks like this warning was suppressed by the @ operator.
|
|
||||||
error(utf8tohtml($errstr), true, array(
|
|
||||||
'file' => $errfile,
|
|
||||||
'line' => $errline,
|
|
||||||
'errno' => $errno,
|
|
||||||
'error' => $errstr,
|
|
||||||
'backtrace' => array_slice(debug_backtrace(), 1)
|
|
||||||
));
|
|
||||||
});
|
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
ini_set('display_errors', true);
|
ini_set('display_errors', false);
|
||||||
ini_set('html_errors', false);
|
ini_set('html_errors', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,6 +234,17 @@ function _syslog($priority, $message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function verbose_error_handler($errno, $errstr, $errfile, $errline) {
|
||||||
|
if (error_reporting() == 0)
|
||||||
|
return false; // Looks like this warning was suppressed by the @ operator.
|
||||||
|
error(utf8tohtml($errstr), true, array(
|
||||||
|
'file' => $errfile . ':' . $errline,
|
||||||
|
'errno' => $errno,
|
||||||
|
'error' => $errstr,
|
||||||
|
'backtrace' => array_slice(debug_backtrace(), 1)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
function create_antibot($board, $thread = null) {
|
function create_antibot($board, $thread = null) {
|
||||||
require_once dirname(__FILE__) . '/anti-bot.php';
|
require_once dirname(__FILE__) . '/anti-bot.php';
|
||||||
|
|
||||||
|
2
mod.php
2
mod.php
@ -23,7 +23,7 @@ $query = isset($_SERVER['QUERY_STRING']) ? urldecode($_SERVER['QUERY_STRING']) :
|
|||||||
$pages = array(
|
$pages = array(
|
||||||
'' => ':?/', // redirect to dashboard
|
'' => ':?/', // redirect to dashboard
|
||||||
'/' => 'dashboard', // dashboard
|
'/' => 'dashboard', // dashboard
|
||||||
'/confirm/(.+)' => 'confirm', // confirm action (if javascript didn't work)
|
'/confir(m/(.+)' => 'confirm', // confirm action (if javascript didn't work)
|
||||||
'/logout' => 'logout', // logout
|
'/logout' => 'logout', // logout
|
||||||
|
|
||||||
'/users' => 'users', // manage users
|
'/users' => 'users', // manage users
|
||||||
|
Loading…
Reference in New Issue
Block a user