Changeset 258 for trunk/b2-include/b2functions.php
- Timestamp:
- 07/19/2003 10:51:43 PM (23 years ago)
- File:
-
- 1 edited
-
trunk/b2-include/b2functions.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/b2-include/b2functions.php
r245 r258 371 371 372 372 function get_lastpostdate() { 373 global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow ;373 global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow, $wpdb; 374 374 if ((!isset($cache_lastpostdate)) OR (!$use_cache)) { 375 375 $now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600))); … … 379 379 $showcatzero = ''; 380 380 } 381 $sql = "SELECT * FROM $tableposts WHERE $showcatzero post_date <= '$now' ORDER BY post_date DESC LIMIT 1"; 382 $result = mysql_query($sql) or die("Your SQL query: <br />$sql<br /><br />MySQL said:<br />".mysql_error()); 381 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE $showcatzero post_date <= '$now' ORDER BY post_date DESC LIMIT 1"); 383 382 ++$querycount; 384 $myrow = mysql_fetch_object($result);385 $lastpostdate = $myrow->post_date;386 383 $cache_lastpostdate = $lastpostdate; 387 384 // echo $lastpostdate; … … 537 534 538 535 function get_commentdata($comment_ID,$no_cache=0) { // less flexible, but saves mysql queries 539 global $postc,$id,$commentdata,$tablecomments,$querycount ;536 global $postc,$id,$commentdata,$tablecomments,$querycount, $wpdb; 540 537 if ($no_cache) { 541 $query="SELECT * FROM $tablecomments WHERE comment_ID = $comment_ID"; 542 $result=mysql_query($query); 538 $myrow = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID = $comment_ID", ARRAY_A); 543 539 ++$querycount; 544 $myrow = mysql_fetch_array($result);545 540 } else { 546 541 $myrow['comment_ID']=$postc->comment_ID; … … 565 560 566 561 function get_catname($cat_ID) { 567 global $tablecategories,$cache_catnames,$use_cache,$querycount ;562 global $tablecategories,$cache_catnames,$use_cache,$querycount, $wpdb; 568 563 if ((!$cache_catnames) || (!$use_cache)) { 569 $sql = "SELECT * FROM $tablecategories"; 570 $result = mysql_query($sql) or die('Oops, couldn\'t query the db for categories.'); 571 $querycount; 572 while ($post = mysql_fetch_object($result)) { 564 $results = $wpdb->get_results("SELECT * FROM $tablecategories") or die('Oops, couldn\'t query the db for categories.'); 565 $querycount++; 566 foreach ($results as $post) { 573 567 $cache_catnames[$post->cat_ID] = $post->cat_name; 574 568 } … … 584 578 585 579 function dropdown_categories($blog_ID=1, $default=1) { 586 global $postdata,$tablecategories,$mode,$querycount ;580 global $postdata,$tablecategories,$mode,$querycount, $wpdb; 587 581 $query="SELECT * FROM $tablecategories"; 588 $result =mysql_query($query);582 $results = $wpdb->get_results($query); 589 583 ++$querycount; 590 584 $width = ($mode=="sidebar") ? "100%" : "170px"; … … 593 587 $default = $postdata["Category"]; 594 588 } 595 while($post = mysql_fetch_object($result)) {589 foreach($results as $post) { 596 590 echo "<option value=\"".$post->cat_ID."\""; 597 591 if ($post->cat_ID == $default) … … 1139 1133 1140 1134 if ($is_comment) { 1135 $text = stripslashes($text); 1141 1136 // sanitise HTML attributes, remove frame/applet tags 1142 1137 $text = preg_replace('#( on[a-z]{1,}|style|class|id)="(.*?)"#i', '', $text); … … 1145 1140 $text = preg_replace('#([a-z]{1,})=\'(( |\t)*?)(javascript|vbscript|about):(.*?)\'#i', '$1=""', $text); 1146 1141 $text = preg_replace('#\<(\/{0,1})([a-z]{0,2})(frame|applet)(.*?)\>#i', '', $text); 1142 $text = addslashes($text); 1147 1143 } 1148 1144 … … 1150 1146 return $text; 1151 1147 } 1148 1152 1149 $tagstack = array(); 1153 1150 $stacksize = 0;
Note: See TracChangeset
for help on using the changeset viewer.