Make WordPress Core


Ignore:
Timestamp:
07/19/2003 10:51:43 PM (23 years ago)
Author:
mikelittle
Message:

Removed mysql reference, converted to EZSQL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2functions.php

    r245 r258  
    371371
    372372function get_lastpostdate() {
    373     global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow;
     373    global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow, $wpdb;
    374374    if ((!isset($cache_lastpostdate)) OR (!$use_cache)) {
    375375        $now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600)));
     
    379379            $showcatzero = '';
    380380        }
    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");
    383382        ++$querycount;
    384         $myrow = mysql_fetch_object($result);
    385         $lastpostdate = $myrow->post_date;
    386383        $cache_lastpostdate = $lastpostdate;
    387384//      echo $lastpostdate;
     
    537534
    538535function 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;
    540537    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);
    543539        ++$querycount;
    544         $myrow = mysql_fetch_array($result);
    545540    } else {
    546541        $myrow['comment_ID']=$postc->comment_ID;
     
    565560
    566561function get_catname($cat_ID) {
    567     global $tablecategories,$cache_catnames,$use_cache,$querycount;
     562    global $tablecategories,$cache_catnames,$use_cache,$querycount, $wpdb;
    568563    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) {
    573567            $cache_catnames[$post->cat_ID] = $post->cat_name;
    574568        }
     
    584578
    585579function dropdown_categories($blog_ID=1, $default=1) {
    586     global $postdata,$tablecategories,$mode,$querycount;
     580    global $postdata,$tablecategories,$mode,$querycount, $wpdb;
    587581    $query="SELECT * FROM $tablecategories";
    588     $result=mysql_query($query);
     582    $results = $wpdb->get_results($query);
    589583    ++$querycount;
    590584    $width = ($mode=="sidebar") ? "100%" : "170px";
     
    593587        $default = $postdata["Category"];
    594588    }
    595     while($post = mysql_fetch_object($result)) {
     589    foreach($results as $post) {
    596590        echo "<option value=\"".$post->cat_ID."\"";
    597591        if ($post->cat_ID == $default)
     
    11391133
    11401134    if ($is_comment) {
     1135        $text = stripslashes($text);
    11411136        // sanitise HTML attributes, remove frame/applet tags
    11421137        $text = preg_replace('#( on[a-z]{1,}|style|class|id)="(.*?)"#i', '', $text);
     
    11451140        $text = preg_replace('#([a-z]{1,})=\'(( |\t)*?)(javascript|vbscript|about):(.*?)\'#i', '$1=""', $text);
    11461141        $text = preg_replace('#\<(\/{0,1})([a-z]{0,2})(frame|applet)(.*?)\>#i', '', $text);
     1142        $text = addslashes($text);
    11471143    }
    11481144   
     
    11501146        return $text;
    11511147    }
     1148
    11521149    $tagstack = array();
    11531150    $stacksize = 0;
Note: See TracChangeset for help on using the changeset viewer.