From 3320dd13802df66b246074f8f3fa76c38f043efa Mon Sep 17 00:00:00 2001 From: markjaquith Date: Wed, 7 Mar 2007 05:29:15 +0000 Subject: [PATCH] Use strpos instead of strstr where ever possible, for speed. Props rob1n. fixes #3920 git-svn-id: http://svn.automattic.com/wordpress/trunk@4990 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- app.php | 4 ++-- wp-admin/admin-functions.php | 17 ++++++++-------- wp-admin/edit-link-form.php | 6 +++--- wp-admin/import/blogger.php | 4 ++-- wp-admin/menu.php | 4 ++-- wp-admin/options.php | 2 +- wp-admin/page.php | 4 ++-- wp-admin/post.php | 4 ++-- wp-admin/templates.php | 2 +- wp-admin/upgrade-functions.php | 14 ++++++------- wp-blog-header.php | 2 +- wp-content/themes/default/functions.php | 4 ++-- wp-includes/classes.php | 4 ++-- wp-includes/comment-template.php | 26 ++++++++++++------------- wp-includes/feed.php | 2 +- wp-includes/formatting.php | 9 ++++----- wp-includes/functions.php | 6 +++--- wp-includes/general-template.php | 4 +--- wp-includes/link-template.php | 4 ++-- wp-includes/pluggable.php | 2 +- wp-includes/post.php | 4 ++-- wp-includes/query.php | 12 ++++++------ wp-includes/rewrite.php | 10 +++++----- wp-includes/vars.php | 4 ++-- wp-includes/wp-db.php | 2 +- wp-settings.php | 10 +++++----- 26 files changed, 82 insertions(+), 84 deletions(-) diff --git a/app.php b/app.php index b22bbd2406..e80ebd0361 100644 --- a/app.php +++ b/app.php @@ -192,7 +192,7 @@ class AtomParser { $this->in_content = array(); } else { $endtag = $this->ns_to_prefix($name); - if(strstr($this->in_content[count($this->in_content)-1], "<$endtag")) { + if (strpos($this->in_content[count($this->in_content)-1], '<' . $endtag) !== false) array_push($this->in_content, "/>"); } else { array_push($this->in_content, ""); @@ -220,7 +220,7 @@ class AtomParser { #print str_repeat(" ", $this->depth * $this->indent) . "data: #" . $data . "#\n"; if(!empty($this->in_content)) { // handle self-closing tags (case: text node found, need to close element started) - if(strstr($this->in_content[count($this->in_content)-1], "<")) { + if (strpos($this->in_content[count($this->in_content)-1], '<') !== false) { array_push($this->in_content, ">"); } array_push($this->in_content, $this->xml_escape($data)); diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 8c9fc400c2..2fa0688e6e 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1143,7 +1143,7 @@ function insert_with_markers( $filename, $marker, $insertion ) { if ( $markerdata ) { $state = true; foreach ( $markerdata as $n => $markerline ) { - if ( strstr( $markerline, "# BEGIN {$marker}" )) + if (strpos($markerline, '# BEGIN ' . $marker) !== false) $state = false; if ( $state ) { if ( $n + 1 < count( $markerdata ) ) @@ -1151,7 +1151,7 @@ function insert_with_markers( $filename, $marker, $insertion ) { else fwrite( $f, "{$markerline}" ); } - if ( strstr( $markerline, "# END {$marker}" ) ) { + if (strpos($markerline, '# END ' . $marker) !== false) { fwrite( $f, "# BEGIN {$marker}\n" ); if ( is_array( $insertion )) foreach ( $insertion as $insertline ) @@ -1189,11 +1189,11 @@ function extract_from_markers( $filename, $marker ) { { $state = false; foreach ( $markerdata as $markerline ) { - if ( strstr( $markerline, "# END {$marker}" )) + if (strpos($markerline, '# END ' . $marker) !== false) $state = false; if ( $state ) $result[] = $markerline; - if ( strstr( $markerline, "# BEGIN {$marker}" )) + if (strpos($markerline, '# BEGIN ' . $marker) !== false) $state = true; } } @@ -1766,7 +1766,8 @@ function browse_happy() {

Browse Happy

'; } -if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' )) + +if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) add_action( 'admin_footer', 'browse_happy' ); function documentation_link( $for ) { @@ -1927,11 +1928,11 @@ function wp_import_cleanup( $id ) { function wp_import_upload_form( $action ) { $size = strtolower( ini_get( 'upload_max_filesize' ) ); $bytes = 0; - if ( strstr( $size, 'k' ) ) + if (strpos($size, 'k') !== false) $bytes = $size * 1024; - if ( strstr( $size, 'm' ) ) + if (strpos($size, 'm') !== false) $bytes = $size * 1024 * 1024; - if ( strstr( $size, 'g' ) ) + if (strpos($size, 'g') !== false) $bytes = $size * 1024 * 1024 * 1024; ?>
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php index 66275913bf..bd226e717a 100644 --- a/wp-admin/edit-link-form.php +++ b/wp-admin/edit-link-form.php @@ -22,9 +22,9 @@ function xfn_check($class, $value = '', $type = 'check') { } if ('' == $value) { - if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"'; - if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact') ) echo ' checked="checked"'; - if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor') ) echo ' checked="checked"'; + if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"'; + if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; + if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; } } diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php index ae7a669d09..92aadb6466 100644 --- a/wp-admin/import/blogger.php +++ b/wp-admin/import/blogger.php @@ -941,7 +941,7 @@ class AtomParser { $this->in_content = array(); } else { $endtag = $this->ns_to_prefix($name); - if(strstr($this->in_content[count($this->in_content)-1], "<$endtag")) { + if (strpos($this->in_content[count($this->in_content)-1], '<' . $endtag) !== false) { array_push($this->in_content, "/>"); } else { array_push($this->in_content, ""); @@ -969,7 +969,7 @@ class AtomParser { #print str_repeat(" ", $this->depth * $this->indent) . "data: #" . $data . "#\n"; if(!empty($this->in_content)) { // handle self-closing tags (case: text node found, need to close element started) - if(strstr($this->in_content[count($this->in_content)-1], "<")) { + if (strpos($this->in_content[count($this->in_content)-1], '<') !== false) { array_push($this->in_content, ">"); } array_push($this->in_content, $this->xml_escape($data)); diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 1707b44c0b..383abeb799 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -6,11 +6,11 @@ // The URL of the item's file $menu[0] = array(__('Dashboard'), 'read', 'index.php'); -if ( strstr($_SERVER['REQUEST_URI'], 'edit-pages.php') ) +if (strpos($_SERVER['REQUEST_URI'], 'edit-pages.php') !== false) $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php'); else $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php'); -if ( strstr($_SERVER['REQUEST_URI'], 'page-new.php') ) +if (strpos($_SERVER['REQUEST_URI'], 'page-new.php') !== false) $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php'); else $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php'); diff --git a/wp-admin/options.php b/wp-admin/options.php index 12c01b764d..98aa3c42e3 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -148,7 +148,7 @@ foreach ( (array) $options as $option) : "; - if (stristr($value, "\n")) echo ""; + if (strpos($value, "\n") !== false) echo ""; else echo ""; echo " diff --git a/wp-admin/page.php b/wp-admin/page.php index 665cd52364..bb4cf27f2d 100644 --- a/wp-admin/page.php +++ b/wp-admin/page.php @@ -148,8 +148,8 @@ case 'delete': } $sendback = wp_get_referer(); - if (strstr($sendback, 'page.php')) $sendback = get_option('siteurl') .'/wp-admin/page.php'; - elseif (strstr($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; + if (strpos($sendback, 'page.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/page.php'; + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); wp_redirect($sendback); exit(); diff --git a/wp-admin/post.php b/wp-admin/post.php index 163e22013c..b19166166d 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -160,8 +160,8 @@ case 'delete': } $sendback = wp_get_referer(); - if (strstr($sendback, 'post.php')) $sendback = get_option('siteurl') .'/wp-admin/post-new.php'; - elseif (strstr($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; + if (strpos($sendback, 'post.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/post-new.php'; + elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); wp_redirect($sendback); exit(); diff --git a/wp-admin/templates.php b/wp-admin/templates.php index 465c35018d..a061072eea 100644 --- a/wp-admin/templates.php +++ b/wp-admin/templates.php @@ -52,7 +52,7 @@ default: if ( ! current_user_can('edit_files') ) wp_die('

'.__('You do not have sufficient permissions to edit templates for this blog.').'

'); - if ( strstr( $file, 'wp-config.php' ) ) + if (strpos($file, 'wp-config.php') !== false) wp_die('

'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'

'); update_recently_edited($file); diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 99491e12d4..065b722c17 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -922,7 +922,7 @@ function make_site_theme_from_oldschool($theme_name, $template) { if ($oldfile == 'index.php') { // Check to make sure it's not a new index $index = implode('', file("$oldpath/$oldfile")); - if ( strstr( $index, 'WP_USE_THEMES' ) ) { + if (strpos($index, 'WP_USE_THEMES') !== false) { if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile")) return false; continue; // Don't copy anything @@ -994,12 +994,12 @@ function make_site_theme_from_default($theme_name, $template) { $f = fopen("$site_dir/style.css", 'w'); foreach ($stylelines as $line) { - if (strstr($line, "Theme Name:")) $line = "Theme Name: $theme_name"; - elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl'); - elseif (strstr($line, "Description:")) $line = "Description: Your theme"; - elseif (strstr($line, "Version:")) $line = "Version: 1"; - elseif (strstr($line, "Author:")) $line = "Author: You"; - fwrite($f, "{$line}\n"); + if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; + elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); + elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; + elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; + elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; + fwrite($f, $line . "\n"); } fclose($f); } diff --git a/wp-blog-header.php b/wp-blog-header.php index 321f35cc41..411b93159e 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -2,7 +2,7 @@ if (! isset($wp_did_header)): if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { - if ( strstr( $_SERVER['PHP_SELF'], 'wp-admin') ) $path = ''; + if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; else $path = 'wp-admin/'; require_once( dirname(__FILE__) . '/wp-includes/classes.php'); diff --git a/wp-content/themes/default/functions.php b/wp-content/themes/default/functions.php index cad93e5682..b3ff7713b3 100644 --- a/wp-content/themes/default/functions.php +++ b/wp-content/themes/default/functions.php @@ -25,7 +25,7 @@ function kubrick_header_image() { } function kubrick_upper_color() { - if ( strstr( $url = kubrick_header_image_url(), 'header-img.php?' ) ) { + if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) { parse_str(substr($url, strpos($url, '?') + 1), $q); return $q['upper']; } else @@ -33,7 +33,7 @@ function kubrick_upper_color() { } function kubrick_lower_color() { - if ( strstr( $url = kubrick_header_image_url(), 'header-img.php?' ) ) { + if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) { parse_str(substr($url, strpos($url, '?') + 1), $q); return $q['lower']; } else diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 5cc42fe316..8c8dcd0dc9 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -120,14 +120,14 @@ class WP { } // If req_uri is empty or if it is a request for ourself, unset error. - if ( empty($request) || $req_uri == $self || strstr($_SERVER['PHP_SELF'], 'wp-admin/') ) { + if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) { if (isset($_GET['error'])) unset($_GET['error']); if (isset($error)) unset($error); - if ( isset($perma_query_vars) && strstr($_SERVER['PHP_SELF'], 'wp-admin/') ) + if (isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) unset($perma_query_vars); $this->did_permalink = false; diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 0782f33eb4..ea3ce15893 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -239,19 +239,19 @@ function trackback_url( $display = true ) { function trackback_rdf($timezone = 0) { global $id; - if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) { - echo ' - \n"; - echo ''; + if (strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) { + echo ' + \n"; + echo ''; } } diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 501bc81773..2259498d23 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -165,7 +165,7 @@ function the_category_rss($type = 'rss') { function html_type_rss() { $type = get_bloginfo('html_type'); - if ( strstr( $type, 'xhtml' ) ) + if (strpos($type, 'xhtml') !== false) $type = 'xhtml'; else $type = 'html'; diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index daafba365f..718a2171fc 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -29,10 +29,9 @@ function wptexturize($text) { if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag // static strings $curl = str_replace($static_characters, $static_replacements, $curl); - // regular expressions $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); - } elseif ( strstr($curl, ']*>)\s*
!', "$1", $pee); $pee = preg_replace('!
(\s*]*>)!', '$1', $pee); - if ( strstr( $pee, ')(.*?)!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' ", $pee); $pee = preg_replace( "|\n

$|", '

', $pee ); @@ -658,7 +657,7 @@ function convert_smilies($text) { function is_email($user_email) { $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i"; - if(strstr($user_email, '@') && strstr($user_email, '.')) { + if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) { if (preg_match($chars, $user_email)) { return true; } else { @@ -1072,7 +1071,7 @@ function clean_url( $url, $protocols = null ) { $strip = array('%0d', '%0a'); $url = str_replace($strip, '', $url); $url = str_replace(';//', '://', $url); - $url = (!strstr($url, '://')) ? 'http://'.$url : $url; + $url = (strpos($url, '://') === false) ? 'http://'.$url : $url; $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); if ( !is_array($protocols) ) $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 90f3b8f982..c1ccfe1c18 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -780,7 +780,7 @@ function add_query_arg() { $protocol = ''; } - if ( strstr($uri, '?') ) { + if (strpos($uri, '?') !== false) { $parts = explode('?', $uri, 2); if ( 1 == count($parts) ) { $base = '?'; @@ -789,7 +789,7 @@ function add_query_arg() { $base = $parts[0] . '?'; $query = $parts[1]; } - } else if ( !empty($protocol) || strstr($uri, '/') ) { + } elseif (!empty($protocol) || strpos($uri, '/') !== false) { $base = $uri . '?'; $query = ''; } else { @@ -1337,7 +1337,7 @@ function wp_die( $message, $title = '' ) { if ( empty($title) ) $title = __('WordPress › Error'); - if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) + if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $admin_dir = ''; else $admin_dir = 'wp-admin/'; diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 11c565bfab..3f50b3ccd8 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -554,9 +554,7 @@ function get_calendar($initial = true) { $daywithpost = array(); } - - - if ( strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') ) + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false) $ak_title_separator = "\n"; else $ak_title_separator = ', '; diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 5e68eb0158..65a502a9dc 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -70,7 +70,7 @@ function get_permalink($id = 0) { $unixtime = strtotime($post->post_date); $category = ''; - if ( strstr($permalink, '%category%') ) { + if (strpos($permalink, '%category%') !== false) { $cats = get_the_category($post->ID); $category = $cats[0]->category_nicename; if ( $parent=$cats[0]->category_parent ) @@ -158,7 +158,7 @@ function get_attachment_link($id = false) { $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front else $parentlink = get_permalink( $object->post_parent ); - if (! strstr($parentlink, '?') ) + if (strpos($parentlink, '?') === false) $link = trim($parentlink, '/') . '/' . $object->post_name . '/'; } diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 42577685c2..875a34700c 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -280,7 +280,7 @@ function check_admin_referer($action = -1) { $adminurl = strtolower(get_option('siteurl')).'/wp-admin'; $referer = strtolower(wp_get_referer()); if ( !wp_verify_nonce($_REQUEST['_wpnonce'], $action) && - !(-1 == $action && strstr($referer, $adminurl)) ) { + !(-1 == $action && strpos($referer, $adminurl) !== false)) wp_nonce_ays($action); die(); } diff --git a/wp-includes/post.php b/wp-includes/post.php index d3ece40ebd..83044b8347 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1198,9 +1198,9 @@ function generate_page_uri_index() { // function is_local_attachment($url) { - if ( !strstr($url, get_bloginfo('url') ) ) + if (strpos($url, get_bloginfo('url')) === false) return false; - if ( strstr($url, get_bloginfo('url') . '/?attachment_id=') ) + if (strpos($url, get_bloginfo('url') . '/?attachment_id=') !== false) return true; if ( $id = url_to_postid($url) ) { $post = & get_post($id); diff --git a/wp-includes/query.php b/wp-includes/query.php index 240d18280f..58e07a0d83 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -29,7 +29,7 @@ function &query_posts($query) { function is_admin () { global $wp_query; - return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/') ); + return ($wp_query->is_admin || (strpos($_SERVER['REQUEST_URI'], 'wp-admin/') !== false)); } function is_archive () { @@ -510,7 +510,7 @@ class WP_Query { if (empty($qv['cat']) || ($qv['cat'] == '0')) { $this->is_category = false; } else { - if (stristr($qv['cat'],'-')) { + if (strpos($qv['cat'], '-') !== false) { $this->is_category = false; } else { $this->is_category = true; @@ -557,7 +557,7 @@ class WP_Query { $this->is_preview = true; } - if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) { + if (strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) { $this->is_admin = true; } @@ -850,7 +850,7 @@ class WP_Query { $in_cats = $out_cats = $out_posts = ''; foreach ( $cat_array as $cat ) { $cat = intval($cat); - $in = strstr($cat, '-') ? false : true; + $in = (strpos($cat, '-') !== false) ? false : true; $cat = trim($cat, '-'); if ( $in ) $in_cats .= "$cat, " . get_category_children($cat, '', ', '); @@ -918,7 +918,7 @@ class WP_Query { } else { $q['author'] = ''.urldecode($q['author']).''; $q['author'] = addslashes_gpc($q['author']); - if (stristr($q['author'], '-')) { + if (strpos($q['author'], '-') !== false) { $eq = '!='; $andor = 'AND'; $q['author'] = explode('-', $q['author']); @@ -938,7 +938,7 @@ class WP_Query { // Author stuff for nice URLs if ('' != $q['author_name']) { - if (stristr($q['author_name'],'/')) { + if (strpos($q['author_name'], '/') !== false) { $q['author_name'] = explode('/',$q['author_name']); if ($q['author_name'][count($q['author_name'])-1]) { $q['author_name'] = $q['author_name'][count($q['author_name'])-1];#no trailing slash diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 95a1b1af93..06f8a16f07 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -591,11 +591,11 @@ class WP_Rewrite { //individual post. Do this by checking it contains at least one of 1) post name, //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and //minute all present). Set these flags now as we need them for the endpoints. - if (strstr($struct, '%postname%') || strstr($struct, '%post_id%') - || strstr($struct, '%pagename%') - || (strstr($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) { + if (strpos($struct, '%postname%') !== false || strpos($struct, '%post_id%') !== false + || strpos($struct, '%pagename%') !== false + || (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false)) { $post = true; - if ( strstr($struct, '%pagename%') ) + if (strpos($struct, '%pagename%') !== false) $page = true; } @@ -809,7 +809,7 @@ class WP_Rewrite { //nada. } - if (strstr($query, $this->index)) { + if (strpos($query, $this->index) !== false) { $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; } else { $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; diff --git a/wp-includes/vars.php b/wp-includes/vars.php index cac99483ae..a2fe8c2bad 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -32,8 +32,8 @@ elseif ( preg_match('/Nav/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Mozill $is_IE = ( $is_macIE || $is_winIE ); // Server detection -$is_apache = ( strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') ) ? 1 : 0; -$is_IIS = strstr($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0; +$is_apache ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? 1 : 0; +$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? 1 : 0; // if the config file does not provide the smilies array, let's define it here if (!isset($wpsmiliestrans)) { diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index d9673037ef..1a043c95be 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -372,7 +372,7 @@ class wpdb { header('Content-Type: text/html; charset=utf-8'); - if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) + if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $admin_dir = ''; else $admin_dir = 'wp-admin/'; diff --git a/wp-settings.php b/wp-settings.php index 44b0fd0f17..3bf6470468 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -40,7 +40,7 @@ if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; // Fix for Dreamhost and other PHP as CGI hosts -if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) ) +if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false) unset($_SERVER['PATH_INFO']); // Fix empty PHP_SELF @@ -140,8 +140,8 @@ include_once(ABSPATH . WPINC . '/streams.php'); include_once(ABSPATH . WPINC . '/gettext.php'); require_once (ABSPATH . WPINC . '/l10n.php'); -if ( !is_blog_installed() && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) { - if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) +if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) { + if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $link = 'install.php'; else $link = 'wp-admin/install.php'; @@ -172,11 +172,11 @@ require (ABSPATH . WPINC . '/version.php'); require (ABSPATH . WPINC . '/deprecated.php'); require (ABSPATH . WPINC . '/script-loader.php'); -if (!strstr($_SERVER['PHP_SELF'], 'install.php')) : +if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) { // Used to guarantee unique hash cookies $cookiehash = md5(get_option('siteurl')); define('COOKIEHASH', $cookiehash); -endif; +} if ( !defined('USER_COOKIE') ) define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);