2003-05-30 20:06:21 -04:00
|
|
|
<?php
|
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
// Links
|
|
|
|
// Copyright (C) 2002 Mike Little -- mike@zed1.com
|
|
|
|
//
|
|
|
|
// This is an add-on to b2 weblog / news publishing tool
|
|
|
|
// b2 is copyright (c)2001, 2002 by Michel Valdrighi - m@tidakada.com
|
|
|
|
//
|
|
|
|
// **********************************************************************
|
|
|
|
// Copyright (C) 2002 Mike Little
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// Mike Little (mike@zed1.com)
|
|
|
|
// *****************************************************************
|
2003-06-12 18:42:48 -04:00
|
|
|
require_once('../wp-config.php');
|
2003-05-30 20:06:21 -04:00
|
|
|
include_once("../wp-links/links.php");
|
|
|
|
|
|
|
|
$title = 'Import Blogroll';
|
2003-08-09 19:10:16 -04:00
|
|
|
$this_file = 'links.import.php';
|
2003-05-30 20:06:21 -04:00
|
|
|
|
|
|
|
$step = $HTTP_GET_VARS['step'];
|
|
|
|
if (!$step) $step = 0;
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
switch ($step) {
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
$standalone = 0;
|
|
|
|
include_once('b2header.php');
|
2003-08-03 19:46:20 -04:00
|
|
|
if ($user_level < get_settings('links_minadminlevel'))
|
2003-06-01 05:01:04 -04:00
|
|
|
die ("Cheatin’ uh?");
|
2003-05-30 20:06:21 -04:00
|
|
|
?>
|
|
|
|
<div class="wrap">
|
2003-06-01 05:01:04 -04:00
|
|
|
|
2003-05-30 20:06:21 -04:00
|
|
|
<h3>On this page you can import your blogroll.</h3>
|
2003-06-01 05:01:04 -04:00
|
|
|
<form name="blogroll" action="links.import.php" method="get">
|
|
|
|
<ol>
|
|
|
|
<li>Go to <a href="http://www.blogrolling.com">Blogrolling.com</a>
|
|
|
|
and sign in. Once you've done that, click on <strong>Get Code</strong>, and then
|
|
|
|
look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr>
|
2003-08-09 19:10:16 -04:00
|
|
|
code</strong><?php echo gethelp_link($this_file,'opml_code');?>.</li>
|
2003-05-30 20:06:21 -04:00
|
|
|
|
2003-06-01 05:01:04 -04:00
|
|
|
<li>Select that and copy it into the box below.<br />
|
|
|
|
|
2003-05-30 20:06:21 -04:00
|
|
|
<input type="hidden" name="step" value="1" />
|
2003-08-09 19:10:16 -04:00
|
|
|
Your OPML code:<?php echo gethelp_link($this_file,'opml_code');?> <input type="text" name="opml_url" size="65" />
|
2003-06-01 05:01:04 -04:00
|
|
|
</li>
|
|
|
|
<li>Now select a category you want to put these links in.<br />
|
2003-08-09 19:10:16 -04:00
|
|
|
Category: <?php echo gethelp_link($this_file,'link_category');?><select name="cat_id">
|
2003-05-30 20:06:21 -04:00
|
|
|
<?php
|
2003-06-01 05:01:04 -04:00
|
|
|
$categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
|
|
|
|
foreach ($categories as $category) {
|
2003-05-30 20:06:21 -04:00
|
|
|
?>
|
2003-06-01 05:01:04 -04:00
|
|
|
<option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option>
|
2003-05-30 20:06:21 -04:00
|
|
|
<?php
|
2003-06-01 05:01:04 -04:00
|
|
|
} // end foreach
|
2003-05-30 20:06:21 -04:00
|
|
|
?>
|
|
|
|
</select>
|
2003-06-01 05:01:04 -04:00
|
|
|
|
|
|
|
</li>
|
|
|
|
|
2003-08-09 19:10:16 -04:00
|
|
|
<li><input type="submit" name="submit" value="Import!" /><?php echo gethelp_link($this_file,'import');?></li>
|
2003-06-01 05:01:04 -04:00
|
|
|
</ol>
|
2003-05-30 20:06:21 -04:00
|
|
|
</form>
|
2003-06-01 05:01:04 -04:00
|
|
|
|
2003-05-30 20:06:21 -04:00
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
} // end case 0
|
|
|
|
|
|
|
|
case 1: {
|
|
|
|
$standalone = 0;
|
|
|
|
include_once('b2header.php');
|
2003-08-03 19:46:20 -04:00
|
|
|
if ($user_level < get_settings('links_minadminlevel'))
|
2003-05-30 20:06:21 -04:00
|
|
|
die ("Cheatin' uh ?");
|
|
|
|
?>
|
|
|
|
<div class="wrap">
|
2003-06-01 05:01:04 -04:00
|
|
|
|
2003-05-30 20:06:21 -04:00
|
|
|
<h3>Importing...</h3>
|
|
|
|
<?php
|
|
|
|
$cat_id = $HTTP_GET_VARS['cat_id'];
|
|
|
|
if (($cat_id == '') || ($cat_id == 0)) {
|
|
|
|
$cat_id = 1;
|
|
|
|
}
|
|
|
|
$opml_url = $HTTP_GET_VARS['opml_url'];
|
|
|
|
if ($opml_url == '') {
|
2003-06-01 05:01:04 -04:00
|
|
|
echo "<p>You need to supply your OPML url. Press back on your browser and try again</p>\n";
|
2003-05-30 20:06:21 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$opml = implode('', file($opml_url));
|
|
|
|
preg_match_all('/<outline text="(.*?)" type="(.*?)" url="(.*?)" title="(.*?)" target="(.*?)" \/>/', $opml, $items);
|
|
|
|
$names = $items[1];
|
|
|
|
$types = $items[2];
|
|
|
|
$urls = $items[3];
|
|
|
|
$titles = $items[4];
|
|
|
|
$targets = $items[5];
|
|
|
|
$link_count = count($names);
|
2003-06-01 05:01:04 -04:00
|
|
|
for ($i = 0; $i < $link_count; $i++) {
|
2003-05-30 20:06:21 -04:00
|
|
|
if ('Last' == substr($titles[$i], 0, 4))
|
2003-06-01 05:01:04 -04:00
|
|
|
$titles[$i] = '';
|
|
|
|
if ('http' == substr($titles[$i], 0, 4))
|
2003-05-30 20:06:21 -04:00
|
|
|
$titles[$i] = '';
|
|
|
|
//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";
|
2003-06-01 05:01:04 -04:00
|
|
|
$query = "INSERT INTO $tablelinks (link_url, link_name, link_target, link_category, link_description, link_owner)
|
|
|
|
VALUES('{$urls[$i]}', '".addslashes($names[$i])."', '{$targets[$i]}', $cat_id, '".addslashes($titles[$i])."', $user_ID)\n";
|
|
|
|
$result = $wpdb->query($query);
|
|
|
|
echo "<p>Inserted <strong>{$names[$i]}</strong></p>";
|
2003-05-30 20:06:21 -04:00
|
|
|
}
|
|
|
|
?>
|
2003-06-01 05:01:04 -04:00
|
|
|
<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>
|
2003-05-30 20:06:21 -04:00
|
|
|
<?php
|
|
|
|
} // end else got url
|
|
|
|
?>
|
2003-06-01 05:01:04 -04:00
|
|
|
|
2003-05-30 20:06:21 -04:00
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
break;
|
|
|
|
} // end case 1
|
|
|
|
} // end switch
|
|
|
|
?>
|
|
|
|
</body>
|
|
|
|
</html>
|