Changeset 114
- Timestamp:
- 05/29/2003 02:04:30 PM (22 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/b2-include/b2functions.php
r111 r114 433 433 $sql = "SELECT * FROM $tableposts WHERE $showcatzero post_date <= '$now' ORDER BY post_date DESC LIMIT 1"; 434 434 $result = mysql_query($sql) or die("Your SQL query: <br />$sql<br /><br />MySQL said:<br />".mysql_error()); 435 $querycount++;435 ++$querycount; 436 436 $myrow = mysql_fetch_object($result); 437 437 $lastpostdate = $myrow->post_date; … … 460 460 $result = mysql_query($sql) or die("Your SQL query: <br />$sql<br /><br />MySQL said:<br />".mysql_error()); 461 461 $myrow = mysql_fetch_array($result); 462 $querycount++;462 ++$querycount; 463 463 $cache_userdata[$userid] = $myrow; 464 464 } else { … … 469 469 470 470 function get_userdata2($userid) { // for team-listing 471 global $tableusers,$ row;471 global $tableusers,$post; 472 472 $user_data['ID'] = $userid; 473 $user_data['user_login'] = $ row->user_login;474 $user_data['user_firstname'] = $ row->user_firstname;475 $user_data['user_lastname'] = $ row->user_lastname;476 $user_data['user_nickname'] = $ row->user_nickname;477 $user_data['user_level'] = $ row->user_level;478 $user_data['user_email'] = $ row->user_email;479 $user_data['user_url'] = $ row->user_url;473 $user_data['user_login'] = $post->user_login; 474 $user_data['user_firstname'] = $post->user_firstname; 475 $user_data['user_lastname'] = $post->user_lastname; 476 $user_data['user_nickname'] = $post->user_nickname; 477 $user_data['user_level'] = $post->user_level; 478 $user_data['user_email'] = $post->user_email; 479 $user_data['user_url'] = $post->user_url; 480 480 return($user_data); 481 481 } … … 488 488 if (!$result) die($sql."<br /><br />".mysql_error()); 489 489 $myrow = mysql_fetch_array($result); 490 $querycount++;490 ++$querycount; 491 491 $cache_userdata["$user_login"] = $myrow; 492 492 } else { … … 502 502 $result = mysql_query($sql) or die("No user with the login <i>$user_login</i>"); 503 503 $myrow = mysql_fetch_array($result); 504 $querycount++;504 ++$querycount; 505 505 $cache_userdata["$user_login"] = $myrow; 506 506 } else { … … 514 514 $sql = "SELECT * FROM $tableposts WHERE post_author = $userid"; 515 515 $result = mysql_query($sql) or die("Your SQL query: <br />$sql<br /><br />MySQL said:<br />".mysql_error()); 516 $querycount++;516 ++$querycount; 517 517 return mysql_num_rows($result); 518 518 } 519 519 520 520 function get_settings($setting) { 521 global $tablesettings, $querycount,$cache_settings,$use_cache;521 global $tablesettings, $wpdb, $cache_settings, $use_cache, $querycount; 522 522 if ((empty($cache_settings)) OR (!$use_cache)) { 523 $sql = "SELECT * FROM $tablesettings"; 524 $result = mysql_query($sql) or die("Your SQL query: <br />$sql<br /><br />MySQL said:<br />".mysql_error()); 525 $querycount++; 526 $myrow = mysql_fetch_object($result); 527 $cache_settings = $myrow; 528 } else { 529 $myrow = $cache_settings; 530 } 531 return($myrow->$setting); 523 $settings = $wpdb->get_row("SELECT * FROM $tablesettings"); 524 ++$querycount; 525 $cache_settings = $settings; 526 } else { 527 $settings = $cache_settings; 528 } 529 return($settings->$setting); 532 530 } 533 531 534 532 function get_postdata($postid) { 535 global $tableusers,$tablesettings,$tablecategories,$tableposts,$tablecomments,$querycount; 536 $sql = "SELECT * FROM $tableposts WHERE ID = $postid"; 537 $result = mysql_query($sql) or die("Your SQL query: <br />$sql<br /><br />MySQL said:<br />".mysql_error()); 538 $querycount++; 539 if (mysql_num_rows($result)) { 540 $myrow = mysql_fetch_object($result); 541 $postdata = array ( 542 'ID' => $myrow->ID, 543 'Author_ID' => $myrow->post_author, 544 'Date' => $myrow->post_date, 545 'Content' => $myrow->post_content, 546 'Excerpt' => $myrow->post_excerpt, 547 'Title' => $myrow->post_title, 548 'Category' => $myrow->post_category, 549 ); 550 return($postdata); 551 } else { 552 return false; 553 } 533 global $tableusers, $tablesettings, $tablecategories, $tableposts, $tablecomments, $querycount, $wpdb; 534 $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID = $postid"); 535 ++$querycount; 536 537 $postdata = array ( 538 'ID' => $post->ID, 539 'Author_ID' => $post->post_author, 540 'Date' => $post->post_date, 541 'Content' => $post->post_content, 542 'Excerpt' => $post->post_excerpt, 543 'Title' => $post->post_title, 544 'Category' => $post->post_category, 545 ); 546 return($postdata); 554 547 } 555 548 556 549 function get_postdata2($postid=0) { // less flexible, but saves mysql queries 557 global $ row;550 global $post; 558 551 $postdata = array ( 559 'ID' => $ row->ID,560 'Author_ID' => $ row->post_author,561 'Date' => $ row->post_date,562 'Content' => $ row->post_content,563 'Excerpt' => $ row->post_excerpt,564 'Title' => $ row->post_title,565 'Category' => $ row->post_category,566 # 'Notify' => $ row->post_notifycomments,567 # 'Clickable' => $ row->post_make_clickable,568 'Karma' => $ row->post_karma // this isn't used yet552 'ID' => $post->ID, 553 'Author_ID' => $post->post_author, 554 'Date' => $post->post_date, 555 'Content' => $post->post_content, 556 'Excerpt' => $post->post_excerpt, 557 'Title' => $post->post_title, 558 'Category' => $post->post_category, 559 # 'Notify' => $post->post_notifycomments, 560 # 'Clickable' => $post->post_make_clickable, 561 'Karma' => $post->post_karma // this isn't used yet 569 562 ); 570 563 return($postdata); … … 572 565 573 566 function get_commentdata($comment_ID,$no_cache=0) { // less flexible, but saves mysql queries 574 global $ rowc,$id,$commentdata,$tablecomments,$querycount;567 global $postc,$id,$commentdata,$tablecomments,$querycount; 575 568 if ($no_cache) { 576 569 $query="SELECT * FROM $tablecomments WHERE comment_ID = $comment_ID"; 577 570 $result=mysql_query($query); 578 $querycount++;571 ++$querycount; 579 572 $myrow = mysql_fetch_array($result); 580 573 } else { 581 $myrow['comment_ID']=$ rowc->comment_ID;582 $myrow['comment_post_ID']=$ rowc->comment_post_ID;583 $myrow['comment_author']=$ rowc->comment_author;584 $myrow['comment_author_email']=$ rowc->comment_author_email;585 $myrow['comment_author_url']=$ rowc->comment_author_url;586 $myrow['comment_author_IP']=$ rowc->comment_author_IP;587 $myrow['comment_date']=$ rowc->comment_date;588 $myrow['comment_content']=$ rowc->comment_content;589 $myrow['comment_karma']=$ rowc->comment_karma;574 $myrow['comment_ID']=$postc->comment_ID; 575 $myrow['comment_post_ID']=$postc->comment_post_ID; 576 $myrow['comment_author']=$postc->comment_author; 577 $myrow['comment_author_email']=$postc->comment_author_email; 578 $myrow['comment_author_url']=$postc->comment_author_url; 579 $myrow['comment_author_IP']=$postc->comment_author_IP; 580 $myrow['comment_date']=$postc->comment_date; 581 $myrow['comment_content']=$postc->comment_content; 582 $myrow['comment_karma']=$postc->comment_karma; 590 583 if (strstr($myrow['comment_content'], '<trackback />')) { 591 584 $myrow['comment_type'] = 'trackback'; … … 605 598 $result = mysql_query($sql) or die('Oops, couldn\'t query the db for categories.'); 606 599 $querycount; 607 while ($ row= mysql_fetch_object($result)) {608 $cache_catnames[$ row->cat_ID] = $row->cat_name;600 while ($post = mysql_fetch_object($result)) { 601 $cache_catnames[$post->cat_ID] = $post->cat_name; 609 602 } 610 603 } … … 622 615 $query="SELECT * FROM $tablecategories"; 623 616 $result=mysql_query($query); 624 $querycount++;617 ++$querycount; 625 618 $width = ($mode=="sidebar") ? "100%" : "170px"; 626 619 echo '<select name="post_category" style="width:'.$width.';" tabindex="2" id="category">'; 627 while($ row= mysql_fetch_object($result)) {628 echo "<option value=\"".$ row->cat_ID."\"";629 if ($ row->cat_ID == $postdata["Category"])620 while($post = mysql_fetch_object($result)) { 621 echo "<option value=\"".$post->cat_ID."\""; 622 if ($post->cat_ID == $postdata["Category"]) 630 623 echo " selected"; 631 echo ">".$ row->cat_name."</option>";624 echo ">".$post->cat_name."</option>"; 632 625 } 633 626 echo "</select>"; … … 892 885 } 893 886 die(); 894 }895 896 // updates the RSS feed !897 function rss_update($blog_ID, $num_posts="", $file="./b2rss.xml") {898 899 global $use_rss, $b2_version, $querystring_start, $querystring_equal, $querystring_separator;900 global $admin_email,$blogname,$siteurl,$blogfilename,$blogdescription,$posts_per_rss,$rss_language;901 global $tableposts,$postdata,$row;902 903 if ($rss_language == '') {904 $rss_language = 'en';905 }906 907 if ($use_rss) {908 909 $num_posts = ($num_posts=="") ? $posts_per_rss : 5;910 911 $date_now = gmdate("D, d M Y H:i:s")." GMT";912 913 # let's build the rss file914 $rss = '';915 916 $rss .= '<?xml version="1.0"?'.">\n";917 $rss .= "<!-- generator=\"b2/$b2_version\" -->\n";918 $rss .= "<rss version=\"0.92\">\n";919 $rss .= "\t<channel>\n";920 $rss .= "\t\t<title>".convert_chars(strip_tags(get_bloginfo("name")),"unicode")."</title>\n";921 $rss .= "\t\t<link>".convert_chars(strip_tags(get_bloginfo("url")),"unicode")."</link>\n";922 $rss .= "\t\t<description>".convert_chars(strip_tags(get_bloginfo("description")),"unicode")."</description>\n";923 $rss .= "\t\t<lastBuildDate>$date_now</lastBuildDate>\n";924 $rss .= "\t\t<docs>http://backend.userland.com/rss092</docs>\n";925 $rss .= "\t\t<managingEditor>$admin_email</managingEditor>\n";926 $rss .= "\t\t<webMaster>$admin_email</webMaster>\n";927 $rss .= "\t\t<language>$rss_language</language>\n";928 929 $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));930 $sql = "SELECT * FROM $tableposts WHERE post_date <= '$now' AND post_category > 0 ORDER BY post_date DESC LIMIT $num_posts";931 $result = mysql_query($sql) or die("Your SQL query: <br />$sql<br /><br />MySQL said:<br />".mysql_error());932 933 while($row = mysql_fetch_object($result)) {934 935 $id = $row->ID;936 $postdata=get_postdata2($id);937 938 $rss .= "\t\t<item>\n";939 $rss .= "\t\t\t<title>".convert_chars(strip_tags(get_the_title()),"unicode")."</title>\n";940 941 // we could add some specific RSS here, but not yet. uncomment if you wish, it's functionnal942 // $rss .= "\t\t\t<category>".convert_chars(strip_tags(get_the_category()),"unicode")."</category>\n";943 944 $content = stripslashes($row->post_content);945 $content = explode("<!--more-->",$content);946 $content = $content[0];947 $rss .= "\t\t\t<description>".convert_chars(make_url_footnote($content),"unicode")."</description>\n";948 949 $rss .= "\t\t\t<link>".htmlentities("$siteurl/$blogfilename".$querystring_start.'p'.$querystring_equal.$row->ID.$querystring_separator.'c'.$querystring_equal.'1')."</link>\n";950 $rss .= "\t\t</item>\n";951 952 }953 954 $rss .= "\t</channel>\n";955 $rss .= "</rss>";956 957 $f=@fopen("$file","w+");958 if ($f) {959 @fwrite($f,$rss);960 @fclose($f);961 962 return(true);963 } else {964 return(false);965 }966 } else {967 return(false);968 }969 887 } 970 888 -
trunk/b2-include/b2template.functions.php
r91 r114 72 72 } 73 73 74 function single_post_title($prefix = '', $display = 1) {74 function single_post_title($prefix = '', $display = true) { 75 75 global $p; 76 76 if (intval($p)) { … … 86 86 } 87 87 88 function single_cat_title($prefix = '', $display = 1) {88 function single_cat_title($prefix = '', $display = true ) { 89 89 global $cat; 90 90 if(!empty($cat) && !(strtoupper($cat) == 'ALL')) { … … 99 99 } 100 100 101 function single_month_title($prefix = '', $display = 1) {101 function single_month_title($prefix = '', $display = true ) { 102 102 global $m, $month; 103 103 if(!empty($m)) { … … 112 112 113 113 function get_archives($type, $limit='') { 114 global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename, $querystring_start, $querystring_equal, $month ;114 global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename, $querystring_start, $querystring_equal, $month, $wpdb; 115 115 // weekly and daily are *broken* 116 dbconnect();117 116 if ('' != $limit) { 118 117 $limit = (int) $limit; … … 131 130 $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); 132 131 133 if ($type == 'monthly') { 134 $arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit; 135 $querycount++; 136 $arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error()); 137 while($arc_row = mysql_fetch_array($arc_result)) { 138 $arc_year = $arc_row['YEAR(post_date)']; 139 $arc_month = $arc_row['MONTH(post_date)']; 140 echo "<li><a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).'">'; 141 echo $month[zeroise($arc_month,2)].' '.$arc_year; 132 if ('monthly' == $type) { 133 ++$querycount; 134 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit); 135 foreach ($arcresults as $arcresult) { 136 echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).'">'; 137 echo $month[zeroise($arcresult->month, 2)].' '.$arcresult->year; 142 138 echo "</a></li>\n"; 143 139 } 144 } elseif ($type == 'daily') { 145 $arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit; 146 $querycount++; 147 $arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error()); 148 while($arc_row = mysql_fetch_array($arc_result)) { 149 $arc_year = $arc_row['YEAR(post_date)']; 150 $arc_month = $arc_row['MONTH(post_date)']; 151 $arc_dayofmonth = $arc_row['DAYOFMONTH(post_date)']; 152 echo "<li><a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).zeroise($arc_dayofmonth,2).'">'; 153 echo mysql2date($archive_day_date_format, $arc_year.'-'.zeroise($arc_month,2).'-'.zeroise($arc_dayofmonth,2).' 00:00:00'); 140 } elseif ('daily' == $type) { 141 ++$querycount; 142 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit); 143 foreach ($arcresults as $arcresult) { 144 echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).zeroise($arcresult->dayofmonth, 2).'">'; 145 echo mysql2date($archive_day_date_format, $arcresult->year.'-'.zeroise($arcresult->month,2).'-'.zeroise($arcresult->dayofmonth,2).' 00:00:00'); 154 146 echo "</a></li>\n"; 155 147 } 156 } elseif ( $type == 'weekly') {148 } elseif ('weekly' == $type) { 157 149 if (!isset($start_of_week)) { 158 150 $start_of_week = 1; 159 151 } 160 $arc_sql = "SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit; 161 $querycount++; 162 $arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error()); 152 ++$querycount; 153 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, WEEK(post_date) AS `week` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit); 163 154 $arc_w_last = ''; 164 while($arc_row = mysql_fetch_array($arc_result)) { 165 $arc_year = $arc_row['YEAR(post_date)']; 166 $arc_w = $arc_row['WEEK(post_date)']; 167 if ($arc_w != $arc_w_last) { 168 $arc_w_last = $arc_w; 169 $arc_ymd = $arc_year.'-'.zeroise($arc_row['MONTH(post_date)'],2).'-' .zeroise($arc_row['DAYOFMONTH(post_date)'],2); 155 foreach ($arcresults as $arcresult) { 156 if ($arcresult->week != $arc_w_last) { 157 $arc_w_last = $arcresult->week; 158 $arc_ymd = $arcresult->year.'-'.zeroise($arcresult->month, 2).'-' .zeroise($arcresult->dayofmonth, 2); 170 159 $arc_week = get_weekstartend($arc_ymd, $start_of_week); 171 160 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); 172 161 $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); 173 echo "<li><a href= \"$siteurl/".$blogfilename."?m=$arc_year&w=$arc_w\">";162 echo "<li><a href='$siteurl/".$blogfilename."?m=$arc_year&w=$arc_w'>"; 174 163 echo $arc_week_start.$archive_week_separator.$arc_week_end; 175 164 echo "</a></li>\n"; 176 165 } 177 166 } 178 } elseif ($type == 'postbypost') { 179 $requestarc = " SELECT ID,post_date,post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit; 180 $querycount++; 181 $resultarc = mysql_query($requestarc); 182 while($row=mysql_fetch_object($resultarc)) { 183 if ($row->post_date != '0000-00-00 00:00:00') { 184 echo "<li><a href=\"$archive_link_p".$row->ID.'">'; 185 $arc_title = stripslashes($row->post_title); 167 } elseif ('postbypost' == $type) { 168 ++$querycount; 169 $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit); 170 foreach ($arcresults as $arcresult) { 171 if ($arcresult->post_date != '0000-00-00 00:00:00') { 172 echo "<li><a href=\"$archive_link_p".$arcresult->ID.'">'; 173 $arc_title = stripslashes($arcresult->post_title); 186 174 if ($arc_title) { 187 175 echo strip_tags($arc_title); 188 176 } else { 189 echo $ row->ID;177 echo $arcresult->ID; 190 178 } 191 179 echo "</a></li>\n"; … … 201 189 /***** Date/Time tags *****/ 202 190 203 function the_date($d='', $before='', $after='', $echo = 1) {204 global $id, $postdata, $day, $previousday, $dateformat,$newday;191 function the_date($d='', $before='', $after='', $echo = true) { 192 global $id, $postdata, $day, $previousday, $dateformat, $newday; 205 193 $the_date = ''; 206 194 if ($day != $previousday) { … … 222 210 } 223 211 224 function the_time($d='', $echo = 1) {212 function the_time($d='', $echo = true) { 225 213 global $id,$postdata,$timeformat; 226 214 if ($d=='') { … … 365 353 } 366 354 function get_the_title() { 367 global $id, $postdata;355 global $id, $postdata; 368 356 $output = stripslashes($postdata['Title']); 369 357 $output = apply_filters('the_title', $output); … … 613 601 614 602 $query = @mysql_query($sql); 615 $querycount++;603 ++$querycount; 616 604 if (($query) && (mysql_num_rows($query))) { 617 605 $p_info = mysql_fetch_object($query); … … 658 646 659 647 $query = @mysql_query($sql); 660 $querycount++;648 ++$querycount; 661 649 if (($query) && (mysql_num_rows($query))) { 662 650 $p_info = mysql_fetch_object($query); … … 806 794 $query="SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'"; 807 795 $result=mysql_query($query); 808 $querycount++;796 ++$querycount; 809 797 $myrow = mysql_fetch_array($result); 810 798 $cat_name = $myrow[0]; … … 821 809 $query="SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'"; 822 810 $result=mysql_query($query); 823 $querycount++;811 ++$querycount; 824 812 $myrow = mysql_fetch_array($result); 825 813 $cat_name = $myrow[0]; … … 851 839 $query="SELECT * FROM $tablecategories"; 852 840 $result=mysql_query($query); 853 $querycount++;841 ++$querycount; 854 842 echo "<select name=\"cat\" class=\"postform\">\n"; 855 843 if (intval($optionall) == 1) { … … 874 862 $query="SELECT * FROM $tablecategories WHERE cat_ID > 0 ORDER BY $sort_column $sort_order"; 875 863 $result=mysql_query($query); 876 $querycount++;864 ++$querycount; 877 865 if (intval($optionall) == 1) { 878 866 $all = apply_filters('list_cats', $all); … … 910 898 911 899 // generic comments/trackbacks/pingbacks numbering 912 function generic_ctp_number($post_id, $mode = 'comments') { 913 global $postdata, $tablecomments, $querycount, $cache_ctp_number, $use_cache; 914 if (!isset($cache_ctp_number[$post_id]) || (!$use_cache)) { 915 $post_id = intval($post_id); 916 $query = "SELECT * FROM $tablecomments WHERE comment_post_ID = $post_id"; 917 $result = mysql_query($query) or die('SQL query: '.$query.'<br />MySQL Error: '.mysql_error()); 918 $querycount++; 919 $ctp_number = array(); 920 while($row = mysql_fetch_object($result)) { 921 if (substr($row->comment_content, 0, 13) == '<trackback />') { 922 $ctp_number['trackbacks']++; 923 } elseif (substr($row->comment_content, 0, 12) == '<pingback />') { 924 $ctp_number['pingbacks']++; 925 } else { 926 $ctp_number['comments']++; 927 } 928 $ctp_number['ctp']++; 929 } 930 $cache_ctp_number[$post_id] = $ctp_number; 931 } else { 932 $ctp_number = $cache_ctp_number[$post_id]; 933 } 934 if (($mode != 'comments') && ($mode != 'trackbacks') && ($mode != 'pingbacks') && ($mode != 'ctp')) { 935 $mode = 'ctp'; 936 } 937 return $ctp_number[$mode]; 938 } 939 940 function comments_number($zero='no comment', $one='1 comment', $more='% comments') { 941 // original hack by dodo@regretless.com 942 global $id,$postdata,$tablecomments,$c,$querycount,$cache_commentsnumber,$use_cache; 943 $number = generic_ctp_number($id, 'comments'); 900 901 function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments') { 902 global $id, $comment, $tablecomments, $querycount, $wpdb; 903 $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id"); 944 904 if ($number == 0) { 945 905 $blah = $zero; … … 947 907 $blah = $one; 948 908 } elseif ($number > 1) { 949 $n = $number; 950 $more=str_replace('%', $n, $more); 951 $blah = $more; 909 $blah = str_replace('%', $number, $more); 952 910 } 953 911 echo $blah; 954 912 } 955 913 956 function comments_link($file='', $echo=true) {957 global $id, $pagenow;914 function comments_link($file='', $echo=true) { 915 global $id, $pagenow; 958 916 global $querystring_start, $querystring_equal, $querystring_separator; 959 917 if ($file == '') $file = $pagenow; … … 963 921 } 964 922 965 function comments_popup_script($width=400, $height=400, $file='b2commentspopup.php' , $trackbackfile='b2trackbackpopup.php', $pingbackfile='b2pingbackspopup.php') {923 function comments_popup_script($width=400, $height=400, $file='b2commentspopup.php') { 966 924 global $b2commentspopupfile, $b2trackbackpopupfile, $b2pingbackpopupfile, $b2commentsjavascript; 967 925 $b2commentspopupfile = $file; 968 $b2trackbackpopupfile = $trackbackfile;969 $b2pingbackpopupfile = $pingbackfile;970 926 $b2commentsjavascript = 1; 971 $javascript = "<script language= \"javascript\" type=\"text/javascript\">\n<!--\nfunction b2open (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n//-->\n</script>\n";927 $javascript = "<script language='javascript' type='text/javascript'>\n<!--\nfunction b2open (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n//-->\n</script>\n"; 972 928 echo $javascript; 973 929 } 974 930 975 function comments_popup_link($zero=' no comment', $one='1 comment', $more='% comments', $CSSclass='') {931 function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='') { 976 932 global $id, $b2commentspopupfile, $b2commentsjavascript; 977 933 global $querystring_start, $querystring_equal, $querystring_separator, $siteurl; 978 echo '<a href="'.$siteurl.'/';934 echo "<a href=\"$siteurl/"; 979 935 if ($b2commentsjavascript) { 980 936 echo $b2commentspopupfile.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'c'.$querystring_equal.'1'; 981 echo ' "onclick="b2open(this.href); return false"';937 echo '\' onclick="b2open(this.href); return false"'; 982 938 } else { 983 939 // if comments_popup_script() is not in the template, display simple comment link … … 994 950 995 951 function comment_ID() { 996 global $commentdata; echo $commentdata['comment_ID']; 952 global $comment; 953 echo $comment->comment_ID; 997 954 } 998 955 999 956 function comment_author() { 1000 global $commentdata; echo stripslashes($commentdata['comment_author']); 957 global $comment; 958 echo stripslashes($comment->comment_author); 1001 959 } 1002 960 1003 961 function comment_author_email() { 1004 global $commentdata; echo antispambot(stripslashes($commentdata['comment_author_email'])); 1005 } 1006 962 global $comment; 963 echo antispambot(stripslashes($comment->comment_author_email)); 964 } 965 966 function comment_author_link() { 967 global $comment; 968 $url = trim(stripslashes(&$comment->comment_author_url)); 969 $email = &$comment->comment_author_email; 970 $author = stripslashes(&$comment->comment_author); 971 972 $url = str_replace('http://url', '', $url); 973 974 if (empty($url) && empty($email)) return $author; 975 echo '<a href="'; 976 if ($url) { 977 $url = str_replace(';//', '://', $url); 978 $url = (!strstr($url, '://')) ? 'http://'.$url : $url; 979 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 980 echo $url; 981 } else { 982 echo antispambot($email); 983 } 984 echo '" rel="external">' . $author . '</a>'; 985 } 986 987 function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') { 988 global $comment; 989 if (preg_match('|<trackback />|', $comment->comment_content)) echo $trackbacktxt; 990 elseif (preg_match('|<pingback />|', $comment->comment_content)) echo $pingbacktxt; 991 else echo $commenttxt; 992 } 1007 993 function comment_author_url() { 1008 global $commentdata; 1009 $url = trim(stripslashes($commentdata['comment_author_url'])); 1010 $url = (!stristr($url, '://')) ? 'http://'.$url : $url; 994 global $comment; 995 $url = trim(stripslashes($comment->comment_author_url)); 996 $url = str_replace(';//', '://', $url); 997 $url = (!strstr($url, '://')) ? 'http://'.$url : $url; 1011 998 // convert & into & 1012 $url = preg_replace(' #&([^amp\;])#is', '&$1', $url);999 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 1013 1000 if ($url != 'http://url') { 1014 1001 echo $url; … … 1017 1004 1018 1005 function comment_author_email_link($linktext='', $before='', $after='') { 1019 global $comment data;1020 $email =$commentdata['comment_author_email'];1006 global $comment; 1007 $email = $comment->comment_author_email; 1021 1008 if ((!empty($email)) && ($email != '@')) { 1022 1009 $display = ($linktext != '') ? $linktext : antispambot(stripslashes($email)); … … 1028 1015 1029 1016 function comment_author_url_link($linktext='', $before='', $after='') { 1030 global $comment data;1031 $url = trim(stripslashes($comment data['comment_author_url']));1032 $url = preg_replace(' #&([^amp\;])#is', '&$1', $url);1017 global $comment; 1018 $url = trim(stripslashes($comment->comment_author_url)); 1019 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 1033 1020 $url = (!stristr($url, '://')) ? 'http://'.$url : $url; 1034 1021 if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) { … … 1041 1028 1042 1029 function comment_author_IP() { 1043 global $commentdata; echo stripslashes($commentdata['comment_author_IP']); 1030 global $comment; 1031 echo stripslashes($comment->comment_author_IP); 1044 1032 } 1045 1033 1046 1034 function comment_text() { 1047 global $comment data;1048 $comment = stripslashes($commentdata['comment_content']);1049 $comment = str_replace('<trackback />', '', $comment);1050 $comment = str_replace('<pingback />', '', $comment);1051 $comment = convert_chars($comment);1052 $comment = convert_bbcode($comment);1053 $comment = convert_gmcode($comment);1054 $comment = convert_smilies($comment);1055 $comment = make_clickable($comment);1056 $comment = balanceTags($comment);1057 $comment = apply_filters('comment_text', $comment);1058 echo $comment ;1035 global $comment; 1036 $comment_text = stripslashes($comment->comment_content); 1037 $comment_text = str_replace('<trackback />', '', $comment_text); 1038 $comment_text = str_replace('<pingback />', '', $comment_text); 1039 $comment_text = convert_chars($comment_text); 1040 $comment_text = convert_bbcode($comment_text); 1041 $comment_text = convert_gmcode($comment_text); 1042 $comment_text = convert_smilies($comment_text); 1043 $comment_text = make_clickable($comment_text); 1044 $comment_text = balanceTags($comment_text); 1045 $comment_text = apply_filters('comment_text', $comment_text); 1046 echo $comment_text; 1059 1047 } 1060 1048 1061 1049 function comment_date($d='') { 1062 global $comment data,$dateformat;1050 global $comment, $dateformat; 1063 1051 if ($d == '') { 1064 echo mysql2date($dateformat, $comment data['comment_date']);1065 } else { 1066 echo mysql2date($d, $comment data['comment_date']);1052 echo mysql2date($dateformat, $comment->comment_date); 1053 } else { 1054 echo mysql2date($d, $comment->comment_date); 1067 1055 } 1068 1056 } 1069 1057 1070 1058 function comment_time($d='') { 1071 global $comment data,$timeformat;1059 global $comment, $timeformat; 1072 1060 if ($d == '') { 1073 echo mysql2date($timeformat, $comment data['comment_date']);1074 } else { 1075 echo mysql2date($d, $comment data['comment_date']);1061 echo mysql2date($timeformat, $comment->comment_date); 1062 } else { 1063 echo mysql2date($d, $comment->comment_date); 1076 1064 } 1077 1065 } … … 1083 1071 /***** TrackBack tags *****/ 1084 1072 1085 function trackback_url($display = 1) {1073 function trackback_url($display = true) { 1086 1074 global $siteurl, $id; 1087 1075 $tb_url = $siteurl.'/b2trackback.php/'.$id; … … 1285 1273 1286 1274 function start_b2() { 1287 global $ row, $id, $postdata, $authordata, $day, $preview, $page, $pages, $multipage, $more, $numpages;1275 global $post, $id, $postdata, $authordata, $day, $preview, $page, $pages, $multipage, $more, $numpages; 1288 1276 global $preview_userid,$preview_date,$preview_content,$preview_title,$preview_category,$preview_notify,$preview_make_clickable,$preview_autobr; 1289 1277 global $pagenow; 1290 1278 global $HTTP_GET_VARS; 1291 1279 if (!$preview) { 1292 $id = $ row->ID;1280 $id = $post->ID; 1293 1281 $postdata=get_postdata2($id); 1294 1282 } else { -
trunk/b2-include/wp-db.php
r112 r114 9 9 // We have modified the HTML it returns slightly. 10 10 11 define('EZSQL_DB_USER', ""); // <-- mysql db user12 define('EZSQL_DB_PASSWORD', ""); // <-- mysql db password13 define('EZSQL_DB_NAME', "mysql"); // <-- mysql db pname14 define('EZSQL_DB_HOST', 'localhost'); // <-- mysql server host15 16 11 define('EZSQL_VERSION', '1.21'); 17 12 define('OBJECT', 'OBJECT', true); … … 400 395 } 401 396 402 $wpdb = new wpdb( EZSQL_DB_USER, EZSQL_DB_PASSWORD, EZSQL_DB_NAME, EZSQL_DB_HOST);397 $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); 403 398 404 399 ?> -
trunk/b2comments.post.php
r96 r114 9 9 include($abspath.$b2inc.'/b2functions.php'); 10 10 11 dbconnect();12 11 13 12 function add_magic_quotes($array) { … … 74 73 75 74 /* flood-protection */ 76 $query = "SELECT * FROM $tablecomments WHERE comment_author_IP='$user_ip' ORDER BY comment_date DESC LIMIT 1"; 77 $result = mysql_query($query); 75 $lasttime = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1"); 78 76 $ok=1; 79 if (!empty($result)) { 80 while($row = mysql_fetch_object($result)) { 81 $then=$row->comment_date; 82 } 83 $time_lastcomment=mysql2date("U","$then"); 84 $time_newcomment=mysql2date("U","$now"); 77 if (!empty($lasttime)) { 78 $time_lastcomment= mysql2date('U', $lasttime); 79 $time_newcomment= mysql2date('U', "$now"); 85 80 if (($time_newcomment - $time_lastcomment) < 30) 86 81 $ok=0; … … 90 85 if ($ok) { 91 86 92 $query = "INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0')"; 93 $result = mysql_query($query); 94 if (!$result) 95 die ("There is an error with the database, it can’t store your comment...<br />Contact the <a href=\"mailto:$admin_email\">webmaster</a>."); 87 $wpdb->query("INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0')"); 96 88 97 89 if ($comments_notify) { … … 111 103 $subject = "[$blogname] Comment: \"".stripslashes($postdata['Title']).'"'; 112 104 113 @mail($recipient, $subject, $notify_message, "From: \"$comment_author\" <$comment_author_email>\r\n"."X-Mailer: wordpress $b2_version with PHP/".phpversion());105 @mail($recipient, $subject, $notify_message, "From: \"$comment_author\" <$comment_author_email>\r\n"."X-Mailer: WordPress $b2_version with PHP/".phpversion()); 114 106 115 107 } … … 121 113 $url = ' '; // this to make sure a cookie is set for 'no url' 122 114 } 123 setcookie( "comment_author", $author, time()+30000000);124 setcookie( "comment_author_email", $email, time()+30000000);125 setcookie( "comment_author_url", $url, time()+30000000);115 setcookie('comment_author', $author, time()+30000000); 116 setcookie('comment_author_email', $email, time()+30000000); 117 setcookie('comment_author_url', $url, time()+30000000); 126 118 127 119 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 128 header('Last-Modified: ' . gmdate( "D, d M Y H:i:s") . ' GMT');120 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 129 121 header('Cache-Control: no-cache, must-revalidate'); 130 122 header('Pragma: no-cache'); -
trunk/b2config.php
r96 r114 22 22 // ** MySQL settings ** 23 23 24 $dbname = 'b2';// The name of the database25 $dbusername = 'user';// Your MySQL username26 $dbpassword = 'pass';// ...and password27 $dbhost = 'localhost'; // 99% chance you won't need to change this value 24 define('DB_NAME', 'b2'); // The name of the database 25 define('DB_USER', 'user'); // Your MySQL username 26 define('DB_PASSWORD', 'pass'); // ...and password 27 define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value 28 28 29 29 -
trunk/blog.header.php
r107 r114 31 31 } 32 32 33 /* Connecting to the db */34 dbconnect();35 33 36 34 /* Sending HTTP headers */ … … 268 266 269 267 //echo $request; 270 $ result = mysql_query($request);268 $posts = $wpdb->get_results($request); 271 269 ?> -
trunk/index.php
r105 r114 30 30 31 31 <!-- // b2 loop start --> 32 <?php while($row = mysql_fetch_object($result)) { start_b2(); ?>32 <?php foreach ($posts as $post) { start_b2(); ?> 33 33 34 34 … … 48 48 <?php link_pages('<br />Pages: ', '<br />', 'number'); ?> 49 49 <?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?> 50 <?php trackback_popup_link('TrackBack (0)', 'TrackBack (1)', 'TrackBack (%)'); ?>51 <?php pingback_popup_link('PingBack (0)', 'PingBack (1)', 'PingBack (%)'); ?>52 50 </div> 53 51 … … 57 55 <?php include('b2comments.php'); ?> 58 56 59 <!-- this includes the trackbacks -->60 <?php include('b2trackback.php'); ?>61 62 <!-- this includes the pingbacks -->63 <?php include('b2pingbacks.php'); ?>64 57 65 58 <!-- // this is just the end of the motor - don't touch that line either :) -->
Note: See TracChangeset
for help on using the changeset viewer.