Beispiel #1
0
function luc_display_by_IP($ip)
{
    global $wpdb;
    $table_name = STATPRESS_V_TABLE_NAME;
    $qry_s = "SELECT *\n\t\t\t\tFROM {$table_name}\n\t\t\t\tWHERE ip = '{$ip}'\n\t\t\t\tORDER BY id DESC\n\t\t\t\t";
    $qry = $wpdb->get_results($qry_s);
    $num = $wpdb->num_rows;
    $qry_sa = "SELECT DISTINCT agent\n\t\t\t\tFROM {$table_name}\n\t\t\t\tWHERE ip = '{$ip}'\n\t\t\t\tORDER BY agent ASC ;\n\t\t\t\t";
    $qrya = $wpdb->get_results($qry_sa);
    if ($_POST['markbot'] == 'Mark as spambot') {
        luc_BanBot('ip', $ip);
    }
    if ($_POST['banip'] == 'Ban IP address') {
        luc_BanIP($ip);
    }
    $text_OS = $StatPressV_Option['StatPressV_Dont_Show_OS_name'] != 'checked' ? true : false;
    $text_browser = $StatPressV_Option['StatPressV_Dont_Show_Browser_name'] != 'checked' ? true : false;
    $text = "Report for " . $ip . " ";
    ?>
	<form method=post>
		<div class='wrap'><table style="width:100%"><tr><td><h2> <?php 
    _e($text);
    ?>
 </h2></td>

		<td width=50px align='right'>
			<input type=submit
				name=banip value='Ban IP address' >
		</td>
		</tr>
		</table>
		<table class='widefat'>
			<thead>
				<tr>
				<th scope='col' colspan='2'></th>
			</thead>
			<tbody>
				<tr>
					<td>Records in database:</td>
					<td> <?php 
    _e($num);
    ?>
 </td>
				</tr>
				<tr>
					<td>Latest hit:</td>
					<td> <?php 
    _e(luc_hdate($qry[0]->date) . " " . $qry[0]->time);
    ?>
 </td>
				</tr>
				<tr>
					<td>First hit:</td>
					<td> <?php 
    _e(luc_hdate($qry[$num - 1]->date) . " " . $qry[$num - 1]->time);
    ?>
 </td>
				</tr>
				<tr>
					<td>User agent(s):</td>
					<td> <?php 
    _e(luc_print_uas($qrya));
    ?>
 </td>
				</tr>
			</tbody>
		</table>
	<?php 
    $geoip = luc_GeoIP_get_data($ip);
    if ($geoip !== false) {
        ?>
		<table class='widefat'>
			<thead><tr><th scope='col' colspan='4'>GeoIP Information</th></tr></thead>
			<tbody>
			<tr>
				<td><strong>Country:</strong></td>
				<td> <?php 
        _e($geoip['cn'] . " (" . $geoip['cc'] . ")");
        ?>
					<IMG style='border:0px;height:16px;' alt='$cn' title='$cn' SRC=' <?php 
        _e(STATPRESS_V_PLUGIN_URL . "/images/domain/" . strtolower($geoip['cc']) . '.png');
        ?>
 '></td>
				<td><strong>Continent Code:</strong></td>
				<td> <?php 
        _e($geoip['continent_code']);
        ?>
 </td>
			</tr>
			<tr>
				<td><strong>Region:</strong></td>
				<td> <?php 
        _e($geoip['region']);
        ?>
 </td>
				<td><strong>Area Code: (USA Only)</strong></td>
				<td> <?php 
        _e($geoip['area_code']);
        ?>
 </td>
			</tr>
			<tr>
				<td><strong>City:</strong></td>
				<td> <?php 
        _e($geoip['city']);
        ?>
 </td>
				<td><strong>Postal Code: (USA Only)</strong></td>
				<td> <?php 
        _e($geoip['postal_code']);
        ?>
 </td>
			</tr>
			<tr>
				<td><strong>Latitude/Longitude</strong></td>
				<td> <a href='http://maps.google.com/maps?q=<?php 
        _e($geoip['latitude'] . "+" . $geoip['longitude']);
        ?>
' target='_blank' title='Lookup latitude/longitude location on Google Maps...'><?php 
        _e($geoip['latitude'] . " " . $geoip['longitude']);
        ?>
</a></td>
				<td><strong>Metro Code: (USA Only)</strong></td>
				<td> <?php 
        _e($geoip['metro_code']);
        ?>
 </td>
			</tr>
			</tbody>
		</table>
		<?php 
    }
    ?>
		<table class='widefat'>
			<thead>
				<tr>
				<th scope='col' colspan='6'>URLs Requested</th>
				</tr>
			</thead>
			<thead>
				<tr>
				<th scope='col'>Date</th>
				<th scope='col'>Time</th>
				<th scope='col'>OS</th>
				<th scope='col'>Browser</th>
				<th scope='col'>Agent</th>
				<th scope='col'>Referrer</th>
				<th scope='col'>URL Requested</th>
				</tr>
			</thead>
			<tbody>
	<?php 
    foreach ($qry as $rk) {
        ?>
				<tr>
					<td> <?php 
        _e(luc_hdate($rk->date));
        ?>
 </td>
					<td> <?php 
        _e($rk->time);
        ?>
 </td>
					<td> <?php 
        _e(luc_HTML_IMG($rk->os, 'os', $text_OS));
        ?>
 </td>
					<td> <?php 
        _e(luc_HTML_IMG($rk->browser, 'browser', $text_browser));
        ?>
</td>
					<td> <?php 
        _e($rk->agent);
        ?>
 </td>
					<td> <?php 
        _e($rk->referrer);
        ?>
 </td>
					<td> <?php 
        _e(luc_post_title_Decode($rk->urlrequested));
        ?>
 </td>
				</tr>
			</tbody>
		<?php 
    }
    ?>
		</table>
		</div>
	</form>
	<?php 
    luc_StatPressV_load_time();
}
Beispiel #2
0
function luc_GeoIP()
{
    global $StatPressV_Option;
    $ipAddress = htmlentities($_SERVER['REMOTE_ADDR']);
    $geoip = luc_GeoIP_get_data($ipAddress);
    if (file_exists(luc_GeoIP_dbname('country'))) {
        $stat = stat(luc_GeoIP_dbname('country'));
        $dbsize = number_format_i18n($stat['size']);
        $dbmtime = date_i18n('r', $stat['mtime']);
    } else {
        $StatPressV_Option['StatPressV_Use_GeoIP'] = '';
        update_option('StatPressV_Option', $StatPressV_Option);
    }
    if (file_exists(luc_GeoIP_dbname('city'))) {
        $statcity = stat(luc_GeoIP_dbname('city'));
        $dbcitysize = number_format_i18n($statcity['size']);
        $dbcitymtime = date_i18n('r', $statcity['mtime']);
    } else {
        $StatPressV_Option['StatPressV_Use_GeoIP'] = '';
        update_option('StatPressV_Option', $StatPressV_Option);
    }
    // Draw page
    ?>
	<table class='widefat'>
		<thead>
			<tr>
				<th scope='col' colspan='2'>GeoIP Lookup</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>
					
					<strong>Warning:</strong> GeoIP consumes lot of CPU time, its use is discouraged, do not use it or have permission from your host before activating.
					</br></br><input type=checkbox name='StatPressV_Use_GeoIP' id='StatPressV_Use_GeoIP' value='checked'/>
					<?php 
    echo $StatPressV_Option['StatPressV_Use_GeoIP'];
    ?>
 <label for='StatPressV_Use_GeoIP'>Enable (requires MaxMind GeoIP database files to be installed first)</label>
					
					
				</td>
				<td>
					<?php 
    if ($StatPressV_Option['StatPressV_Use_GeoIP'] == 'checked') {
        $geoipdb = luc_GeoIP_dbname('country');
        if (file_exists($geoipdb)) {
            echo "<span style='color:green'>Database OK</span>";
        } else {
            echo "<span style='color:red'>Database NOT found.  Please download and install databases first. Disabling Option! </span>";
            $StatPressV_Option['StatPressV_Use_GeoIP'] = '';
            update_option('StatPressV_Option', $StatPressV_Option);
        }
    }
    ?>
				</td>
			</tr>
			<tr>
				<td>
					<table class="form-table" width="100%">
						<tr>
							<td>
							<input type='button' id='dogeoipdbupdate' value='Download/update database from MaxMind' class='button-secondary'>
							<img src="<?php 
    echo STATPRESS_V_PLUGIN_URL;
    ?>
/images/ajax-loader.gif" id="geoipupdatedbLoader" style="display: none;" />
							<br /><br />
							<font size=2><b>WARNING!</b>  Downloading database updates from MaxMind <b>more than once per day</b> will get your <b>IP address banned!</b></font></td>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</tbody>
		<thead><tr>
						<th scope='col' colspan='2'>Indicate the preferred method to locate the country of visitors :</th>
					</tr>
			</thead>
			<tbody>
			<form method="post" >
   <tr><td>
       <input type="radio" name="StatPressV_locate_IP" value="browser" id="browser" <?php 
    if ($StatPressV_Option['StatPressV_locate_IP'] == 'browser') {
        echo 'checked';
    }
    ?>
	   /> <label for="browser">Store the country provided by the browser first, otherwise use GeoIP (default, recommended)</label><br />
       <input type="radio" name="StatPressV_locate_IP" value="GeoIP" id="GeoIP" <?php 
    if ($StatPressV_Option['StatPressV_locate_IP'] == 'GeoIP') {
        echo 'checked';
    }
    ?>
	   /> <label for="GeoIP">Always use GeoIP (accuracy 95%)</label><br />
   </td></tr>
</form>
</tbody>
		<thead><tr><th scope='col' colspan='2'>Status</th></tr></thead>
		<tbody>
		<tr>
			<td><strong>StatPressV GeoIP status:</strong></td>
	<?php 
    if ($StatPressV_Option['StatPressV_Use_GeoIP'] == 'checked') {
        echo "<td><span style='color:green'>Enabled</span></td>";
    } else {
        echo "<td><span style='color:red'>Disabled" . $geoipdb . "</span></td>";
    }
    ?>
		</tbody>
		<thead><tr><th scope='col' colspan='2'>Country database</th></tr></thead>
		<tbody>
		<tr>
			<td><strong>File status:</strong></td>
	<?php 
    if (!file_exists(luc_GeoIP_dbname('country'))) {
        echo "<td><span style='color:red'>Database NOT found" . $geoipdb . "</span></td></tr>";
        $StatPressV_Option['StatPressV_Use_GeoIP'] = '';
        update_option('StatPressV_Option', $StatPressV_Option);
    } else {
        echo "<td><span style='color:green'>Country database file exists</span></td>\r\n\t\t</tr>\r\n\t\t<tr><td><strong>File location:</strong></td>\r\n\t\t\t<td>" . luc_GeoIP_dbname('country') . "</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td><strong>File date (mtime):</strong></td>\r\n\t\t\t<td> {$dbmtime} </td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td><strong>File size:</strong></td>\r\n\t\t\t<td> {$dbsize} bytes </td>\r\n\t\t</tr>";
    }
    ?>
		</tbody>

		<thead><tr><th scope='col' colspan='2'>City database</th></tr></thead>
		<tbody>
		<tr>
			<td><strong>File status:</strong></td>
	<?php 
    if (!file_exists(luc_GeoIP_dbname('city'))) {
        echo "<td><span style='color:red'>City database NOT found" . $geoipcitydb . "</span></td>";
        $StatPressV_Option['StatPressV_Use_GeoIP'] = '';
        update_option('StatPressV_Option', $StatPressV_Option);
    } else {
        echo "<td><span style='color:green'>City database file exists</span></td>\r\n\t\t<tr>\r\n\t\t\t<td><strong>File location:</strong></td>\r\n\t\t\t<td>" . luc_GeoIP_dbname('city') . "</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td><strong>File date (mtime):</strong></td>\r\n\t\t\t<td> {$dbcitymtime} </td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td><strong>File size:</strong></td>\r\n\t\t\t<td> {$dbcitysize} bytes</td>\r\n\t\t</tr>";
    }
    ?>
		</tbody>
	<?php 
    if ($geoip !== false) {
        echo "\r\n\t\t\t<table class='widefat'>\r\n\t\t\t\t<thead><tr><th scope='col' colspan='4'>Your GeoIP Information ({$ipAddress})</th></tr></thead>\r\n\t\t\t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><strong>Country:</strong></td>\r\n\t\t\t\t\t<td>" . $geoip['cn'] . " (" . $geoip['cc'] . ")\r\n\t\t\t\t\t\t<IMG style='border:0px;height:16px;' alt='{$cn}' title='{$cn}' SRC='" . STATPRESS_V_PLUGIN_URL . '/images/domain/' . strtolower($geoip['cc']) . '.png' . "'></td>\r\n\t\t\t\t\t<td><strong>Continent Code:</strong></td>\r\n\t\t\t\t\t<td>" . $geoip['continent_code'] . "</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><strong>Region:</strong></td>\r\n\t\t\t\t\t<td>" . $geoip['region'] . "</td>\r\n\t\t\t\t\t<td><strong>Area Code (USA Only):</strong></td>\r\n\t\t\t\t\t<td>" . $geoip['area_code'] . "</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><strong>City:</strong></td>\r\n\t\t\t\t\t<td>" . $geoip['city'] . "</td>\r\n\t\t\t\t\t<td><strong>Postal Code (USA Only):</strong></td>\r\n\t\t\t\t\t<td>" . $geoip['postal_code'] . "</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><strong>Latitude/Longitude:</strong></td>\r\n\t\t\t\t\t<td>" . $geoip['latitude'] . " " . $geoip['longitude'] . "</td>\r\n\t\t\t\t\t<td><strong>Metro Code (USA Only):</strong></td>\r\n\t\t\t\t\t<td>" . $geoip['metro_code'] . "</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t";
    }
    ?>
	</table>
	<div id='geoipupdatedbResultCountry'></div>
	<div id='geoipupdatedbResultCity'></div>
	<?php 
    //  End of GeoIP page
}