mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-28 01:10:51 +01:00
mod.php: use modern array syntax
This commit is contained in:
parent
e16dc142b7
commit
19082aec56
24
mod.php
24
mod.php
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2014 Tinyboard Development Group
|
* Copyright (c) 2010-2014 Tinyboard Development Group
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'inc/bootstrap.php';
|
require_once 'inc/bootstrap.php';
|
||||||
|
|
||||||
if ($config['debug'])
|
if ($config['debug']) {
|
||||||
$parse_start_time = microtime(true);
|
$parse_start_time = microtime(true);
|
||||||
|
}
|
||||||
|
|
||||||
require_once 'inc/mod/pages.php';
|
require_once 'inc/mod/pages.php';
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ check_login(true);
|
|||||||
|
|
||||||
$query = isset($_SERVER['QUERY_STRING']) ? rawurldecode($_SERVER['QUERY_STRING']) : '';
|
$query = isset($_SERVER['QUERY_STRING']) ? rawurldecode($_SERVER['QUERY_STRING']) : '';
|
||||||
|
|
||||||
$pages = array(
|
$pages = [
|
||||||
'' => ':?/', // redirect to dashboard
|
'' => ':?/', // redirect to dashboard
|
||||||
'/' => 'dashboard', // dashboard
|
'/' => 'dashboard', // dashboard
|
||||||
'/confirm/(.+)' => 'confirm', // confirm action (if javascript didn't work)
|
'/confirm/(.+)' => 'confirm', // confirm action (if javascript didn't work)
|
||||||
@ -109,14 +109,14 @@ $pages = array(
|
|||||||
str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_thread',
|
str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) => 'view_thread',
|
||||||
|
|
||||||
'/(\%b)/' . preg_quote($config['dir']['res'], '!') .
|
'/(\%b)/' . preg_quote($config['dir']['res'], '!') .
|
||||||
str_replace(array('%d','%s'), array('(\d+)', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '!')) => 'view_thread50',
|
str_replace([ '%d','%s' ], [ '(\d+)', '[a-z0-9-]+' ], preg_quote($config['file_page50_slug'], '!')) => 'view_thread50',
|
||||||
'/(\%b)/' . preg_quote($config['dir']['res'], '!') .
|
'/(\%b)/' . preg_quote($config['dir']['res'], '!') .
|
||||||
str_replace(array('%d','%s'), array('(\d+)', '[a-z0-9-]+'), preg_quote($config['file_page_slug'], '!')) => 'view_thread',
|
str_replace([ '%d','%s' ], [ '(\d+)', '[a-z0-9-]+' ], preg_quote($config['file_page_slug'], '!')) => 'view_thread',
|
||||||
);
|
];
|
||||||
|
|
||||||
|
|
||||||
if (!$mod) {
|
if (!$mod) {
|
||||||
$pages = array('!^(.+)?$!' => 'login');
|
$pages = [ '!^(.+)?$!' => 'login' ];
|
||||||
} elseif (isset($_GET['status'], $_GET['r'])) {
|
} elseif (isset($_GET['status'], $_GET['r'])) {
|
||||||
header('Location: ' . $_GET['r'], true, (int)$_GET['status']);
|
header('Location: ' . $_GET['r'], true, (int)$_GET['status']);
|
||||||
exit;
|
exit;
|
||||||
@ -126,10 +126,11 @@ if (isset($config['mod']['custom_pages'])) {
|
|||||||
$pages = array_merge($pages, $config['mod']['custom_pages']);
|
$pages = array_merge($pages, $config['mod']['custom_pages']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_pages = array();
|
$new_pages = [];
|
||||||
foreach ($pages as $key => $callback) {
|
foreach ($pages as $key => $callback) {
|
||||||
if (is_string($callback) && preg_match('/^secure /', $callback))
|
if (is_string($callback) && preg_match('/^secure /', $callback)) {
|
||||||
$key .= '(/(?P<token>[a-f0-9]{8}))?';
|
$key .= '(/(?P<token>[a-f0-9]{8}))?';
|
||||||
|
}
|
||||||
$key = str_replace('\%b', '?P<board>' . sprintf(substr($config['board_path'], 0, -1), $config['board_regex']), $key);
|
$key = str_replace('\%b', '?P<board>' . sprintf(substr($config['board_path'], 0, -1), $config['board_regex']), $key);
|
||||||
$new_pages[(!empty($key) and $key[0] == '!') ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!u'] = $callback;
|
$new_pages[(!empty($key) and $key[0] == '!') ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!u'] = $callback;
|
||||||
}
|
}
|
||||||
@ -172,11 +173,11 @@ foreach ($pages as $uri => $handler) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($config['debug']) {
|
if ($config['debug']) {
|
||||||
$debug['mod_page'] = array(
|
$debug['mod_page'] = [
|
||||||
'req' => $query,
|
'req' => $query,
|
||||||
'match' => $uri,
|
'match' => $uri,
|
||||||
'handler' => $handler,
|
'handler' => $handler,
|
||||||
);
|
];
|
||||||
$debug['time']['parse_mod_req'] = '~' . round((microtime(true) - $parse_start_time) * 1000, 2) . 'ms';
|
$debug['time']['parse_mod_req'] = '~' . round((microtime(true) - $parse_start_time) * 1000, 2) . 'ms';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,4 +205,3 @@ foreach ($pages as $uri => $handler) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
error($config['error']['404']);
|
error($config['error']['404']);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user