3 // Copyright (C) 2002 Mike Little -- mike@zed1.com
5 require_once('admin.php');
6 $parent_file = 'edit.php';
7 $title = __('Import Blogroll');
9 $step = $_POST['step'];
10 if (!$step) $step = 0;
15 include_once('admin-header.php');
16 if ( !current_user_can('manage_links') )
17 wp_die(__('Cheatin’ uh?'));
19 $opmltype = 'blogrolling'; // default.
24 <h2><?php _e('Import your blogroll from another system') ?> </h2>
25 <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
26 <?php wp_nonce_field('import-bookmarks') ?>
28 <p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?></p>
29 <div style="width: 70%; margin: auto; height: 8em;">
30 <input type="hidden" name="step" value="1" />
31 <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
32 <div style="width: 48%;" class="alignleft">
33 <h3><?php _e('Specify an OPML URL:'); ?></h3>
34 <input type="text" name="opml_url" size="50" style="width: 90%;" value="http://" />
37 <div style="width: 48%;" class="alignleft">
38 <h3><?php _e('Or choose from your local disk:'); ?></h3>
39 <input id="userfile" name="userfile" type="file" size="30" />
44 <p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these links in.') ?><br />
45 <?php _e('Category:') ?> <select name="cat_id">
47 $categories = get_terms('link_category', 'get=all');
48 foreach ($categories as $category) {
50 <option value="<?php echo $category->term_id; ?>"><?php echo wp_specialchars(apply_filters('link_category', $category->name)); ?></option>
56 <p class="submit"><input type="submit" name="submit" value="<?php _e('Import OPML File') ?>" /></p>
65 check_admin_referer('import-bookmarks');
67 include_once('admin-header.php');
68 if ( !current_user_can('manage_links') )
69 wp_die(__('Cheatin’ uh?'));
73 <h2><?php _e('Importing...') ?></h2>
75 $cat_id = abs( (int) $_POST['cat_id'] );
79 $opml_url = $_POST['opml_url'];
80 if ( isset($opml_url) && $opml_url != '' && $opml_url != 'http://' ) {
82 } else { // try to get the upload file.
83 $overrides = array('test_form' => false, 'test_type' => false);
84 $file = wp_handle_upload($_FILES['userfile'], $overrides);
86 if ( isset($file['error']) )
87 wp_die($file['error']);
90 $opml_url = $file['file'];
94 if ( isset($opml_url) && $opml_url != '' ) {
95 if ( $blogrolling === true ) {
96 $opml = wp_remote_fopen($opml_url);
98 $opml = file_get_contents($opml_url);
101 include_once('link-parse-opml.php');
103 $link_count = count($names);
104 for ( $i = 0; $i < $link_count; $i++ ) {
105 if ('Last' == substr($titles[$i], 0, 4))
107 if ( 'http' == substr($titles[$i], 0, 4) )
109 $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]);
110 wp_insert_link($link);
111 echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]);
115 <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>
121 echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n";
124 if ( ! $blogrolling )
125 do_action( 'wp_delete_file', $opml_url);
134 include('admin-footer.php');