File: list-manipulation.php

package info (click to toggle)
wordpress 2.0.10-1etch6
  • links: PTS
  • area: main
  • in suites: etch
  • size: 3,040 kB
  • ctags: 7,377
  • sloc: php: 26,382; sh: 4,645; makefile: 23
file content (81 lines) | stat: -rw-r--r-- 1,652 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
require_once('../wp-config.php');
require_once('admin-functions.php');
require_once('admin-db.php');
header("Content-type: text/plain", true);

if ( !is_user_logged_in() )
	die('-1');
if ( !check_ajax_referer() )
	die('-1');

function grab_results() {
	global $ajax_results;
	$ajax_results = func_get_arg(0);
}

function get_out_now() { exit; }
add_action('shutdown', 'get_out_now', -1);

switch ( $_POST['action'] ) :
case 'delete-link' :
	$id = (int) $_POST['id'];
	if ( !current_user_can('manage_links') )
		die ('-1');

	if ( wp_delete_link($id) ) 
		die('1');
	else	die('0');
	break;
case 'delete-post' :
case 'delete-page' :
	$id = (int) $_POST['id'];
	if ( !current_user_can('edit_post', $id) )	{
		die('-1');
	}

	if ( wp_delete_post($id) ) {
		die('1');
	} else	die('0');
	break;
case 'delete-cat' :
	if ( !current_user_can('manage_categories') )
		die ('-1');

	$id = (int) $_POST['id'];
	$cat_name = get_catname($cat_ID);

	if ( wp_delete_category($id) )
		die('1');
	else	die('0');
	break;
case 'delete-comment' :
	$id = (int) $_POST['id'];

	if ( !$comment = get_comment($id) )
		die('0');
	if ( !current_user_can('edit_post', $comment->comment_post_ID) )	
		die('-1');

	if ( wp_delete_comment($comment->comment_ID) ) {
		die('1');
	} else {
		die('0');
	}
	break;
case 'delete-link-category' :
	$id = (int) $_POST['id'];
	if ( 1 == $id )
		die('0');
	if ( !current_user_can('manage_links') )
		die('-1');

	if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) {
		$wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'");
		die('1');
	} else {
		die('0');
	}
	break;
endswitch;		
?>