コード例 #1
0
function wangguard_conf()
{
    global $wpdb;
    global $wangguard_nonce, $wangguard_api_key;
    if (!current_user_can('level_10')) {
        die(__('Cheatin’ 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 
}
コード例 #2
0
/**
 * Recheck user on WangGuard handler
 *
 * @global type $wpdb
 * @global type $wangguard_api_key
 */
function wangguard_ajax_recheck_callback()
{
    global $wpdb;
    global $wangguard_api_key;
    if (!current_user_can('level_10')) {
        die;
    }
    $userid = intval($_POST['userid']);
    $valid = wangguard_verify_key($wangguard_api_key);
    if ($valid == 'failed') {
        echo "-2";
        die;
    } else {
        if ($valid == 'invalid') {
            echo "-1";
            die;
        }
    }
    $user_object = new WP_User($userid);
    if (empty($user_object->user_email)) {
        echo "0";
        die;
    }
    if (wangguard_is_admin($user_object)) {
        echo '<span class="wangguard-status-no-status wangguardstatus-' . $userid . '">' . __('No status', 'wangguard') . '</span>';
        die;
    }
    $user_check_status = wangguard_verify_user($user_object);
    if ($user_check_status == "reported") {
        echo '<span class="wangguard-status-splogguer">' . __('Reported as Splogger', 'wangguard') . '</span>';
    } elseif ($user_check_status == "checked") {
        echo '<span class="wangguard-status-checked">' . __('Checked', 'wangguard') . '</span>';
    } elseif (substr($user_check_status, 0, 5) == "error") {
        echo '<span class="wangguard-status-error">' . __('Error', 'wangguard') . " - " . substr($user_check_status, 6) . '</span>';
    } else {
        return '<span class="wangguard-status-not-checked">' . __('Not checked', 'wangguard') . '</span>';
    }
    die;
}
コード例 #3
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 
}
コード例 #4
0
function wangguard_check_server_connectivity()
{
    if (defined('WANGGUARD_API_HOST')) {
        $wangguard_api_host = WANGGUARD_API_HOST;
    }
    // Some web hosts may disable one or both functions
    if (!function_exists('fsockopen') || !function_exists('gethostbynamel')) {
        return array();
    }
    $ips = gethostbynamel($wangguard_api_host);
    if (!$ips || !is_array($ips) || !count($ips)) {
        return array();
    }
    $servers = array();
    foreach ($ips as $ip) {
        $response = wangguard_verify_key(wangguard_get_key(), $ip);
        // even if the key is invalid, at least we know we have connectivity
        if ($response == 'valid' || $response == 'invalid') {
            $servers[$ip] = true;
        } else {
            $servers[$ip] = false;
        }
    }
    return $servers;
}