📄 link-manager.php
字号:
<?php// Links// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.comrequire_once('../wp-config.php');$title = '链接管理';$this_file = 'link-manager.php';$parent_file = 'link-manager.php';function xfn_check($class, $value = '', $type = 'check') { global $link_rel; if ('' != $value && strstr($link_rel, $value)) { echo ' checked="checked"'; } if ('' == $value) { if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') ) echo ' checked="checked"'; if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') ) echo ' checked="checked"'; if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor') ) echo ' checked="checked"'; }}function category_dropdown($fieldname, $selected = 0) { global $wpdb; $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM {$wpdb->linkcategories} ORDER BY cat_id"); echo "\n<select name='$fieldname' size='1'>"; foreach ($results as $row) { echo "\n\t<option value='$row->cat_id'"; if ($row->cat_id == $selected) echo " selected='selected'"; echo ">$row->cat_id: $row->cat_name"; if ('Y' == $row->auto_toggle) echo ' (自动切换)'; echo "</option>\n"; } echo "\n</select>\n";}function add_magic_quotes($array) { foreach ($array as $k => $v) { if (is_array($v)) { $array[$k] = add_magic_quotes($v); } else { $array[$k] = addslashes($v); } } return $array;}if (!get_magic_quotes_gpc()) { $_GET = add_magic_quotes($_GET); $_POST = add_magic_quotes($_POST); $_COOKIE = add_magic_quotes($_COOKIE);}$wpvarstoreset = array('action','standalone','cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]');for ($i=0; $i<count($wpvarstoreset); $i += 1) { $wpvar = $wpvarstoreset[$i]; if (!isset($$wpvar)) { if (empty($_POST["$wpvar"])) { if (empty($_GET["$wpvar"])) { $$wpvar = ''; } else { $$wpvar = $_GET["$wpvar"]; } } else { $$wpvar = $_POST["$wpvar"]; } }}$links_show_cat_id = $_COOKIE['links_show_cat_id_' . $cookiehash];$links_show_order = $_COOKIE['links_show_order_' . $cookiehash];if (!empty($action2)) { $action = $action2;}switch ($action) { case _LANG_WLM_ASSIGN_TEXT: { $standalone = 1; include_once('admin-header.php'); // check the current user's level first. if ($user_level < get_settings('links_minadminlevel')) die ("Cheatin' uh ?"); //for each link id (in $linkcheck[]): if the current user level >= the //userlevel of the owner of the link then we can proceed. if (count($linkcheck) == 0) { header('Location: ' . $this_file); exit; } $all_links = join(',', $linkcheck); $results = $wpdb->get_results("SELECT link_id, link_owner, user_level FROM {$wpdb->links} LEFT JOIN {$wpdb->users} ON link_owner = ID WHERE link_id in ($all_links)"); foreach ($results as $row) { if (!get_settings('links_use_adminlevels') || ($user_level >= $row->user_level)) { // ok to proceed $ids_to_change[] = $row->link_id; } } // should now have an array of links we can change $all_links = join(',', $ids_to_change); $q = $wpdb->query("update {$wpdb->links} SET link_owner='$newowner' WHERE link_id IN ($all_links)"); header('Location: ' . $this_file); break; } case _LANG_WLM_VISIVILITY_TEXT: { $standalone = 1; include_once('admin-header.php'); // check the current user's level first. if ($user_level < get_settings('links_minadminlevel')) die ("Cheatin' uh ?"); //for each link id (in $linkcheck[]): toggle the visibility if (count($linkcheck) == 0) { header('Location: ' . $this_file); exit; } $all_links = join(',', $linkcheck); $results = $wpdb->get_results("SELECT link_id, link_visible FROM {$wpdb->links} WHERE link_id in ($all_links)"); foreach ($results as $row) { if ($row->link_visible == 'Y') { // ok to proceed $ids_to_turnoff[] = $row->link_id; } else { $ids_to_turnon[] = $row->link_id; } } // should now have two arrays of links to change if (count($ids_to_turnoff)) { $all_linksoff = join(',', $ids_to_turnoff); $q = $wpdb->query("update {$wpdb->links} SET link_visible='N' WHERE link_id IN ($all_linksoff)"); } if (count($ids_to_turnon)) { $all_linkson = join(',', $ids_to_turnon); $q = $wpdb->query("update {$wpdb->links} SET link_visible='Y' WHERE link_id IN ($all_linkson)"); } header('Location: ' . $this_file); break; } case _LANG_WLM_MOVE_TEXT: { $standalone = 1; include_once('admin-header.php'); // check the current user's level first. if ($user_level < get_settings('links_minadminlevel')) die ("Cheatin' uh ?"); //for each link id (in $linkcheck[]) change category to selected value if (count($linkcheck) == 0) { header('Location: ' . $this_file); exit; } $all_links = join(',', $linkcheck); // should now have an array of links we can change $q = $wpdb->query("update {$wpdb->links} SET link_category='$category' WHERE link_id IN ($all_links)"); header('Location: ' . $this_file); break; } case 'Add': { $standalone = 1; include_once('admin-header.php'); wp_refcheck("/wp-admin"); $link_url = $_POST['linkurl']; $link_name = $_POST['name']; $link_image = $_POST['image']; $link_target = $_POST['target']; $link_category = $_POST['category']; $link_category = intval($link_category); $link_description = $_POST['description']; $link_visible = $_POST['visible']; $link_rating = $_POST['rating']; $link_rating = intval($link_rating); $link_rel = $_POST['rel']; $link_notes = $_POST['notes']; $link_rss_uri = $_POST['rss_uri']; $auto_toggle = get_autotoggle($link_category); if ($user_level < get_settings('links_minadminlevel')) die ("Cheatin' uh ?"); // if we are in an auto toggle category and this one is visible then we // need to make the others invisible before we add this new one. if (($auto_toggle == 'Y') && ($link_visible == 'Y')) { $wpdb->query("UPDATE {$wpdb->links} set link_visible = 'N' WHERE link_category = $link_category"); } $wpdb->query("INSERT INTO {$wpdb->links} (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) " . " VALUES('" . addslashes($link_url) . "','" . addslashes($link_name) . "', '" . addslashes($link_image) . "', '$link_target', $link_category, '" . addslashes($link_description) . "', '$link_visible', $user_ID, $link_rating, '" . addslashes($link_rel) . "', '" . addslashes($link_notes) . "', '$link_rss_uri')"); header('Location: ' . $_SERVER['HTTP_REFERER']); break; } // end Add case 'editlink': { if (isset($submit)) { if (isset($links_show_cat_id) && ($links_show_cat_id != '')) $cat_id = $links_show_cat_id; if (!isset($cat_id) || ($cat_id == '')) { if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) $cat_id = 'All'; } $links_show_cat_id = $cat_id; $standalone = 1; include_once('admin-header.php'); wp_refcheck("/wp-admin"); $link_id = $_POST['link_id']; $link_id = intval($link_id); $link_url = $_POST['linkurl']; $link_name = $_POST['name']; $link_image = $_POST['image']; $link_target = $_POST['target']; $link_category = $_POST['category']; $link_category = intval($link_category); $link_description = $_POST['description']; $link_visible = $_POST['visible']; $link_rating = $_POST['rating']; $link_rating = intval($link_rating); $link_rel = $_POST['rel']; $link_notes = $_POST['notes']; $link_rss_uri = $_POST['rss_uri']; $auto_toggle = get_autotoggle($link_category); if ($user_level < get_settings('links_minadminlevel')) die ("Cheatin' uh ?"); // if we are in an auto toggle category and this one is visible then we // need to make the others invisible before we update this one. if (($auto_toggle == 'Y') && ($link_visible == 'Y')) { $wpdb->query("UPDATE {$wpdb->links} set link_visible = 'N' WHERE link_category = $link_category"); } $wpdb->query("UPDATE {$wpdb->links} SET link_url='" . addslashes($link_url) . "', link_name='" . addslashes($link_name) . "',\n link_image='" . addslashes($link_image) . "', link_target='$link_target',\n link_category=$link_category, link_visible='$link_visible',\n link_description='" . addslashes($link_description) . "', link_rating=$link_rating, link_rel='" . addslashes($link_rel) . "', link_notes='" . addslashes($link_notes) . "', link_rss = '$link_rss_uri' WHERE link_id=$link_id"); } // end if save setcookie('links_show_cat_id_' . $cookiehash, $links_show_cat_id, time()+600); header('Location: ' . $this_file); break; } // end Save case 'Delete': { $standalone = 1; include_once('admin-header.php'); wp_refcheck("/wp-admin"); $link_id = $_GET["link_id"]; $link_id = intval($link_id); if ($user_level < get_settings('links_minadminlevel')) die ("Cheatin' uh ?"); $wpdb->query("DELETE FROM {$wpdb->links} WHERE link_id = $link_id"); if (isset($links_show_cat_id) && ($links_show_cat_id != '')) $cat_id = $links_show_cat_id; if (!isset($cat_id) || ($cat_id == '')) { if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) $cat_id = 'All'; } $links_show_cat_id = $cat_id; setcookie("links_show_cat_id_".$cookiehash, $links_show_cat_id, time()+600); header('Location: '.$this_file); break; } // end Delete case 'linkedit': { $standalone=0; $xfn = true; include_once ('admin-header.php'); if ($user_level < get_settings('links_minadminlevel')) { die("You have no right to edit the links for this blog.<br />Ask for a promotion to your <a href='mailto:".get_settings('admin_email')."'>blog admin</a>. :)"); } $link_id = $_GET["link_id"]; $link_id = intval($link_id); $row = $wpdb->get_row("SELECT * FROM {$wpdb->links} WHERE link_id = $link_id"); if ($row) { $link_url = stripslashes($row->link_url); $link_name = stripslashes($row->link_name); $link_image = $row->link_image; $link_target = $row->link_target; $link_category = $row->link_category; $link_description = stripslashes($row->link_description); $link_visible = $row->link_visible; $link_rating = $row->link_rating; $link_rel = stripslashes($row->link_rel); $link_notes = stripslashes($row->link_notes); $link_rss_uri = $row->link_rss; }?><ul id="adminmenu2"> <li><a href="link-manager.php" class="current"><?php echo _LANG_WLA_MANAGE_LINK; ?></a></li> <li><a href="link-add.php"><?php echo _LANG_WLA_ADD_LINK; ?></a></li> <li><a href="link-categories.php"><?php echo _LANG_WLA_LINK_CATE; ?></a></li> <li class="last"><a href="link-import.php"><?php echo _LANG_WLA_IMPORT_BLOG; ?></a></li></ul><style media="screen" type="text/css">th { text-align: right; }</style><div class="wrap"> <form action="" method="post" name="editlink" id="editlink"> <h3><?php echo _LANG_WLM_EDIT_LINK; ?></h3> <table width="100%" border="0" cellspacing="5" cellpadding="3"> <tr> <th scope="row"><?php echo _LANG_WLA_SUB_URI; ?></th> <td><input type="text" name="linkurl" size="80" value="<?php echo $link_url; ?>" /></td> </tr> <tr> <th scope="row"><?php echo _LANG_WLA_SUB_NAME; ?></th> <td><input type="text" name="name" size="80" value="<?php echo $link_name; ?>" /></td> </tr> <tr> <th scope="row"><?php echo _LANG_WLA_SUB_RSS; ?></th> <td><input name="rss_uri" type="text" id="rss_uri" value="<?php echo $link_rss_uri; ?>" size="80"></td> </tr> <tr> <th scope="row"><?php echo _LANG_WLA_SUB_IMAGE; ?></th> <td><input type="text" name="image" size="80" value="<?php echo $link_image; ?>" /></td> </tr> <tr> <th scope="row"><?php echo _LANG_WLA_SUB_DESC; ?></th> <td><input type="text" name="description" size="80" value="<?php echo $link_description; ?>" /></td> </tr> <tr> <th scope="row"><?php echo _LANG_WLA_SUB_REL; ?></th> <td><input type="text" name="rel" id="rel" size="80" value="<?php echo $link_rel; ?>" /></td> </tr> <tr> <th scope="row"><a href="http://gmpg.org/xfn/">XFN</a>:</th> <td><table cellpadding="3" cellspacing="5"> <tr> <th scope="row"> <?php echo _LANG_WLA_SUB_FRIEND; ?> </th> <td> <label for="label"> <input class="valinp" type="radio" name="friendship" value="acquaintance" id="label" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php echo _LANG_WLA_CHECK_ACQUA; ?></label> <label for="label2"> <input class="valinp" type="radio" name="friendship" value="friend" id="label2" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php echo _LANG_WLA_CHECK_FRIE; ?></label> <label for="label3"> <input name="friendship" type="radio" class="valinp" id="label3" value="" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php echo _LANG_WLA_CHECK_NONE; ?></label> </td> </tr> <tr> <th scope="row"> <?php echo _LANG_WLA_SUB_PHYSICAL; ?> </th> <td> <label for="label4"> <input class="valinp" type="checkbox" name="physical" value="met" id="label4" <?php xfn_check('physical', 'met'); ?> /> <?php echo _LANG_WLA_CHECK_MET; ?></label> </td> </tr> <tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -