Example #1
0
function luc_spyvisitors()
{
    global $wpdb;
    global $StatPressV_Option;
    $action = "spyvisitors";
    $table_name = STATPRESS_V_TABLE_NAME;
    // number of IP or bot by page
    $LIMIT = $StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page'] ? $StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page'] : 20;
    $LIMIT_PROOF = $StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP'] ? $StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP'] : 20;
    $pp = luc_page_periode();
    // Number of distinct ip (unique visitors)
    $NumIP = $wpdb->get_var("SELECT count(distinct ip)\n\t\t\t\t\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\t\t\t\t\tWHERE spider='' ;");
    $NP = ceil($NumIP / $LIMIT);
    $LimitValue = $pp * $LIMIT - $LIMIT;
    $sql = "SELECT *\n\t\t\t\t\tFROM {$table_name} as T1\n\t\t\t\t\tJOIN\n\t\t\t\t\t\t(SELECT max(id) as MaxId,ip\n\t\t\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\t\t\tWHERE spider=''\n\t\t\t\t\t\t\tGROUP BY ip\n\t\t\t\t\t\t\tORDER BY MaxId DESC LIMIT {$LimitValue}, {$LIMIT}\n\t\t\t\t\t\t) as T2\n\t\t\t\t\tON T1.ip = T2.ip\n\t\t\t\t\tORDER BY MaxId DESC, id DESC;\n\t\t\t\t";
    $qry = $wpdb->get_results($sql);
    if ($StatPressV_Option['StatPressV_Use_GeoIP'] == 'checked' & function_exists('geoip_open')) {
        // Open the database to read and save info
        if (file_exists(luc_GeoIP_dbname('city'))) {
            $gic = geoip_open(luc_GeoIP_dbname('city'), GEOIP_STANDARD);
            $geoip_isok = true;
        }
    }
    echo "<div class='wrap'><h2>" . __('Visitor Spy', 'statpress') . "</h2>";
    ?>
<script>
	function ttogle(thediv){
	if (document.getElementById(thediv).style.display=="inline") {
	document.getElementById(thediv).style.display="none"
	} else {document.getElementById(thediv).style.display="inline"}
	}
</script>
<?php 
    $MaxId = 0;
    $num_row = 0;
    // Add pagination
    luc_insert_pagination_options("spyvisitors", $NumIP, $LIMIT);
    luc_print_pp_link($NP, $pp, $action);
    echo '<table class="widefat" id="mainspytab" name="mainspytab" width="99%" border="0" cellspacing="0" cellpadding="4">';
    foreach ($qry as $rk) {
        // Visitor Spy
        if ($MaxId != $rk->MaxId) {
            if ($geoip_isok === true) {
                $gir = GeoIP_record_by_addr($gic, $rk->ip);
            }
            echo "<thead><tr><th scope='colgroup' colspan='2'>";
            if ($rk->country != '') {
                echo "HTTP country " . luc_HTML_IMG($rk->country, 'country', false);
            } else {
                echo "Hostip country <IMG SRC='http://api.hostip.info/flag.php?ip=" . $rk->ip . "' border=0 width=18 height=12>  ";
            }
            if ($geoip_isok === true) {
                $lookupsvc = "GeoIP details";
            } else {
                $lookupsvc = "Hostip details";
            }
            echo "\t<strong><span><font size='2' color='#7b7b7b'> " . $rk->ip . " </font></span></strong>\n\t\t\t\t\t<span style='color:#006dca;cursor:pointer;border-bottom:1px dotted #AFD5F9;font-size:8pt;'\n\t\t\t\t\t\tonClick=ttogle('" . $rk->ip . "');>" . $lookupsvc . "</span></div>\n\t\t\t\t\t<div id='" . $rk->ip . "' name='" . $rk->ip . "'>";
            if ($geoip_isok === true) {
                echo "\t<small><br>\n\t\t\t\t\t\t\tCountry: " . utf8_encode($gir->country_name) . " (" . $gir->country_code . ")<br>\n\t\t\t\t\t\t\tCity: " . utf8_encode($gir->city) . "<br>\n\t\t\t\t\t\t\tLatitude/Longitude: <a href='http://maps.google.com/maps?q=" . $gir->latitude . "+" . $gir->longitude . "' target='_blank' title='Lookup latitude/longitude location on Google Maps...'>" . $gir->latitude . " " . $gir->longitude . "</a>\n\t\t\t\t\t\t</small>";
            } else {
                echo "\t<iframe style='overflow:hide;border:0px;width:100%;height:35px;font-family:helvetica;paddng:0;'\n\t\t\t\t\t\t\tscrolling='no' marginwidth=0 marginheight=0 src=http://api.hostip.info/get_html.php?ip=" . $rk->ip . ">\n\t\t\t\t\t\t</iframe>";
            }
            echo "\t<small>\n\t\t\t\t\t\t<br>" . $rk->os . "\n\t\t\t\t\t\t<br>" . $rk->browser . "\n\t\t\t\t\t\t<br>" . gethostbyaddr($rk->ip) . "\n\t\t\t\t\t\t<br>" . $rk->agent . "\n\t\t\t\t\t</small></div></th></tr></thead><tbody>\n\t\t\t\t\t<script> document.getElementById('" . $rk->ip . "').style.display='none';</script>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td>" . luc_hdate($rk->date) . " " . $rk->time . "</td>\n\t\t\t\t\t<td>" . (isset($rk->post_title) ? $rk->post_title : luc_post_title_Decode(urldecode($rk->urlrequested))) . "";
            if ($rk->searchengine != '') {
                echo "<br><small>arrived from <b>" . $rk->searchengine . "</b> searching <a target='_blank' href='" . $rk->referrer . "' >" . urldecode($rk->search) . "</a></small>";
            } elseif ($rk->referrer != '' && strpos($rk->referrer, $home) === false) {
                echo "<br><small>arrived from <a target='_blank' href='" . $rk->referrer . "' >" . $rk->referrer . "</a></small>";
            }
            echo "</div></td></tr>\n";
            $MaxId = $rk->MaxId;
            $num_row = 1;
        } elseif ($num_row < $LIMIT_PROOF) {
            echo "<tr><td>" . luc_hdate($rk->date) . " " . $rk->time . "</td>\n\t\t\t\t\t\t<td>" . (isset($rk->post_title) ? $rk->post_title : luc_post_title_Decode(urldecode($rk->urlrequested))) . "";
            if ($rk->searchengine != '') {
                echo "<br><small>arrived from <b>" . $rk->searchengine . "</b> searching <a target='_blank' href='" . $rk->referrer . "' >" . urldecode($rk->search) . "</a></small>";
            } elseif ($rk->referrer != '' && strpos($rk->referrer, $home) === false) {
                echo "<br><small>arrived from <a target='_blank' href='" . $rk->referrer . "' >" . $rk->referrer . "</a></small>";
            }
            $num_row += 1;
            echo "</td></tr></tbody>";
        }
    }
    echo "</div></td></tr>\n</table>";
    luc_print_pp_link($NP, $pp, $action);
    echo "</div>";
    luc_StatPressV_load_time();
}
Example #2
0
function luc_main()
{
    $start = microtime(true);
    if (isset($_GET['ip'])) {
        // This is a query for an IP address
        luc_Lookup("ip", $_GET['ip']);
        return true;
    }
    if (isset($_GET['pageid'])) {
        // This is a query for a post or page
        luc_Lookup("pageid", $_GET['pageid']);
        return true;
    }
    global $StatPressV_Option;
    $overview = luc_main_table_overview_array(1);
    ?>
	<div class='wrap' >
	<div class="tabbed">
	<!-- The tabs -->
		<ul>
			<li><strong><a href="#tabs-1">Overview</a></strong></li>
			<li><strong><a href="#tabs-2">Latest Hits</a></strong></li>
			<li><strong><a href="#tabs-3">Latest Search Terms</a></strong></li>
			<li><strong><a href="#tabs-4">Latest Referrers</a></strong></li>
			<li><strong><a href="#tabs-5">Latest Feeds</a></strong></li>
	<?php 
    if ($StatPressV_Option['StatPressV_Dont_Collect_Spider'] == '') {
        ?>
			<li><strong><a href="#tabs-6">Latest Spiders</a></strong></li>
			<li><strong><a href="#tabs-7">Latest Spams Bots</a></strong></li>
	<?php 
    }
    ?>
		
			<li><strong><a href="#tabs-8">Latest Undefined Agents</a></strong></li>
	
			</ul>

<!-- tab 1 -->
		<div id="tabs-1">
			<div id="overview"> <?php 
    luc_main_table_overview($overview['total']);
    ?>
 </div>
			<div id="bargraph"> <?php 
    luc_main_table_bargraph($overview);
    ?>
 </div>
			<?php 
    luc_insert_pagination_options("bargraph", $overview['numdays'], $StatPressV_Option['StatPressV_Graph_Days'] == 0 ? 7 : $StatPressV_Option['StatPressV_Graph_Days']);
    ?>
			<form id='bargraphForm'>
				<table class='main'>
					<tr>
						<td align='center'>
							<div id="pagination"></div>
						</td>
						<td>
							<img src="<?php 
    echo STATPRESS_V_PLUGIN_URL;
    ?>
/images/ajax-loader.gif" id="bargraphLoader" style="display: none;" />
							<input type="hidden" name="action" value="table_bargraph" />
						</td>
					</tr>
				</table>
			</form>
		</div>

<!-- tab 2 -->
		<div id="tabs-2">
			<table>
				<form id='latesthitsForm'>
					<table class='main'>
						<tr>
							<td>Rows:</td>
							<td align='right'>
								<select name='hitsrows' id='hitsrows'>
									<option value='0'>--Select--</option>
									<option value='5'>5</option>
									<option value='10'>10</option>
									<option value='25'>25</option>
									<option value='50'>50</option>
									<option value='100'>100</option>
									<option value='250'>250</option>
									<option value='500'>500</option>
								</select>
								<img src="<?php 
    _e(STATPRESS_V_PLUGIN_URL);
    ?>
/images/ajax-loader.gif" id="latesthitsLoader" style="display: none;" />
								<input type="hidden" name="action" value="table_latest_hits" />
							</td>
						</tr>
					</table>
				</form>
			</table>
			<div id="latesthits"> <?php 
    luc_main_table_latest_hits();
    ?>
 </div>
		</div>

<!-- tab 3 -->
		<div id="tabs-3">
			<table>
				<form id='latestsearchForm'>
					<table class='main'>
						<tr>
							<td>Rows:</td>
							<td align='right'>
								<select name='searchrows' id='searchrows'>
									<option value='0'>--Select--</option>
									<option value='5'>5</option>
									<option value='10'>10</option>
									<option value='25'>25</option>
									<option value='50'>50</option>
									<option value='100'>100</option>
									<option value='250'>250</option>
									<option value='500'>500</option>
								</select>
								<img src="<?php 
    _e(STATPRESS_V_PLUGIN_URL);
    ?>
/images/ajax-loader.gif" id="latestsearchLoader" style="display: none;" />
								<input type="hidden" name="action" value="table_latest_search" />
							</td>
						</tr>
					</table>
				</form>
			</table>
			<div id="latestsearch"> <?php 
    luc_main_table_latest_search();
    ?>
 </div>
		</div>

<!-- tab 4 -->
		<div id="tabs-4">
			<table>
				<form id='latestreferrersForm'>
					<table class='main'>
						<tr>
							<td>Rows:</td>
							<td align='right'>
								<select name='referrersrows' id='referrersrows'>
									<option value='0'>--Select--</option>
									<option value='5'>5</option>
									<option value='10'>10</option>
									<option value='25'>25</option>
									<option value='50'>50</option>
									<option value='100'>100</option>
									<option value='250'>250</option>
									<option value='500'>500</option>
								</select>
								<img src="<?php 
    _e(STATPRESS_V_PLUGIN_URL);
    ?>
/images/ajax-loader.gif" id="latestreferrersLoader" style="display: none;" />
								<input type="hidden" name="action" value="table_latest_referrers" />
							</td>
						</tr>
					</table>
				</form>
			</table>
			<div id="latestreferrers"> <?php 
    luc_main_table_latest_referrers();
    ?>
 </div>
		</div>

<!-- tab 5 -->
		<div id="tabs-5">
			<table>
				<form id='latestfeedsForm'>
					<table class='main'>
						<tr>
							<td>Rows:</td>
							<td align='right'>
								<select name='feedsrows' id='feedsrows'>
									<option value='0'>--Select--</option>
									<option value='5'>5</option>
									<option value='10'>10</option>
									<option value='25'>25</option>
									<option value='50'>50</option>
									<option value='100'>100</option>
									<option value='250'>250</option>
									<option value='500'>500</option>
								</select>
								<img src="<?php 
    _e(STATPRESS_V_PLUGIN_URL);
    ?>
/images/ajax-loader.gif" id="latestfeedsLoader" style="display: none;" />
								<input type="hidden" name="action" value="table_latest_feeds" />
							</td>
						</tr>
					</table>
				</form>
			</table>
			<div id="latestfeeds"> <?php 
    luc_main_table_latest_feeds();
    ?>
 </div>
		</div>

<!-- tab 6 -->
	<?php 
    if ($StatPressV_Option['StatPressV_Dont_Collect_Spider'] == '') {
        ?>
		<div id="tabs-6">
			<table>
				<form id='latestspidersForm'>
					<table class='main'>
						<tr>
							<td>Rows:</td>
							<td align='right'>
								<select name='spidersrows' id='spidersrows'>
									<option value='0'>--Select--</option>
									<option value='5'>5</option>
									<option value='10'>10</option>
									<option value='25'>25</option>
									<option value='50'>50</option>
									<option value='100'>100</option>
									<option value='250'>250</option>
									<option value='500'>500</option>
								</select>
								<img src="<?php 
        _e(STATPRESS_V_PLUGIN_URL);
        ?>
/images/ajax-loader.gif" id="latestspidersLoader" style="display: none;" />
								<input type="hidden" name="action" value="table_latest_spiders" />
							</td>
						</tr>
					</table>
				</form>
			</table>
			<div id="latestspiders"> <?php 
        luc_main_table_latest_spiders();
        ?>
 </div>
		</div>

<!-- tab 7 -->
		<div id="tabs-7">
			<table>
				<form id='latestspambotsForm'>
					<table class='main'>
						<tr>
							<td width=270px><h2>Latest Spambots</h2></td>
							<td align='right'>
								<select name='spambotsrows' id='spambotsrows'>
									<option value='0'>Rows:</option>
									<option value='5'>5</option>
									<option value='10'>10</option>
									<option value='25'>25</option>
									<option value='50'>50</option>
									<option value='100'>100</option>
								</select>
								<img src="<?php 
        echo STATPRESS_V_PLUGIN_URL;
        ?>
/images/ajax-loader.gif" id="latestspambotsLoader" style="display: none;" />
								<input type="hidden" name="action" value="table_latest_spambots" />
							</td>
						</tr>
					</table>
				</form>
			</table>
	<div id="latestspambots"> <?php 
        luc_main_table_latest_spambots();
        ?>
 </div>
	</div>
<?php 
    }
    ?>
<!-- tab 8 -->
		<div id="tabs-8">
			<table>
				<form id='latestundefagentsForm'>
					<table class='main'>
						<tr>
							<td>Rows:</td>
							<td align='right'>
								<select name='undefagentsrows' id='undefagentsrows'>
									<option value='0'>--Select--</option>
									<option value='5'>5</option>
									<option value='10'>10</option>
									<option value='25'>25</option>
									<option value='50'>50</option>
									<option value='100'>100</option>
									<option value='250'>250</option>
									<option value='500'>500</option>
								</select>
								<img src="<?php 
    _e(STATPRESS_V_PLUGIN_URL);
    ?>
/images/ajax-loader.gif" id="latestundefagentsLoader" style="display: none;" />
								<input type="hidden" name="action" value="table_latest_undefagents" />
							</td>
						</tr>
					</table>
				</form>
			</table>
			<div id="latestundefagents"> <?php 
    luc_main_table_latest_undefagents();
    ?>
 </div>
		</div>
	
	</div> <!-- End tabbed div -->
		<!-- end of the tab -->
		<br>
	<table style="width:100%;">
		<tbody>
			<tr>
				<td width="200px"><font size="1"><b>StatPress Visitors table size</b></font></td>
				<td><font size="1"><?php 
    _e(luc_tablesize());
    ?>
</font></td>
			</tr>
			<tr>
				<td><font size="1"><b>StatPress Visitors current time</b></font></td>
				<td><font size="1"><?php 
    _e(current_time('mysql'));
    ?>
</font></td>
			</tr>
			<tr>
				<td><font size="1"><b>RSS2 URL</b></font></td>
				<td><font size="1"><?php 
    _e(get_bloginfo('rss2_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('rss2_url')) . ")");
    ?>
</font></td>
			</tr>
			<tr>
				<td><font size="1"><b>ATOM URL</b></font></td>
				<td><font size="1"><?php 
    _e(get_bloginfo('atom_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('atom_url')) . ")");
    ?>
</font></td>
			</tr>
			<tr>
				<td><font size="1"><b>RSS URL</b></font></td>
				<td><font size="1"><?php 
    _e(get_bloginfo('rss_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('rss_url')) . ")");
    ?>
</font></td>
			</tr>
			<tr>
				<td><font size="1"><b>RSS2 Comments URL</b></font></td>
				<td><font size="1"><?php 
    _e(get_bloginfo('comments_rss2_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('comments_rss2_url')) . ")");
    ?>
</font></td>
			</tr>
			<tr>
				<td><font size="1"><b>ATOM Comments URL</b></font></td>
				<td><font size="1"><?php 
    _e(get_bloginfo('comments_atom_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('comments_atom_url')) . ")");
    ?>
</font></td>
			</tr>
		</tbody>
	</table>
	<?php 
    _e(luc_StatPressV_load_time($start));
    ?>
	</div>
	<?php 
}