From 2c69095a1edf7474073451285238659d0f62ce3f Mon Sep 17 00:00:00 2001 From: Appleman1234 Date: Sun, 25 Sep 2022 13:30:13 +1000 Subject: PHP8.1 fixes from Rector --- search.php | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index 394aa3ff..e05bda63 100644 --- a/search.php +++ b/search.php @@ -15,7 +15,7 @@ $boards = listBoards(TRUE); } - $body = Element('search_form.html', Array('boards' => $boards, 'board' => isset($_GET['board']) ? $_GET['board'] : false, 'search' => isset($_GET['search']) ? str_replace('"', '"', utf8tohtml($_GET['search'])) : false)); + $body = Element('search_form.html', ['boards' => $boards, 'board' => $_GET['board'] ?? false, 'search' => isset($_GET['search']) ? str_replace('"', '"', (string) utf8tohtml($_GET['search'])) : false]); if(isset($_GET['search']) && !empty($_GET['search']) && isset($_GET['board']) && in_array($_GET['board'], $boards)) { $phrase = $_GET['search']; @@ -50,14 +50,14 @@ openBoard($_GET['board']); - $filters = Array(); + $filters = []; function search_filters($m) { global $filters; $name = $m[2]; - $value = isset($m[4]) ? $m[4] : $m[3]; + $value = $m[4] ?? $m[3]; - if(!in_array($name, array('id', 'thread', 'subject', 'name'))) { + if(!in_array($name, ['id', 'thread', 'subject', 'name'])) { // unknown filter return $m[0]; } @@ -72,11 +72,7 @@ if(!preg_match('/[^*^\s]/', $phrase) && empty($filters)) { _syslog(LOG_WARNING, 'Query too broad.'); $body .= '

(Query too broad.)

'; - echo Element('page.html', Array( - 'config'=>$config, - 'title'=>'Search', - 'body'=>$body, - )); + echo Element('page.html', ['config'=>$config, 'title'=>'Search', 'body'=>$body]); exit; } @@ -93,7 +89,7 @@ $phrase = str_replace('`', '!`', $phrase); $like = ''; - $match = Array(); + $match = []; // Find exact phrases if(preg_match_all('/"(.+?)"/', $phrase, $m)) { @@ -133,11 +129,7 @@ if($query->rowCount() == $search_limit) { _syslog(LOG_WARNING, 'Query too broad.'); $body .= '

('._('Query too broad.').')

'; - echo Element('page.html', Array( - 'config'=>$config, - 'title'=>'Search', - 'body'=>$body, - )); + echo Element('page.html', ['config'=>$config, 'title'=>'Search', 'body'=>$body]); exit; } @@ -167,8 +159,4 @@ $body .= '

('._('No results.').')

'; } - echo Element('page.html', Array( - 'config'=>$config, - 'title'=>_('Search'), - 'body'=>'' . $body - )); + echo Element('page.html', ['config'=>$config, 'title'=>_('Search'), 'body'=>'' . $body]); -- cgit v1.3