Exemplo n.º 1
0
		<div id="post-body-content" class="has-sidebar">
			<div class="has-sidebar-content">

				<!--start log-in protection-->
				<div class="postbox">
					<h3 class="hndle">Log-in Protection</h3>

					<!--if we can log logins, show login logging options!-->
					<div class="inside">
						<p>Sometimes bad people use robots to cycle through zillions of possible log-in combinations.  If they magically guess a valid combination, your blog will magically become a Canadian pharmacy or Russian dating site, which is generally not desirable.  Luckily, we can mitigate the effectiveness of such an attack by limiting the number of failed log-in attempts allowed per person within a given time frame.</p>

						<?php 
//reverse proxies and intranets can strip visitor IP information before talking to PHP,
//which is bad as the plugin can no longer tell who's who. rather than silently fail,
//let's give the administrator a heads up!
if (false === meow_get_IP()) {
    ?>
							<div class="error fade"><p>Warning: your server or WordPress configuration seems to be masking your IP address (<code><?php 
    echo esc_html($_SERVER[$meowdata['meow_ip_key']]);
    ?>
</code>).  The log-in protection functions require access to the public IP address of each visitor.  If the IP exposed to PHP falls within private or reserved ranges, or if it matches the server's IP, no action can be taken. Please take a look at the proxy configuration below to possibly correct this.</p></div>
						<?php 
}
//end IP error
?>

						<table class="form-table">
							<tbody>
								<tr valign="top">
									<th scope="row">Activate?</th>
									<td>
Exemplo n.º 2
0
function meow_login_log($status = 0, $username = '')
{
    global $wpdb;
    //get MySQL time (as this may not always be the same as PHP)
    $time = (int) $wpdb->get_var("SELECT UNIX_TIMESTAMP()");
    //storing user agent?
    $ua = meow_get_option('meow_store_ua') ? $_SERVER['HTTP_USER_AGENT'] : '';
    //this only works if we have a valid IP
    if (false !== ($ip = meow_get_IP())) {
        //check for and remove pardons, if any
        $meow_ip_pardoned = meow_get_option('meow_ip_pardoned');
        if (false !== ($pardon_key = array_search($ip, $meow_ip_pardoned))) {
            //pardons are only good once
            unset($meow_ip_pardoned[$pardon_key]);
            update_option('meow_ip_pardoned', $meow_ip_pardoned);
        }
        $wpdb->insert("{$wpdb->prefix}meow_log", array("ip" => $ip, "ua" => $ua, "date" => $time, "success" => $status, "username" => $username), array('%s', '%s', '%d', '%d', '%s'));
    }
    return true;
}