diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php index ccb05d22e..4f8a1ad0b 100644 --- a/admin/admin_attachments.php +++ b/admin/admin_attachments.php @@ -135,7 +135,9 @@ if ($search_imagick) { if (preg_match('/convert/i', $imagick)) { return true; - } elseif ($imagick != 'none') { + } + + if ($imagick != 'none') { if (!preg_match('/WIN/i', PHP_OS)) { $retval = @exec('whereis convert'); $paths = explode(' ', $retval); diff --git a/admin/admin_forums.php b/admin/admin_forums.php index 20d97551d..45dd66e0d 100644 --- a/admin/admin_forums.php +++ b/admin/admin_forums.php @@ -568,7 +568,9 @@ if ($mode) { if ($forum_info['forum_parent'] && $prev_forum['forum_parent'] != $forum_info['forum_parent']) { $show_main_page = true; break; - } elseif ($move_down_forum_id = get_prev_root_forum_id($forums, $forum_order)) { + } + + if ($move_down_forum_id = get_prev_root_forum_id($forums, $forum_order)) { $move_up_forum_id = $forum_id; $move_down_ord_val = (get_sf_count($forum_id) + 1) * 10; $move_up_ord_val = ((get_sf_count($move_down_forum_id) + 1) * 10) + $move_down_ord_val; @@ -579,7 +581,9 @@ if ($mode) { if ($forum_info['forum_parent'] && $next_forum['forum_parent'] != $forum_info['forum_parent']) { $show_main_page = true; break; - } elseif ($move_up_forum_id = get_next_root_forum_id($forums, $forum_order)) { + } + + if ($move_up_forum_id = get_next_root_forum_id($forums, $forum_order)) { $move_down_forum_id = $forum_id; $move_down_forum_order = $forum_order; $move_down_ord_val = (get_sf_count($move_up_forum_id) + 1) * 10; diff --git a/dl.php b/dl.php index 949635442..eb2c6cdaa 100644 --- a/dl.php +++ b/dl.php @@ -182,27 +182,27 @@ if ($download_mode == PHYSICAL_LINK) { $url = make_url($upload_dir . '/' . $attachment['physical_filename']); header('Location: ' . $url); exit; -} else { - if (IS_GUEST && !bb_captcha('check')) { - global $template; - - $redirect_url = $_POST['redirect_url'] ?? $_SERVER['HTTP_REFERER'] ?? '/'; - $message = '
'; - - $template->assign_vars(array( - 'ERROR_MESSAGE' => $message, - )); - - require(PAGE_HEADER); - require(PAGE_FOOTER); - } - - send_file_to_browser($attachment, $upload_dir); - exit; } + +if (IS_GUEST && !bb_captcha('check')) { + global $template; + + $redirect_url = $_POST['redirect_url'] ?? $_SERVER['HTTP_REFERER'] ?? '/'; + $message = ''; + + $template->assign_vars(array( + 'ERROR_MESSAGE' => $message, + )); + + require(PAGE_HEADER); + require(PAGE_FOOTER); +} + +send_file_to_browser($attachment, $upload_dir); +exit; diff --git a/library/TorrentPier/TorrentPier/Legacy/Cache/Apc.php b/library/TorrentPier/TorrentPier/Legacy/Cache/Apc.php index f6ab498b7..4e150ebee 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Cache/Apc.php +++ b/library/TorrentPier/TorrentPier/Legacy/Cache/Apc.php @@ -60,9 +60,9 @@ class Apc extends Common $this->num_queries++; return apc_delete($this->prefix . $name); - } else { - return apc_clear_cache(); } + + return apc_clear_cache(); } public function is_installed() diff --git a/library/TorrentPier/TorrentPier/Legacy/Cache/Memcache.php b/library/TorrentPier/TorrentPier/Legacy/Cache/Memcache.php index fe72dfa42..0fe7d706f 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Cache/Memcache.php +++ b/library/TorrentPier/TorrentPier/Legacy/Cache/Memcache.php @@ -101,9 +101,9 @@ class Memcache extends Common $this->num_queries++; return ($this->connected) ? $this->memcache->delete($this->prefix . $name, 0) : false; - } else { - return ($this->connected) ? $this->memcache->flush() : false; } + + return ($this->connected) ? $this->memcache->flush() : false; } public function is_installed() diff --git a/library/TorrentPier/TorrentPier/Legacy/Cache/Redis.php b/library/TorrentPier/TorrentPier/Legacy/Cache/Redis.php index b7ab3d960..e500425d2 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Cache/Redis.php +++ b/library/TorrentPier/TorrentPier/Legacy/Cache/Redis.php @@ -85,9 +85,9 @@ class Redis extends Common $this->num_queries++; return true; - } else { - return false; } + + return false; } public function rm($name = '') @@ -104,9 +104,9 @@ class Redis extends Common $this->num_queries++; return ($this->connected) ? $this->redis->del($this->prefix . $name) : false; - } else { - return ($this->connected) ? $this->redis->flushDB() : false; } + + return ($this->connected) ? $this->redis->flushDB() : false; } public function is_installed() diff --git a/library/TorrentPier/TorrentPier/Legacy/Cache/Sqlite.php b/library/TorrentPier/TorrentPier/Legacy/Cache/Sqlite.php index 20619eada..c8d4d00b7 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Cache/Sqlite.php +++ b/library/TorrentPier/TorrentPier/Legacy/Cache/Sqlite.php @@ -78,9 +78,9 @@ class Sqlite extends Common // return if (is_array($this->prefix . $name)) { return $cached_items; - } else { - return $cached_items[$name] ?? false; } + + return $cached_items[$name] ?? false; } public function set($name, $value, $ttl = 604800) diff --git a/library/TorrentPier/TorrentPier/Legacy/Cache/Xcache.php b/library/TorrentPier/TorrentPier/Legacy/Cache/Xcache.php index 54df788c4..bf864c599 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Cache/Xcache.php +++ b/library/TorrentPier/TorrentPier/Legacy/Cache/Xcache.php @@ -60,11 +60,11 @@ class Xcache extends Common $this->num_queries++; return xcache_unset($this->prefix . $name); - } else { - xcache_clear_cache(XC_TYPE_PHP, 0); - xcache_clear_cache(XC_TYPE_VAR, 0); - return; } + + xcache_clear_cache(XC_TYPE_PHP, 0); + xcache_clear_cache(XC_TYPE_VAR, 0); + return; } public function is_installed() diff --git a/library/TorrentPier/TorrentPier/Legacy/Caches.php b/library/TorrentPier/TorrentPier/Legacy/Caches.php index 9f8d08ec8..3a6e792c8 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Caches.php +++ b/library/TorrentPier/TorrentPier/Legacy/Caches.php @@ -102,9 +102,9 @@ class Caches { if (!empty($cfg['shard_type']) && $cfg['shard_type'] != 'none') { return $this->cfg['db_dir'] . $name . '_*' . $ext; - } else { - return $this->cfg['db_dir'] . $name . $ext; } + + return $this->cfg['db_dir'] . $name . $ext; } public function get_table_schema($cfg) diff --git a/library/TorrentPier/TorrentPier/Legacy/Common/Upload.php b/library/TorrentPier/TorrentPier/Legacy/Common/Upload.php index 6f3574005..58b15f956 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Common/Upload.php +++ b/library/TorrentPier/TorrentPier/Legacy/Common/Upload.php @@ -137,9 +137,9 @@ class Upload if ($mode == 'attach') { $file_path = get_attach_path($params['topic_id']); return $this->_move($file_path); - } else { - trigger_error("Invalid upload mode: $mode", E_USER_ERROR); } + + trigger_error("Invalid upload mode: $mode", E_USER_ERROR); } /** diff --git a/library/TorrentPier/TorrentPier/Legacy/Common/User.php b/library/TorrentPier/TorrentPier/Legacy/Common/User.php index e446a1924..da65582b3 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Common/User.php +++ b/library/TorrentPier/TorrentPier/Legacy/Common/User.php @@ -407,7 +407,9 @@ class User cache_update_userdata($this->data); return $this->data; - } elseif ($new_session_userdata = $this->session_create($userdata, false)) { + } + + if ($new_session_userdata = $this->session_create($userdata, false)) { // Removing guest sessions from this IP OLD_DB()->query(" DELETE FROM " . BB_SESSIONS . " diff --git a/library/attach_mod/attachment_mod.php b/library/attach_mod/attachment_mod.php index df8caa11a..c0682b39f 100644 --- a/library/attach_mod/attachment_mod.php +++ b/library/attach_mod/attachment_mod.php @@ -31,11 +31,11 @@ function attach_mod_get_lang($language_file) $file = LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/' . $language_file . '.php'; if (file_exists($file)) { return $bb_cfg['default_lang']; - } else { - $file = LANG_ROOT_DIR . '/' . $attach_config['board_lang'] . '/' . $language_file . '.php'; - if (file_exists($file)) { - return $attach_config['board_lang']; - } + } + + $file = LANG_ROOT_DIR . '/' . $attach_config['board_lang'] . '/' . $language_file . '.php'; + if (file_exists($file)) { + return $attach_config['board_lang']; } bb_die('Attachment mod language file does not exist: language/' . $attach_config['board_lang'] . '/' . $language_file . '.php'); diff --git a/library/attach_mod/includes/functions_thumbs.php b/library/attach_mod/includes/functions_thumbs.php index fd9bbe509..f9ae58970 100644 --- a/library/attach_mod/includes/functions_thumbs.php +++ b/library/attach_mod/includes/functions_thumbs.php @@ -26,12 +26,12 @@ function get_img_size_format($width, $height) round($width * ($max_width / $width)), round($height * ($max_width / $width)) ); - } else { - return array( - round($width * ($max_width / $height)), - round($height * ($max_width / $height)) - ); } + + return array( + round($width * ($max_width / $height)), + round($height * ($max_width / $height)) + ); } /** @@ -44,9 +44,9 @@ function is_imagick() if ($attach_config['img_imagick'] != '') { $imagick = $attach_config['img_imagick']; return true; - } else { - return false; } + + return false; } /** diff --git a/library/includes/functions.php b/library/includes/functions.php index c26777b78..13b246183 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -587,9 +587,9 @@ function bt_show_ip($ip, $port = '') $ip = decode_ip($ip); $ip .= ($port) ? ":$port" : ''; return $ip; - } else { - return ($bb_cfg['bt_show_ip_only_moder']) ? false : decode_ip_xx($ip); } + + return ($bb_cfg['bt_show_ip_only_moder']) ? false : decode_ip_xx($ip); } function bt_show_port($port) @@ -598,9 +598,9 @@ function bt_show_port($port) if (IS_AM) { return $port; - } else { - return ($bb_cfg['bt_show_port_only_moder']) ? false : $port; } + + return ($bb_cfg['bt_show_port_only_moder']) ? false : $port; } function decode_ip_xx($ip) @@ -741,10 +741,10 @@ function get_username($user_id) $usernames[$row['user_id']] = $row['username']; } return $usernames; - } else { - $row = OLD_DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1"); - return $row['username']; } + + $row = OLD_DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1"); + return $row['username']; } function get_user_id($username) @@ -846,9 +846,9 @@ function get_attachments_dir($cfg = null) if ($cfg['upload_dir'][0] == '/' || ($cfg['upload_dir'][0] != '/' && $cfg['upload_dir'][1] == ':')) { return $cfg['upload_dir']; - } else { - return BB_ROOT . $cfg['upload_dir']; } + + return BB_ROOT . $cfg['upload_dir']; } function bb_get_config($table, $from_db = false, $update_cache = true) diff --git a/library/includes/functions_atom.php b/library/includes/functions_atom.php index 77e848442..7a17b185d 100644 --- a/library/includes/functions_atom.php +++ b/library/includes/functions_atom.php @@ -81,9 +81,9 @@ function update_forum_feed($forum_id, $forum_data) } if (create_atom($file_path, 'f', $forum_id, htmlCHR($forum_data['forum_name']), $topics)) { return true; - } else { - return false; } + + return false; } function update_user_feed($user_id, $username) @@ -127,9 +127,9 @@ function update_user_feed($user_id, $username) } if (create_atom($file_path, 'u', $user_id, wbr($username), $topics)) { return true; - } else { - return false; } + + return false; } function create_atom($file_path, $mode, $id, $title, $topics) diff --git a/library/includes/functions_torrent.php b/library/includes/functions_torrent.php index 6c05f373a..9fd21df9f 100644 --- a/library/includes/functions_torrent.php +++ b/library/includes/functions_torrent.php @@ -576,9 +576,9 @@ function get_registered_torrents($id, $mode) if ($rowset = @OLD_DB()->sql_fetchrowset($result)) { return $rowset; - } else { - return false; } + + return false; } function torrent_error_exit($message) diff --git a/library/includes/functions_validate.php b/library/includes/functions_validate.php index 61f7c4311..6e747cd34 100644 --- a/library/includes/functions_validate.php +++ b/library/includes/functions_validate.php @@ -24,7 +24,9 @@ function validate_username($username, $check_ban_and_taken = true) // Length if (mb_strlen($username, 'UTF-8') > USERNAME_MAX_LENGTH) { return $lang['USERNAME_TOO_LONG']; - } elseif (mb_strlen($username, 'UTF-8') < USERNAME_MIN_LENGTH) { + } + + if (mb_strlen($username, 'UTF-8') < USERNAME_MIN_LENGTH) { return $lang['USERNAME_TOO_SMALL']; } // Allowed symbols @@ -94,9 +96,9 @@ function validate_email($email, $check_ban_and_taken = true) if ($row = OLD_DB()->fetch_row("SELECT `user_email` FROM " . BB_USERS . " WHERE user_email = '$email_sql' LIMIT 1")) { if ($row['user_email'] == $userdata['user_email']) { return false; - } else { - return $lang['EMAIL_TAKEN']; } + + return $lang['EMAIL_TAKEN']; } }