From 19082aec56e4ae677575d362ebb273a68b05f5b8 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Thu, 15 Aug 2024 16:52:29 +0200 Subject: [PATCH] mod.php: use modern array syntax --- mod.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mod.php b/mod.php index 20cff8e5..f1e1245c 100644 --- a/mod.php +++ b/mod.php @@ -1,13 +1,13 @@ ':?/', // redirect to dashboard '/' => 'dashboard', // dashboard '/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', '/(\%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'], '!') . - 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) { - $pages = array('!^(.+)?$!' => 'login'); + $pages = [ '!^(.+)?$!' => 'login' ]; } elseif (isset($_GET['status'], $_GET['r'])) { header('Location: ' . $_GET['r'], true, (int)$_GET['status']); exit; @@ -126,10 +126,11 @@ if (isset($config['mod']['custom_pages'])) { $pages = array_merge($pages, $config['mod']['custom_pages']); } -$new_pages = array(); +$new_pages = []; foreach ($pages as $key => $callback) { - if (is_string($callback) && preg_match('/^secure /', $callback)) + if (is_string($callback) && preg_match('/^secure /', $callback)) { $key .= '(/(?P[a-f0-9]{8}))?'; + } $key = str_replace('\%b', '?P' . sprintf(substr($config['board_path'], 0, -1), $config['board_regex']), $key); $new_pages[(!empty($key) and $key[0] == '!') ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!u'] = $callback; } @@ -172,11 +173,11 @@ foreach ($pages as $uri => $handler) { } if ($config['debug']) { - $debug['mod_page'] = array( + $debug['mod_page'] = [ 'req' => $query, 'match' => $uri, 'handler' => $handler, - ); + ]; $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']); -