From a12b8f3062ee4143171932859ca7b5f47d22620d Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 24 Nov 2023 00:16:18 -0500 Subject: [PATCH 1/3] General fixes Signed-off-by: Michael --- Sources/Actions/Memberlist.php | 2 +- Sources/Actions/NotifyBoard.php | 1 + Sources/Actions/NotifyTopic.php | 2 ++ Sources/Actions/Post2.php | 2 +- Sources/Actions/Register2.php | 2 +- Sources/Actions/TopicRestore.php | 1 + Sources/Actions/TopicSplit.php | 6 +++--- Sources/BBCodeParser.php | 2 +- Sources/Db/DatabaseApi.php | 2 +- Sources/Graphics/Image.php | 1 + Sources/Msg.php | 4 ++-- Sources/PackageManager/PackageManager.php | 2 +- Sources/Subscriptions/PayPal/Payment.php | 1 + Sources/WebFetch/APIs/FtpFetcher.php | 3 ++- Sources/tasks/RemoveTempAttachments.php | 1 + Sources/tasks/UpdateUnicode.php | 2 +- Themes/default/Admin.template.php | 3 ++- 17 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Sources/Actions/Memberlist.php b/Sources/Actions/Memberlist.php index e15bd594a6..4df6e61490 100644 --- a/Sources/Actions/Memberlist.php +++ b/Sources/Actions/Memberlist.php @@ -508,7 +508,7 @@ public function search() $_POST['fields'] = ['name']; } - $_POST['fields'] = array_intersect($_POST['fields'], array_merge(['name', 'website', 'group', 'email'], array_keys($context['custom_search_fields']))); + $_POST['fields'] = array_intersect($_POST['fields'], array_merge(['name', 'website', 'group', 'email'], array_keys(Utils::$context['custom_search_fields']))); // Set defaults for how the results are sorted if (!isset($_REQUEST['sort']) || !isset(Utils::$context['columns'][$_REQUEST['sort']])) { diff --git a/Sources/Actions/NotifyBoard.php b/Sources/Actions/NotifyBoard.php index 2eb5084fbf..b3cc5b3224 100644 --- a/Sources/Actions/NotifyBoard.php +++ b/Sources/Actions/NotifyBoard.php @@ -15,6 +15,7 @@ use SMF\BackwardCompatibility; use SMF\Board; +use SMF\Config; use SMF\ErrorHandler; use SMF\Lang; use SMF\Utils; diff --git a/Sources/Actions/NotifyTopic.php b/Sources/Actions/NotifyTopic.php index 9c91506a76..83f9ebf8a3 100644 --- a/Sources/Actions/NotifyTopic.php +++ b/Sources/Actions/NotifyTopic.php @@ -14,10 +14,12 @@ namespace SMF\Actions; use SMF\BackwardCompatibility; +use SMF\Config; use SMF\Db\DatabaseApi as Db; use SMF\ErrorHandler; use SMF\Lang; use SMF\Topic; +use SMF\Utils; /** * Toggles email notification preferences for topics. diff --git a/Sources/Actions/Post2.php b/Sources/Actions/Post2.php index 460a2fd8f1..e21b71a378 100644 --- a/Sources/Actions/Post2.php +++ b/Sources/Actions/Post2.php @@ -543,7 +543,7 @@ public function submit(): void // If you're not allowed to edit any and all events, you have to be the poster. if (!User::$me->allowedTo('calendar_edit_any')) { - User::$me->isAllowedTo('calendar_edit_' . (!empty(User::$me->id) && self::getEventPoster($_REQUEST['eventid']) == User::$me->id ? 'own' : 'any')); + User::$me->isAllowedTo('calendar_edit_' . (!empty(User::$me->id) && Calendar::getEventPoster($_REQUEST['eventid']) == User::$me->id ? 'own' : 'any')); } // Delete it? diff --git a/Sources/Actions/Register2.php b/Sources/Actions/Register2.php index 1601b81f30..e0e877cc88 100644 --- a/Sources/Actions/Register2.php +++ b/Sources/Actions/Register2.php @@ -417,7 +417,7 @@ function (&$value, $key) { // Don't update if the default is the same. if ($var != $pref) { - setNotifyPrefs($member_id, ['announcements' => (int) !empty($_POST['notify_announcements'])]); + Notify::setNotifyPrefs($member_id, ['announcements' => (int) !empty($_POST['notify_announcements'])]); } // We'll do custom fields after as then we get to use the helper function! diff --git a/Sources/Actions/TopicRestore.php b/Sources/Actions/TopicRestore.php index b53c0bf7ce..2c4d15d97d 100644 --- a/Sources/Actions/TopicRestore.php +++ b/Sources/Actions/TopicRestore.php @@ -16,6 +16,7 @@ use SMF\BackwardCompatibility; use SMF\Config; use SMF\Db\DatabaseApi as Db; +use SMF\ErrorHandler; use SMF\Logging; use SMF\Msg; use SMF\Topic; diff --git a/Sources/Actions/TopicSplit.php b/Sources/Actions/TopicSplit.php index 4eaea427d6..1d44cf6c9c 100644 --- a/Sources/Actions/TopicSplit.php +++ b/Sources/Actions/TopicSplit.php @@ -201,7 +201,7 @@ public function index() // Check if this is the first message in the topic (if so, the first and second option won't be available) if ($id_first_msg == $_GET['at']) { - return select(); + return $this->select(); } // Basic template information.... @@ -271,7 +271,7 @@ public function split() } Utils::$context['old_topic'] = Topic::$topic_id; - Utils::$context['new_topic'] = splitTopic(Topic::$topic_id, $messagesToBeSplit, $_POST['subname']); + Utils::$context['new_topic'] = $this->splitTopic(Topic::$topic_id, $messagesToBeSplit, $_POST['subname']); Utils::$context['page_title'] = Lang::$txt['split']; } @@ -591,7 +591,7 @@ public function splitSelection() } Utils::$context['old_topic'] = Topic::$topic_id; - Utils::$context['new_topic'] = splitTopic(Topic::$topic_id, $_SESSION['split_selection'][Topic::$topic_id], $_POST['subname']); + Utils::$context['new_topic'] = $this->splitTopic(Topic::$topic_id, $_SESSION['split_selection'][Topic::$topic_id], $_POST['subname']); Utils::$context['page_title'] = Lang::$txt['split']; } diff --git a/Sources/BBCodeParser.php b/Sources/BBCodeParser.php index 3b2cad2587..89b201b6e5 100644 --- a/Sources/BBCodeParser.php +++ b/Sources/BBCodeParser.php @@ -614,7 +614,7 @@ class BBCodeParser 'parameters' => [ 'author' => ['match' => '([^<>]{1,192}?)'], 'link' => ['match' => '(?:board=\\d+;)?((?:topic|threadid)=[\\dmsg#\\./]{1,40}(?:;start=[\\dmsg#\\./]{1,40})?|msg=\\d+?|action=profile;u=\\d+)'], - 'date' => ['match' => '(\\d+)', 'validate' => 'timeformat'], + 'date' => ['match' => '(\\d+)', 'validate' => 'SMF\Time::timeformat'], ], 'before' => '
{txt_quote_from}: {author} {txt_search_on} {date}', 'after' => '
', diff --git a/Sources/Db/DatabaseApi.php b/Sources/Db/DatabaseApi.php index e124f14fea..53fc3504b4 100644 --- a/Sources/Db/DatabaseApi.php +++ b/Sources/Db/DatabaseApi.php @@ -363,7 +363,7 @@ final public static function load(array $options = []) // Double check that we found what we expected. if (!(self::$db instanceof DatabaseApi)) { - unset($self::$db); + unset(self::$db); ErrorHandler::displayDbError(); } diff --git a/Sources/Graphics/Image.php b/Sources/Graphics/Image.php index 9dfd4fb1a5..ca042aaf4f 100644 --- a/Sources/Graphics/Image.php +++ b/Sources/Graphics/Image.php @@ -14,6 +14,7 @@ namespace SMF\Graphics; use SMF\BackwardCompatibility; +use SMF\Cache\CacheApi; use SMF\Config; use SMF\ErrorHandler; use SMF\Url; diff --git a/Sources/Msg.php b/Sources/Msg.php index e2c3741e81..9f0a072324 100644 --- a/Sources/Msg.php +++ b/Sources/Msg.php @@ -726,7 +726,7 @@ function ($a) { $non_breaking_space = Utils::$context['utf8'] ? '\\x{A0}' : '\\xA0'; // Now that we've fixed all the code tags, let's fix the img and url tags... - fixTags($message); + self::fixTags($message); // Replace /me.+?\n with [me=name]dsf[/me]\n. if (strpos(User::$me->name, '[') !== false || strpos(User::$me->name, ']') !== false || strpos(User::$me->name, '\'') !== false || strpos(User::$me->name, '"') !== false) { @@ -1033,7 +1033,7 @@ public static function fixTags(&$message): void // Fix each type of tag. foreach ($fixArray as $param) { - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); + self::fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); } // Now fix possible security problems with images loading links automatically... diff --git a/Sources/PackageManager/PackageManager.php b/Sources/PackageManager/PackageManager.php index b2fb665656..2c3307eb96 100644 --- a/Sources/PackageManager/PackageManager.php +++ b/Sources/PackageManager/PackageManager.php @@ -2046,7 +2046,7 @@ public function permissions() // If we're submitting then let's move on to another function to keep things cleaner.. if (isset($_POST['action_changes'])) { - return PackagePermissionsAction(); + return $this->PackagePermissionsAction(); } Utils::$context['look_for'] = []; diff --git a/Sources/Subscriptions/PayPal/Payment.php b/Sources/Subscriptions/PayPal/Payment.php index b46140038f..df766b5ad1 100644 --- a/Sources/Subscriptions/PayPal/Payment.php +++ b/Sources/Subscriptions/PayPal/Payment.php @@ -15,6 +15,7 @@ use SMF\Config; use SMF\Lang; +use SMF\Db\DatabaseApi as Db; /** * Class of functions to validate a IPN response and provide details of the payment diff --git a/Sources/WebFetch/APIs/FtpFetcher.php b/Sources/WebFetch/APIs/FtpFetcher.php index b5f2b0afe7..5ffa241c84 100644 --- a/Sources/WebFetch/APIs/FtpFetcher.php +++ b/Sources/WebFetch/APIs/FtpFetcher.php @@ -15,6 +15,7 @@ use SMF\Config; use SMF\Lang; +use SMF\PackageManager\FtpConnection; use SMF\Url; use SMF\WebFetch\WebFetchApi; @@ -120,7 +121,7 @@ public function request(string $url, array|string $post_data = []): object $this->port = !empty($url->port) ? $url->port : 21; // Establish a connection and attempt to enable passive mode. - $ftp = new SMF\PackageManager\FtpConnection($this->host, $this->port, $this->user, $this->email); + $ftp = new FtpConnection($this->host, $this->port, $this->user, $this->email); $this->error_message = !empty($ftp->error) ? (string) ($ftp->last_message ?? $ftp->error) : ''; diff --git a/Sources/tasks/RemoveTempAttachments.php b/Sources/tasks/RemoveTempAttachments.php index 536443fa7c..20ea48d771 100644 --- a/Sources/tasks/RemoveTempAttachments.php +++ b/Sources/tasks/RemoveTempAttachments.php @@ -14,6 +14,7 @@ namespace SMF\Tasks; use SMF\Config; +use SMF\ErrorHandler; use SMF\Lang; use SMF\Theme; use SMF\Utils; diff --git a/Sources/tasks/UpdateUnicode.php b/Sources/tasks/UpdateUnicode.php index a775b92975..d851eec6fb 100644 --- a/Sources/tasks/UpdateUnicode.php +++ b/Sources/tasks/UpdateUnicode.php @@ -14,7 +14,7 @@ namespace SMF\Tasks; use SMF\Config; -use SMF\DatabaseApi as Db; +use SMF\Db\DatabaseApi as Db; use SMF\ErrorHandler; use SMF\Lang; use SMF\TaskRunner; diff --git a/Themes/default/Admin.template.php b/Themes/default/Admin.template.php index 86e1c0691d..f65a612ad2 100644 --- a/Themes/default/Admin.template.php +++ b/Themes/default/Admin.template.php @@ -10,6 +10,7 @@ * @version 3.0 Alpha 1 */ +use SMF\Actions\Admin\Permissions; use SMF\Config; use SMF\Lang; use SMF\Theme; @@ -928,7 +929,7 @@ function ($v) '; // Permission group? elseif ($config_var['type'] == 'permissions') - theme_inline_permissions($config_var['name']); + Permissions::theme_inline_permissions($config_var['name']); // BBC selection? elseif ($config_var['type'] == 'bbc') From aa7ec56b8c7a29df9ce5360f44331e0fddc23455 Mon Sep 17 00:00:00 2001 From: Jon Stovell Date: Thu, 23 Nov 2023 12:53:26 -0700 Subject: [PATCH 2/3] Cleans up whitespace Signed-off-by: Jon Stovell --- .php-cs-fixer.dist.php | 1 + Sources/Actions/Activate.php | 1 - Sources/Actions/Admin/ACP.php | 4 ---- Sources/Actions/Admin/AntiSpam.php | 1 - Sources/Actions/Admin/Attachments.php | 3 --- Sources/Actions/Admin/Boards.php | 1 - Sources/Actions/Admin/Find.php | 1 - Sources/Actions/Admin/Languages.php | 1 - Sources/Actions/Admin/Maintenance.php | 3 --- Sources/Actions/Admin/Membergroups.php | 1 - Sources/Actions/Admin/Members.php | 2 -- Sources/Actions/Admin/Registration.php | 1 - Sources/Actions/Admin/RepairBoards.php | 1 - Sources/Actions/Admin/Search.php | 2 -- Sources/Actions/Admin/Smileys.php | 4 ---- Sources/Actions/Admin/Subscriptions.php | 1 - Sources/Actions/Admin/Tasks.php | 1 - Sources/Actions/Admin/Themes.php | 4 ---- Sources/Actions/Admin/Warnings.php | 1 - Sources/Actions/Announce.php | 1 - Sources/Actions/AttachmentUpload.php | 1 - Sources/Actions/Calendar.php | 1 - Sources/Actions/Display.php | 1 - Sources/Actions/FindMember.php | 1 - Sources/Actions/Groups.php | 2 -- Sources/Actions/Like.php | 3 +-- Sources/Actions/Login2.php | 2 -- Sources/Actions/MessageIndex.php | 1 - Sources/Actions/Moderation/Logs.php | 1 - Sources/Actions/Moderation/Warnings.php | 1 - Sources/Actions/NotifyBoard.php | 1 - Sources/Actions/NotifyTopic.php | 1 - Sources/Actions/Post.php | 1 - Sources/Actions/Post2.php | 2 -- Sources/Actions/Profile/Delete.php | 1 - Sources/Actions/Profile/Main.php | 2 -- Sources/Actions/Profile/PaidSubs.php | 2 -- Sources/Actions/Profile/Popup.php | 1 - Sources/Actions/Recent.php | 1 - Sources/Actions/Register2.php | 1 - Sources/Actions/SendActivation.php | 1 - Sources/Actions/TopicMove.php | 1 - Sources/Actions/TopicMove2.php | 2 -- Sources/Actions/TopicRemove.php | 1 - Sources/Actions/TopicRestore.php | 1 - Sources/Actions/UnreadReplies.php | 1 - Sources/Actions/VerificationCode.php | 1 - Sources/Actions/Who.php | 2 -- Sources/Attachment.php | 5 ---- Sources/BBCodeParser.php | 4 ---- Sources/Board.php | 1 - Sources/Cache/APIs/Apcu.php | 1 - Sources/Cache/APIs/FileBased.php | 2 -- Sources/Cache/APIs/MemcacheImplementation.php | 3 --- .../Cache/APIs/MemcachedImplementation.php | 3 --- Sources/Cache/CacheApi.php | 1 - Sources/Cache/CacheApiInterface.php | 1 - Sources/Config.php | 3 --- Sources/Cookie.php | 4 +--- Sources/Db/APIs/MySQL.php | 7 +----- Sources/Db/APIs/PostgreSQL.php | 7 +----- Sources/DynamicPropertyHelper.php | 8 ------- Sources/Event.php | 6 ----- Sources/Forum.php | 4 +--- Sources/Graphics/Gif/FileHeader.php | 1 - Sources/Graphics/Gif/ImageHeader.php | 1 - Sources/Graphics/Image.php | 7 +----- Sources/Lang.php | 1 - Sources/Mail.php | 2 -- Sources/Menu.php | 11 ++------- Sources/Msg.php | 6 ----- Sources/PackageManager/FtpConnection.php | 3 --- Sources/PackageManager/SubsPackage.php | 4 +--- Sources/PackageManager/XmlArray.php | 6 +---- Sources/PersonalMessage/PM.php | 3 --- Sources/PersonalMessage/Received.php | 1 - Sources/PersonalMessage/Rule.php | 1 - Sources/PersonalMessage/Search.php | 2 -- Sources/Profile.php | 5 ---- Sources/Punycode.php | 4 ---- Sources/QueryString.php | 2 -- Sources/Search/APIs/Custom.php | 2 -- Sources/Search/APIs/Standard.php | 1 - Sources/Search/SearchApi.php | 1 - Sources/Security.php | 6 ----- Sources/ServerSideIncludes.php | 4 ---- Sources/Subscriptions/PayPal/Payment.php | 24 ++++--------------- Sources/TaskRunner.php | 7 ------ Sources/Theme.php | 1 - Sources/Time.php | 2 -- Sources/Url.php | 6 +---- Sources/User.php | 8 +------ Sources/Utils.php | 4 ---- Sources/Verifier.php | 1 - Sources/WebFetch/APIs/CurlFetcher.php | 2 -- Sources/WebFetch/APIs/FtpFetcher.php | 2 -- Sources/WebFetch/APIs/SocketFetcher.php | 2 -- Sources/WebFetch/WebFetchApi.php | 2 -- Sources/tasks/CreatePost_Notify.php | 4 ---- Sources/tasks/ExportProfileData.php | 4 +--- Sources/tasks/RemoveTopicRedirects.php | 2 +- Sources/tasks/UpdateUnicode.php | 8 ------- subscriptions.php | 2 -- 103 files changed, 20 insertions(+), 267 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 218820fbcc..66d4e55a95 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -113,6 +113,7 @@ 'no_useless_return' => true, 'simplified_null_return' => true, 'no_empty_statement' => true, + 'multiline_whitespace_before_semicolons' => true, 'no_singleline_whitespace_before_semicolons' => true, 'escape_implicit_backslashes' => [ 'double_quoted' => true, diff --git a/Sources/Actions/Activate.php b/Sources/Actions/Activate.php index 86383af226..871c37447f 100644 --- a/Sources/Actions/Activate.php +++ b/Sources/Actions/Activate.php @@ -44,7 +44,6 @@ class Activate implements ActionInterface ], ]; - /******************* * Public properties *******************/ diff --git a/Sources/Actions/Admin/ACP.php b/Sources/Actions/Admin/ACP.php index 3b320b9c8e..f7561864b2 100644 --- a/Sources/Actions/Admin/ACP.php +++ b/Sources/Actions/Admin/ACP.php @@ -726,7 +726,6 @@ class ACP implements ActionInterface ], ]; - /**************************** * Internal static properties ****************************/ @@ -1981,7 +1980,6 @@ protected static function adminLogin_outputPostVars($k, $v) return "\n" . ' '"', '<' => '<', '>' => '>']) . '">'; } - $ret = ''; foreach ($v as $k2 => $v2) { @@ -1989,7 +1987,6 @@ protected static function adminLogin_outputPostVars($k, $v) } return $ret; - } /** @@ -2029,7 +2026,6 @@ protected static function construct_query_string($get) return $query_string; } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/Admin/AntiSpam.php b/Sources/Actions/Admin/AntiSpam.php index 9e43b6e9b9..b9aa7e6a1c 100644 --- a/Sources/Actions/Admin/AntiSpam.php +++ b/Sources/Actions/Admin/AntiSpam.php @@ -486,7 +486,6 @@ public static function modifyAntispamSettings($return_config = false) */ protected function __construct() { - } } diff --git a/Sources/Actions/Admin/Attachments.php b/Sources/Actions/Admin/Attachments.php index 03111116cf..ebc1ed485b 100644 --- a/Sources/Actions/Admin/Attachments.php +++ b/Sources/Actions/Admin/Attachments.php @@ -1323,7 +1323,6 @@ public function repair(): void // What stage are we at? Utils::$context['completed'] = $fix_errors ? true : false; Utils::$context['errors_found'] = !empty($to_fix) ? true : false; - } /** @@ -2036,13 +2035,11 @@ public function transfer(): void break; } - // Hmm, not in auto. Time to bail out then... $results[] = Lang::$txt['attachment_transfer_no_room']; $break = true; break; - } } diff --git a/Sources/Actions/Admin/Boards.php b/Sources/Actions/Admin/Boards.php index 5b6247682e..16d40e1ffa 100644 --- a/Sources/Actions/Admin/Boards.php +++ b/Sources/Actions/Admin/Boards.php @@ -1024,7 +1024,6 @@ protected function __construct() *************************/ // code... - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/Admin/Find.php b/Sources/Actions/Admin/Find.php index 165f1e165c..1243e3f89f 100644 --- a/Sources/Actions/Admin/Find.php +++ b/Sources/Actions/Admin/Find.php @@ -199,7 +199,6 @@ public function execute(): void } } - /** * A complicated but relatively quick internal search. */ diff --git a/Sources/Actions/Admin/Languages.php b/Sources/Actions/Admin/Languages.php index 62f9340a0d..4380f9c2f6 100644 --- a/Sources/Actions/Admin/Languages.php +++ b/Sources/Actions/Admin/Languages.php @@ -981,7 +981,6 @@ function ($val1, $val2) { 'string' => $this->cleanLangString($_POST['entry'][$k][$subk], false), ]; } - } } } diff --git a/Sources/Actions/Admin/Maintenance.php b/Sources/Actions/Admin/Maintenance.php index 118837969e..e8d07f6c8a 100644 --- a/Sources/Actions/Admin/Maintenance.php +++ b/Sources/Actions/Admin/Maintenance.php @@ -2025,7 +2025,6 @@ function ($accumulator, $functions) { return $instance . Lang::$txt['hooks_field_function'] . ': ' . $data['real_function'] . '
' . Lang::$txt['hooks_field_included_file'] . ': ' . $data['included_file']; } - return $instance . $data['real_function']; }, 'class' => 'word_break', @@ -2060,7 +2059,6 @@ function ($accumulator, $functions) { return ''; } - $change_status = ['before' => '', 'after' => '']; // Can only enable/disable if it exists... @@ -2070,7 +2068,6 @@ function ($accumulator, $functions) { } return $change_status['before'] . '' . $change_status['after']; - }, 'class' => 'centertext', ], diff --git a/Sources/Actions/Admin/Membergroups.php b/Sources/Actions/Admin/Membergroups.php index 44e85a2c8a..c29f1446f0 100644 --- a/Sources/Actions/Admin/Membergroups.php +++ b/Sources/Actions/Admin/Membergroups.php @@ -543,7 +543,6 @@ public function add(): void ['id_group', 'id_board', 'deny'], ); } - } // If this is joinable then set it to show group membership in people's profiles. diff --git a/Sources/Actions/Admin/Members.php b/Sources/Actions/Admin/Members.php index d8c12cb3c6..384627d965 100644 --- a/Sources/Actions/Admin/Members.php +++ b/Sources/Actions/Admin/Members.php @@ -398,7 +398,6 @@ public function view() $where_params[$param_name . '_low'] = $search_params[$param_name]['low']; $where_params[$param_name . '_high'] = $search_params[$param_name]['high']; } - } elseif ($param_info['type'] != 'groups') { // Replace the wildcard characters ('*' and '?') into MySQL ones. $parameter = strtolower(strtr(Utils::htmlspecialchars($search_params[$param_name], ENT_QUOTES), ['%' => '\\%', '_' => '\\_', '*' => '%', '?' => '_'])); @@ -1427,7 +1426,6 @@ public static function searchMembers(): void self::$obj->execute(); } - /****************** * Internal methods ******************/ diff --git a/Sources/Actions/Admin/Registration.php b/Sources/Actions/Admin/Registration.php index b40df514c3..74e1fe9e76 100644 --- a/Sources/Actions/Admin/Registration.php +++ b/Sources/Actions/Admin/Registration.php @@ -598,7 +598,6 @@ public static function modifyRegistrationSettings($return_config = false) self::$obj->execute(); } - /****************** * Internal methods ******************/ diff --git a/Sources/Actions/Admin/RepairBoards.php b/Sources/Actions/Admin/RepairBoards.php index da64390cd1..59c772db49 100644 --- a/Sources/Actions/Admin/RepairBoards.php +++ b/Sources/Actions/Admin/RepairBoards.php @@ -1393,7 +1393,6 @@ protected function fixMissingTopics($row): void ); } - /** * Callback to remove all topics that have zero messages in the messages table. */ diff --git a/Sources/Actions/Admin/Search.php b/Sources/Actions/Admin/Search.php index 0940f284ac..cfd7b60e06 100644 --- a/Sources/Actions/Admin/Search.php +++ b/Sources/Actions/Admin/Search.php @@ -675,9 +675,7 @@ public function createmsgindex() break; } - Config::updateModSettings(['search_custom_index_resume' => Utils::jsonEncode(array_merge(Utils::$context['index_settings'], ['resume_at' => Utils::$context['start']]))]); - } // Since there are still two steps to go, 80% is the maximum here. diff --git a/Sources/Actions/Admin/Smileys.php b/Sources/Actions/Admin/Smileys.php index 4c317513f9..91153f920a 100644 --- a/Sources/Actions/Admin/Smileys.php +++ b/Sources/Actions/Admin/Smileys.php @@ -2369,14 +2369,10 @@ protected function __construct() // If customized smileys is disabled don't show the setting page if (empty(Config::$modSettings['smiley_enable'])) { unset(self::$subactions['addsmiley'], self::$subactions['editsmileys'], self::$subactions['setorder'], self::$subactions['modifysmiley']); - - - } if (empty(Config::$modSettings['messageIcons_enable'])) { unset(self::$subactions['editicon'], self::$subactions['editicons']); - } // Load up all the tabs... diff --git a/Sources/Actions/Admin/Subscriptions.php b/Sources/Actions/Admin/Subscriptions.php index c5312552e8..a2bd465adb 100644 --- a/Sources/Actions/Admin/Subscriptions.php +++ b/Sources/Actions/Admin/Subscriptions.php @@ -976,7 +976,6 @@ public function modifyUser(): void ], ['id_sublog'], ); - } } // Updating. diff --git a/Sources/Actions/Admin/Tasks.php b/Sources/Actions/Admin/Tasks.php index 678e83aa12..82e463ffa2 100644 --- a/Sources/Actions/Admin/Tasks.php +++ b/Sources/Actions/Admin/Tasks.php @@ -728,7 +728,6 @@ public static function taskSettings($return_config = false) self::$obj->execute(); } - /****************** * Internal methods ******************/ diff --git a/Sources/Actions/Admin/Themes.php b/Sources/Actions/Admin/Themes.php index 369def94a1..7be7665291 100644 --- a/Sources/Actions/Admin/Themes.php +++ b/Sources/Actions/Admin/Themes.php @@ -1089,7 +1089,6 @@ public function edit() return; } - if (substr($_REQUEST['filename'], 0, 1) == '.') { $_REQUEST['filename'] = ''; } else { @@ -1106,7 +1105,6 @@ public function edit() ErrorHandler::fatalLang('theme_edit_missing', false); } - if (isset($_POST['save'])) { if (User::$me->checkSession('post', '', false) == '' && SecurityToken::validate('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) { if (is_array($_POST['entire_file'])) { @@ -1578,9 +1576,7 @@ protected function installFile() return Utils::$context['to_install']; } - ErrorHandler::fatalLang('theme_install_error_title', false); - } /** diff --git a/Sources/Actions/Admin/Warnings.php b/Sources/Actions/Admin/Warnings.php index 14668bb73f..e11dbb646b 100644 --- a/Sources/Actions/Admin/Warnings.php +++ b/Sources/Actions/Admin/Warnings.php @@ -244,7 +244,6 @@ public static function modifyWarningSettings($return_config = false) */ protected function __construct() { - } } diff --git a/Sources/Actions/Announce.php b/Sources/Actions/Announce.php index a9372d86d8..36726457f9 100644 --- a/Sources/Actions/Announce.php +++ b/Sources/Actions/Announce.php @@ -277,7 +277,6 @@ public function send(): void Mail::send($member_email, $mail['subject'], $body, null, null, false, 5); } - } Utils::$context['percentage_done'] = round(100 * Utils::$context['start'] / Config::$modSettings['latestMember'], 1); diff --git a/Sources/Actions/AttachmentUpload.php b/Sources/Actions/AttachmentUpload.php index 31756f21e9..4dad251024 100644 --- a/Sources/Actions/AttachmentUpload.php +++ b/Sources/Actions/AttachmentUpload.php @@ -490,7 +490,6 @@ protected function createAttach(): void // You don't need to know. unset($attachmentOptions['tmp_name'], $attachmentOptions['destination']); - // Regardless of errors, pass the results. $this->_attachResults[] = $attachmentOptions; } diff --git a/Sources/Actions/Calendar.php b/Sources/Actions/Calendar.php index 581775cbf3..defd18264c 100644 --- a/Sources/Actions/Calendar.php +++ b/Sources/Actions/Calendar.php @@ -1457,7 +1457,6 @@ public static function loadDatePair($container, $date_class = '', $time_class = Theme::addInlineJavaScript(' $("' . $container . '").datepair({' . $datepair_options . "\n\t});", true); - } /** diff --git a/Sources/Actions/Display.php b/Sources/Actions/Display.php index 6dfd109f67..a13630554f 100644 --- a/Sources/Actions/Display.php +++ b/Sources/Actions/Display.php @@ -904,7 +904,6 @@ protected function setPaginationAndLinks(): void Utils::$context['page_index'] .= sprintf(strtr(Theme::$current->settings['page_index']['page'], ['{URL}' => Config::$scripturl . '?topic=' . Topic::$info->id . '.0;all']), '', Lang::$txt['all']); } } - } /** diff --git a/Sources/Actions/FindMember.php b/Sources/Actions/FindMember.php index 538093237a..ad826a359b 100644 --- a/Sources/Actions/FindMember.php +++ b/Sources/Actions/FindMember.php @@ -158,7 +158,6 @@ public static function call(): void protected function __construct() { } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/Groups.php b/Sources/Actions/Groups.php index 5f128f76b3..0e743f524a 100644 --- a/Sources/Actions/Groups.php +++ b/Sources/Actions/Groups.php @@ -850,9 +850,7 @@ public static function listMembergroupMembers_Href(&$members, $membergroup, $lim return true; } - return false; - } /** diff --git a/Sources/Actions/Like.php b/Sources/Actions/Like.php index e8d38c4df0..589cf1d400 100644 --- a/Sources/Actions/Like.php +++ b/Sources/Actions/Like.php @@ -766,8 +766,8 @@ protected function respond(): void return; } - // A like operation. + // A like operation. // Not an AJAX request so send the user back to the previous // location or the main page. @@ -788,7 +788,6 @@ protected function respond(): void Utils::$context['sub_template'] = $this->subaction; Utils::$context['data'] = $this->data; } - } /** diff --git a/Sources/Actions/Login2.php b/Sources/Actions/Login2.php index 819eef535f..cb4e5582ef 100644 --- a/Sources/Actions/Login2.php +++ b/Sources/Actions/Login2.php @@ -463,7 +463,6 @@ public static function validatePasswordFlood($id_member, $member_name, $password // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! User::updateMemberData($id_member, ['passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries]); - } /****************** @@ -836,7 +835,6 @@ protected function DoLogin() Utils::redirectexit('action=logout;' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'], Utils::$context['server']['needs_login_fix']); } } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/MessageIndex.php b/Sources/Actions/MessageIndex.php index b221886bb6..943887bf00 100644 --- a/Sources/Actions/MessageIndex.php +++ b/Sources/Actions/MessageIndex.php @@ -1109,7 +1109,6 @@ protected function buildButtons(): void // Note: Utils::$context['normal_buttons'] is added for backward compatibility with 2.0, but is deprecated and should not be used IntegrationHook::call('integrate_messageindex_buttons', [&Utils::$context['normal_buttons']]); } - } // Export public static functions to global namespace for backward compatibility. diff --git a/Sources/Actions/Moderation/Logs.php b/Sources/Actions/Moderation/Logs.php index 349473335a..731e2bf76f 100644 --- a/Sources/Actions/Moderation/Logs.php +++ b/Sources/Actions/Moderation/Logs.php @@ -999,7 +999,6 @@ protected function createList(): void *************************/ // code... - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/Moderation/Warnings.php b/Sources/Actions/Moderation/Warnings.php index 57efe313dd..f20667d5ed 100644 --- a/Sources/Actions/Moderation/Warnings.php +++ b/Sources/Actions/Moderation/Warnings.php @@ -818,7 +818,6 @@ protected function __construct() *************************/ // code... - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/NotifyBoard.php b/Sources/Actions/NotifyBoard.php index b3cc5b3224..cb0a7c573f 100644 --- a/Sources/Actions/NotifyBoard.php +++ b/Sources/Actions/NotifyBoard.php @@ -156,7 +156,6 @@ protected function getSuccessMsg() *************************/ // code... - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/NotifyTopic.php b/Sources/Actions/NotifyTopic.php index 83f9ebf8a3..9bfb667407 100644 --- a/Sources/Actions/NotifyTopic.php +++ b/Sources/Actions/NotifyTopic.php @@ -188,7 +188,6 @@ protected function getSuccessMsg() { return sprintf(Lang::$txt['notify_topic' . (!empty($this->alert_pref & parent::PREF_EMAIL) ? '_subscribed' : '_unsubscribed')], $this->member_info['email']); } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/Post.php b/Sources/Actions/Post.php index 85ac21b295..da68715419 100644 --- a/Sources/Actions/Post.php +++ b/Sources/Actions/Post.php @@ -1512,7 +1512,6 @@ protected function showAttachments(): void } elseif ($type == 'attachmentPostLimit' && Utils::$context['attachments']['total_size'] > 0) { Utils::$context['attachment_restrictions'][$type] .= ' (' . sprintf(Lang::$txt['attach_available'], round(max(Config::$modSettings['attachmentPostLimit'] - (Utils::$context['attachments']['total_size'] / 1024), 0), 2)) . ')'; } - } } } diff --git a/Sources/Actions/Post2.php b/Sources/Actions/Post2.php index e21b71a378..329433895a 100644 --- a/Sources/Actions/Post2.php +++ b/Sources/Actions/Post2.php @@ -285,7 +285,6 @@ public function submit(): void if (Utils::htmlTrim(strip_tags(BBCodeParser::load()->parse($_POST['message'], false), implode('', Utils::$context['allowed_html_tags']))) === '' && (!User::$me->allowedTo('bbc_html') || strpos($_POST['message'], '[html]') === false)) { $this->errors[] = 'no_message'; } - } if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && Utils::htmlTrim($_POST['evtitle']) === '') { @@ -1050,7 +1049,6 @@ protected function prepareEdit(): void $searchAPI->postRemoved($_REQUEST['msg']); } } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/Profile/Delete.php b/Sources/Actions/Profile/Delete.php index 786e2b1b0f..9bb256b64a 100644 --- a/Sources/Actions/Profile/Delete.php +++ b/Sources/Actions/Profile/Delete.php @@ -96,7 +96,6 @@ public function show(): void Utils::$context['page_title'] = Lang::$txt['deleteAccount'] . ': ' . Profile::$member->name; } - /** * Actually deletes the account. */ diff --git a/Sources/Actions/Profile/Main.php b/Sources/Actions/Profile/Main.php index cd0568a03b..144677749a 100644 --- a/Sources/Actions/Profile/Main.php +++ b/Sources/Actions/Profile/Main.php @@ -826,7 +826,6 @@ function (&$value, $key) { $this->profile_areas['info']['areas']['viewwarning']['enabled'] = Config::$modSettings['warning_settings'][0] == 1 && Profile::$member->warning; - $this->profile_areas['edit_profile']['areas']['account']['enabled'] = User::$me->is_admin || (Profile::$member->group_id != 1 && !in_array(1, Profile::$member->additional_groups)); $this->profile_areas['edit_profile']['areas']['tfasetup']['enabled'] = !empty(Config::$modSettings['tfa_mode']); @@ -839,7 +838,6 @@ function (&$value, $key) { $this->profile_areas['edit_profile']['areas']['groupmembership']['enabled'] = !empty(Config::$modSettings['show_group_membership']) && User::$me->is_owner; - $this->profile_areas['profile_action']['areas']['sendpm']['enabled'] = User::$me->allowedTo('profile_view'); $this->profile_areas['profile_action']['areas']['report']['enabled'] = User::$me->allowedTo('profile_view'); diff --git a/Sources/Actions/Profile/PaidSubs.php b/Sources/Actions/Profile/PaidSubs.php index d34113ed06..ee8cd29073 100644 --- a/Sources/Actions/Profile/PaidSubs.php +++ b/Sources/Actions/Profile/PaidSubs.php @@ -339,9 +339,7 @@ public function execute(): void return; } - Utils::$context['sub_template'] = 'user_subscription'; - } /*********************** diff --git a/Sources/Actions/Profile/Popup.php b/Sources/Actions/Profile/Popup.php index 3a8eea7f06..94383bd792 100644 --- a/Sources/Actions/Profile/Popup.php +++ b/Sources/Actions/Profile/Popup.php @@ -109,7 +109,6 @@ class Popup implements ActionInterface ], ]; - /**************************** * Internal static properties ****************************/ diff --git a/Sources/Actions/Recent.php b/Sources/Actions/Recent.php index 5ad130ec87..b4559a708a 100644 --- a/Sources/Actions/Recent.php +++ b/Sources/Actions/Recent.php @@ -111,7 +111,6 @@ class Recent implements ActionInterface 'any' => [], ]; - /**************************** * Internal static properties ****************************/ diff --git a/Sources/Actions/Register2.php b/Sources/Actions/Register2.php index e0e877cc88..624bca2ca7 100644 --- a/Sources/Actions/Register2.php +++ b/Sources/Actions/Register2.php @@ -923,7 +923,6 @@ public static function registerMember(&$reg_options, $return_errors = false) */ protected function __construct() { - } } diff --git a/Sources/Actions/SendActivation.php b/Sources/Actions/SendActivation.php index 4d44753f37..668d5a3a7b 100644 --- a/Sources/Actions/SendActivation.php +++ b/Sources/Actions/SendActivation.php @@ -108,7 +108,6 @@ public static function call(): void */ protected function __construct() { - } } diff --git a/Sources/Actions/TopicMove.php b/Sources/Actions/TopicMove.php index dd3a6887a5..e973d20e7f 100644 --- a/Sources/Actions/TopicMove.php +++ b/Sources/Actions/TopicMove.php @@ -161,7 +161,6 @@ public function execute(): void // Register this form and get a sequence number in Utils::$context. Security::checkSubmitOnce('register'); - } /*********************** diff --git a/Sources/Actions/TopicMove2.php b/Sources/Actions/TopicMove2.php index 9ab430f937..625a093307 100644 --- a/Sources/Actions/TopicMove2.php +++ b/Sources/Actions/TopicMove2.php @@ -368,7 +368,6 @@ public static function moveTopicConcurrence() return true; } - $request = Db::$db->query( '', 'SELECT m.subject, b.name @@ -389,7 +388,6 @@ public static function moveTopicConcurrence() $topic_link = '' . $topic_subject . ''; ErrorHandler::fatalLang('topic_already_moved', false, [$topic_link, $board_link]); - } /****************** diff --git a/Sources/Actions/TopicRemove.php b/Sources/Actions/TopicRemove.php index 899407c664..baf4ec45cb 100644 --- a/Sources/Actions/TopicRemove.php +++ b/Sources/Actions/TopicRemove.php @@ -279,7 +279,6 @@ protected function __construct() /************************* * Internal static methods *************************/ - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/TopicRestore.php b/Sources/Actions/TopicRestore.php index 2c4d15d97d..c4941a394c 100644 --- a/Sources/Actions/TopicRestore.php +++ b/Sources/Actions/TopicRestore.php @@ -594,7 +594,6 @@ protected static function mergePosts($msgs, $from_topic, $target_topic) Msg::updateLastMessages([$from_board, $target_board]); } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Actions/UnreadReplies.php b/Sources/Actions/UnreadReplies.php index 2114f4919b..17bca06ece 100644 --- a/Sources/Actions/UnreadReplies.php +++ b/Sources/Actions/UnreadReplies.php @@ -395,7 +395,6 @@ protected function getTopicRequestWithoutTempTable() ], ); } - } ?> \ No newline at end of file diff --git a/Sources/Actions/VerificationCode.php b/Sources/Actions/VerificationCode.php index 940710beeb..206f901165 100644 --- a/Sources/Actions/VerificationCode.php +++ b/Sources/Actions/VerificationCode.php @@ -167,7 +167,6 @@ protected function __construct() $this->verification_id = $_GET['vid'] ?? ''; $this->code = $this->verification_id && isset($_SESSION[$this->verification_id . '_vv']) ? $_SESSION[$this->verification_id . '_vv']['code'] : ($_SESSION['visual_verification_code'] ?? ''); - } /** diff --git a/Sources/Actions/Who.php b/Sources/Actions/Who.php index 738b229fb0..8d604b3cb7 100644 --- a/Sources/Actions/Who.php +++ b/Sources/Actions/Who.php @@ -674,9 +674,7 @@ public static function determineActions($urls, $preferred_prefix = false) return $data[0] ?? false; } - return $data; - } /****************** diff --git a/Sources/Attachment.php b/Sources/Attachment.php index 9936a89e9d..3fe877c45c 100644 --- a/Sources/Attachment.php +++ b/Sources/Attachment.php @@ -929,9 +929,7 @@ public static function automanageBySpace() return true; } - return false; - } /** @@ -1978,10 +1976,8 @@ public static function parseAttachBBC($attachID = 0) return 'attachments_no_data_loaded'; } - $attachContext = $attachLoaded[$attachID]; - // It's theoretically possible that prepareByMsg() changed the board id, so check again. if ($check_board_perms && !in_array($attachContext['board'], $view_attachment_boards)) { return 'attachments_not_allowed_to_see'; @@ -2531,7 +2527,6 @@ protected static function queryData(array $selects, array $params = [], string $ } Db::$db->free_result($request); } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/BBCodeParser.php b/Sources/BBCodeParser.php index 89b201b6e5..8e419d73e2 100644 --- a/Sources/BBCodeParser.php +++ b/Sources/BBCodeParser.php @@ -2919,9 +2919,7 @@ function ($matches) { return '[email=' . $url->path . ']' . $url . '[/email]'; } - return $url; - } // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? @@ -3562,9 +3560,7 @@ function ($matches) { return Lang::$txt[substr($matches[1], 4)]; } - return $matches[0]; - }, $string, ); diff --git a/Sources/Board.php b/Sources/Board.php index b272cc171b..523aa1e14e 100644 --- a/Sources/Board.php +++ b/Sources/Board.php @@ -2278,7 +2278,6 @@ function ($field) { LIMIT ' . $limit : ''), $params, ); - } while ($row = Db::$db->fetch_assoc($request)) { diff --git a/Sources/Cache/APIs/Apcu.php b/Sources/Cache/APIs/Apcu.php index 99e6b76bc0..74642146fd 100644 --- a/Sources/Cache/APIs/Apcu.php +++ b/Sources/Cache/APIs/Apcu.php @@ -73,7 +73,6 @@ public function putData($key, $value, $ttl = null) return apcu_delete($key . 'smf'); } - return apcu_store($key . 'smf', $value, $ttl !== null ? $ttl : $this->ttl); } diff --git a/Sources/Cache/APIs/FileBased.php b/Sources/Cache/APIs/FileBased.php index c18533faad..e5c06f23e9 100644 --- a/Sources/Cache/APIs/FileBased.php +++ b/Sources/Cache/APIs/FileBased.php @@ -141,8 +141,6 @@ public function getData($key, $ttl = null) @unlink($file); } - - } /** diff --git a/Sources/Cache/APIs/MemcacheImplementation.php b/Sources/Cache/APIs/MemcacheImplementation.php index bdaf51b776..d50efce3cb 100644 --- a/Sources/Cache/APIs/MemcacheImplementation.php +++ b/Sources/Cache/APIs/MemcacheImplementation.php @@ -59,12 +59,9 @@ function ($server) { return [$server, 0]; } - - $server = explode(':', $server); return [$server[0], isset($server[1]) ? (int) $server[1] : 11211]; - }, array_map('trim', explode(',', Config::$cache_memcached)), ); diff --git a/Sources/Cache/APIs/MemcachedImplementation.php b/Sources/Cache/APIs/MemcachedImplementation.php index 14d32cf754..23552147ee 100644 --- a/Sources/Cache/APIs/MemcachedImplementation.php +++ b/Sources/Cache/APIs/MemcachedImplementation.php @@ -59,12 +59,9 @@ function ($server) { return [$server, 0]; } - - $server = explode(':', $server); return [$server[0], isset($server[1]) ? (int) $server[1] : 11211]; - }, explode(',', Config::$cache_memcached), ); diff --git a/Sources/Cache/CacheApi.php b/Sources/Cache/CacheApi.php index 707abd0148..efee95372f 100644 --- a/Sources/Cache/CacheApi.php +++ b/Sources/Cache/CacheApi.php @@ -326,7 +326,6 @@ public function getImplementationClassKeyName() return substr($class_name, $position + 1); } - return get_class($this); } diff --git a/Sources/Cache/CacheApiInterface.php b/Sources/Cache/CacheApiInterface.php index 48bc4f9cf9..99d89d6a29 100644 --- a/Sources/Cache/CacheApiInterface.php +++ b/Sources/Cache/CacheApiInterface.php @@ -17,7 +17,6 @@ die('No direct access...'); } - interface CacheApiInterface { /** diff --git a/Sources/Config.php b/Sources/Config.php index b6d7d471e6..50c7fea52f 100644 --- a/Sources/Config.php +++ b/Sources/Config.php @@ -1796,9 +1796,7 @@ function ($a, $b) { return 1; } - return strcasecmp($b, $a); - }, ); @@ -2967,7 +2965,6 @@ public static function checkCron() } } } - } ?> \ No newline at end of file diff --git a/Sources/Cookie.php b/Sources/Cookie.php index 5453a60ebe..23fca97c50 100644 --- a/Sources/Cookie.php +++ b/Sources/Cookie.php @@ -316,9 +316,8 @@ public static function getCookie(string $name): ?object return new self($name, [$member, $hash], $expires, $domain, $path); } - // Other cookies. - + // Other cookies. $data = Utils::jsonDecode($_COOKIE[$name], true, false); if (json_last_error() !== JSON_ERROR_NONE) { @@ -326,7 +325,6 @@ public static function getCookie(string $name): ?object } return new self($name, $data); - } /** diff --git a/Sources/Db/APIs/MySQL.php b/Sources/Db/APIs/MySQL.php index 49cd8706e8..ad97579a38 100644 --- a/Sources/Db/APIs/MySQL.php +++ b/Sources/Db/APIs/MySQL.php @@ -1162,10 +1162,7 @@ public function allow_persistent() { $value = ini_get('mysqli.allow_persistent'); - return (bool) (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') - - - ; + return (bool) (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1'); } /***************************************** @@ -1223,7 +1220,6 @@ public function create_word_search($size) */ public function search_language() { - } /******************************************* @@ -2281,7 +2277,6 @@ protected function replacement__callback($matches) return implode(', ', $replacement); } - $this->error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); break; diff --git a/Sources/Db/APIs/PostgreSQL.php b/Sources/Db/APIs/PostgreSQL.php index de15e2e54e..20e6126513 100644 --- a/Sources/Db/APIs/PostgreSQL.php +++ b/Sources/Db/APIs/PostgreSQL.php @@ -1095,10 +1095,7 @@ public function allow_persistent() { $value = ini_get('pgsql.allow_persistent'); - return (bool) (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') - - - ; + return (bool) (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1'); } /***************************************** @@ -1295,7 +1292,6 @@ public function add_column($table_name, $column_info, $parameters = [], $if_exis ], ); - // If there's more attributes they need to be done via a change on PostgreSQL. unset($column_info['type'], $column_info['size']); @@ -1802,7 +1798,6 @@ public function create_table($table_name, $columns, $indexes = [], $parameters = ); } - // And the indexes... foreach ($index_queries as $query) { $this->query( diff --git a/Sources/DynamicPropertyHelper.php b/Sources/DynamicPropertyHelper.php index caf0598303..0246202d20 100644 --- a/Sources/DynamicPropertyHelper.php +++ b/Sources/DynamicPropertyHelper.php @@ -234,9 +234,7 @@ protected function customPropertyGet(mixed $prop): mixed return $this->{$prop} ?? null; } - return $this->custom[$prop] ?? null; - } /** @@ -261,23 +259,17 @@ protected function customPropertyIsset(mixed $prop): bool return isset($this->{$real_prop[0]}->{$real_prop[1]}); } - return isset($this->{$real_prop[0]}[$real_prop[1]]); - } - return isset($this->{$real_prop}); - } if (property_exists($this, $prop)) { return isset($this->{$prop}); } - return isset($this->custom[$prop]); - } /** diff --git a/Sources/Event.php b/Sources/Event.php index 0624046407..2ff5c16209 100644 --- a/Sources/Event.php +++ b/Sources/Event.php @@ -629,7 +629,6 @@ public function __get(string $prop): mixed return $not ? !$value : $value; } - if (in_array($prop, ['year', 'month', 'day', 'hour', 'minute', 'second'])) { $prop = 'start_' . $prop; } @@ -767,7 +766,6 @@ public function __get(string $prop): mixed } return $value; - } /** @@ -790,12 +788,9 @@ public function __isset(string $prop): bool return isset($this->{$real_prop[0]}[$real_prop[1]]); } - return isset($this->{$real_prop}); - } - if (in_array($prop, ['year', 'month', 'day', 'hour', 'minute', 'second'])) { $prop = 'start_' . $prop; } @@ -856,7 +851,6 @@ public function __isset(string $prop): bool default: return isset($this->custom[$prop]); } - } /*********************** diff --git a/Sources/Forum.php b/Sources/Forum.php index 63944d3305..6cff8f27d8 100644 --- a/Sources/Forum.php +++ b/Sources/Forum.php @@ -359,11 +359,9 @@ protected function main() if (isset($_REQUEST['action']) && (in_array($_REQUEST['action'], ['login2', 'logintfa', 'logout']))) { return self::$actions[$_REQUEST['action']][1]; } - // Don't even try it, sonny. - + // Don't even try it, sonny. return __CLASS__ . '::inMaintenance'; - } // If guest access is off, a guest can only do one of the very few following actions. diff --git a/Sources/Graphics/Gif/FileHeader.php b/Sources/Graphics/Gif/FileHeader.php index 46e9cfa6f9..28d971423b 100644 --- a/Sources/Graphics/Gif/FileHeader.php +++ b/Sources/Graphics/Gif/FileHeader.php @@ -37,7 +37,6 @@ class FileHeader public function __construct() { unset($this->m_lpVer, $this->m_nWidth, $this->m_nHeight, $this->m_bGlobalClr, $this->m_nColorRes, $this->m_bSorted, $this->m_nTableSize, $this->m_nBgColor, $this->m_nPixelRatio, $this->m_colorTable); - } public function load($lpData, &$hdrLen) diff --git a/Sources/Graphics/Gif/ImageHeader.php b/Sources/Graphics/Gif/ImageHeader.php index f370c5b14b..6cfdd9c650 100644 --- a/Sources/Graphics/Gif/ImageHeader.php +++ b/Sources/Graphics/Gif/ImageHeader.php @@ -36,7 +36,6 @@ class ImageHeader public function __construct() { unset($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight, $this->m_bLocalClr, $this->m_bInterlace, $this->m_bSorted, $this->m_nTableSize, $this->m_colorTable); - } public function load($lpData, &$hdrLen) diff --git a/Sources/Graphics/Image.php b/Sources/Graphics/Image.php index ca042aaf4f..3df8318382 100644 --- a/Sources/Graphics/Image.php +++ b/Sources/Graphics/Image.php @@ -538,10 +538,7 @@ function ($constant_name) { return false; } - return !($constant_name === 'IMAGETYPE_UNKNOWN' || $constant_name === 'IMAGETYPE_COUNT') - - - ; + return !($constant_name === 'IMAGETYPE_UNKNOWN' || $constant_name === 'IMAGETYPE_COUNT'); }, ARRAY_FILTER_USE_KEY, ); @@ -1220,9 +1217,7 @@ protected function resizeUsingGD(string $destination, int $max_width, int $max_h return imagejpeg($dst_img, $destination, !empty(Config::$modSettings['avatar_jpeg_quality']) ? Config::$modSettings['avatar_jpeg_quality'] : 82); } - return $imagesave($dst_img, $destination); - } /** diff --git a/Sources/Lang.php b/Sources/Lang.php index c8a24bfa0b..ead5f8331d 100644 --- a/Sources/Lang.php +++ b/Sources/Lang.php @@ -618,7 +618,6 @@ public static function numberFormat(int|float $number, ?int $decimals = null): s self::$thousands_separator, ); } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Mail.php b/Sources/Mail.php index 1b706b1729..f9ad4fde0d 100644 --- a/Sources/Mail.php +++ b/Sources/Mail.php @@ -555,7 +555,6 @@ public static function reduceQueue($number = false, $override_limit = false, $fo } } - // Any emails that didn't send? if (!empty($failed_emails)) { // Update the failed attempts check. @@ -729,7 +728,6 @@ function ($m) { return [$charset, $string, 'base64']; } - return [$charset, $string, '7bit']; } diff --git a/Sources/Menu.php b/Sources/Menu.php index 517f551fde..814e36b8d5 100644 --- a/Sources/Menu.php +++ b/Sources/Menu.php @@ -338,7 +338,6 @@ public function __construct(array $data, array $options = []) unset(Utils::$context['max_menu_id'], $this->data, $this->options); } - $this->include_data = []; return; @@ -461,10 +460,7 @@ protected function enabledAndAllowed($menu_item): bool return false; } - return !(isset($menu_item['permission']) && !User::$me->allowedTo($menu_item['permission'])) - - - ; + return !(isset($menu_item['permission']) && !User::$me->allowedTo($menu_item['permission'])); } /** @@ -558,9 +554,8 @@ protected function buildArea($area): void return; } - // Set which one is first, last, and selected in the group. - + // Set which one is first, last, and selected in the group. $first_sa = array_key_first($this_area['subsections']); $last_sa = array_key_last($this_area['subsections']); @@ -571,7 +566,6 @@ protected function buildArea($area): void if ($this->current_area == $this->area_id && empty($this->current_subsection)) { $this->current_subsection = $first_sa; } - } $this->setCurrentSectionAndArea(); @@ -750,7 +744,6 @@ protected function checkBaseUrl(): void $this->sections[$section_id]['url'] = $first_area['url'] ?? $this->base_url . ';area=' . array_key_first($section['areas']); } } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Msg.php b/Sources/Msg.php index 9f0a072324..5067a7d745 100644 --- a/Sources/Msg.php +++ b/Sources/Msg.php @@ -1044,7 +1044,6 @@ function ($m) { }, $message, ); - } /** @@ -2247,7 +2246,6 @@ public static function clearApprovalAlerts($content_ids, $content_action): void ], true, ); - } /** @@ -2896,10 +2894,8 @@ public static function spell_init() return $enchant_link; } - // Free up any resources used... @enchant_broker_free(Utils::$context['enchant_broker']); - } // Fall through to pspell if enchant didn't work @@ -2988,9 +2984,7 @@ public static function spell_suggest($dict, $word): array return $suggestions; } - return enchant_dict_suggest($dict, $word); - } if (Utils::$context['provider'] == 'pspell') { diff --git a/Sources/PackageManager/FtpConnection.php b/Sources/PackageManager/FtpConnection.php index 02fe9594ef..46c8fe0a26 100644 --- a/Sources/PackageManager/FtpConnection.php +++ b/Sources/PackageManager/FtpConnection.php @@ -183,8 +183,6 @@ public function chmod($ftp_file, $chmod) break; } - - // Convert the chmod value from octal (0777) to text ("777"). fwrite($this->connection, 'SITE CHMOD ' . decoct($val) . ' ' . $ftp_file . "\r\n"); @@ -192,7 +190,6 @@ public function chmod($ftp_file, $chmod) $this->error = 'bad_file'; break; } - } return $is_writable; diff --git a/Sources/PackageManager/SubsPackage.php b/Sources/PackageManager/SubsPackage.php index 04cc2dddd4..f17212c88e 100644 --- a/Sources/PackageManager/SubsPackage.php +++ b/Sources/PackageManager/SubsPackage.php @@ -1705,8 +1705,8 @@ public static function compareVersions($version1, $version2) if ($category == 'dev') { return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); } - // Otherwise a simple comparison. + // Otherwise a simple comparison. return $versions[1][$category] > $versions[2][$category] ? 1 : -1; } } @@ -1879,7 +1879,6 @@ public static function mktree($strPath, $mode) return false; } - @mkdir($strPath, $mode); $test = @opendir($strPath); @@ -1890,7 +1889,6 @@ public static function mktree($strPath, $mode) } return false; - } /** diff --git a/Sources/PackageManager/XmlArray.php b/Sources/PackageManager/XmlArray.php index 2fd4dc54ec..03fe5f4eae 100644 --- a/Sources/PackageManager/XmlArray.php +++ b/Sources/PackageManager/XmlArray.php @@ -164,7 +164,6 @@ public function path($path, $return_full = false) return $array[$el]; } - $trace = debug_backtrace(); $i = 0; @@ -180,7 +179,6 @@ public function path($path, $return_full = false) } return false; - } else { $lvl = null; } @@ -462,10 +460,8 @@ protected function _parse($data) break; } - $last_tag_end = $next_tag_end; $offset = $next_tag_start + 1; - } // Parse the insides. $inner_match = substr($data, 0, $last_tag_end); @@ -763,8 +759,8 @@ protected function _path($array, $path, $level, $no_error = false) if (count($results) == 1 || $level !== null) { return $results[0]; } - // Return the result set. + // Return the result set. return $results + ['name' => $path . '[]']; } } diff --git a/Sources/PersonalMessage/PM.php b/Sources/PersonalMessage/PM.php index 1c4f01e8be..fb3bdf14dc 100644 --- a/Sources/PersonalMessage/PM.php +++ b/Sources/PersonalMessage/PM.php @@ -1368,7 +1368,6 @@ public static function send($recipients, $subject, $message, $store_outbox = fal unset($all_to[array_search($row['id_member'], $all_to)]); continue; - } // Do they have any of the allowed groups? @@ -1378,7 +1377,6 @@ public static function send($recipients, $subject, $message, $store_outbox = fal unset($all_to[array_search($row['id_member'], $all_to)]); continue; - } } @@ -1555,7 +1553,6 @@ public static function send($recipients, $subject, $message, $store_outbox = fal $notification_texts[$lang]['body'] = ''; } - if ($lang != User::$me->language) { Lang::load('index+Modifications', User::$me->language, false); } diff --git a/Sources/PersonalMessage/Received.php b/Sources/PersonalMessage/Received.php index 975bdbff91..7f20c3b537 100644 --- a/Sources/PersonalMessage/Received.php +++ b/Sources/PersonalMessage/Received.php @@ -287,7 +287,6 @@ public function save(): void $inserts, [], ); - } } diff --git a/Sources/PersonalMessage/Rule.php b/Sources/PersonalMessage/Rule.php index eeba6289b3..8650dc68cc 100644 --- a/Sources/PersonalMessage/Rule.php +++ b/Sources/PersonalMessage/Rule.php @@ -665,7 +665,6 @@ public static function manage(): void Utils::redirectexit('action=pm;sa=manrules'); } } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/PersonalMessage/Search.php b/Sources/PersonalMessage/Search.php index db29af6824..42bfacb343 100644 --- a/Sources/PersonalMessage/Search.php +++ b/Sources/PersonalMessage/Search.php @@ -187,7 +187,6 @@ public function __construct(int $inbox) 'url' => Config::$scripturl . '?action=pm;sa=search', 'name' => Lang::$txt['pm_search_bar_title'], ]; - } /** @@ -694,7 +693,6 @@ protected function setSearchQuery(): void $this->search_query = implode(!empty($this->params['searchtype']) && $this->params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); } } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Profile.php b/Sources/Profile.php index 615c9314dc..d3d5041bf8 100644 --- a/Sources/Profile.php +++ b/Sources/Profile.php @@ -414,11 +414,9 @@ public function loadStandardFields(bool $force_reload = false) return true; } - $value = empty($this->birthdate) ? '1004-01-01' : $this->birthdate; return false; - }, ], 'date_registered' => [ @@ -549,11 +547,9 @@ public function loadStandardFields(bool $force_reload = false) return true; } - $value = $this->language; return false; - }, ], // The username is not always editable - so adjust it as such. @@ -1795,7 +1791,6 @@ public function validateAvatarData(string &$value): bool|string default: $result = $this->setAvatarNone(); break; - } if (is_string($result)) { diff --git a/Sources/Punycode.php b/Sources/Punycode.php index 554e1b8e37..e0355a235d 100755 --- a/Sources/Punycode.php +++ b/Sources/Punycode.php @@ -478,9 +478,7 @@ protected function charToCodePoint($char) return (($code - 224) * 4096) + ((ord($char[1]) - 128) * 64) + (ord($char[2]) - 128); } - return (($code - 240) * 262144) + ((ord($char[1]) - 128) * 4096) + ((ord($char[2]) - 128) * 64) + (ord($char[3]) - 128); - } /** @@ -503,9 +501,7 @@ protected function codePointToChar($code) return chr(($code >> 12) + 224) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128); } - return chr(($code >> 18) + 240) . chr((($code >> 12) & 63) + 128) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128); - } /** diff --git a/Sources/QueryString.php b/Sources/QueryString.php index f6dded2852..dc1d73b071 100644 --- a/Sources/QueryString.php +++ b/Sources/QueryString.php @@ -60,7 +60,6 @@ public static function cleanRequest(): void // Save some memory.. (since we don't use these anyway.) unset($GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_POST_FILES'], $GLOBALS['HTTP_POST_FILES']); - // These keys shouldn't be set...ever. if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { die('Invalid request variable.'); @@ -555,7 +554,6 @@ public function matchIPtoCIDR(string $ip_address, string $cidr_address): bool return (ip2long($ip_address) & (~((1 << (32 - $cidr_subnetmask)) - 1))) == ip2long($cidr_network); } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Search/APIs/Custom.php b/Sources/Search/APIs/Custom.php index 77e9800a4e..6cf163d6d5 100644 --- a/Sources/Search/APIs/Custom.php +++ b/Sources/Search/APIs/Custom.php @@ -135,7 +135,6 @@ public function prepareIndexes($word, array &$wordsSearch, array &$wordsExclude, return; } - foreach ($subwords as $subword) { if (Utils::entityStrlen($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) { $wordsSearch['indexed_words'][] = $subword; @@ -145,7 +144,6 @@ public function prepareIndexes($word, array &$wordsSearch, array &$wordsExclude, } } } - } /** diff --git a/Sources/Search/APIs/Standard.php b/Sources/Search/APIs/Standard.php index 45e5527e6c..f4d1bed09d 100644 --- a/Sources/Search/APIs/Standard.php +++ b/Sources/Search/APIs/Standard.php @@ -42,7 +42,6 @@ public function __construct() { parent::__construct(); } - } ?> \ No newline at end of file diff --git a/Sources/Search/SearchApi.php b/Sources/Search/SearchApi.php index 8b9646fd52..41f716b13d 100644 --- a/Sources/Search/SearchApi.php +++ b/Sources/Search/SearchApi.php @@ -1198,7 +1198,6 @@ protected function setSearchTerms(): void $this->searchWords[$orIndex]['indexed_words'] = array_slice($this->searchWords[$orIndex]['indexed_words'], 0, 7); $this->searchWords[$orIndex]['subject_words'] = array_slice($this->searchWords[$orIndex]['subject_words'], 0, 7); $this->searchWords[$orIndex]['words'] = array_slice($this->searchWords[$orIndex]['words'], 0, 4); - } } diff --git a/Sources/Security.php b/Sources/Security.php index 5c299c323b..3c18094912 100644 --- a/Sources/Security.php +++ b/Sources/Security.php @@ -108,13 +108,11 @@ public static function checkConfirm(string $action): bool|string return true; } - $token = bin2hex(Utils::randomBytes(16)); $_SESSION['confirm_' . $action] = hash_hmac('md5', $_SERVER['HTTP_USER_AGENT'], $token); return $token; - } /** @@ -316,7 +314,6 @@ public static function secureDirectory(string|array $paths, bool $attachments = continue; } - $fh = @fopen($path . '/.htaccess', 'w'); if ($fh) { @@ -326,7 +323,6 @@ public static function secureDirectory(string|array $paths, bool $attachments = $errors[] = 'htaccess_cannot_create_file'; } - // Next, the index.php file if (file_exists($path . '/index.php')) { $errors[] = 'index-php_exists'; @@ -334,7 +330,6 @@ public static function secureDirectory(string|array $paths, bool $attachments = continue; } - $contents = << '; - } /** @@ -2597,7 +2594,6 @@ public static function recentAttachments($num_attachments = 10, $attachment_ext '; } - /****************** * Primary methods. ******************/ diff --git a/Sources/Subscriptions/PayPal/Payment.php b/Sources/Subscriptions/PayPal/Payment.php index df766b5ad1..3c89e62b60 100644 --- a/Sources/Subscriptions/PayPal/Payment.php +++ b/Sources/Subscriptions/PayPal/Payment.php @@ -54,9 +54,7 @@ public function isValid() return false; } - return !(strtolower(Config::$modSettings['paypal_email']) != strtolower($_POST['business']) && (empty(Config::$modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', Config::$modSettings['paypal_additional_emails'])))) - - ; + return !(strtolower(Config::$modSettings['paypal_email']) != strtolower($_POST['business']) && (empty(Config::$modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', Config::$modSettings['paypal_additional_emails'])))); } /** @@ -188,10 +186,7 @@ public function precheck() */ public function isRefund() { - return (bool) ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) - - - ; + return (bool) ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')); } /** @@ -201,10 +196,7 @@ public function isRefund() */ public function isSubscription() { - return (bool) (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') - - - ; + return (bool) (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed'); } /** @@ -214,10 +206,7 @@ public function isSubscription() */ public function isPayment() { - return (bool) ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') - - - ; + return (bool) ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept'); } /** @@ -230,10 +219,7 @@ public function isCancellation() // subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment // Neither require us to *do* anything as per performCancel(). // subscr_eot, if sent, indicates an end of payments term. - return (bool) (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') - - - ; + return (bool) (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot'); } /** diff --git a/Sources/TaskRunner.php b/Sources/TaskRunner.php index 749306f7db..261fe83d9d 100644 --- a/Sources/TaskRunner.php +++ b/Sources/TaskRunner.php @@ -525,19 +525,15 @@ protected function fetchTask(): bool|array return $row; } - // Uh oh, we just missed it. Try to claim another one, and let // it fall through if there aren't any. return $this->fetchTask(); - } - // No dice. Clean up and go home. Db::$db->free_result($request); return false; - } /** @@ -743,7 +739,6 @@ protected function getScheduledTaskDetails(int $id, string $task, bool $is_calla ]; } - /* Helper functions that resemble their big brother counterparts. */ /** @@ -780,11 +775,9 @@ protected function obExit(): void die(0); } - header('content-type: image/gif'); die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); - } /************************* diff --git a/Sources/Theme.php b/Sources/Theme.php index 0323911abb..f41523eb96 100644 --- a/Sources/Theme.php +++ b/Sources/Theme.php @@ -3118,7 +3118,6 @@ protected static function templateInclude($filename, $once = false) die; } } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/Time.php b/Sources/Time.php index 06b129eb91..c2d5b150cd 100644 --- a/Sources/Time.php +++ b/Sources/Time.php @@ -574,9 +574,7 @@ public function format(?string $format = null, ?bool $relative = null, ?bool $st break; } - $placeholders[str_replace($f, $num, $placeholder)] = Lang::$txt[$key][$num]; - } $parts[$i] = $txt_strings_exist ? $placeholder : self::FORMAT_EQUIVALENTS[$parts[$i]]; diff --git a/Sources/Url.php b/Sources/Url.php index c07e782bb5..5b29780010 100644 --- a/Sources/Url.php +++ b/Sources/Url.php @@ -617,10 +617,7 @@ public static function setTldRegex(bool $update = false): void function ($line) { $line = trim($line); - return !(empty($line) || strlen($line) != strspn($line, 'abcdefghijklmnopqrstuvwxyz0123456789-')) - - - ; + return !(empty($line) || strlen($line) != strspn($line, 'abcdefghijklmnopqrstuvwxyz0123456789-')); }, ); @@ -819,7 +816,6 @@ protected function checkIfAscii(): void { $this->is_ascii = mb_check_encoding($this->url, 'ASCII'); } - } // Export public static functions and properties to global namespace for backward compatibility. diff --git a/Sources/User.php b/Sources/User.php index 11f6032f7f..25339f7373 100644 --- a/Sources/User.php +++ b/Sources/User.php @@ -2269,10 +2269,8 @@ public function checkSession(string $type = 'post', string $from_action = '', bo die; } - ErrorHandler::fatalLang($error, isset($log_error) ? 'user' : false); - // We really should never fall through here, for very important reasons. Let's make sure. trigger_error('No direct access...', E_USER_ERROR); } @@ -2490,13 +2488,11 @@ public function boardsAllowedTo(string|array $permissions, bool $check_access = return [0]; } - foreach ($permissions as $permission) { $boards[$permission] = [0]; } return $boards; - } // All groups the user is in except 'moderator'. @@ -2891,16 +2887,14 @@ public static function setAvatarData(array $data = []): array 'url' => $image, ]; } - // Fallback to make life easier for everyone... - + // Fallback to make life easier for everyone... return [ 'name' => '', 'image' => '', 'href' => '', 'url' => '', ]; - } /** diff --git a/Sources/Utils.php b/Sources/Utils.php index 2337a96f09..6f768e8e3c 100644 --- a/Sources/Utils.php +++ b/Sources/Utils.php @@ -317,9 +317,7 @@ function ($matches) use ($substitute) { return $substitute; } - return '&#' . $num . ';'; - }, (string) $string, ); @@ -591,7 +589,6 @@ public static function entityStrpos(string $haystack, string $needle, int $offse return is_int($result) ? $result + $offset : false; } - $needle_arr = preg_split('~(' . self::ENT_LIST . '|\\X)~u', self::sanitizeEntities($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $needle_size = count($needle_arr); @@ -609,7 +606,6 @@ public static function entityStrpos(string $haystack, string $needle, int $offse } return false; - } /** diff --git a/Sources/Verifier.php b/Sources/Verifier.php index c4d15a45ae..db2d5961bf 100644 --- a/Sources/Verifier.php +++ b/Sources/Verifier.php @@ -380,7 +380,6 @@ protected function addCaptchaJavaScript(): void '; - } /** diff --git a/Sources/WebFetch/APIs/CurlFetcher.php b/Sources/WebFetch/APIs/CurlFetcher.php index 864e3199a0..bce9611c01 100644 --- a/Sources/WebFetch/APIs/CurlFetcher.php +++ b/Sources/WebFetch/APIs/CurlFetcher.php @@ -273,11 +273,9 @@ public function resultRaw(?int $response_number = null): array return $this->response; } - $response_number = min($response_number, count($this->response) - 1); return $this->response[$response_number]; - } /****************** diff --git a/Sources/WebFetch/APIs/FtpFetcher.php b/Sources/WebFetch/APIs/FtpFetcher.php index 5ffa241c84..8ad34687ca 100644 --- a/Sources/WebFetch/APIs/FtpFetcher.php +++ b/Sources/WebFetch/APIs/FtpFetcher.php @@ -209,9 +209,7 @@ public function resultRaw(?int $response_number = null): array return $this->response; } - return $this->response[0]; - } } diff --git a/Sources/WebFetch/APIs/SocketFetcher.php b/Sources/WebFetch/APIs/SocketFetcher.php index 388e792d74..ef0d84576e 100644 --- a/Sources/WebFetch/APIs/SocketFetcher.php +++ b/Sources/WebFetch/APIs/SocketFetcher.php @@ -323,11 +323,9 @@ public function resultRaw(?int $response_number = null): array return $this->response; } - $response_number = min($response_number, count($this->response) - 1); return $this->response[$response_number]; - } /** diff --git a/Sources/WebFetch/WebFetchApi.php b/Sources/WebFetch/WebFetchApi.php index e4564eda03..6eba083912 100644 --- a/Sources/WebFetch/WebFetchApi.php +++ b/Sources/WebFetch/WebFetchApi.php @@ -173,9 +173,7 @@ protected function buildPostData(array|string $post_data): string return http_build_query($post_data, '', '&'); } - return trim($post_data); - } } diff --git a/Sources/tasks/CreatePost_Notify.php b/Sources/tasks/CreatePost_Notify.php index bd296e8c8c..e49db2caa9 100644 --- a/Sources/tasks/CreatePost_Notify.php +++ b/Sources/tasks/CreatePost_Notify.php @@ -161,11 +161,9 @@ public function execute() continue; } - $row['groups'] = $groups; unset($row['id_group'], $row['id_post_group'], $row['additional_groups']); - $this->members['watching'][$row['id_member']] = $row; } Db::$db->free_result($request); @@ -201,7 +199,6 @@ public function execute() return empty($member['sent']); }); - // Modified post, or dealing with delayed mention and quote notifications. if ($type == 'edit' || !empty($this->_details['respawns'])) { // Notifications about modified posts only go to members who were mentioned or quoted @@ -727,7 +724,6 @@ protected function handleMentionedNotifications() ]; } - // Bitwise check: Receiving a email notification? if (!($pref & self::RECEIVE_NOTIFY_EMAIL)) { // Don't want an email, so forget this member in any respawned tasks. diff --git a/Sources/tasks/ExportProfileData.php b/Sources/tasks/ExportProfileData.php index f32abe1c3c..c9acbdbd9f 100644 --- a/Sources/tasks/ExportProfileData.php +++ b/Sources/tasks/ExportProfileData.php @@ -1164,9 +1164,8 @@ function ($datatype) { $delay = Taskrunner::MAX_CLAIM_THRESHOLD; break; } - // All went well. - + // All went well. // Track progress by ID where appropriate, and by time otherwise. $progress[$datatype] = !isset($last_id) ? time() : $last_id; file_put_contents($progressfile, Utils::jsonEncode($progress)); @@ -1187,7 +1186,6 @@ function ($datatype) { // Should we append more items to this file next time? $new_item_count = isset($last_id) ? $prev_item_count + count($items) : 0; } - } } } diff --git a/Sources/tasks/RemoveTopicRedirects.php b/Sources/tasks/RemoveTopicRedirects.php index b2dc1f9536..970eb8e285 100644 --- a/Sources/tasks/RemoveTopicRedirects.php +++ b/Sources/tasks/RemoveTopicRedirects.php @@ -13,9 +13,9 @@ namespace SMF\Tasks; +use SMF\Db\DatabaseApi as Db; use SMF\Theme; use SMF\Topic; -use SMF\Db\DatabaseApi as Db; /** * Deletes moved topic notices that have passed their best-by date. diff --git a/Sources/tasks/UpdateUnicode.php b/Sources/tasks/UpdateUnicode.php index d851eec6fb..373cc65a1c 100644 --- a/Sources/tasks/UpdateUnicode.php +++ b/Sources/tasks/UpdateUnicode.php @@ -1391,7 +1391,6 @@ private function build_regex_variation_selectors() continue; } - $class_string .= '\\x{' . strtoupper(sprintf('%04s', dechex($current_range['start']))) . '}'; if ($current_range['start'] != $current_range['end']) { @@ -1399,7 +1398,6 @@ private function build_regex_variation_selectors() } $current_range = ['start' => $ord, 'end' => $ord]; - } if (isset($current_range['start'])) { @@ -1699,9 +1697,7 @@ private function build_regex_joining_type() return $b['stats']['count'] - $a['stats']['count']; } - return $a['stats']['age'] - $b['stats']['age']; - }); foreach ($this->funcs['utf8_regex_joining_type']['data'] as $char_script => &$joining_types) { @@ -1777,9 +1773,7 @@ private function build_regex_indic() return $b['stats']['count'] - $a['stats']['count']; } - return $a['stats']['age'] - $b['stats']['age']; - }); // We only want scripts with viramas. @@ -1847,7 +1841,6 @@ private function build_regex_indic() continue; } - $class_string .= '\\x{' . strtoupper(sprintf('%04s', dechex($current_range['start']))) . '}'; if ($current_range['start'] != $current_range['end']) { @@ -1855,7 +1848,6 @@ private function build_regex_indic() } $current_range = ['start' => $ord, 'end' => $ord]; - } if (isset($current_range['start'])) { diff --git a/subscriptions.php b/subscriptions.php index 01ed124dac..fd0ef92091 100644 --- a/subscriptions.php +++ b/subscriptions.php @@ -291,7 +291,6 @@ } } - // Some other "valid" transaction such as: // // subscr_signup: This IPN response (txn_type) is sent only the first time the user signs up for a subscription. @@ -300,7 +299,6 @@ // // Should we log any of these ... - // In case we have anything specific to do. $gatewayClass->close(); From 16c890b39817a7aba030b3601c97b87baf2bf594 Mon Sep 17 00:00:00 2001 From: Jon Stovell Date: Fri, 24 Nov 2023 12:52:15 -0700 Subject: [PATCH 3/3] Revert unnecessary escaping in regular expressions Signed-off-by: Jon Stovell --- .php-cs-fixer.dist.php | 5 - Sources/Actions/Admin/ACP.php | 16 +- Sources/Actions/Admin/Bans.php | 6 +- Sources/Actions/Admin/Features.php | 12 +- Sources/Actions/Admin/Find.php | 4 +- Sources/Actions/Admin/Languages.php | 44 ++--- Sources/Actions/Admin/Maintenance.php | 4 +- Sources/Actions/Admin/Membergroups.php | 2 +- Sources/Actions/Admin/Search.php | 6 +- Sources/Actions/Admin/Server.php | 6 +- Sources/Actions/Admin/Smileys.php | 6 +- Sources/Actions/Admin/Subscriptions.php | 6 +- Sources/Actions/Admin/Tasks.php | 2 +- Sources/Actions/Admin/Themes.php | 32 +-- Sources/Actions/Calendar.php | 2 +- Sources/Actions/Feed.php | 10 +- Sources/Actions/FindMember.php | 2 +- Sources/Actions/HelpAdmin.php | 2 +- Sources/Actions/JavaScriptModify.php | 2 +- Sources/Actions/Like.php | 2 +- Sources/Actions/Login2.php | 14 +- Sources/Actions/Moderation/Logs.php | 2 +- Sources/Actions/Post.php | 10 +- Sources/Actions/Post2.php | 2 +- Sources/Actions/Profile/Export.php | 4 +- Sources/Actions/Profile/ExportDownload.php | 2 +- Sources/Actions/Profile/PaidSubs.php | 2 +- Sources/Actions/QuoteFast.php | 2 +- Sources/Actions/Register2.php | 2 +- Sources/Actions/Search2.php | 6 +- Sources/Actions/VerificationCode.php | 4 +- Sources/Actions/ViewQuery.php | 4 +- Sources/Alert.php | 2 +- Sources/Attachment.php | 6 +- Sources/BBCodeParser.php | 220 ++++++++++----------- Sources/Board.php | 2 +- Sources/BrowserDetector.php | 12 +- Sources/Config.php | 86 ++++---- Sources/Cookie.php | 6 +- Sources/Db/APIs/MySQL.php | 32 +-- Sources/Db/APIs/PostgreSQL.php | 58 +++--- Sources/Draft.php | 4 +- Sources/Event.php | 2 +- Sources/Graphics/Image.php | 28 +-- Sources/Group.php | 2 +- Sources/IP.php | 8 +- Sources/ItemList.php | 2 +- Sources/Lang.php | 10 +- Sources/Logging.php | 4 +- Sources/Mail.php | 14 +- Sources/Mentions.php | 22 +-- Sources/Msg.php | 104 +++++----- Sources/PackageManager/FtpConnection.php | 2 +- Sources/PackageManager/PackageManager.php | 44 ++--- Sources/PackageManager/SubsPackage.php | 20 +- Sources/PackageManager/XmlArray.php | 10 +- Sources/PersonalMessage/Folder.php | 2 +- Sources/PersonalMessage/PM.php | 4 +- Sources/PersonalMessage/Search.php | 4 +- Sources/Poll.php | 2 +- Sources/Profile.php | 14 +- Sources/Punycode.php | 2 +- Sources/QueryString.php | 30 +-- Sources/Search/SearchApi.php | 12 +- Sources/Search/SearchResult.php | 6 +- Sources/ServerSideIncludes.php | 2 +- Sources/Session.php | 4 +- Sources/Subscriptions/PayPal/Display.php | 2 +- Sources/Theme.php | 6 +- Sources/Time.php | 38 ++-- Sources/Unicode/Utf8String.php | 96 ++++----- Sources/Url.php | 4 +- Sources/User.php | 14 +- Sources/Utils.php | 42 ++-- Sources/Verifier.php | 2 +- Sources/WebFetch/APIs/SocketFetcher.php | 6 +- Sources/tasks/ExportProfileData.php | 14 +- Sources/tasks/UpdateUnicode.php | 16 +- 78 files changed, 621 insertions(+), 626 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 66d4e55a95..eb03871553 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -115,11 +115,6 @@ 'no_empty_statement' => true, 'multiline_whitespace_before_semicolons' => true, 'no_singleline_whitespace_before_semicolons' => true, - 'escape_implicit_backslashes' => [ - 'double_quoted' => true, - 'heredoc_syntax' => true, - 'single_quoted' => true, - ], 'explicit_string_variable' => true, 'simple_to_complex_string_variable' => true, 'single_quote' => true, diff --git a/Sources/Actions/Admin/ACP.php b/Sources/Actions/Admin/ACP.php index f7561864b2..557c39e81d 100644 --- a/Sources/Actions/Admin/ACP.php +++ b/Sources/Actions/Admin/ACP.php @@ -1094,7 +1094,7 @@ public static function saveSettings(&$config_vars): void // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) if (isset($_POST['cookiename'])) { - $_POST['cookiename'] = preg_replace('~[,;\\s\\.$]+~' . (Utils::$context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . (Utils::$context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); } // Fix the forum's URL if necessary. @@ -1545,7 +1545,7 @@ public static function getFileVersions(&$versionOptions) fclose($fp); // The comment looks rougly like... that. - if (preg_match('~\\*\\s@version\\s+(.+)[\\s]{2}~i', $header, $match) == 1) { + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { $version_info['file_versions']['SSI.php'] = $match[1]; } // Not found! This is bad. @@ -1561,7 +1561,7 @@ public static function getFileVersions(&$versionOptions) fclose($fp); // Found it? - if (preg_match('~\\*\\s@version\\s+(.+)[\\s]{2}~i', $header, $match) == 1) { + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { $version_info['file_versions']['subscriptions.php'] = $match[1]; } // If we haven't how do we all get paid? @@ -1581,7 +1581,7 @@ public static function getFileVersions(&$versionOptions) fclose($fp); // Look for the version comment in the file header. - if (preg_match('~\\*\\s@version\\s+(.+)[\\s]{2}~i', $header, $match) == 1) { + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { $version_info['file_versions'][$entry] = $match[1]; } // It wasn't found, but the file was... show a '??'. @@ -1604,7 +1604,7 @@ public static function getFileVersions(&$versionOptions) fclose($fp); // Look for the version comment in the file header. - if (preg_match('~\\*\\s@version\\s+(.+)[\\s]{2}~i', $header, $match) == 1) { + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { $version_info['tasks_versions'][$entry] = $match[1]; } // It wasn't found, but the file was... show a '??'. @@ -1634,7 +1634,7 @@ public static function getFileVersions(&$versionOptions) fclose($fp); // Look for the version comment in the file header. - if (preg_match('~\\*\\s@version\\s+(.+)[\\s]{2}~i', $header, $match) == 1) { + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { $version_info[$type][$entry] = $match[1]; } // It wasn't found, but the file was... show a '??'. @@ -1660,7 +1660,7 @@ public static function getFileVersions(&$versionOptions) list($name, $language) = explode('.', $entry); // Look for the version comment in the file header. - if (preg_match('~(?://|/\\*)\\s*Version:\\s+(.+?);\\s*' . preg_quote($name, '~') . '(?:[\\s]{2}|\\*/)~i', $header, $match) == 1) { + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { $version_info['default_language_versions'][$language][$name] = $match[1]; } // It wasn't found, but the file was... show a '??'. @@ -2003,7 +2003,7 @@ protected static function construct_query_string($get) $q = strpos(Config::$scripturl, '?'); if ($q !== false) { - parse_str(preg_replace('/&(\\w+)(?=&|$)/', '&$1=', strtr(substr(Config::$scripturl, $q + 1), ';', '&')), $temp); + parse_str(preg_replace('/&(\w+)(?=&|$)/', '&$1=', strtr(substr(Config::$scripturl, $q + 1), ';', '&')), $temp); foreach ($get as $k => $v) { // Only if it's not already in the Config::$scripturl! diff --git a/Sources/Actions/Admin/Bans.php b/Sources/Actions/Admin/Bans.php index 0e47ef3726..3eeb8c5d79 100644 --- a/Sources/Actions/Admin/Bans.php +++ b/Sources/Actions/Admin/Bans.php @@ -1984,7 +1984,7 @@ protected function validateTriggers(&$triggers): array ]; } } elseif ($key == 'hostname') { - if (preg_match('/[^\\w.\\-*]/', $value) == 1) { + if (preg_match('/[^\w.\-*]/', $value) == 1) { Utils::$context['ban_errors'][] = 'invalid_hostname'; } else { // Replace the * wildcard by a MySQL wildcard %. @@ -1993,7 +1993,7 @@ protected function validateTriggers(&$triggers): array $ban_triggers['hostname']['hostname'] = $value; } } elseif ($key == 'email') { - if (preg_match('/[^\\w.\\-\\+*@]/', $value) == 1) { + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { Utils::$context['ban_errors'][] = 'invalid_email'; } @@ -2020,7 +2020,7 @@ protected function validateTriggers(&$triggers): array $ban_triggers['email']['email_address'] = $value; } elseif ($key == 'user') { - $user = preg_replace('~&#(\\d{4,5}|[2-9]\\d{2,4}|1[2-9]\\d);~', '&#$1;', Utils::htmlspecialchars($value, ENT_QUOTES)); + $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', Utils::htmlspecialchars($value, ENT_QUOTES)); $request = Db::$db->query( '', diff --git a/Sources/Actions/Admin/Features.php b/Sources/Actions/Admin/Features.php index d710a1bbb9..f490990e72 100644 --- a/Sources/Actions/Admin/Features.php +++ b/Sources/Actions/Admin/Features.php @@ -389,7 +389,7 @@ public function signature(): void } } - if (!empty($sig_limits[7]) && preg_match_all('~\\[size=([\\d\\.]+)?(px|pt|em|x-large|larger)~i', $sig, $matches) !== false && isset($matches[2])) { + if (!empty($sig_limits[7]) && preg_match_all('~\[size=([\d\.]+)?(px|pt|em|x-large|larger)~i', $sig, $matches) !== false && isset($matches[2])) { foreach ($matches[1] as $ind => $size) { $limit_broke = 0; @@ -416,10 +416,10 @@ public function signature(): void $img_count = 0; // Get all BBC tags... - preg_match_all('~\\[img(\\s+width=([\\d]+))?(\\s+height=([\\d]+))?(\\s+width=([\\d]+))?\\s*\\](?:
)*([^<">]+?)(?:
)*\\[/img\\]~i', $sig, $matches); + preg_match_all('~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?(\s+width=([\d]+))?\s*\](?:
)*([^<">]+?)(?:
)*\[/img\]~i', $sig, $matches); // ... and all HTML ones. - preg_match_all('~<img\\s+src=(?:")?((?:http://|ftp://|https://|ftps://).+?)(?:")?(?:\\s+alt=(?:")?(.*?)(?:")?)?(?:\\s?/)?>~i', $sig, $matches2, PREG_PATTERN_ORDER); + preg_match_all('~<img\s+src=(?:")?((?:http://|ftp://|https://|ftps://).+?)(?:")?(?:\s+alt=(?:")?(.*?)(?:")?)?(?:\s?/)?>~i', $sig, $matches2, PREG_PATTERN_ORDER); // And stick the HTML in the BBC. if (!empty($matches2)) { @@ -536,9 +536,9 @@ public function signature(): void // Try to fix disabled tags. if (!empty($disabledTags)) { - $sig = preg_replace('~\\[(?:' . implode('|', $disabledTags) . ').+?\\]~i', '', $sig); + $sig = preg_replace('~\[(?:' . implode('|', $disabledTags) . ').+?\]~i', '', $sig); - $sig = preg_replace('~\\[/(?:' . implode('|', $disabledTags) . ')\\]~i', '', $sig); + $sig = preg_replace('~\[/(?:' . implode('|', $disabledTags) . ')\]~i', '', $sig); } $sig = strtr($sig, ["\n" => '
']); @@ -1172,7 +1172,7 @@ public function profileEdit() if (empty(Utils::$context['fid'])) { $col_name = Utils::normalize($_POST['field_name'], 'kc_casefold'); $col_name = Utils::sanitizeChars($col_name, 2, '-'); - $col_name = preg_replace('~[^\\w-]~u', '', $col_name); + $col_name = preg_replace('~[^\w-]~u', '', $col_name); $col_name = trim($col_name, '-_'); $col_name = Utils::truncate($col_name, 6); diff --git a/Sources/Actions/Admin/Find.php b/Sources/Actions/Admin/Find.php index 1243e3f89f..2c19b9c9fb 100644 --- a/Sources/Actions/Admin/Find.php +++ b/Sources/Actions/Admin/Find.php @@ -292,7 +292,7 @@ public function internal() // Format the name - and remove any descriptions the entry may have. $name = Lang::$txt[$found] ?? (Lang::$txt['setting_' . $found] ?? (!empty($item['alttxt']) ? $item['alttxt'] : $found)); - $name = preg_replace('~<(?:div|span)\\sclass="smalltext">.+?~', '', $name); + $name = preg_replace('~<(?:div|span)\sclass="smalltext">.+?~', '', $name); Utils::$context['search_results'][] = [ 'url' => (substr($item[1], 0, 4) == 'area' ? Config::$scripturl . '?action=admin;' . $item[1] : $item[1]) . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id'] . ((substr($item[1], 0, 4) == 'area' && $section == 'settings' ? '#' . $item[0][0] : '')), @@ -344,7 +344,7 @@ public function online() $search_results = WebFetchApi::fetch(Utils::$context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? - if (!$search_results || preg_match('~<' . '\\?xml\\sversion="\\d+\\.\\d+"\\?' . '>\\s*(]*>.+?)~is', $search_results, $matches) != true) { + if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(]*>.+?)~is', $search_results, $matches) != true) { ErrorHandler::fatalLang('cannot_connect_doc_site'); } diff --git a/Sources/Actions/Admin/Languages.php b/Sources/Actions/Admin/Languages.php index 4380f9c2f6..fa8ea74001 100644 --- a/Sources/Actions/Admin/Languages.php +++ b/Sources/Actions/Admin/Languages.php @@ -219,7 +219,7 @@ public function download(): void // Check writable status. foreach ($_POST['copy_file'] as $file) { // Check it's not very bad. - if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\\.[A-Za-z-_0-9]+\\.txt$~', $file))) { + if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) { ErrorHandler::fatal(Lang::$txt['languages_download_illegal_paths']); } @@ -318,7 +318,7 @@ public function download(): void } // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... - if ($extension == 'php' && preg_match('~\\w+\\.\\w+(?:-utf8)?\\.php~', $basename)) { + if ($extension == 'php' && preg_match('~\w+\.\w+(?:-utf8)?\.php~', $basename)) { $context_data += [ 'version' => '??', 'cur_version' => false, @@ -328,7 +328,7 @@ public function download(): void list($name, $language) = explode('.', $basename); // Let's get the new version, I like versions, they tell me that I'm up to date. - if (preg_match('~\\s*Version:\\s+(.+?);\\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { + if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { $context_data['version'] = $match[1]; } @@ -340,7 +340,7 @@ public function download(): void fclose($fp); // Find the version. - if (preg_match('~(?://|/\\*)\\s*Version:\\s+(.+?);\\s*' . preg_quote($name, '~') . '(?:[\\s]{2}|\\*/)~i', $header, $match) == 1) { + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { $context_data['cur_version'] = $match[1]; // How does this compare? @@ -778,7 +778,7 @@ public function editEntries() while ($entry = $dir->read()) { // We're only after the files for this language. - if (!preg_match('~^([A-Za-z]+)\\.' . $lang_id . '\\.php$~', $entry, $matches)) { + if (!preg_match('~^([A-Za-z]+)\.' . $lang_id . '\.php$~', $entry, $matches)) { continue; } @@ -902,7 +902,7 @@ function ($val1, $val2) { $replace_array = []; foreach ($primary_settings as $setting => $type) { - $replace_array['~\\$txt\\[\'' . $setting . '\'\\]\\s*=\\s*[^\\r\\n]+~'] = '$txt[\'' . $setting . '\'] = ' . ($type === 'bool' ? (!empty($_POST[$setting]) ? 'true' : 'false') : '\'' . ($setting = 'native_name' ? htmlentities(Utils::htmlspecialcharsDecode($_POST[$setting]), ENT_QUOTES, Utils::$context['character_set']) : preg_replace('~[^\\w-]~i', '', $_POST[$setting])) . '\'') . ';'; + $replace_array['~\$txt\[\'' . $setting . '\'\]\s*=\s*[^\r\n]+~'] = '$txt[\'' . $setting . '\'] = ' . ($type === 'bool' ? (!empty($_POST[$setting]) ? 'true' : 'false') : '\'' . ($setting = 'native_name' ? htmlentities(Utils::htmlspecialcharsDecode($_POST[$setting]), ENT_QUOTES, Utils::$context['character_set']) : preg_replace('~[^\w-]~i', '', $_POST[$setting])) . '\'') . ';'; } $current_data = preg_replace(array_keys($replace_array), array_values($replace_array), $current_data); @@ -1020,12 +1020,12 @@ function ($val1, $val2) { // Also, remove any lines for uneditable variables like $forum_copyright from the working data. $entries = []; - foreach (preg_split('~^(?=\\$(?:' . implode('|', $string_types) . ')\\[\'([^\\n]+?)\'\\])~m' . (Utils::$context['utf8'] ? 'u' : ''), preg_replace('~\\s*\\n(\\$(?!(?:' . implode('|', $string_types) . '))[^\\n]*)~', '', file_get_contents($current_file))) as $blob) { + foreach (preg_split('~^(?=\$(?:' . implode('|', $string_types) . ')\[\'([^\n]+?)\'\])~m' . (Utils::$context['utf8'] ? 'u' : ''), preg_replace('~\s*\n(\$(?!(?:' . implode('|', $string_types) . '))[^\n]*)~', '', file_get_contents($current_file))) as $blob) { // Comment lines at the end of the blob can make terrible messes - $blob = preg_replace('~(\\n[ \\t]*//[^\\n]*)*$~' . (Utils::$context['utf8'] ? 'u' : ''), '', $blob); + $blob = preg_replace('~(\n[ \t]*//[^\n]*)*$~' . (Utils::$context['utf8'] ? 'u' : ''), '', $blob); // Extract the variable - if (preg_match('~^\\$(' . implode('|', $string_types) . ')\\[\'([^\\n]+?)\'\\](?:\\[\'?([^\\n]+?)\'?\\])?\\s?=\\s?(.+);([ \\t]*(?://[^\\n]*)?)$~ms' . (Utils::$context['utf8'] ? 'u' : ''), strtr($blob, ["\r" => '']), $matches)) { + if (preg_match('~^\$(' . implode('|', $string_types) . ')\[\'([^\n]+?)\'\](?:\[\'?([^\n]+?)\'?\])?\s?=\s?(.+);([ \t]*(?://[^\n]*)?)$~ms' . (Utils::$context['utf8'] ? 'u' : ''), strtr($blob, ["\r" => '']), $matches)) { // If no valid subkey was found, we need it to be explicitly null $matches[3] = isset($matches[3]) && $matches[3] !== '' ? $matches[3] : null; @@ -1070,29 +1070,29 @@ function ($val1, $val2) { # Optional explicit key assignment (?: (?: - \\d+ + \d+ | (?: (?: - \'(?:[^\']|(?<=\\\\)\')*\' + \'(?:[^\']|(?<=\\\)\')*\' ) | (?: - "(?:[^"]|(?<=\\\\)")*" + "(?:[^"]|(?<=\\\)")*" ) ) ) - \\s*=>\\s* + \s*=>\s* )? # String value in single or double quotes (?: (?: - \'(?:[^\']|(?<=\\\\)\')*\' + \'(?:[^\']|(?<=\\\)\')*\' ) | (?: - "(?:[^"]|(?<=\\\\)")*" + "(?:[^"]|(?<=\\\)")*" ) ) @@ -1116,7 +1116,7 @@ function ($val1, $val2) { foreach ($entryValue['entry'] as $id => $subValue) { // Is this a new index? - if (preg_match('/^(\\d+|(?:(?:\'(?:[^\']|(?<=\\\\)\')*\')|(?:"(?:[^"]|(?<=\\\\)")*")))\\s*=>/', $subValue, $matches)) { + if (preg_match('/^(\d+|(?:(?:\'(?:[^\']|(?<=\\\)\')*\')|(?:"(?:[^"]|(?<=\\\)")*")))\s*=>/', $subValue, $matches)) { $subKey = trim($matches[1], '\'"'); if (ctype_digit($subKey)) { @@ -1295,7 +1295,7 @@ function ($val1, $val2) { } $final_saves[$string_key] = [ - 'find' => '\\s*\\?' . '>$', + 'find' => '\s*\?' . '>$', 'replace' => "\n\$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?" . '>', 'is_regex' => true, ]; @@ -1312,7 +1312,7 @@ function ($val1, $val2) { $subKey = ctype_digit(trim($substring_key, '\'')) ? trim($substring_key, '\'') : '\'' . $substring_key . '\''; $final_saves[$string_key . '[' . $substring_key . ']'] = [ - 'find' => '\\s*\\?' . '>$', + 'find' => '\s*\?' . '>$', 'replace' => "\n\$" . $type . '[\'' . $string_key . '\'][' . $subKey . '] = ' . $substring_val['string'] . ';' . "\n\n?" . '>', 'is_regex' => true, ]; @@ -1362,7 +1362,7 @@ function add_lang_entry(group) { if (key !== null) { ++entry_num; - var array_regex = /^(.*)(\\[[^\\[\\]]*\\])$/ + var array_regex = /^(.*)(\[[^\[\]]*\])$/ var result = array_regex.exec(key); if (result != null) { key = result[1]; @@ -1371,7 +1371,7 @@ function add_lang_entry(group) { var subkey = ""; } - var bracket_regex = /[\\[\\]]/ + var bracket_regex = /[\[\]]/ if (bracket_regex.test(key)) { alert("' . Lang::$txt['languages_invalid_key'] . '" + key + subkey); return; @@ -1799,7 +1799,7 @@ protected function cleanLangString($string, $to_display = true) // Start of a variable? elseif ($in_string == 0 && $string[$i] == '$') { // Find the whole of it! - preg_match('~([\\$A-Za-z0-9\'\\[\\]_-]+)~', substr($string, $i), $matches); + preg_match('~([\$A-Za-z0-9\'\[\]_-]+)~', substr($string, $i), $matches); if (!empty($matches[1])) { // Come up with some pseudo thing to indicate this is a var. @@ -1850,7 +1850,7 @@ protected function cleanLangString($string, $to_display = true) // Is this a variable? if ($string[$i] == '{' && $string[$i + 1] == '%' && $string[$i + 2] == '$') { // Grab the variable. - preg_match('~\\{%([\\$A-Za-z0-9\'\\[\\]_-]+)%\\}~', substr($string, $i), $matches); + preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches); if (!empty($matches[1])) { if ($in_string == 1) { diff --git a/Sources/Actions/Admin/Maintenance.php b/Sources/Actions/Admin/Maintenance.php index e8d07f6c8a..3986cc9baf 100644 --- a/Sources/Actions/Admin/Maintenance.php +++ b/Sources/Actions/Admin/Maintenance.php @@ -996,7 +996,7 @@ public function optimize(): void Utils::$context['continue_countdown'] = 3; // Only optimize the tables related to this smf install, not all the tables in the db - $real_prefix = preg_match('~^(`?)(.+?)\\1\\.(.*?)$~', Db::$db->prefix, $match) === 1 ? $match[3] : Db::$db->prefix; + $real_prefix = preg_match('~^(`?)(.+?)\1\.(.*?)$~', Db::$db->prefix, $match) === 1 ? $match[3] : Db::$db->prefix; // Get a list of tables, as well as how many there are. $temp_tables = Db::$db->list_tables(false, $real_prefix . '%'); @@ -2732,7 +2732,7 @@ protected static function getDefinedFunctionsInFile(string $file): array { $source = file_get_contents($file); // token_get_all() is too slow so use a nice little regex instead. - preg_match_all('/\\bnamespace\\s++((?P>label)(?:\\\\(?P>label))*+)\\s*+;|\\bclass\\s++((?P>label))[\\w\\s]*+{|\\bfunction\\s++((?P>label))\\s*+\\(.*\\)[:\\|\\w\\s]*+{(?(DEFINE)(?