Make WordPress Core

Changeset 128


Ignore:
Timestamp:
06/01/2003 09:01:04 AM (22 years ago)
Author:
saxmatt
Message:

Uses ezSQL, added "status", tested. Works great!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/links.import.php

    r118 r128  
    3333$title = 'Import Blogroll';
    3434
    35 function mysql_doh($msg,$sql,$error) {
    36     echo "<p>$msg</p>";
    37     echo "<p>query:<br />$sql</p>";
    38     echo "<p>error:<br />$error</p>";
    39     die();
    40 }
    41 
    42 $connexion = mysql_connect($server, $loginsql, $passsql) or die("<h1>Check your b2config.php file!</h1>Can't connect to the database<br />".mysql_error());
    43 $dbconnexion = mysql_select_db($base, $connexion);
    44 
    45 if (!$dbconnexion) {
    46     echo mysql_error();
    47     die();
    48 }
    4935$step = $HTTP_GET_VARS['step'];
    5036if (!$step) $step = 0;
     
    5743        include_once('b2header.php');
    5844        if ($user_level < $minadminlevel)
    59             die ("Cheatin' uh ?");
     45            die ("Cheatin&#8217; uh?");
    6046?>
    6147<div class="wrap">
    62     <table width="75%" cellpadding="5" cellspacing="0" border="0">
    63     <tr><td>
     48
    6449    <h3>On this page you can import your blogroll.</h3>
    65     <p>You will need your unique blogrolling.com Id.</p>
    66     <p>First, go to <a href="http://www.blogrolling.com">Blogrolling.com</a>
    67     and sign in. Once you've done that, click on <b>Get Code</b>, and then
    68     look for the <b><abbr title="Outline Processor Markup Language">OPML</abbr>
    69     code</b>.</p>
     50    <form name="blogroll" action="links.import.php" method="get">
     51    <ol>
     52    <li>Go to <a href="http://www.blogrolling.com">Blogrolling.com</a>
     53    and sign in. Once you've done that, click on <strong>Get Code</strong>, and then
     54    look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr>
     55    code</strong>.</li>
    7056
    71     <p>Select that and copy it into the box below.</p>
    72     <form name="blogroll" action="links.import.php" method="GET">
     57    <li>Select that and copy it into the box below.<br />
     58   
    7359       <input type="hidden" name="step" value="1" />
    7460       Your OPML code: <input type="text" name="opml_url" size="65" />
    75     <p>Please select a category for these links.</p>
     61       </li>
     62    <li>Now select a category you want to put these links in.<br />
     63    Category: <select name="cat_id">
    7664<?php
    77         $query = "SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id";
    78         $result = mysql_query($query) or die("Couldn't execute query. ".mysql_error());
     65    $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     66    foreach ($categories as $category) {
    7967?>
    80     <p>Select category: <select name="cat_id">
     68    <option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option>
    8169<?php
    82         while($row = mysql_fetch_object($result)) {
    83 ?>
    84     <option value="<?php echo $row->cat_id; ?>"><?php echo $row->cat_id.': '.$row->cat_name; ?></option>
    85 <?php
    86         } // end while
     70        } // end foreach
    8771?>
    8872    </select>
    89     <p>Finally, click on the 'Import' button and we're off!</p>
    90         <input type="submit" name="submit" value="Import" />
     73   
     74    </li>
     75
     76    <li><input type="submit" name="submit" value="Import!" /></li>
     77    </ol>
    9178    </form>
    92         </td>
    93       </tr>
    94     </table>
     79
    9580</div>
    9681<?php
     
    10590?>
    10691<div class="wrap">
    107     <table width="75%" cellpadding="5" cellspacing="0" border="0">
    108     <tr><td>
     92
    10993     <h3>Importing...</h3>
    11094<?php
     
    11599                $opml_url = $HTTP_GET_VARS['opml_url'];
    116100                if ($opml_url == '') {
    117                     echo "<p>You need to supply your OLPML url. Press back on your browser and try again</p>\n";
     101                    echo "<p>You need to supply your OPML url. Press back on your browser and try again</p>\n";
    118102                }
    119103                else
     
    127111                    $targets = $items[5];
    128112                    $link_count = count($names);
    129                     for ($i = 0; $i < count($names); $i++) {
     113                    for ($i = 0; $i < $link_count; $i++) {
    130114                        if ('Last' == substr($titles[$i], 0, 4))
    131115                            $titles[$i] = '';
     116                        if ('http' == substr($titles[$i], 0, 4))
     117                            $titles[$i] = '';
    132118                        //echo "INSERT INTO $tablelinks (link_url, link_name, link_target, link_category, link_description, link_owner) VALUES('{$urls[$i]}', '{$names[$i]}', '{$targets[$i]}', $cat_id, '{$titles[$i]}', \$user_ID)<br />\n";
    133                         $query = "INSERT INTO $tablelinks (link_url, link_name, link_target, link_category, link_description, link_owner)\n " .
    134                                  " VALUES('{$urls[$i]}', '".addslashes($names[$i])."', '{$targets[$i]}', $cat_id, '".addslashes($titles[$i])."', $user_ID)\n";
    135                         $result = mysql_query($query) or die("Couldn't insert link. Sorry".mysql_error());
     119                        $query = "INSERT INTO $tablelinks (link_url, link_name, link_target, link_category, link_description, link_owner)
     120                        VALUES('{$urls[$i]}', '".addslashes($names[$i])."', '{$targets[$i]}', $cat_id, '".addslashes($titles[$i])."', $user_ID)\n";
     121                        $result = $wpdb->query($query);
     122                        echo "<p>Inserted <strong>{$names[$i]}</strong></p>";
    136123                    }
    137124?>
    138      <p>Inserted <?php echo $link_count ?> links into category <?php echo $cat_id; ?>.</p>
     125     <p>Inserted <?php echo $link_count ?> links into category <?php echo $cat_id; ?>. All done! Go <a href="linkmanager.php">manage those links</a>.</p>
    139126<?php
    140127                } // end else got url
    141128?>
    142         </td>
    143       </tr>
    144     </table>
     129
    145130</div>
    146131<?php
Note: See TracChangeset for help on using the changeset viewer.