2003-05-31 02:06:21 +02:00
< ? php
// Links
// Copyright (C) 2002 Mike Little -- mike@zed1.com
2003-12-08 04:46:42 +01:00
2003-06-13 00:42:48 +02:00
require_once ( '../wp-config.php' );
2003-05-31 02:06:21 +02:00
2003-12-11 01:22:36 +01:00
$parent_file = 'link-manager.php' ;
2004-04-26 01:25:31 +02:00
$title = __ ( 'Import Blogroll' );
2003-12-11 01:22:36 +01:00
$this_file = 'link-import.php' ;
2003-05-31 02:06:21 +02:00
2004-04-21 00:56:47 +02:00
$step = $_POST [ 'step' ];
2003-05-31 02:06:21 +02:00
if ( ! $step ) $step = 0 ;
?>
< ? php
switch ( $step ) {
case 0 :
{
$standalone = 0 ;
2003-12-11 01:22:36 +01:00
include_once ( 'admin-header.php' );
2003-08-04 01:46:20 +02:00
if ( $user_level < get_settings ( 'links_minadminlevel' ))
2004-04-26 01:25:31 +02:00
die ( __ ( " Cheatin’ uh? " ));
2003-12-10 01:43:15 +01:00
2003-12-08 04:46:42 +01:00
$opmltype = 'blogrolling' ; // default.
2003-05-31 02:06:21 +02:00
?>
2003-12-08 04:46:42 +01:00
< ul id = " adminmenu2 " >
2004-04-26 01:25:31 +02:00
< li >< a href = " link-manager.php " >< ? php _e ( 'Manage Links' ) ?> </a></li>
< li >< a href = " link-add.php " >< ? php _e ( 'Add Link' ) ?> </a></li>
< li >< a href = " link-categories.php " >< ? php _e ( 'Link Categories' ) ?> </a></li>
< li class = " last " >< a href = " link-import.php " class = " current " >< ? php _e ( 'Import Blogroll' ) ?> </a></li>
2003-12-08 04:46:42 +01:00
</ ul >
2003-05-31 02:06:21 +02:00
< div class = " wrap " >
2003-06-01 11:01:04 +02:00
2004-04-26 01:25:31 +02:00
< h2 >< ? php _e ( 'Import your blogroll from another system' ) ?> </h2>
2003-12-11 01:22:36 +01:00
<!-- < form name = " blogroll " action = " link-import.php " method = " get " > -->
< form enctype = " multipart/form-data " action = " link-import.php " method = " post " name = " blogroll " >
2003-12-10 01:43:15 +01:00
2003-06-01 11:01:04 +02:00
< ol >
2004-04-26 01:25:31 +02:00
< li >< ? php _e ( ' Go to < a href = " http://www.blogrolling.com " > Blogrolling . com </ a >
and sign in . Once you & #8217;ve done that, click on <strong>Get Code</strong>, and then
2003-06-01 11:01:04 +02:00
look for the < strong >< abbr title = " Outline Processor Markup Language " > OPML </ abbr >
2004-08-04 05:35:49 +02:00
code </ strong > ' ) ?> .</li>
2004-04-26 01:25:31 +02:00
< li >< ? php _e ( ' Or go to < a href = " http://blo.gs " > Blo . gs </ a > and sign in . Once you & #8217;ve done
that in the \ ' Welcome Back\ ' box on the right , click on < strong > share </ strong > , and then
2003-10-31 01:37:06 +01:00
look for the < strong >< abbr title = " Outline Processor Markup Language " > OPML </ abbr >
2004-08-04 05:35:49 +02:00
link </ strong > ( favorites . opml ) . ' ) ?> </li>
2004-04-26 01:25:31 +02:00
< li >< ? php _e ( 'Select that text and copy it or copy the link/shortcut into the box below.' ) ?> <br />
2003-05-31 02:06:21 +02:00
< input type = " hidden " name = " step " value = " 1 " />
2004-08-04 05:35:49 +02:00
< ? php _e ( 'Your OPML URL:' ) ?> <input type="text" name="opml_url" size="65" />
2003-10-31 01:37:06 +01:00
</ li >
2003-12-10 01:43:15 +01:00
< li >
2004-04-26 01:25:31 +02:00
< ? php _e ( '<strong>or</strong> you can upload an OPML file from your desktop aggregator:' ) ?> <br />
2003-12-10 01:43:15 +01:00
< input type = " hidden " name = " MAX_FILE_SIZE " value = " 30000 " />
2004-04-26 01:25:31 +02:00
< label >< ? php _e ( 'Upload this file:' ) ?> <input name="userfile" type="file" /></label>
2003-10-31 01:37:06 +01:00
</ li >
2004-04-26 01:25:31 +02:00
< li >< ? php _e ( 'Now select a category you want to put these links in.' ) ?> <br />
2004-08-04 05:35:49 +02:00
< ? php _e ( 'Category:' ) ?> <select name="cat_id">
2003-05-31 02:06:21 +02:00
< ? php
2004-05-24 10:22:18 +02:00
$categories = $wpdb -> get_results ( " SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id " );
2003-06-01 11:01:04 +02:00
foreach ( $categories as $category ) {
2003-05-31 02:06:21 +02:00
?>
2003-06-01 11:01:04 +02:00
< option value = " <?php echo $category->cat_id ; ?> " >< ? php echo $category -> cat_id . ': ' . $category -> cat_name ; ?> </option>
2003-05-31 02:06:21 +02:00
< ? php
2003-06-01 11:01:04 +02:00
} // end foreach
2003-05-31 02:06:21 +02:00
?>
</ select >
2003-12-10 01:43:15 +01:00
2003-06-01 11:01:04 +02:00
</ li >
2004-08-04 05:35:49 +02:00
< li >< input type = " submit " name = " submit " value = " <?php _e('Import!') ?> " /></ li >
2003-06-01 11:01:04 +02:00
</ ol >
2003-05-31 02:06:21 +02:00
</ form >
2003-06-01 11:01:04 +02:00
2003-05-31 02:06:21 +02:00
</ div >
< ? php
break ;
} // end case 0
case 1 : {
$standalone = 0 ;
2003-12-11 01:22:36 +01:00
include_once ( 'admin-header.php' );
2003-08-04 01:46:20 +02:00
if ( $user_level < get_settings ( 'links_minadminlevel' ))
2004-04-26 01:25:31 +02:00
die ( __ ( " Cheatin' uh ? " ));
2003-05-31 02:06:21 +02:00
?>
< div class = " wrap " >
2003-06-01 11:01:04 +02:00
2004-04-26 01:25:31 +02:00
< h2 >< ? php _e ( 'Importing...' ) ?> </h2>
2003-05-31 02:06:21 +02:00
< ? php
2004-04-21 00:56:47 +02:00
$cat_id = $_POST [ 'cat_id' ];
2003-05-31 02:06:21 +02:00
if (( $cat_id == '' ) || ( $cat_id == 0 )) {
$cat_id = 1 ;
}
2003-12-10 01:43:15 +01:00
2004-04-21 00:56:47 +02:00
$opml_url = $_POST [ 'opml_url' ];
2003-12-10 01:43:15 +01:00
if ( isset ( $opml_url ) && $opml_url != '' ) {
$blogrolling = true ;
2003-05-31 02:06:21 +02:00
}
2003-12-10 01:43:15 +01:00
else // try to get the upload file.
{
2004-03-01 07:13:32 +01:00
$uploaddir = get_settings ( 'fileupload_realpath' );
2003-12-10 01:43:15 +01:00
$uploadfile = $uploaddir . '/' . $_FILES [ 'userfile' ][ 'name' ];
if ( move_uploaded_file ( $_FILES [ 'userfile' ][ 'tmp_name' ], $uploadfile ))
{
2004-04-26 17:45:42 +02:00
//echo "Upload successful.";
2003-12-10 01:43:15 +01:00
$blogrolling = false ;
$opml_url = $uploadfile ;
} else {
2004-04-26 17:45:42 +02:00
echo __ ( " Upload error " );
2003-12-10 01:43:15 +01:00
}
}
if ( isset ( $opml_url ) && $opml_url != '' ) {
2003-05-31 02:06:21 +02:00
$opml = implode ( '' , file ( $opml_url ));
2003-12-11 01:22:36 +01:00
include_once ( 'link-parse-opml.php' );
2003-10-31 01:37:06 +01:00
2003-05-31 02:06:21 +02:00
$link_count = count ( $names );
2003-06-01 11:01:04 +02:00
for ( $i = 0 ; $i < $link_count ; $i ++ ) {
2003-05-31 02:06:21 +02:00
if ( 'Last' == substr ( $titles [ $i ], 0 , 4 ))
2003-06-01 11:01:04 +02:00
$titles [ $i ] = '' ;
2003-12-10 01:43:15 +01:00
if ( 'http' == substr ( $titles [ $i ], 0 , 4 ))
2003-05-31 02:06:21 +02:00
$titles [ $i ] = '' ;
2004-05-24 10:22:18 +02:00
$query = " INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
2004-04-21 00:01:15 +02:00
VALUES ( '{$urls[$i]}' , '".addslashes($names[$i])."' , '' , $cat_id , '".addslashes($descriptions[$i])."' , $user_ID , '{$feeds[$i]}' ) \n " ;
2003-06-01 11:01:04 +02:00
$result = $wpdb -> query ( $query );
2004-04-26 01:25:31 +02:00
echo sprintf ( __ ( " <p>Inserted <strong>%s</strong></p> " ), $names [ $i ]);
2003-05-31 02:06:21 +02:00
}
?>
2004-04-26 01:25:31 +02:00
< p >< ? php printf ( __ ( 'Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.' ), $link_count , $cat_id , 'link-manager.php' ) ?> </p>
2003-05-31 02:06:21 +02:00
< ? php
2003-12-10 01:43:15 +01:00
} // end if got url
else
{
2004-04-26 01:25:31 +02:00
echo " <p> " . __ ( " You need to supply your OPML url. Press back on your browser and try again " ) . " </p> \n " ;
2003-12-10 01:43:15 +01:00
} // end else
2003-06-01 11:01:04 +02:00
2003-12-10 01:43:15 +01:00
?>
2004-06-11 20:23:12 +02:00
</ div >
2003-05-31 02:06:21 +02:00
< ? php
break ;
} // end case 1
} // end switch
?>
</ body >
2004-04-26 01:25:31 +02:00
</ html >