Changeset 4953 for trunk/wp-admin/link-import.php
- Timestamp:
- 02/27/2007 03:24:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/link-import.php
r4734 r4953 13 13 <?php 14 14 switch ($step) { 15 case 0: 16 { 17 include_once('admin-header.php'); 18 if ( !current_user_can('manage_links') ) 19 wp_die(__('Cheatin’ uh?')); 15 case 0: { 16 include_once('admin-header.php'); 17 if ( !current_user_can('manage_links') ) 18 wp_die(__('Cheatin’ uh?')); 20 19 21 20 $opmltype = 'blogrolling'; // default. 22 21 ?> 23 22 24 23 <div class="wrap"> 24 25 25 <h2><?php _e('Import your blogroll from another system') ?> </h2> 26 26 <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll"> … … 40 40 <input id="userfile" name="userfile" type="file" size="30" /> 41 41 </div> 42 43 42 44 43 </div> … … 61 60 </div> 62 61 <?php 63 64 62 break; 63 } // end case 0 65 64 66 65 case 1: { 67 66 check_admin_referer('import-bookmarks'); 68 67 69 70 71 68 include_once('admin-header.php'); 69 if ( !current_user_can('manage_links') ) 70 wp_die(__('Cheatin’ uh?')); 72 71 ?> 73 72 <div class="wrap"> 74 73 75 74 <h2><?php _e('Importing...') ?></h2> 76 75 <?php 77 $cat_id = $_POST['cat_id']; 78 if (($cat_id == '') || ($cat_id == 0)) { 79 $cat_id = 1; 80 } 76 $cat_id = $_POST['cat_id']; 77 if ( $cat_id == '' || $cat_id == 0 ) 78 $cat_id = 1; 81 79 82 $opml_url = $_POST['opml_url']; 83 if (isset($opml_url) && $opml_url != '' && $opml_url != 'http://') { 84 $blogrolling = true; 85 } 86 else // try to get the upload file. 87 { 88 $overrides = array('test_form' => false, 'test_type' => false); 89 $file = wp_handle_upload($_FILES['userfile'], $overrides); 80 $opml_url = $_POST['opml_url']; 81 if ( isset($opml_url) && $opml_url != '' && $opml_url != 'http://' ) { 82 $blogrolling = true; 83 } else { // try to get the upload file. 84 $overrides = array('test_form' => false, 'test_type' => false); 85 $file = wp_handle_upload($_FILES['userfile'], $overrides); 90 86 91 92 87 if ( isset($file['error']) ) 88 wp_die($file['error']); 93 89 94 95 96 97 90 $url = $file['url']; 91 $opml_url = $file['file']; 92 $blogrolling = false; 93 } 98 94 99 if (isset($opml_url) && $opml_url != '') {100 101 95 if ( isset($opml_url) && $opml_url != '' ) { 96 $opml = wp_remote_fopen($opml_url); 97 include_once('link-parse-opml.php'); 102 98 103 104 for ($i = 0; $i < $link_count; $i++) {105 106 107 if ('http' == substr($titles[$i], 0, 4))108 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 111 112 99 $link_count = count($names); 100 for ( $i = 0; $i < $link_count; $i++ ) { 101 if ('Last' == substr($titles[$i], 0, 4)) 102 $titles[$i] = ''; 103 if ( 'http' == substr($titles[$i], 0, 4) ) 104 $titles[$i] = ''; 105 $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]); 106 wp_insert_link($link); 107 echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]); 108 } 113 109 ?> 114 <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> 110 111 <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> 112 115 113 <?php 116 117 118 119 120 114 } // end if got url 115 else 116 { 117 echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n"; 118 } // end else 121 119 122 123 120 if ( ! $blogrolling ) 121 @unlink($opml_url); 124 122 ?> 125 123 </div> 126 124 <?php 127 128 125 break; 126 } // end case 1 129 127 } // end switch 130 128
Note: See TracChangeset
for help on using the changeset viewer.