Make WordPress Core


Ignore:
Timestamp:
07/19/2003 08:45:27 PM (21 years ago)
Author:
mikelittle
Message:

Converted to ezSQL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/linkmanager.php

    r212 r254  
    2727// Mike Little (mike@zed1.com)
    2828// *****************************************************************
    29 include_once('../wp-config.php');
    30 include_once('../wp-links/links.config.php');
    31 include_once("../wp-links/links.php");
     29require_once('../wp-config.php');
     30require_once('../wp-links/links.config.php');
     31require_once("../wp-links/links.php");
    3232
    3333$title = 'Manage Links';
     
    6969
    7070$links_show_cat_id = $HTTP_COOKIE_VARS["links_show_cat_id"];
     71$links_show_order = $HTTP_COOKIE_VARS["links_show_order"];
    7172
    7273// error_log("start, links_show_cat_id=$links_show_cat_id"); 
     
    9596    // need to make the others invisible before we add this new one.
    9697    if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
    97       $sql = "UPDATE $tablelinks set link_visible = 'N' WHERE link_category = $link_category";
    98       $sql_result = mysql_query($sql) or die("Couldn't execute query."."sql=[$sql]". mysql_error());
    99     }
    100 
    101     $sql = "INSERT INTO $tablelinks (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel) " .
     98      $wpdb->query("UPDATE $tablelinks set link_visible = 'N' WHERE link_category = $link_category");
     99    }
     100
     101    $wpdb->query("INSERT INTO $tablelinks (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel) " .
    102102      " VALUES('" . addslashes($link_url) . "','"
    103103           . addslashes($link_name) . "', '"
    104104           . addslashes($link_image) . "', '$link_target', $link_category, '"
    105            . addslashes($link_description) . "', '$link_visible', $user_ID, $link_rating, '" . addslashes($link_rel) ."')";
    106 
    107     $sql_result = mysql_query($sql) or die("Couldn't execute query."."sql=[$sql]". mysql_error());
     105           . addslashes($link_description) . "', '$link_visible', $user_ID, $link_rating, '" . addslashes($link_rel) ."')");
    108106
    109107    header('Location: linkmanager.php');
     
    145143      // need to make the others invisible before we update this one.
    146144      if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
    147         $sql = "UPDATE $tablelinks set link_visible = 'N' WHERE link_category = $link_category";
    148         $sql_result = mysql_query($sql) or die("Couldn't execute query."."sql=[$sql]". mysql_error());
     145        $wpdb->query("UPDATE $tablelinks set link_visible = 'N' WHERE link_category = $link_category");
    149146      }
    150147
    151       $sql = "UPDATE $tablelinks SET link_url='" . addslashes($link_url) . "',\n " .
     148      $wpdb->query("UPDATE $tablelinks SET link_url='" . addslashes($link_url) . "',\n " .
    152149             " link_name='" . addslashes($link_name) . "',\n link_image='" . addslashes($link_image) . "',\n " .
    153150             " link_target='$link_target',\n link_category=$link_category,\n " .
     
    155152             " link_rating=$link_rating,\n" .
    156153             " link_rel='" . addslashes($link_rel) . "'\n" .
    157              " WHERE link_id=$link_id";
     154             " WHERE link_id=$link_id");
    158155      //error_log($sql);
    159       $sql_result = mysql_query($sql) or die("Couldn't execute query."."sql=[$sql]". mysql_error());
    160 
    161156    } // end if save
    162157    setcookie('links_show_cat_id', $links_show_cat_id, time()+600);
     
    175170      die ("Cheatin' uh ?");
    176171
    177     $sql = "DELETE FROM $tablelinks WHERE link_id = '$link_id'";
    178     $sql_result = mysql_query($sql) or die("Couldn't execute query.".mysql_error());
     172    $wpdb->query("DELETE FROM $tablelinks WHERE link_id = '$link_id'");
    179173
    180174    if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
     
    199193    }
    200194
    201     $sql = "SELECT link_url, link_name, link_image, link_target, link_description, link_visible, link_category AS cat_id, link_rating, link_rel " .
     195    $row = $wpdb->get_row("SELECT link_url, link_name, link_image, link_target, link_description, link_visible, link_category AS cat_id, link_rating, link_rel " .
    202196      " FROM $tablelinks " .
    203       " WHERE link_id = $link_id";
    204 
    205     $result = mysql_query($sql) or die("Couldn't execute query.".mysql_error());
    206     if ($row = mysql_fetch_object($result)) {
     197      " WHERE link_id = $link_id");
     198
     199    if ($row) {
    207200      $link_url = $row->link_url;
    208201      $link_name = stripslashes($row->link_name);
     
    287280      <td>
    288281        <?php
    289     $query = "SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id";
    290     $result = mysql_query($query) or die("Couldn't execute query. ".mysql_error());
     282    $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
    291283    echo "        <select name=\"category\" size=\"1\">\n";
    292     while($row = mysql_fetch_object($result)) {
     284    foreach($results as $row) {
    293285      echo "          <option value=\"".$row->cat_id."\"";
    294286      if ($row->cat_id == $link_category)
     
    321313    }
    322314    $links_show_cat_id = $cat_id;
     315    if (!isset($order_by) || ($order_by == '')) {
     316        if (!isset($links_show_order) || ($links_show_order == ''))
     317        $order_by = 'order_name';
     318    }
     319    $links_show_order = $order_by;
    323320    //break; fall through
    324321  } // end Show
     
    339336    }
    340337    $links_show_cat_id = $cat_id;
     338    if (isset($links_show_order) && ($links_show_order != ''))
     339        $order_by = $links_show_order;
     340   
    341341    if (!isset($order_by) || ($order_by == ''))
    342342        $order_by = 'order_name';
     343    $links_show_order = $order_by;
     344
    343345    setcookie('links_show_cat_id', $links_show_cat_id, time()+600);
     346    setcookie('links_show_order', $links_show_order, time()+600);
    344347    $standalone=0;
    345348    include_once ("./b2header.php");
     
    377380        <td>
    378381<?php
    379     $query = "SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id";
    380     $result = mysql_query($query) or die("Couldn't execute query. ".mysql_error());
     382    $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
    381383    echo "        <select name=\"cat_id\">\n";
    382384    echo "          <option value=\"All\"";
     
    384386      echo " selected";
    385387    echo "> All</option>\n";
    386     while($row = mysql_fetch_object($result)) {
     388    foreach ($results as $row) {
    387389      echo "          <option value=\"".$row->cat_id."\"";
    388390      if ($row->cat_id == $cat_id)
     
    434436  </tr>
    435437<?php
    436     $sql = "SELECT link_url, link_name, link_image, link_description, link_visible, link_category AS cat_id, cat_name AS category, $tableusers.user_login, link_id, link_rating, link_rel FROM $tablelinks LEFT JOIN $tablelinkcategories ON $tablelinks.link_category = $tablelinkcategories.cat_id LEFT JOIN $tableusers on $tableusers.ID = $tablelinks.link_owner ";
     438    $sql = "SELECT link_url, link_name, link_image, link_description, link_visible,
     439    link_category AS cat_id, cat_name AS category, $tableusers.user_login, link_id,
     440    link_rating, link_rel
     441    FROM $tablelinks
     442    LEFT JOIN $tablelinkcategories ON $tablelinks.link_category = $tablelinkcategories.cat_id
     443    LEFT JOIN $tableusers on $tableusers.ID = $tablelinks.link_owner ";
     444   
    437445    // have we got a where clause?
    438446    if (($use_adminlevels) || (isset($cat_id) && ($cat_id != 'All')) ) {
    439447        $sql .= " WHERE ";
    440448    }
     449    // FIX ME This make higher level links invisible rather than just uneditable
    441450    if ($use_adminlevels) {
    442451        $sql .= " ($tableusers.user_level <= $user_level"
     
    550559        <td>
    551560<?php
    552     $query = "SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id";
    553     $result = mysql_query($query) or die("Couldn't execute query. ".mysql_error());
     561    $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
    554562    echo "        <select name=\"category\" size=\"1\">\n";
    555     while($row = mysql_fetch_object($result)) {
     563    foreach ($results as $row) {
    556564      echo "          <option value=\"".$row->cat_id."\"";
    557565      if ($row->cat_id == $cat_id)
Note: See TracChangeset for help on using the changeset viewer.