Skip to content

Commit b4d079f

Browse files
committed
'str(i)str(...)' could be replaced with 'str(i)pos(...)'.
1 parent e89f017 commit b4d079f

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

Diff for: admin/admin_user_search.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271

272272
$username = preg_replace('/\*/', '%', trim(strip_tags(strtolower($username))));
273273

274-
if (strstr($username, '%')) {
274+
if (false !== strpos($username, '%')) {
275275
$op = 'LIKE';
276276
} else {
277277
$op = '=';
@@ -292,7 +292,7 @@
292292

293293
$email = preg_replace('/\*/', '%', trim(strip_tags(strtolower($email))));
294294

295-
if (strstr($email, '%')) {
295+
if (false !== strpos($email, '%')) {
296296
$op = 'LIKE';
297297
} else {
298298
$op = '=';
@@ -577,7 +577,7 @@
577577
break;
578578
case 'equals':
579579
// looking for a -
580-
if (strstr($postcount_value, '-')) {
580+
if (false !== strpos($postcount_value, '-')) {
581581
$range = preg_split('/[-\s]+/', $postcount_value);
582582

583583
$range_begin = (int)$range[0];
@@ -624,7 +624,7 @@
624624

625625
$userfield_value = preg_replace('/\*/', '%', trim(strip_tags(strtolower($userfield_value))));
626626

627-
if (strstr($userfield_value, '%')) {
627+
if (false !== strpos($userfield_value, '%')) {
628628
$op = 'LIKE';
629629
} else {
630630
$op = '=';

Diff for: dl.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function send_file_to_browser($attachment, $upload_dir)
5454

5555
// Correct the mime type - we force application/octet-stream for all files, except images
5656
// Please do not change this, it is a security precaution
57-
if (!strstr($attachment['mimetype'], 'image')) {
57+
if (false === strpos($attachment['mimetype'], 'image')) {
5858
$attachment['mimetype'] = 'application/octet-stream';
5959
}
6060

Diff for: library/attach_mod/includes/functions_attach.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ function attachment_sync_topic($topics)
410410
*/
411411
function get_extension($filename)
412412
{
413-
if (!stristr($filename, '.')) {
413+
if (false === stripos($filename, '.')) {
414414
return '';
415415
}
416416
$extension = strrchr(strtolower($filename), '.');

Diff for: library/attach_mod/includes/functions_delete.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
4141
$post_id_array = array();
4242

4343
if (!is_array($attach_id_array)) {
44-
if (strstr($attach_id_array, ', ')) {
44+
if (false !== strpos($attach_id_array, ', ')) {
4545
$attach_id_array = explode(', ', $attach_id_array);
4646
} elseif (strstr($attach_id_array, ',')) {
4747
$attach_id_array = explode(',', $attach_id_array);
@@ -82,7 +82,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
8282
return;
8383
}
8484

85-
if (strstr($post_id_array, ', ')) {
85+
if (false !== strpos($post_id_array, ', ')) {
8686
$post_id_array = explode(', ', $post_id_array);
8787
} elseif (strstr($post_id_array, ',')) {
8888
$post_id_array = explode(',', $post_id_array);
@@ -127,7 +127,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
127127
}
128128

129129
if (!is_array($attach_id_array)) {
130-
if (strstr($attach_id_array, ', ')) {
130+
if (false !== strpos($attach_id_array, ', ')) {
131131
$attach_id_array = explode(', ', $attach_id_array);
132132
} elseif (strstr($attach_id_array, ',')) {
133133
$attach_id_array = explode(',', $attach_id_array);

Diff for: library/includes/functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ function redirect($url)
17411741
trigger_error("Headers already sent in $filename($linenum)", E_USER_ERROR);
17421742
}
17431743

1744-
if (strstr(urldecode($url), "\n") || strstr(urldecode($url), "\r") || strstr(urldecode($url), ';url')) {
1744+
if (false !== strpos(urldecode($url), "\n") || false !== strpos(urldecode($url), "\r") || false !== strpos(urldecode($url), ';url')) {
17451745
bb_die('Tried to redirect to potentially insecure url');
17461746
}
17471747

Diff for: library/includes/init_bb.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ function bb_setcookie($name, $val, $lifetime = COOKIE_PERSIST, $httponly = false
378378

379379
if (!empty($banned_user_agents)) {
380380
foreach ($banned_user_agents as $agent) {
381-
if (strstr(USER_AGENT, $agent)) {
381+
if (false !== strpos(USER_AGENT, $agent)) {
382382
$filename = 'Download files by using browser';
383383
$output = '@';
384384
header('Content-Type: text/plain');

Diff for: library/includes/template.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public function assign_var_from_handle($varname, $handle): bool
393393
*/
394394
public function assign_block_vars($blockname, $vararray): bool
395395
{
396-
if (strstr($blockname, '.')) {
396+
if (false !== strpos($blockname, '.')) {
397397
// Nested block.
398398
$blocks = explode('.', $blockname);
399399
$blockcount = count($blocks) - 1;

Diff for: login.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
if (preg_match('/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si', $_SERVER['QUERY_STRING'], $matches)) {
4949
$redirect_url = $matches[1];
5050

51-
if (!strstr($redirect_url, '?') && $first_amp = strpos($redirect_url, '&')) {
51+
if (false === strpos($redirect_url, '?') && $first_amp = strpos($redirect_url, '&')) {
5252
$redirect_url[$first_amp] = '?';
5353
}
5454
} elseif (!empty($_POST['redirect'])) {
@@ -60,7 +60,7 @@
6060
$redirect_url = str_replace('&admin=1', '', $redirect_url);
6161
$redirect_url = str_replace('?admin=1', '', $redirect_url);
6262

63-
if (!$redirect_url || strstr(urldecode($redirect_url), "\n") || strstr(urldecode($redirect_url), "\r") || strstr(urldecode($redirect_url), ';url')) {
63+
if (!$redirect_url || false !== strpos(urldecode($redirect_url), "\n") || false !== strpos(urldecode($redirect_url), "\r") || false !== strpos(urldecode($redirect_url), ';url')) {
6464
$redirect_url = "index.php";
6565
}
6666

0 commit comments

Comments
 (0)