示例#1
0
function ust_do_ajax()
{
    global $wpdb, $current_site;
    //make sure we have permission!
    if (!current_user_can('manage_sites')) {
        die;
    }
    if (isset($_POST['url'])) {
        $query = parse_url($_POST['url']);
        parse_str($query['query'], $_GET);
    }
    //process any actions and messages
    if (isset($_GET['spam_user'])) {
        //spam a user and all blogs they are associated with
        //don't spam site admin
        $user_info = get_userdata((int) $_GET['spam_user']);
        if (!is_super_admin($user_info->user_login)) {
            $blogs = get_blogs_of_user((int) $_GET['spam_user'], true);
            foreach ((array) $blogs as $key => $details) {
                if ($details->userblog_id == $current_site->blog_id) {
                    continue;
                }
                // main blog not a spam !
                update_blog_status($details->userblog_id, "spam", '1');
                set_time_limit(60);
            }
            update_user_status((int) $_GET['spam_user'], "spam", '1');
        }
    } else {
        if (isset($_POST['check_ip'])) {
            //count all blogs created or modified with the IP address
            $ip_query = parse_url($_POST['check_ip']);
            parse_str($ip_query['query'], $ip_data);
            $spam_ip = addslashes($ip_data['spam_ip']);
            $query = "SELECT COUNT(b.blog_id)\r\n        \t\t\t\tFROM {$wpdb->blogs} b, {$wpdb->registration_log} r, {$wpdb->base_prefix}ust u\r\n        \t\t\t\tWHERE b.site_id = '{$wpdb->siteid}'\r\n        \t\t\t\tAND b.blog_id = r.blog_id\r\n        \t\t\t\tAND b.blog_id = u.blog_id\r\n        \t\t\t\tAND b.spam = 0\r\n        \t\t\t\tAND (r.IP = '{$spam_ip}' OR u.last_ip = '{$spam_ip}')";
            $query2 = "SELECT COUNT(b.blog_id)\r\n        \t\t\t\tFROM {$wpdb->blogs} b, {$wpdb->registration_log} r, {$wpdb->base_prefix}ust u\r\n        \t\t\t\tWHERE b.site_id = '{$wpdb->siteid}'\r\n        \t\t\t\tAND b.blog_id = r.blog_id\r\n        \t\t\t\tAND b.blog_id = u.blog_id\r\n        \t\t\t\tAND b.spam = 1\r\n        \t\t\t\tAND (r.IP = '{$spam_ip}' OR u.last_ip = '{$spam_ip}')";
            //return json response
            echo '{"num":"' . $wpdb->get_var($query) . '", "numspam":"' . $wpdb->get_var($query2) . '", "bid":"' . $ip_data['id'] . '", "ip":"' . $ip_data['spam_ip'] . '"}';
        } else {
            if (isset($_GET['spam_ip'])) {
                //spam all blogs created or modified with the IP address
                $spam_ip = addslashes($_GET['spam_ip']);
                $query = "SELECT b.blog_id\r\n        \t\t\t\tFROM {$wpdb->blogs} b, {$wpdb->registration_log} r, {$wpdb->base_prefix}ust u\r\n        \t\t\t\tWHERE b.site_id = '{$wpdb->siteid}'\r\n        \t\t\t\tAND b.blog_id = r.blog_id\r\n        \t\t\t\tAND b.blog_id = u.blog_id\r\n        \t\t\t\tAND b.spam = 0\r\n        \t\t\t\tAND (r.IP = '{$spam_ip}' OR u.last_ip = '{$spam_ip}')";
                $blogs = $wpdb->get_results($query, ARRAY_A);
                foreach ((array) $blogs as $blog) {
                    if ($blog['blog_id'] == $current_site->blog_id) {
                        continue;
                    }
                    // main blog not a spam !
                    update_blog_status($blog['blog_id'], "spam", '1');
                    set_time_limit(60);
                }
            } else {
                if (isset($_GET['ignore_blog'])) {
                    //ignore a single blog so it doesn't show up on the possible spam list
                    ust_blog_ignore((int) $_GET['id']);
                    echo $_GET['id'];
                } else {
                    if (isset($_GET['unignore_blog'])) {
                        //unignore a single blog so it can show up on the possible spam list
                        ust_blog_unignore((int) $_GET['id']);
                        echo $_GET['id'];
                    } else {
                        if (isset($_GET['spam_blog'])) {
                            //spam a single blog
                            update_blog_status((int) $_GET['id'], "spam", '1');
                            echo $_GET['id'];
                        } else {
                            if (isset($_GET['unspam_blog'])) {
                                update_blog_status((int) $_GET['id'], "spam", '0');
                                ust_blog_ignore((int) $_GET['id'], false);
                                echo $_GET['id'];
                            } else {
                                if (isset($_POST['allblogs'])) {
                                    parse_str($_POST['allblogs'], $blog_list);
                                    foreach ((array) $blog_list['allblogs'] as $key => $val) {
                                        if ($val != '0' && $val != $current_site->blog_id) {
                                            if (isset($_POST['allblog_ignore'])) {
                                                ust_blog_ignore($val);
                                                set_time_limit(60);
                                            } else {
                                                if (isset($_POST['allblog_unignore'])) {
                                                    ust_blog_unignore($val);
                                                    set_time_limit(60);
                                                } else {
                                                    if (isset($_POST['allblog_spam'])) {
                                                        update_blog_status($val, "spam", '1');
                                                        set_time_limit(60);
                                                    } else {
                                                        if (isset($_POST['allblog_notspam'])) {
                                                            update_blog_status($val, "spam", '0');
                                                            ust_blog_ignore($val, false);
                                                            set_time_limit(60);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    _e("Selected blogs processed", 'ust');
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    die;
}
示例#2
0
     ust_blog_ignore((int) $_GET['id'], false);
 } else {
     if (isset($_GET['action']) && $_GET['action'] == 'all_notspam') {
         $_GET['updatedmsg'] = __('Blogs marked as not spam.', 'ust');
     } else {
         if (isset($_GET['action']) && $_GET['action'] == 'allblogs') {
             foreach ((array) $_POST['allblogs'] as $key => $val) {
                 if ($val != '0' && $val != $current_site->blog_id) {
                     if (isset($_POST['allblog_ignore'])) {
                         $_GET['updatedmsg'] = __('Selected Blogs Ignored.', 'ust');
                         ust_blog_ignore($val);
                         set_time_limit(60);
                     } else {
                         if (isset($_POST['allblog_unignore'])) {
                             $_GET['updatedmsg'] = __('Selected Blogs Un-ignored.', 'ust');
                             ust_blog_unignore($val);
                             set_time_limit(60);
                         } else {
                             if (isset($_POST['allblog_spam'])) {
                                 $_GET['updatedmsg'] = __('Blogs marked as spam.', 'ust');
                                 update_blog_status($val, "spam", '1');
                                 set_time_limit(60);
                             }
                         }
                     }
                 }
             }
         } else {
             if (isset($_GET['action']) && $_GET['action'] == 'delete') {
                 $_GET['updatedmsg'] = __('Blog Deleted!', 'ust');
             }