get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
echo "\n\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= 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 'visibility':
{
$standalone = 1;
include_once('admin-header.php');
check_admin_referer();
// 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 'move':
{
$standalone = 1;
include_once('admin-header.php');
check_admin_referer();
// 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');
check_admin_referer();
$link_url = $_POST['linkurl'];
$link_name = $_POST['name'];
$link_image = $_POST['image'];
$link_target = $_POST['target'];
$link_category = $_POST['category'];
$link_description = $_POST['description'];
$link_visible = $_POST['visible'];
$link_rating = $_POST['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'] . '?added=true');
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');
check_admin_referer();
$link_id = $_POST['link_id'];
$link_url = $_POST['linkurl'];
$link_name = $_POST['name'];
$link_image = $_POST['image'];
$link_target = $_POST['target'];
$link_category = $_POST['category'];
$link_description = $_POST['description'];
$link_visible = $_POST['visible'];
$link_rating = $_POST['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');
check_admin_referer();
$link_id = $_GET["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 do not have sufficient permissions to edit the links for this blog.'));
}
$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;
}
?>
get_results("SELECT ID, user_login FROM $wpdb->users WHERE user_level > 0 ORDER BY ID");
echo " \n";
?>