mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-24 07:30:10 +01:00
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts: inc/functions.php
This commit is contained in:
commit
b95840adcb
@ -60,10 +60,8 @@ class Cache {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// debug
|
if ($config['debug'])
|
||||||
if ($data !== false && $config['debug']) {
|
$debug['cached'][] = $key . ($data === false ? ' (miss)' : ' (hit)');
|
||||||
$debug['cached'][] = $key;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -95,10 +93,13 @@ class Cache {
|
|||||||
case 'php':
|
case 'php':
|
||||||
self::$cache[$key] = $value;
|
self::$cache[$key] = $value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($config['debug'])
|
||||||
|
$debug['cached'][] = $key . ' (set)';
|
||||||
}
|
}
|
||||||
public static function delete($key) {
|
public static function delete($key) {
|
||||||
global $config;
|
global $config, $debug;
|
||||||
|
|
||||||
$key = $config['cache']['prefix'] . $key;
|
$key = $config['cache']['prefix'] . $key;
|
||||||
|
|
||||||
@ -119,6 +120,9 @@ class Cache {
|
|||||||
unset(self::$cache[$key]);
|
unset(self::$cache[$key]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($config['debug'])
|
||||||
|
$debug['cached'][] = $key . ' (deleted)';
|
||||||
}
|
}
|
||||||
public static function flush() {
|
public static function flush() {
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -9,6 +9,8 @@ if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$microtime_start = microtime(true);
|
||||||
|
|
||||||
require_once 'inc/display.php';
|
require_once 'inc/display.php';
|
||||||
require_once 'inc/template.php';
|
require_once 'inc/template.php';
|
||||||
require_once 'inc/database.php';
|
require_once 'inc/database.php';
|
||||||
@ -24,7 +26,7 @@ mb_internal_encoding('UTF-8');
|
|||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
function loadConfig() {
|
function loadConfig() {
|
||||||
global $board, $config, $__ip, $debug, $__version;
|
global $board, $config, $__ip, $debug, $__version, $microtime_start;
|
||||||
|
|
||||||
$error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet';
|
$error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet';
|
||||||
|
|
||||||
@ -82,7 +84,8 @@ function loadConfig() {
|
|||||||
if ($config['debug']) {
|
if ($config['debug']) {
|
||||||
if (!isset($debug)) {
|
if (!isset($debug)) {
|
||||||
$debug = array('sql' => array(), 'exec' => array(), 'purge' => array(), 'cached' => array(), 'write' => array());
|
$debug = array('sql' => array(), 'exec' => array(), 'purge' => array(), 'cached' => array(), 'write' => array());
|
||||||
$debug['start'] = microtime(true);
|
$debug['start'] = $microtime_start;
|
||||||
|
$debug['start_debug'] = microtime(true);;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,7 +650,7 @@ function checkBan($board = 0) {
|
|||||||
if (event('check-ban', $board))
|
if (event('check-ban', $board))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
$query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, ``bans``.`id` FROM ``bans`` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1");
|
$query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, ``bans``.`id` FROM ``bans`` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1");
|
||||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
||||||
$query->bindValue(':board', $board);
|
$query->bindValue(':board', $board);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
@ -47,7 +47,9 @@ function Element($templateFile, array $options) {
|
|||||||
if (isset($options['body']) && $config['debug']) {
|
if (isset($options['body']) && $config['debug']) {
|
||||||
if (isset($debug['start'])) {
|
if (isset($debug['start'])) {
|
||||||
$debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms';
|
$debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms';
|
||||||
|
$debug['time (initialization)'] = '~' . round(($debug['start_debug'] - $debug['start']) * 1000, 2) . 'ms';
|
||||||
unset($debug['start']);
|
unset($debug['start']);
|
||||||
|
unset($debug['start_debug']);
|
||||||
}
|
}
|
||||||
$debug['included'] = get_included_files();
|
$debug['included'] = get_included_files();
|
||||||
$debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB';
|
$debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB';
|
||||||
|
Loading…
Reference in New Issue
Block a user