Exemplo n.º 1
0
function wangguard_wizard()
{
    global $wpdb, $wangguard_nonce, $wangguard_api_key, $wangguard_is_network_admin;
    $urlFunc = "admin_url";
    if ($wangguard_is_network_admin && function_exists("network_admin_url")) {
        $urlFunc = "network_admin_url";
    }
    if (wangguard_is_multisite()) {
        $spamFieldName = "spam";
        $sqlSpamWhere = "spam = 1";
        $sqlNoSpamWhere = "spam = 0";
    } else {
        $spamFieldName = "user_status";
        $sqlSpamWhere = "user_status = 1";
        $sqlNoSpamWhere = "user_status <> 1";
    }
    if (!current_user_can('level_10')) {
        die(__('Cheatin&#8217; uh?', 'wangguard'));
    }
    $step = 0;
    if (isset($_REQUEST['wangguard_step'])) {
        $step = (int) $_REQUEST['wangguard_step'];
    }
    if (isset($_POST['submit']) || !empty($step)) {
        check_admin_referer($wangguard_nonce);
    }
    ?>

<div class="wrap" id="wangguard-wizard-cont">
	<div class="wangguard-confico"><img src="<?php 
    echo WP_PLUGIN_URL;
    ?>
/wangguard/img/wizard.png" alt="<?php 
    echo htmlentities(__('WangGuard Wizard', 'wangguard'));
    ?>
" /></div>
	<div class="icon32" id="icon-wangguard"><br></div>
	<h2><?php 
    _e('WangGuard Wizard', 'wangguard');
    ?>
</h2>
	
	<script type="text/javascript">
	function wangguard_progress() {
		jQuery("#wangguard-visible-step-status").hide();
		jQuery("#wangguard-hidden-step-status").show();
		return true;
	}

	jQuery(document).ready(function() {
		jQuery(".wangguard-hidewhendone").hide();
	});
	</script>



	<form action="admin.php" method="get" id="wangguardWizardForm" name="wangguardWizardForm" onsubmit="return wangguard_progress()">
		<input type="hidden" name="page" value="wangguard_wizard" />
		<?php 
    echo wp_nonce_field($wangguard_nonce);
    ?>

		<?php 
    switch ($step) {
        case "1":
            ?>
				<div id="wangguard-visible-step-status">
					<h3><?php 
            echo __("Reporting spam users to WangGuard...", "wangguard");
            ?>
</h3>
					<?php 
            $usersPerStint = 50;
            //how many users to check on each iteration
            $fromUser = isset($_REQUEST['wangguard_wiz_from']) ? (int) $_REQUEST['wangguard_wiz_from'] : 0;
            if ($fromUser < 0) {
                $fromUser = 0;
            }
            $spamUsersTotal = $wpdb->get_col("select count(*) from {$wpdb->users} where {$sqlSpamWhere}");
            $spamUsersTotal = $spamUsersTotal[0];
            $step1Finished = $fromUser > 0 && $fromUser >= $spamUsersTotal;
            if (!$step1Finished) {
                $spamUsers = $wpdb->get_col("select ID from {$wpdb->users} where {$sqlSpamWhere} order by ID LIMIT {$fromUser} , {$usersPerStint}");
                $userCount = count($spamUsers);
                $reportingUserFrom = $fromUser + $usersPerStint;
                $reportingUserFrom = $reportingUserFrom > $spamUsersTotal ? $spamUsersTotal : $reportingUserFrom;
                if ($userCount == 0) {
                    ?>
							<p><?php 
                    echo __("No spam users were found on your site. Click the button below to check your users.", "wangguard");
                    ?>
</p>
							<input type="hidden" name="wangguard_step" value="2" />
							<p class="submit"><input type="submit" name="submit" class="button-primary" value="<?php 
                    _e('Continue', 'wangguard');
                    ?>
" /></p>
							<?php 
                } else {
                    ?>
							<p><img id="wangguard-progress-wait" style="vertical-align: middle; margin-right: 8px;" src="<?php 
                    echo esc_url(admin_url('images/wpspin_light.gif'));
                    ?>
" alt="..." /><?php 
                    echo sprintf(__("The WangGuard wizard is reporting %d of %d spam users as Sploggers.", "wangguard"), $reportingUserFrom, $spamUsersTotal);
                    ?>
</p>
							<?php 
                    @flush();
                    ?>
							<?php 
                    @ob_flush();
                    ?>

							<?php 
                    $progress = 0;
                    $reported = 0;
                    $lastProgressSent = 0;
                    foreach ($spamUsers as $userid) {
                        //get the WangGuard user status, if status is force-checked then ignore the user
                        $table_name = $wpdb->base_prefix . "wangguarduserstatus";
                        $user_status = $wpdb->get_var($wpdb->prepare("select user_status from {$table_name} where ID = %d", $userid));
                        if ($user_status == 'force-checked') {
                            continue;
                        }
                        $dummyArr = array();
                        $dummyArr[] = $userid;
                        set_time_limit(15);
                        wangguard_report_users($dummyArr, "email", false);
                        $reported++;
                    }
                    ?>

							<input type="hidden" name="wangguard_wiz_from" value="<?php 
                    echo $fromUser + $usersPerStint;
                    ?>
" />
							<script type="text/javascript">
								document.getElementById('wangguardWizardForm').onsubmit='';
								jQuery(document).ready(function() {
									location.href='admin.php?page=wangguard_wizard&wangguard_step=1&wangguard_wiz_from=<?php 
                    echo $fromUser + $usersPerStint;
                    ?>
&_wpnonce=<?php 
                    echo wp_create_nonce($wangguard_nonce);
                    ?>
';
								});
							</script>
							<input type="hidden" name="wangguard_step" value="1" />

						<?php 
                }
                ?>

					<?php 
            } else {
                ?>
						<p><?php 
                echo __("The WangGuard wizard has finished reporting spam users. Click the button below to check the rest of your users.", "wangguard");
                ?>
</p>
						<input type="hidden" name="wangguard_step" value="2" />
						<p class="submit"><input type="submit" name="submit" class="button-primary" value="<?php 
                _e('Continue', 'wangguard');
                ?>
" /></p>
					<?php 
            }
            ?>

				</div>

				<?php 
            if ($step1Finished) {
                ?>
				<div id="wangguard-hidden-step-status" style="display: none">
					<h3><?php 
                echo __("Verifying users against the WangGuard service...", "wangguard");
                ?>
</h3>
					<?php 
                $goodUsers = $wpdb->get_col("select ID from {$wpdb->users} where {$sqlNoSpamWhere}");
                $userCount = count($goodUsers);
                if ($userCount == 0) {
                    ?>
						<p><img id="wangguard-progress-wait" style="vertical-align: middle; margin-right: 8px;" src="<?php 
                    echo esc_url(admin_url('images/wpspin_light.gif'));
                    ?>
" alt="..." /></p>
					<?php 
                } else {
                    ?>
						<p><img id="wangguard-progress-wait" style="vertical-align: middle; margin-right: 8px;" src="<?php 
                    echo esc_url(admin_url('images/wpspin_light.gif'));
                    ?>
" alt="..." /><?php 
                    echo sprintf(__("The WangGuard wizard is verifying %d users against the WangGuard service.", "wangguard"), $userCount);
                    ?>
</p>
					<?php 
                }
                ?>
				</div>
				<?php 
            }
            ?>

				<?php 
            break;
        case "2":
            ?>
				<div id="wangguard-visible-step-status">
					<h3><?php 
            echo __("Verifying users against the WangGuard service...", "wangguard");
            ?>
</h3>
					<?php 
            $usersPerStint = 50;
            //how many users to check on each iteration
            $fromUser = isset($_REQUEST['wangguard_wiz_from']) ? (int) $_REQUEST['wangguard_wiz_from'] : 0;
            if ($fromUser < 0) {
                $fromUser = 0;
            }
            $goodUsersTotal = $wpdb->get_col("select count(*) from {$wpdb->users} where {$sqlNoSpamWhere}");
            $goodUsersTotal = $goodUsersTotal[0];
            $step2Finished = $fromUser > 0 && $fromUser >= $goodUsersTotal;
            $reported = isset($_REQUEST['reported']) ? (int) $_REQUEST['reported'] : 0;
            $noUsersToCheck = false;
            if (!$step2Finished) {
                $goodUsers = $wpdb->get_col("select ID from {$wpdb->users} where {$sqlNoSpamWhere} ORDER BY ID LIMIT {$fromUser} , {$usersPerStint}");
                $userCount = count($goodUsers);
                $reportingUserFrom = $fromUser + $usersPerStint;
                $reportingUserFrom = $reportingUserFrom > $goodUsersTotal ? $goodUsersTotal : $reportingUserFrom;
                if ($userCount == 0) {
                    $step2Finished = true;
                    $noUsersToCheck = true;
                    ?>
							<p><?php 
                    echo __("No users were found on your site.", "wangguard");
                    ?>
</p>
							<?php 
                } else {
                    ?>
							<p><img id="wangguard-progress-wait" style="vertical-align: middle; margin-right: 8px;" src="<?php 
                    echo esc_url(admin_url('images/wpspin_light.gif'));
                    ?>
" alt="..." /><?php 
                    echo sprintf(__("The WangGuard wizard is verifying %d of %d users against the WangGuard service.", "wangguard"), $reportingUserFrom, $goodUsersTotal);
                    ?>
</p>
							<?php 
                    @flush();
                    ?>
							<?php 
                    @ob_flush();
                    ?>

							<?php 
                    $progress = 0;
                    $verified = 0;
                    $lastProgressSent = 0;
                    foreach ($goodUsers as $userid) {
                        //get the WangGuard user status, if status is force-checked then ignore the user
                        $table_name = $wpdb->base_prefix . "wangguarduserstatus";
                        $user_status = $wpdb->get_var($wpdb->prepare("select user_status from {$table_name} where ID = %d", $userid));
                        if ($user_status == 'force-checked') {
                            continue;
                        }
                        $dummyArr = array();
                        $dummyArr[] = $userid;
                        $user_object = new WP_User($userid);
                        set_time_limit(15);
                        $user_check_status = wangguard_verify_user($user_object);
                        if ($user_check_status == "reported") {
                            $reported++;
                            if (function_exists("update_user_status")) {
                                update_user_status($userid, $spamFieldName, 1);
                            } else {
                                $wpdb->query($wpdb->prepare("update {$wpdb->users} set {$spamFieldName} = 1 where ID = %d", $userid));
                            }
                        }
                        $verified++;
                    }
                    ?>
							<input type="hidden" name="wangguard_wiz_from" value="<?php 
                    echo $fromUser + $usersPerStint;
                    ?>
" />
							<script type="text/javascript">
								document.getElementById('wangguardWizardForm').onsubmit='';
								jQuery(document).ready(function() {
									location.href='admin.php?page=wangguard_wizard&wangguard_step=2&reported=<?php 
                    echo $reported;
                    ?>
&wangguard_wiz_from=<?php 
                    echo $fromUser + $usersPerStint;
                    ?>
&_wpnonce=<?php 
                    echo wp_create_nonce($wangguard_nonce);
                    ?>
';
								});
							</script>
							<input type="hidden" name="wangguard_step" value="2" />


						<?php 
                }
            }
            if ($step2Finished) {
                $table_name = $wpdb->base_prefix . "wangguarduserstatus";
                $reportedUsers = $wpdb->get_col("select count(*) from {$table_name} where user_status IN ( 'reported', 'autorep' )");
                $reportedUsersCount = $reportedUsers[0];
                if (!$noUsersToCheck) {
                    ?>
							<p><?php 
                    echo sprintf(__("The WangGuard wizard has finished verifying your users and found <strong>%d</strong> Sploggers.", "wangguard"), $reported);
                    ?>
</p>
						<?php 
                }
                ?>

						<input type="hidden" name="wangguard_step" value="3" />
						<input type="hidden" name="wangguard_splogcnt" value="<?php 
                echo $reportedUsersCount;
                ?>
" />
						
						<?php 
                if ($reportedUsersCount) {
                    ?>
							<p><?php 
                    echo sprintf(__("There are <strong>%d</strong> users identified as Sploggers, you can delete them or manage them by clicking the buttons below.", "wangguard"), $reportedUsersCount);
                    ?>
</p>
						<?php 
                }
                ?>

						<div id="wangguard-visible-step-status">
							<input type="hidden" value="" name="wangguard_delete_splogguers" id="wangguard_delete_splogguers" />
							<p class="submit">
								<?php 
                if ($reportedUsersCount) {
                    ?>
									<input type="submit" name="do_wangguard_delete_splogguers" class="button-primary" id="do_wangguard_delete_splogguers" value="<?php 
                    _e('Delete all Sploggers', 'wangguard');
                    ?>
" />
									<input type="button" name="button" class="button-primary" onclick="document.location='admin.php?page=wangguard_users&type=spl'" value="<?php 
                    _e('Manage Sploggers', 'wangguard');
                    ?>
" />
								<?php 
                }
                ?>
								<input type="submit" name="submit" class="button-primary" value="<?php 
                _e('Finish', 'wangguard');
                ?>
" />
							</p>
						</div>

						<script type="text/javascript">
							jQuery(document).ready(function() {
								jQuery("#do_wangguard_delete_splogguers").click(function() {
									if (confirm('<?php 
                echo addslashes(__('Do you confirm to delete all Sploggers?', 'wangguard'));
                ?>
')) {
										jQuery('#wangguard_delete_splogguers').val('1');
										return true;
									}
									else
										return false;
								});
							});
						</script>			
						
						<div id="wangguard-hidden-step-status" style="display: none">
							<p><img id="wangguard-progress-wait" style="vertical-align: middle; margin-right: 8px;" src="<?php 
                echo esc_url(admin_url('images/wpspin_light.gif'));
                ?>
" alt="..." /></p>
						</div>
					<?php 
            }
            ?>
				</div>



				<?php 
            break;
        case "3":
            if (@$_REQUEST['wangguard_delete_splogguers'] == 1) {
                $usersPerStint = 10;
                //how many users to check on each iteration
                $table_name = $wpdb->base_prefix . "wangguarduserstatus";
                $reportedUsers = $wpdb->get_col("select ID from {$table_name} where user_status IN ( 'reported', 'autorep' ) LIMIT 0 , {$usersPerStint}");
                $reportedUsersCount = count($reportedUsers);
                $reportedUsersTotal = (int) @$_REQUEST['wangguard_splogcnt'];
                $reportingUserFrom = (int) @$_REQUEST['wangguard_wiz_from'];
                $reportingUserFrom = $reportingUserFrom > $reportedUsersTotal ? $reportedUsersTotal : $reportingUserFrom;
                $step3Finished = $reportedUsersCount == 0;
                if (!$step3Finished) {
                    ?>
						<h3><?php 
                    echo __("Deleting Splogguers from your site...", "wangguard");
                    ?>
</h3>
						<p><img id="wangguard-progress-wait" style="vertical-align: middle; margin-right: 8px;" src="<?php 
                    echo esc_url(admin_url('images/wpspin_light.gif'));
                    ?>
" alt="..." /><?php 
                    echo sprintf(__("The WangGuard wizard is deleting %d of %d Splogguers from your site.", "wangguard"), $reportingUserFrom, $reportedUsersTotal);
                    ?>
</p>
						<?php 
                    @flush();
                    ?>
						<?php 
                    @ob_flush();
                    ?>
						<?php 
                    foreach ($reportedUsers as $userid) {
                        set_time_limit(15);
                        wangguard_delete_user_and_blogs($userid);
                    }
                    ?>
						<script type="text/javascript">
							document.getElementById('wangguardWizardForm').onsubmit='';
							jQuery(document).ready(function() {
								location.href='admin.php?page=wangguard_wizard&wangguard_step=3&wangguard_delete_splogguers=1&wangguard_splogcnt=<?php 
                    echo $reportedUsersTotal;
                    ?>
&wangguard_wiz_from=<?php 
                    echo $reportingUserFrom + $usersPerStint;
                    ?>
&_wpnonce=<?php 
                    echo wp_create_nonce($wangguard_nonce);
                    ?>
';
							});
						</script>
						<?php 
                } else {
                    ?>
						<h3><?php 
                    echo __("The WangGuard Wizard has finished", "wangguard");
                    ?>
</h3>
						<p><?php 
                    echo sprintf(__("%d sploggers users has been deleted from your site.", "wangguard"), $reportedUsersTotal);
                    ?>
</p>
						<p><a class="button-primary" href="<?php 
                    echo $urlFunc('admin.php?page=wangguard_users');
                    ?>
"><?php 
                    echo __('Click here to manage your Users', 'wangguard');
                    ?>
</a></p>
				<?php 
                }
            } else {
                ?>

					<h3><?php 
                echo __("The WangGuard Wizard has finished", "wangguard");
                ?>
</h3>
					<p><a class="button-primary" href="<?php 
                echo $urlFunc('admin.php?page=wangguard_users');
                ?>
"><?php 
                echo __('Click here to manage your Users', 'wangguard');
                ?>
</a></p>

				<?php 
            }
            break;
        default:
            ?>
				<div id="wangguard-visible-step-status">
					<h3><?php 
            echo __("Welcome to the WangGuard Wizard", "wangguard");
            ?>
</h3>
					<p><?php 
            echo __("This wizard will perform the following actions on your WordPress installation", "wangguard");
            ?>
</p>
					<ol>
						<li><?php 
            echo __("It will report to WangGuard all users you have flagged as 'spam' on your site.", "wangguard");
            ?>
</li>
						<li><?php 
            echo __("For the rest of the users, it will check against WangGuard service if any of them was reported as Splogger.", "wangguard");
            ?>
</li>
						<li><?php 
            echo __("It will let you know how many Sploggers the wizard found (if any) and, optionally, will let you delete your spam users and Sploggers from your site.", "wangguard");
            ?>
</li>
					</ol>
					<p><?php 
            echo sprintf(__("Note: The wizard will NOT verify the users flagged as %s, these are the users for which you've selected the &quot;Not a Splogger&quot; option from the Users admin or flagged as &quot;Not Spam&quot;.", "wangguard"), "<span class='wangguard-status-checked'>" . __("Checked (forced)", "wangguard") . "</span>");
            ?>
</p>
					<?php 
            $valid = wangguard_verify_key($wangguard_api_key);
            if ($valid == 'failed' || $valid == 'invalid') {
                ?>
						<p class="wangguard-info wangguard-error" style="margin-right: 20px;"><?php 
                echo __('Your WangGuard API KEY is invalid.', 'wangguard');
                ?>
</p>
						<?php 
            } else {
                ?>
						<p><?php 
                echo __("Click the button below when you're ready to clean your site!.", "wangguard");
                ?>
</p>
						<input type="hidden" name="wangguard_step" value="1" />
						<p class="submit"><input type="submit" name="submit" class="button-primary" value="<?php 
                _e('Start cleaning my site!', 'wangguard');
                ?>
" /></p>
						<?php 
            }
            ?>
				</div>


				<div id="wangguard-hidden-step-status" style="display: none">
					<h3><?php 
            echo __("Reporting spam users to WangGuard...", "wangguard");
            ?>
</h3>
					<?php 
            $spamUsers = $wpdb->get_col("select ID from {$wpdb->users} where {$sqlSpamWhere}");
            $userCount = count($spamUsers);
            if ($userCount == 0) {
                ?>
						<p><img id="wangguard-progress-wait" style="vertical-align: middle; margin-right: 8px;" src="<?php 
                echo esc_url(admin_url('images/wpspin_light.gif'));
                ?>
" alt="..." /></p>
					<?php 
            } else {
                ?>
						<p><img id="wangguard-progress-wait" style="vertical-align: middle; margin-right: 8px;" src="<?php 
                echo esc_url(admin_url('images/wpspin_light.gif'));
                ?>
" alt="..." /><?php 
                echo sprintf(__("The WangGuard wizard is reporting %d spam users as Sploggers.", "wangguard"), $userCount);
                ?>
</p>
					<?php 
            }
            ?>
				</div>

				<?php 
            break;
    }
    ?>

	</form>

</div>
<?php 
}
Exemplo n.º 2
0
function wangguard_conf()
{
    global $wpdb;
    global $wangguard_nonce, $wangguard_api_key;
    if (!current_user_can('level_10')) {
        die(__('Cheatin&#8217; uh?', 'wangguard'));
    }
    $key_status = "";
    $selectedTab = 0;
    if (isset($_POST['submit'])) {
        check_admin_referer($wangguard_nonce);
        $key = preg_replace('/[^a-h0-9]/i', '', $_POST['key']);
        if (empty($key)) {
            $key_status = 'empty';
            $ms[] = 'new_key_empty';
            wangguard_update_option('wangguard_api_key', "");
        } else {
            $key_status = wangguard_verify_key($key);
        }
        if ($key_status == 'valid') {
            wangguard_update_option('wangguard_api_key', $key);
            $ms[] = 'new_key_valid';
        } else {
            if ($key_status == 'invalid') {
                $ms[] = 'new_key_invalid';
            } else {
                if ($key_status == 'failed') {
                    $ms[] = 'new_key_failed';
                }
            }
        }
    } elseif (isset($_POST['saveblockeddomain'])) {
        echo "<div id='wangguard-warning' class='updated fade'><p><strong>" . __('Blocked domains has been saved.', 'wangguard') . "</strong></p></div>";
        $selectedDomains = array();
        if (is_array($_POST['domains'])) {
            foreach ($_POST['domains'] as $domain) {
                $selectedDomains[$domain] = true;
            }
        }
        wangguard_update_option('blocked-list-domains', $selectedDomains);
        $selectedTab = 3;
    } elseif (isset($_POST['check'])) {
        wangguard_get_server_connectivity(0);
        $selectedTab = 4;
    } elseif (isset($_POST['optssave'])) {
        wangguard_update_option('wangguard-expertmode', @$_POST['wangguardexpertmode'] == '1' ? 1 : 0);
        wangguard_update_option('wangguard-report-posts', @$_POST['wangguardreportposts'] == '1' ? 1 : 0);
        wangguard_update_option('wangguard-delete-users-on-report', @$_POST['wangguard-delete-users-on-report'] == '1' ? 1 : -1);
        wangguard_update_option('wangguard-enable-bp-report-btn', @$_POST['wangguardenablebpreportbtn'] == '1' ? 1 : -1);
        wangguard_update_option('wangguard-enable-bp-report-blog', @$_POST['wangguardenablebpreportblog'] == '1' ? 1 : -1);
        wangguard_update_option('wangguard-verify-gmail', @$_POST['wangguard-verify-gmail'] == '1' ? 1 : 0);
        wangguard_update_option('wangguard_disable-meta-header', @$_POST['wangguard_disable-meta-header'] == '1' ? 1 : 0);
        wangguard_update_option('wangguard-verify-dns-mx', @$_POST['wangguard-verify-dns-mx'] == '1' ? 1 : 0);
        wangguard_update_option('wangguard-do-not-check-client-ip', @$_POST['wangguard-do-not-check-client-ip'] == '1' ? 1 : 0);
        $selectedTab = 2;
        echo "<div id='wangguard-warning' class='updated fade'><p><strong>" . __('WangGuard settings has been saved.', 'wangguard') . "</strong></p></div>";
    }
    if ($key_status != 'valid') {
        $key = wangguard_get_option('wangguard_api_key');
        if (empty($key)) {
            if ($key_status != 'failed') {
                if (wangguard_verify_key('1234567890ab') == 'failed') {
                    $ms[] = 'no_connection';
                } else {
                    $ms[] = 'key_empty';
                }
            }
            $key_status = 'empty';
        } else {
            $key_status = wangguard_verify_key($key);
        }
        if ($key_status == 'valid') {
            $ms[] = 'key_valid';
        } else {
            if ($key_status == 'invalid') {
                delete_option('wangguard_api_key');
                $ms[] = 'key_empty';
            } else {
                if (!empty($key) && $key_status == 'failed') {
                    $ms[] = 'key_failed';
                }
            }
        }
    }
    $messages = array('new_key_empty' => array('class' => 'wangguard-info', 'text' => __('Your key has been cleared.', 'wangguard')), 'new_key_valid' => array('class' => 'wangguard-info wangguard-success', 'text' => __('Your key has been verified!', 'wangguard')), 'new_key_invalid' => array('class' => 'wangguard-info wangguard-error', 'text' => __('The key you entered is invalid. Please double-check it.', 'wangguard')), 'new_key_failed' => array('class' => 'wangguard-info wangguard-error', 'text' => __('The key you entered could not be verified because a connection to wangguard.com could not be established. Please check your server configuration.', 'wangguard')), 'no_connection' => array('class' => 'wangguard-info wangguard-error', 'text' => __('There was a problem connecting to the WangGuard server. Please check your server configuration.', 'wangguard')), 'key_empty' => array('class' => 'wangguard-info', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key here.</a>)', 'wangguard'), 'http://wangguard.com/getapikey')), 'key_valid' => array('class' => 'wangguard-info wangguard-success', 'text' => __('This key is valid.', 'wangguard')), 'key_failed' => array('class' => 'wangguard-info wangguard-error', 'text' => __('The key below was previously validated but a connection to wangguard.com can not be established at this time. Please check your server configuration.', 'wangguard')));
    wp_enqueue_script("jquery-ui-tabs");
    wp_print_scripts("jquery-ui-tabs");
    ?>


<?php 
    if (!empty($_POST['submit'])) {
        ?>
<div id="message" class="updated fade"><p><strong><?php 
        _e('Options saved.', 'wangguard');
        ?>
</strong></p></div>
<?php 
    }
    ?>


<div class="wrap">
	<div class="icon32" id="icon-wangguard"><br></div>
	<h2><?php 
    _e('WangGuard Configuration', 'wangguard');
    ?>
</h2>
	<div class="">


		<div id="wangguard-conf-tabs">
			<ul id="wangguard-tabs">
				<li><a href="#wangguard-conf-apikeys"><?php 
    _e('WangGuard API Key', 'wangguard');
    ?>
</a></li>
				<li><a href="#wangguard-conf-questions"><?php 
    _e('Security questions', 'wangguard');
    ?>
</a></li>
				<li><a href="#wangguard-conf-settings"><?php 
    _e('WangGuard settings', 'wangguard');
    ?>
</a></li>
				<li><a href="#wangguard-conf-domains"><?php 
    _e('Blocked domains', 'wangguard');
    ?>
</a></li>
				<li><a href="#wangguard-conf-conectivity"><?php 
    _e('Server Connectivity', 'wangguard');
    ?>
</a></li>
			</ul>
			<div id="wangguard-tabs-container">
				

			<!--WANGGUARD API KEY-->
			<div id="wangguard-conf-apikeys">
					<div class="wangguard-confico"><img src="<?php 
    echo WP_PLUGIN_URL;
    ?>
/wangguard/img/apikey.png" alt="<?php 
    echo htmlentities(__('WangGuard API Key', 'wangguard'));
    ?>
" /></div>
				<form action="" method="post" id="wangguard-conf" style="margin: auto;">
					<p><?php 
    printf(__('For many people, <a href="%1$s">WangGuard</a> will greatly reduce or even completely eliminate the Sploggers you get on your site. If one does happen to get through, simply mark it as Splogger on the Users screen. If you don\'t have an API key yet, <a href="%2$s" target="_new">get one here</a>.', 'wangguard'), 'http://wangguard.com/', 'http://wangguard.com/getapikey');
    ?>
</p>

					<h3><label for="key"><?php 
    _e('WangGuard API Key', 'wangguard');
    ?>
</label></h3>
					<?php 
    foreach ($ms as $m) {
        ?>
						<p class="<?php 
        echo $messages[$m]['class'];
        ?>
"><?php 
        echo $messages[$m]['text'];
        ?>
</p>
					<?php 
    }
    ?>
					<p><input id="key" name="key" type="text" size="35" maxlength="32" value="<?php 
    echo wangguard_get_option('wangguard_api_key');
    ?>
" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php 
    _e('<a href="http://wangguard.com/faq" target="_new">What is this?</a>', 'wangguard');
    ?>
)</p>

					<?php 
    if ($key_status == 'invalid') {
        ?>
						<h3><?php 
        _e('Why might my key be invalid?', 'wangguard');
        ?>
</h3>
						<p><?php 
        _e('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the WangGuard servers, which is most often caused by an issue with your web host around firewalls or similar.', 'wangguard');
        ?>
</p>
					<?php 
    }
    ?>


					<?php 
    wangguard_nonce_field($wangguard_nonce);
    ?>

					<p class="submit"><input type="submit" name="submit" class="button-primary" value="<?php 
    _e('Update options &raquo;', 'wangguard');
    ?>
" /></p>
				</form>
			</div>



			<!--WANGGUARD QUESTIONS-->
			<div id="wangguard-conf-questions" style="margin: auto;">

				<div class="wangguard-confico"><img src="<?php 
    echo WP_PLUGIN_URL;
    ?>
/wangguard/img/security.png" alt="<?php 
    echo htmlentities(__('Security questions', 'wangguard'));
    ?>
" /></div>
				
				<h3><?php 
    _e('Security questions', 'wangguard');
    ?>
</h3>
				<p><?php 
    _e('Security questions are randomly asked on the registration form to prevent automated signups.', 'wangguard');
    ?>
</p>
				<p><?php 
    _e('Security questions are optional, it\'s up to you whether to use them or not.', 'wangguard');
    ?>
</p>
				<p><?php 
    _e('Create you own security questions from the form below, or delete the questions you don\'t want anymore.', 'wangguard');
    ?>
</p>
				<?php 
    $table_name = $wpdb->base_prefix . "wangguardquestions";
    $wgquestRs = $wpdb->get_results("select * from {$table_name} order by id");
    ?>
				
				<h4><?php 
    _e('Existing security questions', 'wangguard');
    ?>
</h4>				
				
				<?php 
    if (empty($wgquestRs)) {
        ?>
<div id="wangguard-question-noquestion"><?php 
        _e('No security questions created yet', 'wangguard');
        ?>
</div><?php 
    }
    foreach ($wgquestRs as $question) {
        ?>
					<div class="wangguard-question" id="wangguard-question-<?php 
        echo $question->id;
        ?>
">
					<?php 
        _e("Question", 'wangguard');
        ?>
: <strong><?php 
        echo $question->Question;
        ?>
</strong><br/>
					<?php 
        _e("Answer", 'wangguard');
        ?>
: <strong><?php 
        echo $question->Answer;
        ?>
</strong><br/>
					<?php 
        _e("Replied OK / Wrong", 'wangguard');
        ?>
: <strong><?php 
        echo $question->RepliedOK;
        ?>
 / <?php 
        echo $question->RepliedWRONG;
        ?>
</strong><br/>
					<a href="javascript:void(0)" rel="<?php 
        echo $question->id;
        ?>
" class="wangguard-delete-question"><?php 
        _e('delete question', 'wangguard');
        ?>
</a>
					</div>
				<?php 
    }
    ?>
				<div id="wangguard-new-question-container">
				</div>

				<h4><?php 
    _e('Add a new security question', 'wangguard');
    ?>
</h4>
				<?php 
    _e("Question", 'wangguard');
    ?>
<br/><input type="text" name="wangguardnewquestion" id="wangguardnewquestion" class="wangguard-input" maxlength="255" value="" />
				<br/><br style="line-height: 5px"/>
				<?php 
    _e("Answer", 'wangguard');
    ?>
<br/><input type="text" name="wangguardnewquestionanswer" id="wangguardnewquestionanswer" class="wangguard-input" maxlength="50" value="" />
				<div id="wangguardnewquestionerror">
					<?php 
    _e('Fill in both the question and the answer fields to create a new security question', 'wangguard');
    ?>
				</div>
				<p class="submit"><input type="button" id="wangguardnewquestionbutton" class="button-primary" name="submit" value="<?php 
    _e('Create question &raquo;', 'wangguard');
    ?>
" /></p>
			</div>


			
			


			<!--WANGGUARD SETTINGS-->
			<div id="wangguard-conf-settings" style="margin: auto;">
				
				<div class="wangguard-confico"><img src="<?php 
    echo WP_PLUGIN_URL;
    ?>
/wangguard/img/settings.png" alt="<?php 
    echo htmlentities(__('WangGuard settings', 'wangguard'));
    ?>
" /></div>
				
				<?php 
    $wangguard_edit_prefix = "";
    if (function_exists('is_network_admin')) {
        if (is_network_admin()) {
            $wangguard_edit_prefix = "../";
        }
    }
    ?>
				<form action="" method="post" id="wangguard-settings" style="margin:0px auto 0 auto; ">
					<h3><?php 
    _e("WangGuard settings", 'wangguard');
    ?>
</h3>
					<p>
						<input type="checkbox" name="wangguardreportposts" id="wangguardreportposts" value="1" <?php 
    echo wangguard_get_option("wangguard-report-posts") == '1' ? 'checked' : '';
    ?>
 />
						<label for="wangguardreportposts"><?php 
    _e(sprintf("<strong>Allow reporting users from Posts admin screen.</strong><br/>By checking this option a new link to report a post's author will be added for each post on the <a href=\"%s\">Posts admin screen</a>.", $wangguard_edit_prefix . "edit.php"), 'wangguard');
    ?>
</label>
					</p>
					<p>
						<input type="checkbox" name="wangguard-delete-users-on-report" id="wangguard-delete-users-on-report" value="1" <?php 
    echo wangguard_get_option("wangguard-delete-users-on-report") == '1' ? 'checked' : '';
    ?>
 />
						<label for="wangguard-delete-users-on-report"><?php 
    _e("<strong>Delete users when reporting them to WangGuard.</strong><br/>By checking this option, the users you report as Sploggers will be deleted from your site.", 'wangguard');
    ?>
</label>
					</p>
					
					<?php 
    if (defined('BP_VERSION')) {
        ?>
					<p>
						<input type="checkbox" name="wangguardenablebpreportbtn" id="wangguardenablebpreportbtn" value="1" <?php 
        echo wangguard_get_option("wangguard-enable-bp-report-btn") == '1' ? 'checked' : '';
        ?>
 />
						<label for="wangguardenablebpreportbtn"><?php 
        _e("<strong>Show the 'report user' button on BuddyPress.</strong><br/>BuddyPress only. By checking this option a link called 'report user' will be shown on each user's activity and profile page.", 'wangguard');
        ?>
</label>
					</p>
					<?php 
    }
    ?>
					<?php 
    if (defined('BP_VERSION') || wangguard_is_multisite()) {
        ?>
					<p>
						<input type="checkbox" name="wangguardenablebpreportblog" id="wangguardenablebpreportblog" value="1" <?php 
        echo wangguard_get_option("wangguard-enable-bp-report-blog") == '1' ? 'checked' : '';
        ?>
 />
						<label for="wangguardenablebpreportblog"><?php 
        _e("<strong>Show the 'Report blog and author' menu item in the Admin Bar.</strong><br/>By checking this option a new menu item on the Admin Bar called 'Report blog and author' will be shown on each blog.", 'wangguard');
        ?>
</label>
					</p>
					<?php 
    }
    ?>

					<p>
						<input type="checkbox" name="wangguard-verify-gmail" id="wangguard-verify-gmail" value="1" <?php 
    echo wangguard_get_option("wangguard-verify-gmail") == '1' ? 'checked' : '';
    ?>
 />
						<label for="wangguard-verify-gmail"><?php 
    _e("<strong>Check for duplicated gmail.com and googlemail.com emails on sign up.</strong><br/>Checks that duplicated accounts @gmail.com and @googlemail.com accounts doesn't exists, also takes in count that gMail ignores the dots and what's after a + sign on the left side of the @.", 'wangguard');
    ?>
</label>
					</p>

					<p>
						<input type="checkbox" name="wangguard_disable-meta-header" id="wangguard_disable-meta-header" value="1" <?php 
    echo wangguard_get_option("wangguard_disable-meta-header") == '1' ? 'checked' : '';
    ?>
 />
						<label for="wangguard_disable-meta-header"><?php 
    _e("<strong>Remove the generator META tag.</strong><br/>By checking this option, WangGuard will remove the generator META tag from the generated pages of your site, this will prevent automated bots to easilly identify a WordPress site by looking at this META tag.", 'wangguard');
    ?>
</label>
					</p>

					<?php 
    //verifies if the getmxrr() function is availabe
    $wangguard_mx_ok = function_exists('getmxrr');
    ?>
					<p>
						<input <?php 
    echo !$wangguard_mx_ok ? "disabled = 'disabled'" : "";
    ?>
 type="checkbox" name="wangguard-verify-dns-mx" id="wangguard-verify-dns-mx" value="1" <?php 
    echo $wangguard_mx_ok && wangguard_get_option("wangguard-verify-dns-mx") == '1' ? 'checked' : '';
    ?>
 />
						<label for="wangguard-verify-dns-mx"><?php 
    _e("<strong>Check email domains agains the DNS server.</strong><br/>Verifies that an associated Mail eXchange (MX) record exists for the email domain, if the verification fails, the sign up process is stopped. Recommeded for non multi user or BuddyPress WordPress installations. Users may notice a small delay of around 1 or 2 seconds on the sign up process due to the DNS verification.", 'wangguard');
    ?>
</label>
						<?php 
    if (!$wangguard_mx_ok) {
        echo "<div>";
        _e("<strong>Warning:</strong> PHP function <strong>getmxrr()</strong> is not available on your server. Contact your server admin to enable it in order to activate this feature.", "wangguard");
        echo "</div>";
    }
    ?>
					</p>

					<p>
						<input type="checkbox" name="wangguard-do-not-check-client-ip" id="wangguard-do-not-check-client-ip" value="1" <?php 
    echo wangguard_get_option("wangguard-do-not-check-client-ip") == '1' ? 'checked' : '';
    ?>
 />
						<label for="wangguard-do-not-check-client-ip"><?php 
    _e("<strong>Do NOT verify client IP address.</strong><br/>By checking this option, when checking a user, the IP address of the user will not be sent along with the e-mail address to the WangGuard service. Selecting this option reduces WangGuard effectiveness, but if your new accounts come mostly from the same IP, in the case of colleges, universities or other large institutions, this would prevent WangGuard from flagging the IP address as suspicious.", 'wangguard');
    ?>
</label>
					</p>

					<p>
						<input type="checkbox" name="wangguardexpertmode" id="wangguardexpertmode" value="1" <?php 
    echo wangguard_get_option("wangguard-expertmode") == '1' ? 'checked' : '';
    ?>
 />
						<label for="wangguardexpertmode"><?php 
    _e("<strong>Ninja mode.</strong><br/>By checking this option no confirmation message will be asked for report operations on the Users manager. Just remember that users gets deleted when reported and the option 'Delete users when reporting them to WangGuard' is selected.", 'wangguard');
    ?>
</label>
					</p>

					<p class="submit"><input class="button-primary" type="submit" name="optssave" value="<?php 
    _e('Save options &raquo;', 'wangguard');
    ?>
" /></p>

				</form>
			</div>

			


			
			
			

			<!--WANGGUARD BLOCKED DOMAINS-->
			<div id="wangguard-conf-domains" style="margin: auto;">
				
				<div class="wangguard-confico"><img src="<?php 
    echo WP_PLUGIN_URL;
    ?>
/wangguard/img/blocked.png" alt="<?php 
    echo htmlentities(__('Blocked domains', 'wangguard'));
    ?>
" /></div>
				
				<h3><?php 
    _e('Blocked domains', 'wangguard');
    ?>
</h3>
				<p><?php 
    _e('Here are different domain lists maintained by WangGuard.', 'wangguard');
    ?>
</p>
				<p><?php 
    _e('You should never block all domains contained in these listings or no one can register on your site.', 'wangguard');
    ?>
</p>
				<p><?php 
    _e('If a domain is in this list, it is because one or more of its users have used for undesirable activities, but that does not mean they are entirely sploggers.', 'wangguard');
    ?>
</p>
				<p><?php 
    _e('These lists are updated automatically each time you enter this screen.', 'wangguard');
    ?>
</p>
				
				<?php 
    $lang = substr(WPLANG, 0, 2);
    $response = wangguard_http_post("wg=<in><apikey>{$wangguard_api_key}</apikey><lang>{$lang}</lang></in>", 'get-domain-list.php');
    $xml = XML_unserialize($response);
    if (!is_array($xml)) {
        ?>
<p><?php 
        _e("There was an error while pulling the domains list from WangGuard, please try again later. If the problem persists please contact WangGuard to report it.", 'wangguard');
        ?>
</p><?php 
    } else {
        $selectedDomains = maybe_unserialize(wangguard_get_option('blocked-list-domains'));
        if (!is_array($selectedDomains)) {
            $selectedDomains = array();
        }
        ?>
					<form action="" method="post" id="wangguard-blockeddomainsform">
						<?php 
        $first = true;
        $lists = $xml['out']['list'];
        $domainix = 0;
        foreach ($lists as $ix => $list) {
            $domainQ = 0;
            if (@is_array($list['domains']['domain'])) {
                $domainQ = count($list['domains']['domain']);
            } elseif (isset($list['domains']['domain'])) {
                $domainQ = 1;
            }
            echo "<div class='wangguard-blockeddomain-header' id='wangguard-blockeddomain-header-" . $ix . "'><a href='javascript:void(0)' rel='" . $ix . "'>" . $list['name'] . "&nbsp;&nbsp;&nbsp;(<span id='wangguard-domain-count-" . $ix . "'>0</span> " . sprintf(__('out of %d domains selected', 'wangguard'), $domainQ) . ")</a></div>";
            echo "<div class='wangguard-blockeddomain-domains' id='wangguard-blockeddomain-domains-" . $ix . "' wgix='" . $ix . "' " . "style='display:none'" . ">";
            echo "<p>" . $list['description'] . "</p>";
            echo "<div class='wangguard-blockeddomain-list'>";
            echo '<table class="wp-list-table widefat" cellspacing="0">';
            echo '<thead>';
            echo '<tr>';
            echo '<td colspan="4" class="check-column" style="padding: 4px 7px 2px; font-style:italic; font-weight:bold">';
            echo "<input type='checkbox' wgix='" . $ix . "' id='wangguard-selectall-" . $ix . "' /> <label for='wangguard-selectall-" . $ix . "'>" . __('select / unselect all domains', 'wangguard') . "</label><br/>";
            echo "</td>";
            echo "</tr>";
            echo '</thead>';
            echo '<tbody>';
            if (@is_array($list['domains']['domain'])) {
                echo '<tr>';
                $colIX = 1;
                foreach ($list['domains']['domain'] as $domain) {
                    $checked = isset($selectedDomains[$domain]) ? "checked" : "";
                    echo '<td class="check-column wangguard-domain" style="padding: 4px 7px 2px;">';
                    echo "<input wgix='" . $ix . "' name='domains[]' type='checkbox' value='{$domain}' {$checked} id='wangguard-domain-" . ++$domainix . "' /> <label for='wangguard-domain-" . $domainix . "'>" . $domain . "</label><br/>";
                    echo "</td>";
                    if (++$colIX > 4) {
                        echo '</tr><tr>';
                        $colIX = 1;
                    }
                }
                echo "</tr>";
            } elseif (isset($list['domains']['domain'])) {
                $domain = $list['domains']['domain'];
                $checked = isset($selectedDomains[$domain]) ? "checked" : "";
                echo '<tr>';
                echo '<td class="check-column wangguard-domain" style="padding: 4px 7px 2px;">';
                echo "<input wgix='" . $ix . "' name='domains[]' type='checkbox' value='{$domain}' {$checked} id='wangguard-domain-" . ++$domainix . "' /> <label for='wangguard-domain-" . $domainix . "'>" . $domain . "</label><br/>";
                echo "</td>";
                echo "</tr>";
            }
            echo "</tbody>";
            echo "</table>";
            echo "</div>";
            echo "</div>";
            $first = false;
        }
        ?>
						<p class="submit"><input class="button-primary" type="submit" name="saveblockeddomain" value="<?php 
        _e('Save blocked domains &raquo;', 'wangguard');
        ?>
" /></p>
					</form>
					<script type="text/javascript">
						
						function wangguard_update_domain_count(ix) {
							var q = jQuery("#wangguard-blockeddomain-domains-"+ix+" td.wangguard-domain input[type=checkbox]:checked").length;
							jQuery('#wangguard-domain-count-' + ix).html(q);
						}
						
						var wangguardDomainBlockIX = -1;
						jQuery(document).ready(function() {
							
							jQuery(".wangguard-blockeddomain-domains input[type=checkbox]").change(function() {
								wangguard_update_domain_count(jQuery(this).attr("wgix"));
							});
							
							jQuery(".wangguard-blockeddomain-header a").click(function() {
								var ix = jQuery(this).attr('rel');
								
								if (wangguardDomainBlockIX == ix) {
									jQuery('#wangguard-blockeddomain-domains-'+wangguardDomainBlockIX).slideUp('fast');
									wangguardDomainBlockIX = -1;
								}
								else {
									if (wangguardDomainBlockIX != -1)
										jQuery('#wangguard-blockeddomain-domains-'+wangguardDomainBlockIX).slideUp('fast');
									
									jQuery('#wangguard-blockeddomain-domains-'+ix).slideDown('fast');
									wangguardDomainBlockIX = ix;
								}
							});
							
							jQuery(".wangguard-blockeddomain-domains").each(function() {
								wangguard_update_domain_count(jQuery(this).attr("wgix"));
							});
						});
					</script>
					<?php 
    }
    ?>
				
			</div>
			<!--WANGGUARD BLOCKED DOMAINS-->

			

			<!--WANGGUARD SERVERS-->
			<div id="wangguard-conf-conectivity" style="margin: auto;">

				<div class="wangguard-confico"><img src="<?php 
    echo WP_PLUGIN_URL;
    ?>
/wangguard/img/connectivity.png" alt="<?php 
    echo htmlentities(__('Server Connectivity', 'wangguard'));
    ?>
" /></div>
			
				<form action="" method="post" id="wangguard-connectivity" style="margin:0px auto 0 auto;  ">

					<h3 style="margin-bottom: 30px;"><?php 
    _e('Server Connectivity', 'wangguard');
    ?>
</h3>
				<?php 
    if (!function_exists('fsockopen') || !function_exists('gethostbynamel')) {
        ?>
							<p style="padding: .5em; background-color: #00a000; color: #fff; font-weight:bold;"><?php 
        _e('Network functions are disabled.', 'wangguard');
        ?>
</p>
							<p><?php 
        echo sprintf(__('Your web host or server administrator has disabled PHP\'s <code>fsockopen</code> or <code>gethostbynamel</code> functions.  <strong>WangGuard cannot work correctly until this is fixed.</strong>  Please contact your web host or firewall administrator.', 'wangguard'));
        ?>
</p>
						<?php 
    } else {
        $servers = wangguard_get_server_connectivity();
        $fail_count = count($servers) - count(array_filter($servers));
        if (is_array($servers) && count($servers) > 0) {
            // some connections work, some fail
            if ($fail_count > 0 && $fail_count < count($servers)) {
                ?>
								<p class="wangguard-info wangguard-error"><?php 
                _e('Unable to reach some WangGuard servers.', 'wangguard');
                ?>
</p>
								<p><?php 
                echo sprintf(__('A network problem or firewall is blocking some connections from your web server to WangGuard.com.  WangGuard is working but this may cause problems during times of network congestion.', 'wangguard'));
                ?>
</p>
							<?php 
                // all connections fail
            } elseif ($fail_count > 0) {
                ?>
								<p class="wangguard-info wangguard-error"><?php 
                _e('Unable to reach any WangGuard servers.', 'wangguard');
                ?>
</p>
								<p><?php 
                echo sprintf(__('A network problem or firewall is blocking all connections from your web server to WangGuard.com.  <strong>WangGuard cannot work correctly until this is fixed.</strong>', 'wangguard'));
                ?>
</p>
							<?php 
                // all connections work
            } else {
                ?>
								<p class="wangguard-info wangguard-success"><?php 
                _e('All WangGuard servers are available.', 'wangguard');
                ?>
</p>
								<p><?php 
                _e('WangGuard is working correctly.  All servers are accessible.', 'wangguard');
                ?>
</p>
							<?php 
            }
        } else {
            ?>
								<p class="wangguard-info wangguard-error"><?php 
            _e('Unable to find WangGuard servers.', 'wangguard');
            ?>
</p>
								<p><?php 
            echo sprintf(__('A DNS problem or firewall is preventing all access from your web server to wangguard.com.  <strong>WangGuard cannot work correctly until this is fixed.</strong>', 'wangguard'));
            ?>
</p>
							<?php 
        }
    }
    if (!empty($servers)) {
        ?>
						<table style="width: 100%;"> 
						<thead>
							<th style="border-bottom: 1px solid #999; padding-bottom: 5px; margin-bottom: 5px;"><?php 
        _e('WangGuard server', 'wangguard');
        ?>
</th>
							<th style="border-bottom: 1px solid #999; padding-bottom: 5px; margin-bottom: 5px;"><?php 
        _e('Network Status', 'wangguard');
        ?>
</th>
						</thead>
						<tbody>
							<?php 
        asort($servers);
        foreach ($servers as $ip => $status) {
            $class = $status ? 'wangguard-info wangguard-success' : 'wangguard-info wangguard-error';
            ?>
							<tr>
								<td style="text-align:center; font-weight:bold;"><?php 
            echo htmlspecialchars($ip);
            ?>
</td>
								<td><p class="<?php 
            echo $class;
            ?>
"><?php 
            echo $status ? __('No problems', 'wangguard') : __('Obstructed', 'wangguard');
            ?>
</p></td>
							</tr>
							<?php 
        }
        ?>
						</tbody>
						</table>
						<?php 
    }
    ?>
					<p><?php 
    if (wangguard_get_option('wangguard_connectivity_time')) {
        echo sprintf(__('Last checked %s ago.', 'wangguard'), human_time_diff(wangguard_get_option('wangguard_connectivity_time')));
    }
    ?>
</p>
					<p class="submit"><input type="submit" name="check" class="button-primary" value="<?php 
    _e('Check network status &raquo;', 'wangguard');
    ?>
" /></p>
				</form>
			</div>

			</div>
			
		</div>


		<script type="text/javascript">
		  jQuery(document).ready(function() {
			  jQuery('#wangguard-conf-tabs').tabs();
			  jQuery('#wangguard-conf-tabs').tabs("select" , <?php 
    echo $selectedTab;
    ?>
);
		  });
		</script>

	</div>
</div>
<?php 
}
function wangguard_cronjobs()
{
    global $wpdb, $wangguard_nonce, $wangguard_api_key, $wangguard_is_network_admin;
    global $wangguard_cronjob_run_options, $wangguard_cronjob_actions_options, $wangguard_cronjob_lookup_options;
    $urlFunc = "admin_url";
    if ($wangguard_is_network_admin && function_exists("network_admin_url")) {
        $urlFunc = "network_admin_url";
    }
    if (wangguard_is_multisite()) {
        $spamFieldName = "spam";
        $sqlSpamWhere = "spam = 1";
        $sqlNoSpamWhere = "spam = 0";
    } else {
        $spamFieldName = "user_status";
        $sqlSpamWhere = "user_status = 1";
        $sqlNoSpamWhere = "user_status <> 1";
    }
    if (!current_user_can('level_10')) {
        die(__('Cheatin&#8217; uh?', 'wangguard'));
    }
    ?>
<div class="wrap" id="wangguard-wizard-cont">
	<div class="wangguard-confico"><img src="<?php 
    echo WP_PLUGIN_URL;
    ?>
/wangguard/img/settings.png" alt="<?php 
    echo htmlentities(__('WangGuard Cron Jobs', 'wangguard'));
    ?>
" /></div>
	<div class="icon32" id="icon-wangguard"><br></div>
	<h2><?php 
    _e('WangGuard Cron Jobs', 'wangguard');
    ?>
</h2>
		<p><?php 
    _e("Create one or more WangGuard cron jobs. WangGuard to periodically check your registered users for Sploggers and flag or delete them.", 'wangguard');
    ?>
</p>
		<p><?php 
    echo sprintf(__("Note: WangGuard cron jobs will NOT verify the users flagged as %s, these are the users for which you've selected the &quot;Not a Splogger&quot; option from the Users admin or flagged as &quot;Not Spam&quot;.", "wangguard"), "<span class='wangguard-status-checked'>" . __("Checked (forced)", "wangguard") . "</span>");
    ?>
</p>
		<?php 
    $table_name = $wpdb->base_prefix . "wangguardcronjobs";
    $wgcronRs = $wpdb->get_results("select * from {$table_name} order by id");
    ?>
<h3><?php 
    _e('Existing WangGuard cron jobs', 'wangguard');
    ?>
</h3>
		<?php 
    if (empty($wgcronRs)) {
        ?>
		<div id="wangguard-cron-nocron"><?php 
        _e('No cron jobs created yet', 'wangguard');
        ?>
</div> 
		<?php 
    }
    ?>
		<?php 
    foreach ($wgcronRs as $cronjob) {
        $args = array((int) $cronjob->id);
        $timestamp = wp_next_scheduled('wangguard_cronjob_runner', $args);
        $date = date(get_option('date_format') . ' ' . get_option('time_format'), $timestamp);
        ?>
			<div class="wangguard-cronjob" id="wangguard-cronjob-<?php 
        echo $cronjob->id;
        ?>
">
			<?php 
        _e("Cron Job Code", 'wangguard');
        ?>
: <strong><?php 
        echo $cronjob->id;
        ?>
</strong><br/>
			<?php 
        _e("Run", 'wangguard');
        ?>
: <strong><?php 
        echo $wangguard_cronjob_run_options[$cronjob->RunOn];
        ?>
 @ <?php 
        echo $cronjob->RunAt;
        ?>
</strong><br/>
			<?php 
        _e("Action", 'wangguard');
        ?>
: <strong><?php 
        echo $wangguard_cronjob_actions_options[$cronjob->Action];
        ?>
</strong><br/>
			<?php 
        _e("Check users registered in the last", 'wangguard');
        ?>
: <strong><?php 
        echo $wangguard_cronjob_lookup_options[$cronjob->UsersTF];
        ?>
</strong><br/>
			<?php 
        _e("Last run", 'wangguard');
        ?>
: <strong><?php 
        echo $cronjob->LastRun ? date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($cronjob->LastRun)) : "-";
        ?>
</strong><br/>
			<?php 
        _e("Next run", 'wangguard');
        ?>
: <strong><?php 
        echo $date;
        ?>
</strong><br/>
			<a href="javascript:void(0)" rel="<?php 
        echo $cronjob->id;
        ?>
" class="wangguard-delete-cronjob"><?php 
        _e('delete cron job', 'wangguard');
        ?>
</a>
			</div>
		<?php 
    }
    ?>
		<div id="wangguard-new-cronjob-container">
		</div>
		<h3><?php 
    _e('Add a new cron job', 'wangguard');
    ?>
</h3>
		<table>
			<tr>
				<td style="text-align:right;"><?php 
    _e("Run", 'wangguard');
    ?>
&nbsp;</td>
				<td><select name="wangguardnewcronjob" id="wangguardnewcronjob" class="wangguard_select">
			<?php 
    foreach ($wangguard_cronjob_run_options as $v => $o) {
        ?>
			<option value="<?php 
        echo $v;
        ?>
"><?php 
        echo $o;
        ?>
</option>
			<?php 
    }
    ?>
		</select> @ <select name="wangguardnewcronjobtimeh" id="wangguardnewcronjobtimeh" class="wangguard_select">
			<option value="00">00</option>
			<option value="01">01</option>
			<option value="02">02</option>
			<option value="03">03</option>
			<option value="04">04</option>
			<option value="05">05</option>
			<option value="06">06</option>
			<option value="07">07</option>
			<option value="08">08</option>
			<option value="09">09</option>
			<option value="10">10</option>
			<option value="11">11</option>
			<option value="12">12</option>
			<option value="13">13</option>
			<option value="14">14</option>
			<option value="15">15</option>
			<option value="16">16</option>
			<option value="17">17</option>
			<option value="18">18</option>
			<option value="19">19</option>
			<option value="20">20</option>
			<option value="21">21</option>
			<option value="22">22</option>
			<option value="23">23</option>
		</select> : <select name="wangguardnewcronjobtimem" id="wangguardnewcronjobtimem" class="wangguard_select">
			<option value="00">00</option>
			<option value="01">01</option>
			<option value="02">02</option>
			<option value="03">03</option>
			<option value="04">04</option>
			<option value="05">05</option>
			<option value="06">06</option>
			<option value="07">07</option>
			<option value="08">08</option>
			<option value="09">09</option>
			<option value="10">10</option>
			<option value="11">11</option>
			<option value="12">12</option>
			<option value="13">13</option>
			<option value="14">14</option>
			<option value="15">15</option>
			<option value="16">16</option>
			<option value="17">17</option>
			<option value="18">18</option>
			<option value="19">19</option>
			<option value="20">20</option>
			<option value="21">21</option>
			<option value="22">22</option>
			<option value="23">23</option>
			<option value="24">24</option>
			<option value="25">25</option>
			<option value="26">26</option>
			<option value="27">27</option>
			<option value="28">28</option>
			<option value="29">29</option>
			<option value="30">30</option>
			<option value="31">31</option>
			<option value="32">32</option>
			<option value="33">33</option>
			<option value="34">34</option>
			<option value="35">35</option>
			<option value="36">36</option>
			<option value="37">37</option>
			<option value="38">38</option>
			<option value="39">39</option>
			<option value="40">40</option>
			<option value="41">41</option>
			<option value="42">42</option>
			<option value="43">43</option>
			<option value="44">44</option>
			<option value="45">45</option>
			<option value="46">46</option>
			<option value="47">47</option>
			<option value="48">48</option>
			<option value="49">49</option>
			<option value="50">50</option>
			<option value="51">51</option>
			<option value="52">52</option>
			<option value="53">53</option>
			<option value="54">54</option>
			<option value="55">55</option>
			<option value="56">56</option>
			<option value="57">57</option>
			<option value="58">58</option>
			<option value="59">59</option>
		</select>
		</td>
			</tr>
			<tr>
				<td style="text-align:right;"><?php 
    _e("Action", 'wangguard');
    ?>
&nbsp;</td>
				<td><select name="wangguardnewcronjobaction" id="wangguardnewcronjobaction" class="wangguard_select">
			<?php 
    foreach ($wangguard_cronjob_actions_options as $v => $o) {
        ?>
			<option value="<?php 
        echo $v;
        ?>
"><?php 
        echo $o;
        ?>
</option>
			<?php 
    }
    ?>
		</select></td>
			</tr>
			<tr>
				<td style="text-align:right;"><?php 
    _e("Check users registered in the last", 'wangguard');
    ?>
&nbsp;</td>
				<td><select name="wangguardnewcronjoblookup" id="wangguardnewcronjoblookup" class="wangguard_select">
			<?php 
    foreach ($wangguard_cronjob_lookup_options as $v => $o) {
        ?>
			<option value="<?php 
        echo $v;
        ?>
"><?php 
        echo $o;
        ?>
</option>
			<?php 
    }
    ?>
					</select></td>
			</tr>
			<tr>
				<td></td>
				<td>
					<div id="wangguardnewconjoberror">
						<?php 
    _e('The cron job cannot be created', 'wangguard');
    ?>
					</div>
					<p class="submit"><input type="button" id="wangguardnewcronjobbutton" class="button-primary" name="submit" value="<?php 
    _e('Create con job &raquo;', 'wangguard');
    ?>
" /></p>
				</td>
			</tr>
		</table>
		<br/>
</div>
<?php 
}
function wangguard_delete_user_and_blogs($userid)
{
    global $wpdb;
    if (function_exists("get_blogs_of_user") && function_exists("update_blog_status") && method_exists($wpdb, 'get_blog_prefix')) {
        $blogs = get_blogs_of_user($userid, true);
        if (is_array($blogs)) {
            foreach ((array) $blogs as $key => $details) {
                $isMainBlog = false;
                if (isset($current_site)) {
                    $isMainBlog = $details->userblog_id != $current_site->blog_id;
                    // main blog not a spam !
                } elseif (defined("BP_ROOT_BLOG")) {
                    $isMainBlog = 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id;
                } else {
                    $isMainBlog = $details->userblog_id == 1;
                }
                $userIsAuthor = false;
                if (!$isMainBlog) {
                    //Only works on WP 3+
                    $blog_prefix = $wpdb->get_blog_prefix($details->userblog_id);
                    $authorcaps = $wpdb->get_var(sprintf("SELECT meta_value as caps FROM {$wpdb->users} u, {$wpdb->usermeta} um WHERE u.ID = %d and u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities'", $userid));
                    $caps = maybe_unserialize($authorcaps);
                    $userIsAuthor = isset($caps['administrator']);
                }
                //Update blog to spam if the user is the author and its not the main blog
                if (!$isMainBlog && $userIsAuthor) {
                    @update_blog_status($details->userblog_id, 'spam', '1');
                    //remove blog from queue
                    $table_name = $wpdb->base_prefix . "wangguardreportqueue";
                    $wpdb->query($wpdb->prepare("delete from {$table_name} where blog_id = '%d'", $details->userblog_id));
                }
            }
        }
    }
    if (wangguard_is_multisite()) {
        if (function_exists('bp_core_mark_user_spam_admin')) {
            @(include_once ABSPATH . 'wp-admin/includes/ms.php');
            bp_core_mark_user_spam_admin($userid);
            wpmu_delete_user($userid);
        } else {
            @(include_once ABSPATH . 'wp-admin/includes/ms.php');
            wpmu_delete_user($userid);
        }
    } else {
        if (function_exists('wp_delete_user') && function_exists('bp_core_mark_user_spam_admin')) {
            @(include_once ABSPATH . 'wp-admin/includes/user.php');
            bp_core_mark_user_spam_admin($userid);
            wp_delete_user($userid);
        } else {
            @(include_once ABSPATH . 'wp-admin/includes/user.php');
            wp_delete_user($userid);
        }
    }
}
 /**
  * Prepare the query variables
  */
 function prepare_query()
 {
     global $wpdb;
     $qv =& $this->query_vars;
     $tableUserStatus = $wpdb->base_prefix . "wangguarduserstatus";
     $this->query_fields_u = "{$wpdb->users}.ID , {$wpdb->users}.user_login , {$tableUserStatus}.user_status, {$tableUserStatus}.user_ip as status_user_ip, {$tableUserStatus}.user_proxy_ip as status_user_proxy_ip";
     $this->query_from_u = "FROM {$wpdb->users} LEFT JOIN {$tableUserStatus} ON {$wpdb->users}.ID = {$tableUserStatus}.ID";
     //search
     $this->query_where_u = '';
     if (!empty($qv['search'])) {
         if (empty($this->query_where_u)) {
             $this->query_where_u = " WHERE ";
         } else {
             $this->query_where_u .= " AND ";
         }
         $this->query_where_u .= "({$wpdb->users}.user_login LIKE '%" . like_escape($qv['search']) . "%' OR {$wpdb->users}.user_nicename LIKE '%" . like_escape($qv['search']) . "%' OR {$wpdb->users}.user_email LIKE '%" . like_escape($qv['search']) . "%')";
     }
     switch ($qv['type']) {
         case 'l':
             //Legitimate users filter
             if (empty($this->query_where_u)) {
                 $this->query_where_u = " WHERE ";
             } else {
                 $this->query_where_u .= " AND ";
             }
             //Legitimate users
             $wgLegitimateSQL = " {$tableUserStatus}.user_status IN ( 'checked', 'force-checked' )";
             if (wangguard_is_multisite()) {
                 $wgLegitimateSQL = " {$wpdb->users}.user_status <> 1 AND {$wpdb->users}.spam = 0 AND " . $wgLegitimateSQL;
             } elseif (defined('BP_VERSION')) {
                 $wgLegitimateSQL = " {$wpdb->users}.user_status <> 1 AND " . $wgLegitimateSQL;
             } else {
                 $wgLegitimateSQL = " {$wpdb->users}.user_status <> 1 AND " . $wgLegitimateSQL;
             }
             $this->query_where_u .= $wgLegitimateSQL;
             break;
         case 'spam':
             //Spam users filter
             if (!wangguard_is_multisite() && !defined('BP_VERSION')) {
                 break;
             }
             if (empty($this->query_where_u)) {
                 $this->query_where_u = " WHERE ";
             } else {
                 $this->query_where_u .= " AND ";
             }
             if (wangguard_is_multisite()) {
                 $wgLegitimateSQL = " {$wpdb->users}.user_status = 1 OR {$wpdb->users}.spam = 1";
             } else {
                 $wgLegitimateSQL = " {$wpdb->users}.user_status = 1";
             }
             $this->query_where_u .= $wgLegitimateSQL;
             break;
         case 'spl':
             //Spoggers users filter
             if (empty($this->query_where_u)) {
                 $this->query_where_u = " WHERE ";
             } else {
                 $this->query_where_u .= " AND ";
             }
             $wgLegitimateSQL = " {$tableUserStatus}.user_status IN ( 'reported', 'autorep' )";
             $this->query_where_u .= $wgLegitimateSQL;
             break;
     }
     // sorting
     switch ($qv['orderby']) {
         case "email":
             $orderby = "{$wpdb->users}.user_email";
             break;
         case "user_registered":
             $orderby = "{$wpdb->users}.user_registered";
             break;
         case "from_ip":
             $orderby = "case when {$tableUserStatus}.user_proxy_ip = '' then {$tableUserStatus}.user_ip else {$tableUserStatus}.user_proxy_ip end";
             break;
         case "login":
         default:
             $orderby = "{$wpdb->users}.user_login";
             break;
     }
     $qv['order'] = strtoupper($qv['order']);
     if ('ASC' == $qv['order']) {
         $order = 'ASC';
     } else {
         $order = 'DESC';
     }
     $this->query_orderby = "ORDER BY {$orderby} {$order}";
     // limit
     if ($qv['number']) {
         if ($qv['offset']) {
             $this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
         } else {
             $this->query_limit = $wpdb->prepare("LIMIT %d", $qv['number']);
         }
     }
     //_parse_meta_query( $qv );
 }
Exemplo n.º 6
0
function func_wangguard_reg()
{
    // Code
    if (!is_user_logged_in() && !wangguard_is_multisite()) {
        echo "<div>";
        wp_login_form();
        $websiteURL = get_site_url();
        echo "</div>";
        echo "<div><form name='registerform' action='" . $websiteURL . "/wp-login.php?action=register' method='post'>\n\t<fieldset>\n\t\t<label>Username\n\t\t<input type='text' name='user_login' value='' /></label>\n\t\t<label>E-mail\n\t\t<input type='text' name='user_email' value='' /></label>\n\t\t<input type='hidden' name='redirect_to' value='' />\n\t\t<input type='submit' name='wp-submit' />\n\t</fieldset>\n</form></div>";
    } else {
        if (!is_user_logged_in() && wangguard_is_multisite()) {
            echo "<div>";
            wp_login_form();
            echo "</div>";
        } else {
            echo "Ya estás identificado";
        }
    }
}
Exemplo n.º 7
0
function wangguard_users()
{
    global $wpdb, $wangguard_is_network_admin, $wangguard_nonce, $wangguard_g_splog_users_count;
    if (!current_user_can('level_10')) {
        die(__('Cheatin&#8217; uh?', 'wangguard'));
    }
    include 'wangguard-class-wp-users.php';
    $wp_list_table = new WangGuard_Users_Table();
    $pagenum = $wp_list_table->get_pagenum();
    $messages = array();
    switch ($wp_list_table->current_action()) {
        case 'delete':
            if (!wp_verify_nonce($_REQUEST['_wpnonce'], "bulk-users")) {
                die("bad nonce");
            }
            //report selected users
            $reportedUsers = 0;
            $users = (array) @$_REQUEST['users'];
            if (wangguard_is_multisite() && function_exists("wpmu_delete_user")) {
                $delFunc = 'wpmu_delete_user';
            } else {
                if (!function_exists('wp_delete_user')) {
                    @(include_once ABSPATH . 'wp-admin/includes/user.php');
                }
                $delFunc = 'wp_delete_user';
            }
            $deletedUsers = 0;
            foreach ($users as $spuserID) {
                $user_object = new WP_User($spuserID);
                if (!wangguard_is_admin($user_object)) {
                    $delFunc($spuserID);
                    $deletedUsers++;
                }
            }
            if ($deletedUsers) {
                $messages[] = '<div id="message" class="updated fade"><p><strong>' . sprintf(__("%d user(s) were deleted", "wangguard"), $deletedUsers) . '</strong></p></div>';
            }
            break;
        case 'reportassplog':
            if (!wp_verify_nonce($_REQUEST['_wpnonce'], "bulk-users")) {
                die("bad nonce");
            }
            //report selected users
            $reportedUsers = 0;
            $users = (array) $_REQUEST['users'];
            $res = wangguard_report_users($users);
            $resArr = explode(",", $res);
            $reportedUsers = count($users) == 0 ? 0 : count($resArr);
            if ($reportedUsers) {
                if (wangguard_get_option("wangguard-delete-users-on-report") == '1') {
                    $messages[] = '<div id="message" class="updated fade"><p><strong>' . sprintf(__("%d user(s) were reported as Splogger(s) and deleted", "wangguard"), $reportedUsers) . '</strong></p></div>';
                } else {
                    $messages[] = '<div id="message" class="updated fade"><p><strong>' . sprintf(__("%d user(s) were reported as Splogger(s)", "wangguard"), $reportedUsers) . '</strong></p></div>';
                }
            }
            break;
        case 'spam':
            $spamUsers = 0;
            $users = (array) $_REQUEST['users'];
            foreach ($users as $spuserID) {
                $user = new WP_User($spuserID);
                if (in_array($user->user_login, get_super_admins())) {
                    continue;
                }
                if (function_exists('get_blogs_of_user') && function_exists('update_blog_status')) {
                    $blogs = get_blogs_of_user($spuserID, true);
                    foreach ((array) $blogs as $key => $details) {
                        //						if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
                        //							update_blog_status( $details->userblog_id, 'spam', '1' );
                        $isMainBlog = false;
                        if (isset($current_site)) {
                            $isMainBlog = $details->userblog_id != $current_site->blog_id;
                            // main blog not a spam !
                        } elseif (defined("BP_ROOT_BLOG")) {
                            $isMainBlog = 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id;
                        } else {
                            $isMainBlog = $details->userblog_id == 1;
                        }
                        $userIsAuthor = false;
                        if (!$isMainBlog) {
                            //Only works on WP 3+
                            $blog_prefix = $wpdb->get_blog_prefix($details->userblog_id);
                            $authorcaps = $wpdb->get_var(sprintf("SELECT meta_value as caps FROM {$wpdb->users} u, {$wpdb->usermeta} um WHERE u.ID = %d and u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities'", $spuserID));
                            $caps = maybe_unserialize($authorcaps);
                            $userIsAuthor = isset($caps['administrator']);
                        }
                        //Update blog to spam if the user is the author and its not the main blog
                        if (!$isMainBlog && $userIsAuthor) {
                            @update_blog_status($details->userblog_id, 'spam', '1');
                            //remove blog from queue
                            $table_name = $wpdb->base_prefix . "wangguardreportqueue";
                            $wpdb->query($wpdb->prepare("delete from {$table_name} where blog_id = '%d'", $details->userblog_id));
                        }
                    }
                }
                if (function_exists('update_user_status')) {
                    update_user_status($spuserID, 'spam', '1');
                }
                $wpdb->update($wpdb->users, array('user_status' => 1), array('ID' => $spuserID));
                $spamUsers++;
            }
            if ($spamUsers) {
                $messages[] = '<div id="message" class="updated fade"><p><strong>' . sprintf(__("%d user(s) were marked as Spam", "wangguard"), $spamUsers) . '</strong></p></div>';
            }
            break;
        case 'notspam':
            $spamUsers = 0;
            $users = (array) $_REQUEST['users'];
            foreach ($users as $spuserID) {
                if (function_exists('get_blogs_of_user') && function_exists('update_blog_status')) {
                    $blogs = get_blogs_of_user($spuserID, true);
                    foreach ((array) $blogs as $key => $details) {
                        update_blog_status($details->userblog_id, 'spam', '0');
                    }
                }
                if (function_exists('update_user_status')) {
                    update_user_status($spuserID, 'spam', '0');
                }
                $wpdb->update($wpdb->users, array('user_status' => 0), array('ID' => $spuserID));
                $spamUsers++;
            }
            if ($spamUsers) {
                $messages[] = '<div id="message" class="updated fade"><p><strong>' . sprintf(__("%d user(s) were marked as Safe", "wangguard"), $spamUsers) . '</strong></p></div>';
            }
            break;
    }
    if (count($messages)) {
        foreach ($messages as $msg) {
            echo $msg;
        }
    }
    ?>

	
	
	<div class="wrap" id="wangguard-users-cont">
		<div class="wangguard-confico"><img src="<?php 
    echo WP_PLUGIN_URL;
    ?>
/wangguard/img/users.png" alt="<?php 
    echo htmlentities(__('WangGuard Users', 'wangguard'));
    ?>
" /></div>
		<div class="icon32" id="icon-wangguard"><br></div>
		<h2><?php 
    _e('WangGuard Users', 'wangguard');
    ?>
</h2>

		<?php 
    $wp_list_table->prepare_items();
    ?>
		
		<form action="" method="get">
			<input type="hidden" name="page" value="wangguard_users" />
			<?php 
    $wp_list_table->search_box(__('Search Users'), 'user');
    ?>
		</form>
		
	
		<form action="admin.php" method="get" id="wangguard-users-form">

			<input type="hidden" name="page" value="wangguard_users" />
			<?php 
    $total_pages = $wp_list_table->get_pagination_arg('total_pages');
    if ($pagenum > $total_pages && $total_pages > 0) {
        wp_redirect(add_query_arg('paged', $total_pages));
        exit;
    }
    $wp_list_table->views();
    ?>
			
			<?php 
    $requestType = "";
    if (isset($_REQUEST['type'])) {
        $requestType = $_REQUEST['type'];
    }
    if ($requestType == 'spl') {
        ?>
				<div id="wangguard-deleteallsplcont" class="subsubsub"><a class="button-primary" id="wangguard-deleteallspl" href="javascript:void(0)"><?php 
        echo __('Delete All Sploggers', 'wangguard');
        ?>
</a></div>
				<script type="text/javascript">
					<?php 
        $urlFunc = "admin_url";
        if ($wangguard_is_network_admin && function_exists("network_admin_url")) {
            $urlFunc = "network_admin_url";
        }
        $deleteSPURL = $urlFunc('admin.php?page=wangguard_wizard&wangguard_delete_splogguers=1&wangguard_splogcnt=' . $wangguard_g_splog_users_count . '&wangguard_step=3&_wpnonce=' . wp_create_nonce($wangguard_nonce));
        ?>
					
					jQuery("a#wangguard-deleteallspl").click(function() {
						if (confirm('<?php 
        echo __('Do you confirm to delete ALL Sploggers?', 'wangguard');
        ?>
')) {
							document.location = '<?php 
        echo $deleteSPURL;
        ?>
';
						}
					});
				</script>
			<?php 
    }
    ?>
				

			<?php 
    $wp_list_table->display();
    ?>
	
			
		</form>
		<br class="clear" />
	</div>
	<?php 
}
Exemplo n.º 8
0
function wangguard_page_wangguard_users_headers($v)
{
    $cols = array('cb' => '<input type="checkbox" />', 'username' => __('Username'), 'name' => __('Name'), 'email' => __('E-mail'), 'user_registered' => __('Signed up on', 'wangguard'), 'from_ip' => __('User IP', 'wangguard'), 'posts' => __('Posts'), 'blogs' => __('Sites'), 'wgstatus' => __('WangGuard Status', 'wangguard'));
    if (!wangguard_is_multisite()) {
        unset($cols['blogs']);
    }
    return $cols;
}
 public function check_unverified_users($limit)
 {
     global $wpdb;
     // code forked from wangguard-wizard.php line 8
     if (wangguard_is_multisite()) {
         $spamFieldName = "spam";
     } else {
         $spamFieldName = "user_status";
     }
     // code forked from wangguard-class-wp-users.php line 70
     $table_name = $wpdb->base_prefix . "wangguarduserstatus";
     $users_to_check = $wpdb->get_results("select ID from {$wpdb->users} where  (not EXISTS (select user_status from {$table_name} where {$table_name}.ID = {$wpdb->users}.ID) OR EXISTS (select user_status from {$table_name} where {$table_name}.ID = {$wpdb->users}.ID and {$table_name}.user_status IN ( '', 'not-checked' ))) LIMIT {$limit}", ARRAY_A);
     $verified = 0;
     $reported = 0;
     // code forked from wangguard-wizard.php line 156
     foreach ($users_to_check as $key => $user) {
         $userid = $user['ID'];
         //get the WangGuard user status, if status is force-checked or buyer then ignore the user
         $table_name = $wpdb->base_prefix . "wangguarduserstatus";
         $user_status = $wpdb->get_var($wpdb->prepare("select user_status from {$table_name} where ID = %d", $userid));
         if ($user_status == 'force-checked' || $user_status == 'buyer' || $user_status == 'whitelisted') {
             continue;
         }
         $user_object = new WP_User($userid);
         set_time_limit(300);
         $user_check_status = wangguard_verify_user($user_object);
         $checked_users[$userid] = $user_check_status;
         if ($user_check_status == "reported") {
             $reported++;
             do_action('wangguard_pre_mark_user_spam_wizard');
             if (function_exists("update_user_status")) {
                 update_user_status($userid, $spamFieldName, 1);
             } else {
                 $wpdb->query($wpdb->prepare("update {$wpdb->users} set {$spamFieldName} = 1 where ID = %d", $userid));
             }
         }
         $verified++;
     }
     $log = array('verified' => $verified, 'reported' => $reported, 'activity' => $checked_users);
     return $log;
 }