コード例 #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();
}
コード例 #2
0
ファイル: luc_admin.php プロジェクト: dtekcth/dns
function luc_print_pp_pa_link($NP, $pp, $action, $NA, $pa)
{
    if ($NP != 0) {
        luc_print_pp_link($NP, $pp, $action);
    }
    // For all pages ($NP) display first 5 pages, 3 pages before current page($pa), 3 pages after current page , 3 last pages
    $GUIL1 = FALSE;
    // suspension points not writed
    $GUIL2 = FALSE;
    echo '<table width="100%" border="0"><tr></tr></table>';
    if ($NA > 1) {
        echo "<div class='tablenav-pages'>";
        echo "<font size='2'>Pages: </font>";
        for ($j = 1; $j <= $NA; $j++) {
            if ($j <= $NA) {
                if ($j == $pa) {
                    // $i is current page
                    echo " [{$j}] ";
                } else {
                    // Not the current page Hyperlink them
                    if ($j <= 5 or $j >= $pa - 2 and $j <= $pa + 2 or $j >= $NA - 2) {
                        echo '<a class="pagin" href="' . admin_url() . 'admin.php?page=statpress-visitors/action=' . $action . '&pp=' . $pp . '&pa=' . $j . '">' . $j . '</a> ';
                    } else {
                        if ($GUIL1 == FALSE) {
                            echo "... ";
                        }
                        $GUIL1 = TRUE;
                        if ($j == $pa + 4 and $GUIL2 == FALSE) {
                            echo " ... ";
                            $GUIL2 = TRUE;
                        }
                        // suspension points writed
                    }
                }
            }
        }
        echo "</div>";
    }
}