From a5ab0fc858985fc07bc33332a26484509b9d0c52 Mon Sep 17 00:00:00 2001 From: mikelittle Date: Sun, 30 Nov 2003 00:55:19 +0000 Subject: [PATCH] Fixed several instances in WordPress where PHP Notices are not being handled correctly. Fixes supplied by Aaron Jensen (aaron@visualprose.com). git-svn-id: http://svn.automattic.com/wordpress/trunk@559 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- b2-include/b2functions.php | 9 ++++++--- b2-include/b2template.functions.php | 5 +++++ b2comments.php | 6 +++--- blog.header.php | 11 +++++++---- wp-rss.php | 29 +++++++++++++++++------------ wp-settings.php | 2 +- 6 files changed, 39 insertions(+), 23 deletions(-) diff --git a/b2-include/b2functions.php b/b2-include/b2functions.php index f743e33a28..26e8c90f2c 100644 --- a/b2-include/b2functions.php +++ b/b2-include/b2functions.php @@ -293,14 +293,14 @@ function convert_gmcode($content) { function convert_smilies($text) { global $smilies_directory, $use_smilies; global $b2_smiliessearch, $b2_smiliesreplace; - + $output = ''; if ($use_smilies) { // HTML loop taken from texturize function, could possible be consolidated $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between $stop = count($textarr);// loop stuff for ($i = 0; $i < $stop; $i++) { $content = $textarr[$i]; - if ('<' != $content{0}) { // If it's not a tag + if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag $content = str_replace($b2_smiliessearch, $b2_smiliesreplace, $content); } $output .= $content; @@ -1628,7 +1628,10 @@ function apply_filters($tag, $string) { global $b2_filter; if (isset($b2_filter['all'])) { $b2_filter['all'] = (is_string($b2_filter['all'])) ? array($b2_filter['all']) : $b2_filter['all']; - $b2_filter[$tag] = array_merge($b2_filter['all'], $b2_filter[$tag]); + if (isset($b2_filter[$tag])) + $b2_filter[$tag] = array_merge($b2_filter['all'], $b2_filter[$tag]); + else + $b2_filter[$tag] = array_merge($b2_filter['all'], array()); $b2_filter[$tag] = array_unique($b2_filter[$tag]); } if (isset($b2_filter[$tag])) { diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 8a4a9dffc6..9d63ca3ee3 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -919,6 +919,7 @@ function the_excerpt_rss($cut = 0, $encode_html = 0) { $output = strip_tags($output); } if ($cut) { + $excerpt = ''; $blah = explode(' ', $output); if (count($blah) > $cut) { $k = $cut; @@ -970,6 +971,7 @@ function get_the_excerpt($fakeit = false) { $k = count($blah); $use_dotdotdot = 0; } + $excerpt = ''; for ($i=0; $i<$k; $i++) { $excerpt .= $blah[$i].' '; } @@ -1227,6 +1229,9 @@ function get_category_link($echo = false, $file='') { if ($file == '') { $file = "$siteurl/$blogfilename"; } + if ('http:' != substr($file,0,5)) { + $file = "$siteurl/$file"; + } $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID; if ($echo) echo($link); diff --git a/b2comments.php b/b2comments.php index d6da0f3249..33ea662c77 100644 --- a/b2comments.php +++ b/b2comments.php @@ -10,9 +10,9 @@ } } - $comment_author = trim($HTTP_COOKIE_VARS["comment_author_".$cookiehash]); - $comment_author_email = trim($HTTP_COOKIE_VARS["comment_author_email_".$cookiehash]); - $comment_author_url = trim($HTTP_COOKIE_VARS["comment_author_url_".$cookiehash]); + $comment_author = (isset($HTTP_COOKIE_VARS['comment_author_'.$cookiehash])) ? trim($HTTP_COOKIE_VARS['comment_author_'.$cookiehash]) : ''; + $comment_author_email = (isset($HTTP_COOKIE_VARS['comment_author_email_'.$cookiehash])) ? trim($HTTP_COOKIE_VARS['comment_author_email_'.$cookiehash]) : ''; + $comment_author_url = (isset($HTTP_COOKIE_VARS['comment_author_url_'.$cookiehash])) ? trim($HTTP_COOKIE_VARS['comment_author_url_'.$cookiehash]) : ''; $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date"); ++$querycount; diff --git a/blog.header.php b/blog.header.php index b834531a5a..7e2766d305 100644 --- a/blog.header.php +++ b/blog.header.php @@ -41,9 +41,9 @@ $b2varstoreset = array('m','p','posts','w','c', 'cat','withcomments','s','search @header ("X-Pingback: $siteurl/xmlrpc.php"); /* Getting settings from db */ -if ($doing_rss == 1) +if (isset($doing_rss) && $doing_rss == 1) $posts_per_page=get_settings('posts_per_rss'); -if ($posts_per_page == 0) +if (!isset($posts_per_page) || $posts_per_page == 0) $posts_per_page = get_settings('posts_per_page'); $what_to_show = get_settings('what_to_show'); $archive_mode = get_settings('archive_mode'); @@ -61,7 +61,7 @@ $distinct = ''; if ($pagenow != 'wp-post.php') { timer_start(); } -if ($showposts) { +if (isset($showposts) && $showposts) { $showposts = (int)$showposts; $posts_per_page = $showposts; } @@ -288,7 +288,10 @@ if ($pagenow != 'wp-post.php') { $where .= ' AND (post_status = "publish"'; // Get private posts -if ('' != intval($user_ID)) $where .= " OR post_author = $user_ID AND post_status != 'draft')"; else $where .= ')'; +if (isset($user_ID) && ('' != intval($user_ID))) + $where .= " OR post_author = $user_ID AND post_status != 'draft')"; +else + $where .= ')'; $request = " SELECT $distinct * FROM $tableposts WHERE 1=1".$where." ORDER BY post_$orderby $limits"; diff --git a/wp-rss.php b/wp-rss.php index 494fe551cd..d4584a4736 100644 --- a/wp-rss.php +++ b/wp-rss.php @@ -1,25 +1,23 @@ get_var($sql); +$maxdate = $wpdb->get_var("SELECT max(post_date) FROM $tableposts"); ++$querycount; $unixtime = strtotime($maxdate); // format timestamp for Last-Modified header -$clast = gmdate("D, d M Y H:i:s \G\M\T",$unixtime); -$cetag = md5($last); +$clast = gmdate("D, d M Y H:i:s \G\M\T", $unixtime); +$cetag = (isset($last)) ? md5($last) : ''; -$slast = $_SERVER['HTTP_IF_MODIFIED_SINCE']; -$setag = $_SERVER['HTTP_IF_NONE_MATCH']; +$slast = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : '' ; +$setag = (isset($_SERVER['HTTP_IF_NONE_MATCH'])) ? $_SERVER['HTTP_IF_NONE_MATCH'] : ''; // send it in a Last-Modified header header("Last-Modified: " . $clast, true); @@ -32,10 +30,17 @@ header("Etag: " . $cetag, true); // but if both headers exist, they *both* must match up with the locally // generated values. //if (($slast?($slast == $clast):true) && ($setag?($setag == $cetag):true)){ -if (($slast && $setag)?(($slast == $clast) && ($setag == $cetag)):(($slast == $clast) || ($setag == $cetag))) { - header("HTTP/1.1 304 Not Modified"); - echo "\r\n\r\n"; - exit; +if (($slast != '') && ($setag != '')) { + if (($slast == $clast) && ($setag == $cetag)) { + header("HTTP/1.1 304 Not Modified"); + echo "\r\n\r\n"; + exit; + } else if (($slast == $clast) + || ($setag == $cetag)) { + header("HTTP/1.1 304 Not Modified"); + echo "\r\n\r\n"; + exit; + } } if (!isset($rss_language)) { $rss_language = 'en'; } diff --git a/wp-settings.php b/wp-settings.php index f2192d4b07..de462bcb6f 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -4,7 +4,7 @@ // We should eventually migrate to either calling // get_settings() wherever these are needed OR // accessing a single global $all_settings var -if (!$_wp_installing) { +if (!isset($_wp_installing) || !$_wp_installing) { $siteurl = get_settings('siteurl'); // "When trying to design a foolproof system, // never underestimate the ingenuity of the fools :)"