php 开发的内容管理系统
源代码在线查看: link-import.php
// Links // Copyright (C) 2002 Mike Little -- mike@zed1.com require_once('admin.php'); $parent_file = 'link-manager.php'; $title = __('Import Blogroll'); $this_file = 'link-import.php'; $step = $_POST['step']; if (!$step) $step = 0; ?> switch ($step) { case 0: { include_once('admin-header.php'); if ( !current_user_can('manage_links') ) die (__("Cheatin’ uh?")); $opmltype = 'blogrolling'; // default. ?> $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); foreach ($categories as $category) { ?> } // end foreach ?> break; } // end case 0 case 1: { check_admin_referer('import-bookmarks'); include_once('admin-header.php'); if ( !current_user_can('manage_links') ) die (__("Cheatin' uh ?")); ?> $cat_id = $_POST['cat_id']; if (($cat_id == '') || ($cat_id == 0)) { $cat_id = 1; } $opml_url = $_POST['opml_url']; if (isset($opml_url) && $opml_url != '' && $opml_url != 'http://') { $blogrolling = true; } else // try to get the upload file. { $overrides = array('test_form' => false, 'test_type' => false); $file = wp_handle_upload($_FILES['userfile'], $overrides); if ( isset($file['error']) ) die($file['error']); $url = $file['url']; $opml_url = $file['file']; $blogrolling = false; } if (isset($opml_url) && $opml_url != '') { $opml = wp_remote_fopen($opml_url); include_once('link-parse-opml.php'); $link_count = count($names); for ($i = 0; $i < $link_count; $i++) { if ('Last' == substr($titles[$i], 0, 4)) $titles[$i] = ''; if ('http' == substr($titles[$i], 0, 4)) $titles[$i] = ''; // FIXME: Use wp_insert_link(). $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss) VALUES('{$urls[$i]}', '".$wpdb->escape($names[$i])."', '', $cat_id, '".$wpdb->escape($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n"; $result = $wpdb->query($query); echo sprintf(''.__('Inserted %s').'', $names[$i]); } ?> } // end if got url else { echo "" . __("You need to supply your OPML url. Press back on your browser and try again") . "\n"; } // end else if ( ! $blogrolling ) @unlink($opml_url); ?> break; } // end case 1 } // end switch include('admin-footer.php'); ?>