Changeset 570 for trunk/b2-include/b2functions.php
- Timestamp:
- 12/05/2003 01:27:00 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/b2-include/b2functions.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/b2-include/b2functions.php
r559 r570 374 374 375 375 function get_lastpostdate() { 376 global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow, $wpdb , $querycount;376 global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow, $wpdb; 377 377 if ((!isset($cache_lastpostdate)) OR (!$use_cache)) { 378 378 $now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600))); … … 383 383 } 384 384 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE $showcatzero post_date <= '$now' ORDER BY post_date DESC LIMIT 1"); 385 ++$querycount;386 385 $cache_lastpostdate = $lastpostdate; 387 386 // echo $lastpostdate; … … 416 415 417 416 function get_userdata($userid) { 418 global $wpdb, $ querycount, $cache_userdata, $use_cache, $tableusers;417 global $wpdb, $cache_userdata, $use_cache, $tableusers; 419 418 if ((empty($cache_userdata[$userid])) || (!$use_cache)) { 420 419 $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID = $userid"); … … 424 423 $user->user_firstname = stripslashes($user->user_firstname); 425 424 $user->user_lastname = stripslashes($user->user_lastname); 426 ++$querycount;427 425 $cache_userdata[$userid] = $user; 428 426 } else { … … 446 444 447 445 function get_userdatabylogin($user_login) { 448 global $tableusers, $ querycount, $cache_userdata, $use_cache, $wpdb;446 global $tableusers, $cache_userdata, $use_cache, $wpdb; 449 447 if ((empty($cache_userdata["$user_login"])) OR (!$use_cache)) { 450 448 $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE user_login = '$user_login'"); 451 ++$querycount;452 449 $cache_userdata["$user_login"] = $user; 453 450 } else { … … 458 455 459 456 function get_userid($user_login) { 460 global $tableusers, $ querycount, $cache_userdata, $use_cache, $wpdb;457 global $tableusers, $cache_userdata, $use_cache, $wpdb; 461 458 if ((empty($cache_userdata["$user_login"])) OR (!$use_cache)) { 462 459 $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$user_login'"); 463 460 464 ++$querycount;465 461 $cache_userdata["$user_login"] = $user_id; 466 462 } else { … … 471 467 472 468 function get_usernumposts($userid) { 473 global $tableposts, $tablecomments, $querycount, $wpdb; 474 ++$querycount; 469 global $tableposts, $tablecomments, $wpdb; 475 470 return $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_author = $userid"); 476 471 } … … 479 474 // determine the post ID it represents. 480 475 function url_to_postid($url = '') { 481 global $wpdb, $ querycount, $tableposts, $siteurl;476 global $wpdb, $tableposts, $siteurl; 482 477 483 478 // Take a link like 'http://example.com/blog/something' … … 537 532 538 533 // Run the query to get the post ID: 539 ++$querycount;540 534 return intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where)); 541 535 } … … 545 539 546 540 function get_settings($setting) { 547 global $wpdb, $cache_settings, $use_cache , $querycount;541 global $wpdb, $cache_settings, $use_cache; 548 542 if ((empty($cache_settings)) OR (!$use_cache)) { 549 543 $settings = get_alloptions(); … … 559 553 560 554 function get_alloptions() { 561 global $tableoptions, $wpdb , $querycount;555 global $tableoptions, $wpdb; 562 556 $options = $wpdb->get_results("SELECT option_name, option_value FROM $tableoptions"); 563 ++$querycount;564 557 if ($options) { 565 558 foreach ($options as $option) { … … 583 576 584 577 function get_postdata($postid) { 585 global $tableusers, $tablecategories, $tableposts, $tablecomments, $ querycount, $wpdb;578 global $tableusers, $tablecategories, $tableposts, $tablecomments, $wpdb; 586 579 $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID = $postid"); 587 ++$querycount;588 580 589 581 $postdata = array ( … … 626 618 627 619 function get_commentdata($comment_ID,$no_cache=0,$include_unapproved=false) { // less flexible, but saves DB queries 628 global $postc,$id,$commentdata,$tablecomments, $querycount,$wpdb;620 global $postc,$id,$commentdata,$tablecomments, $wpdb; 629 621 if ($no_cache) { 630 622 $query = "SELECT * FROM $tablecomments WHERE comment_ID = $comment_ID"; … … 633 625 } 634 626 $myrow = $wpdb->get_row($query, ARRAY_A); 635 ++$querycount;636 627 } else { 637 628 $myrow['comment_ID']=$postc->comment_ID; … … 656 647 657 648 function get_catname($cat_ID) { 658 global $tablecategories,$cache_catnames,$use_cache, $querycount,$wpdb;649 global $tablecategories,$cache_catnames,$use_cache, $wpdb; 659 650 if ((!$cache_catnames) || (!$use_cache)) { 660 651 $results = $wpdb->get_results("SELECT * FROM $tablecategories") or die('Oops, couldn\'t query the db for categories.'); 661 $querycount++;662 652 foreach ($results as $post) { 663 653 $cache_catnames[$post->cat_ID] = $post->cat_name; … … 674 664 675 665 function dropdown_categories($blog_ID=1, $default=1) { 676 global $postdata,$tablecategories,$mode, $querycount,$wpdb;666 global $postdata,$tablecategories,$mode, $wpdb; 677 667 $query="SELECT * FROM $tablecategories ORDER BY cat_name"; 678 668 $results = $wpdb->get_results($query); 679 ++$querycount;680 669 $width = ($mode=="sidebar") ? "100%" : "170px"; 681 670 echo '<select name="post_category" style="width:'.$width.';" tabindex="2" id="category">'; … … 683 672 $default = $postdata["Category"]; 684 673 } 685 ++$querycount;686 674 foreach($results as $post) { 687 675 echo "<option value=\"".$post->cat_ID."\""; … … 1442 1430 */ 1443 1431 function wp_get_comment_status($comment_id) { 1444 global $wpdb, $ querycount, $tablecomments;1432 global $wpdb, $tablecomments; 1445 1433 1446 1434 $result = $wpdb->get_var("SELECT comment_approved FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1"); 1447 ++$querycount;1448 1435 if ($result == NULL) { 1449 1436 return "deleted"; … … 1458 1445 1459 1446 function wp_notify_postauthor($comment_id, $comment_type) { 1460 global $wpdb, $ querycount, $tablecomments, $tableposts, $tableusers;1447 global $wpdb, $tablecomments, $tableposts, $tableusers; 1461 1448 global $querystring_start, $querystring_equal, $querystring_separator; 1462 1449 global $blogfilename, $blogname, $siteurl; 1463 1450 1464 1451 $comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1"); 1465 ++$querycount;1466 1452 $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1"); 1467 ++$querycount;1468 1453 $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1"); 1469 ++$querycount;1470 1454 1471 1455 if ('' == $user->user_email) return false; // If there's no email to send the comment to … … 1518 1502 */ 1519 1503 function wp_notify_moderator($comment_id) { 1520 global $wpdb, $ querycount, $tablecomments, $tableposts, $tableusers;1504 global $wpdb, $tablecomments, $tableposts, $tableusers; 1521 1505 global $querystring_start, $querystring_equal, $querystring_separator; 1522 1506 global $blogfilename, $blogname, $siteurl; 1523 1507 1524 1508 $comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1"); 1525 ++$querycount;1526 1509 $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1"); 1527 ++$querycount;1528 1510 $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1"); 1529 ++$querycount;1530 1511 1531 1512 $comment_author_domain = gethostbyaddr($comment->comment_author_IP); 1532 1513 $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $tablecomments WHERE comment_approved = '0'"); 1533 ++$querycount;1534 1514 1535 1515 $notify_message = "A new comment on the post #$comment->comment_post_ID \"".stripslashes($post->post_title)."\" is waiting for your approval\r\n\r\n";
Note: See TracChangeset
for help on using the changeset viewer.