<?php
// Log-Page
function geo_capblack_log_page() {
	global $wpdb, $table_prefix;
	
	$logs = $wpdb->get_results("SELECT * FROM " . $table_prefix . "geo_capblack_log ORDER BY date DESC", ARRAY_A); 
	
?>
  <div class="wrap">
   <div id="icon-geo-captcha-blacklist" class="icon32"><br /></div><h2><?php _e('Geo Captcha', 'geo-captcha-blacklist'); ?> &bull; <?php _e('Logs', 'geo-captcha-blacklist'); ?></h2>
   <p><?php _e('The log shows you all comments and registrations checked by Geo Captcha.', 'geo-captcha-blacklist'); ?></p>
   <dl>
	<dt><img src="<?php echo WP_PLUGIN_URL; ?>/geo-captcha-geo-blacklist/images/icon_good.png" alt="" border="0" /></dt>
	<dd><?php _e('Captcha has been entered correctly!', 'geo-captcha-blacklist'); ?></dd>
	<dt><img src="<?php echo WP_PLUGIN_URL; ?>/geo-captcha-geo-blacklist/images/icon_bad.png" alt="" border="0" /></dt>
	<dd><?php _e('Captcha has NOT been entered correctly!', 'geo-captcha-blacklist'); ?></dd>
	<dt><img src="<?php echo WP_PLUGIN_URL; ?>/geo-captcha-geo-blacklist/images/icon_user.png" alt="" border="0" /></dt>
	<dd><?php _e('Registered user has posted this comment!', 'geo-captcha-blacklist'); ?></dd>
	<dt><img src="<?php echo WP_PLUGIN_URL; ?>/geo-captcha-geo-blacklist/images/icon_white.png" alt="" border="0" /></dt>
	<dd><?php _e('User on the Whitelist has posted this comment!', 'geo-captcha-blacklist'); ?></dd>
	<dt><img src="<?php echo WP_PLUGIN_URL; ?>/geo-captcha-geo-blacklist/images/icon_black.png" alt="" border="0" /></dt>
	<dd><?php _e('Someone on the blacklist tried to directly submit a comment without even seeing the comment form!', 'geo-captcha-blacklist'); ?></dd>
   </dl>
   <table class="widefat geocaptcha_log">
     <thead>
       <tr>
	     <th><?php _e('Country', 'geo-captcha-blacklist'); ?></th>
		 <th><?php _e('Date', 'geo-captcha-blacklist'); ?></th>
		 <th><?php _e('Location', 'geo-captcha-blacklist'); ?></th>
		 <th><?php _e('IP-Address', 'geo-captcha-blacklist'); ?></th>
	   </tr>   
     </thead>
	 <tfoot>
       <tr>
	     <th><?php _e('Country', 'geo-captcha-blacklist'); ?></th>
		 <th><?php _e('Date', 'geo-captcha-blacklist'); ?></th>
		 <th><?php _e('Location', 'geo-captcha-blacklist'); ?></th>
		 <th><?php _e('IP-Address', 'geo-captcha-blacklist'); ?></th>
	   </tr>   
     </tfoot>
     <tbody>
	<?php 
	if(is_array($logs)) {
		foreach($logs as $log) {
		?>
		<tr>
		  <td><img src="<?php echo WP_PLUGIN_URL; ?>/geo-captcha-geo-blacklist/images/icon_<?php echo $log['type']; ?>.png" alt="" border="0" /> <?php echo $log['country']; ?></td>
		  <td><?php echo date("d.m.Y H:i:s", strtotime($log['date'])); ?></td>
		  <td>
		  <?php
		  if('comments' == $log['where']) {
			_e('Comments', 'geo-captcha-blacklist');
		  } elseif ('registration' == $log['where']) {
			_e('Registration', 'geo-captcha-blacklist');
		  } else {
			_e('Unknown', 'geo-captcha-blacklist');
		  }
		  ?>
		  </td>
		  <td><?php echo $log['ip']; ?></td>
		</tr>
		<?php
		}
	}
	 ?>
	 </tbody>
   </table>
   <p>
   <form method="post" action="">
      <input type="submit" class="button" value="<?php _e('Clear Log', 'geo-captcha-blacklist'); ?>" />
      <input name="action" value="clear_log" type="hidden" />
    </form>
	</p>
  </div>
<?php
}
?>