mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Replaced strpos() with simplified realization (#1172)
This commit is contained in:
parent
bb20d523b0
commit
493cd910cf
13 changed files with 24 additions and 24 deletions
|
@ -255,7 +255,7 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
|
||||
$username = str_replace("\*", '%', trim(strip_tags(strtolower($username))));
|
||||
|
||||
if (false !== strpos($username, '%')) {
|
||||
if (str_contains($username, '%')) {
|
||||
$op = 'LIKE';
|
||||
} else {
|
||||
$op = '=';
|
||||
|
@ -276,7 +276,7 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
|
||||
$email = str_replace("\*", '%', trim(strip_tags(strtolower($email))));
|
||||
|
||||
if (false !== strpos($email, '%')) {
|
||||
if (str_contains($email, '%')) {
|
||||
$op = 'LIKE';
|
||||
} else {
|
||||
$op = '=';
|
||||
|
@ -524,7 +524,7 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
break;
|
||||
case 'equals':
|
||||
// looking for a -
|
||||
if (false !== strpos($postcount_value, '-')) {
|
||||
if (str_contains($postcount_value, '-')) {
|
||||
$range = preg_split('/[-\s]+/', $postcount_value);
|
||||
|
||||
$range_begin = (int)$range[0];
|
||||
|
@ -571,7 +571,7 @@ if (!isset($_REQUEST['dosearch'])) {
|
|||
|
||||
$userfield_value = str_replace("\*", '%', trim(strip_tags(strtolower($userfield_value))));
|
||||
|
||||
if (false !== strpos($userfield_value, '%')) {
|
||||
if (str_contains($userfield_value, '%')) {
|
||||
$op = 'LIKE';
|
||||
} else {
|
||||
$op = '=';
|
||||
|
|
|
@ -27,7 +27,7 @@ if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
|
|||
}
|
||||
|
||||
// Initial request verification
|
||||
if (strpos($_SERVER['REQUEST_URI'], 'scrape') !== false) {
|
||||
if (str_contains($_SERVER['REQUEST_URI'], 'scrape')) {
|
||||
msg_die('Please disable SCRAPE!');
|
||||
}
|
||||
|
||||
|
|
2
dl.php
2
dl.php
|
@ -38,7 +38,7 @@ function send_file_to_browser($attachment, $upload_dir)
|
|||
|
||||
// Correct the mime type - we force application/octet-stream for all files, except images
|
||||
// Please do not change this, it is a security precaution
|
||||
if (false === strpos($attachment['mimetype'], 'image')) {
|
||||
if (!str_contains($attachment['mimetype'], 'image')) {
|
||||
$attachment['mimetype'] = 'application/octet-stream';
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ switch ($mode) {
|
|||
$dir = $template->cachedir;
|
||||
$res = @opendir($dir);
|
||||
while (($file = readdir($res)) !== false) {
|
||||
if (0 === strpos($file, $match)) {
|
||||
if (str_starts_with($file, $match)) {
|
||||
@unlink($dir . $file);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ function attachment_sync_topic($topics)
|
|||
*/
|
||||
function get_extension($filename)
|
||||
{
|
||||
if (false === strpos($filename, '.')) {
|
||||
if (!str_contains($filename, '.')) {
|
||||
return '';
|
||||
}
|
||||
$extension = strrchr(strtolower($filename), '.');
|
||||
|
|
|
@ -26,9 +26,9 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
|
|||
$post_id_array = [];
|
||||
|
||||
if (!is_array($attach_id_array)) {
|
||||
if (false !== strpos($attach_id_array, ', ')) {
|
||||
if (str_contains($attach_id_array, ', ')) {
|
||||
$attach_id_array = explode(', ', $attach_id_array);
|
||||
} elseif (false !== strpos($attach_id_array, ',')) {
|
||||
} elseif (str_contains($attach_id_array, ',')) {
|
||||
$attach_id_array = explode(',', $attach_id_array);
|
||||
} else {
|
||||
$attach_id = (int)$attach_id_array;
|
||||
|
@ -67,9 +67,9 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
|
|||
return;
|
||||
}
|
||||
|
||||
if (false !== strpos($post_id_array, ', ')) {
|
||||
if (str_contains($post_id_array, ', ')) {
|
||||
$post_id_array = explode(', ', $post_id_array);
|
||||
} elseif (false !== strpos($post_id_array, ',')) {
|
||||
} elseif (str_contains($post_id_array, ',')) {
|
||||
$post_id_array = explode(',', $post_id_array);
|
||||
} else {
|
||||
$post_id = (int)$post_id_array;
|
||||
|
@ -112,9 +112,9 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
|
|||
}
|
||||
|
||||
if (!is_array($attach_id_array)) {
|
||||
if (false !== strpos($attach_id_array, ', ')) {
|
||||
if (str_contains($attach_id_array, ', ')) {
|
||||
$attach_id_array = explode(', ', $attach_id_array);
|
||||
} elseif (false !== strpos($attach_id_array, ',')) {
|
||||
} elseif (str_contains($attach_id_array, ',')) {
|
||||
$attach_id_array = explode(',', $attach_id_array);
|
||||
} else {
|
||||
$attach_id = (int)$attach_id_array;
|
||||
|
|
|
@ -97,7 +97,7 @@ define('CRON_RUNNING', TRIGGERS_DIR . '/cron_running');
|
|||
|
||||
// Gzip
|
||||
define('GZIP_OUTPUT_ALLOWED', extension_loaded('zlib') && !ini_get('zlib.output_compression'));
|
||||
define('UA_GZIP_SUPPORTED', isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false);
|
||||
define('UA_GZIP_SUPPORTED', isset($_SERVER['HTTP_ACCEPT_ENCODING']) && str_contains($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'));
|
||||
|
||||
// Torrents (reserved: -1)
|
||||
define('TOR_NOT_APPROVED', 0); // не проверено
|
||||
|
|
|
@ -553,7 +553,7 @@ function url_arg($url, $arg, $value, $amp = '&')
|
|||
$url = str_replace($cur, $new, $url);
|
||||
} // добавляем параметр
|
||||
elseif (null !== $value) {
|
||||
$div = (strpos($url, '?') !== false) ? $amp : '?';
|
||||
$div = str_contains($url, '?') ? $amp : '?';
|
||||
$url = $url . $div . $arg . '=' . urlencode($value);
|
||||
}
|
||||
return $url . $anchor;
|
||||
|
@ -1469,7 +1469,7 @@ function redirect($url)
|
|||
trigger_error("Headers already sent in $filename($linenum)", E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (false !== strpos(urldecode($url), "\n") || false !== strpos(urldecode($url), "\r") || false !== strpos(urldecode($url), ';url')) {
|
||||
if (str_contains(urldecode($url), "\n") || str_contains(urldecode($url), "\r") || str_contains(urldecode($url), ';url')) {
|
||||
bb_die('Tried to redirect to potentially insecure url');
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ $login_errors = [];
|
|||
if (preg_match('/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si', $_SERVER['QUERY_STRING'], $matches)) {
|
||||
$redirect_url = $matches[1];
|
||||
|
||||
if (false === strpos($redirect_url, '?') && $first_amp = strpos($redirect_url, '&')) {
|
||||
if (!str_contains($redirect_url, '?') && $first_amp = strpos($redirect_url, '&')) {
|
||||
$redirect_url[$first_amp] = '?';
|
||||
}
|
||||
} elseif (!empty($_POST['redirect'])) {
|
||||
|
@ -43,7 +43,7 @@ if (preg_match('/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si', $_SERVER['QUERY_STRING
|
|||
|
||||
$redirect_url = str_replace(['&admin=1', '?admin=1'], '', $redirect_url);
|
||||
|
||||
if (!$redirect_url || false !== strpos(urldecode($redirect_url), "\n") || false !== strpos(urldecode($redirect_url), "\r") || false !== strpos(urldecode($redirect_url), ';url')) {
|
||||
if (!$redirect_url || str_contains(urldecode($redirect_url), "\n") || str_contains(urldecode($redirect_url), "\r") || str_contains(urldecode($redirect_url), ';url')) {
|
||||
$redirect_url = 'index.php';
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class IPHelper extends Ip
|
|||
public static function anonymizeIP(string $ip): string
|
||||
{
|
||||
$wrappedIPv6 = false;
|
||||
if ('[' === substr($ip, 0, 1) && ']' === substr($ip, -1, 1)) {
|
||||
if (str_starts_with($ip, '[') && str_ends_with($ip, ']')) {
|
||||
$wrappedIPv6 = true;
|
||||
$ip = substr($ip, 1, -1);
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ class BBCode
|
|||
private function parse($text): string
|
||||
{
|
||||
// Tag parse
|
||||
if (strpos($text, '[') === false) {
|
||||
if (!str_contains($text, '[')) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
|
|
@ -968,7 +968,7 @@ class SqlDb
|
|||
$query = "SELECT * FROM $m[1] WHERE $m[2]";
|
||||
}
|
||||
|
||||
if (0 === strpos($query, "SELECT")) {
|
||||
if (str_starts_with($query, "SELECT")) {
|
||||
$html_table = false;
|
||||
|
||||
if ($result = mysqli_query($this->link, "EXPLAIN $query")) {
|
||||
|
|
|
@ -310,7 +310,7 @@ class Template
|
|||
*/
|
||||
public function assign_block_vars($blockname, $vararray)
|
||||
{
|
||||
if (false !== strpos($blockname, '.')) {
|
||||
if (str_contains($blockname, '.')) {
|
||||
// Nested block.
|
||||
$blocks = explode('.', $blockname);
|
||||
$blockcount = \count($blocks) - 1;
|
||||
|
@ -994,7 +994,7 @@ class Template
|
|||
$this->vars['LANG'] ??= $bb_cfg['default_lang'];
|
||||
// adding current template
|
||||
$tpl = $this->root . '/';
|
||||
if (0 === strpos($tpl, './')) {
|
||||
if (str_starts_with($tpl, './')) {
|
||||
$tpl = substr($tpl, 2, \strlen($tpl));
|
||||
}
|
||||
$this->vars['TEMPLATE'] ??= $tpl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue