s.php
by webproger on 2020-03-25
<?php
include $_SERVER['DOCUMENT_ROOT'].'/i/i.php';
if($_SERVER['REMOTE_ADDR']!=$v_ip) {
    header("Location: http://qindex.info/q.php");
    exit();
}
if(!$_GET['d']) $_GET['d'] = 'qindex.info';
if(!$_GET['n']) $_GET['n'] = 'r';
if(!$_GET['t']) $_GET['t'] = 60*60*24;
if(!$_GET['b']) $_GET['b'] = 0;
?>
<!DOCTYPE html><html><head>
    <title>stats</title>
    <meta name='viewport' content='width=device-width,initial-scale=1.0'>
    <script src='/i/j.php'></script>
    <link rel='stylesheet' href='/i/c.css'>
    <style type='text/css'>
        body {
            padding:15px;
        }
        body,table {
            font-size:0.9em;
        }
        td { padding:3px; border:1px solid silver; font-family:courier new; }
        .cb { font-weight:bold; }
        .ct { text-align:right; }
        .cg { background-color:whitesmoke; }
    </style>
    <script>
        function change(n,v) {
            location.href = jif.nw(n,v);
        }
    </script>
</head><body>
<?php
echo "\n<table><tr><td colspan='2'>";
$ln = 34;
$ad = array('kallery.net','ood.or.kr','qindex.info','spigon.com');
$an = array('referrer','land','relation','page','country');
$av = array('r','l','rl','p','c');
for($i=0; $i<count($ad); $i++) {
    echo "\n<input type='radio' name='d' value='".$ad[$i]."'";
    if($_GET['d']==$ad[$i]) echo " checked='checked'";
    else echo " onclick=\"change('d',this.value);\"";
    echo ">".$ad[$i]."<br>";
}
echo "</td><td>";
for($i=0; $i<count($av); $i++) {
    echo "\n<input type='radio' name='n' value='".$av[$i]."'";
    if($_GET['n']==$av[$i]) echo " checked='checked'";
    else echo " onclick=\"change('n',this.value);\"";
    echo ">".$an[$i]."<br>";
}
echo "</td><td>";
?>
<input type='radio' name='b' value='0'<?php
    if($_GET['b']==0) echo " checked='checked'"; ?>
    onclick="change('b',this.value);">human<br>
<input type='radio' name='b' value='1'<?php
    if($_GET['b']==1) echo " checked='checked'"; ?>
    onclick="change('b',this.value);">robot<br>
<?php
echo "\n</td></tr></table>";

echo "\n<table>";
$st = "SELECT *,COUNT(*) AS c FROM sts WHERE dm='".$_GET['d']."' AND tm>".(time()-$_GET['t']);
if($_GET['b']) $st .= " AND bt=1"; else $st .= " AND bt=0";
$tl = " GROUP BY vl ORDER BY c DESC LIMIT 100";
if($_GET['n']=='r') {
    echo "\n<tr><td class='cb'>referrer</td><td class='cb'>count</td></tr>";
    $r = mysql_query($st." AND nm='r'".$tl,$d_link);
    while($a=mysql_fetch_array($r)) {
        echo "\n<tr>";
        echo "\n<td><a href='".$a['vl']."' target='_blank'>".mb_substr($a['vl'],0,$ln,'UTF-8')."</a></td>";
        echo "\n<td class='ct'>".$a['c']."</td>";
        echo "\n</tr>";
    }
} elseif($_GET['n']=='l') {
    echo "\n<tr><td class='cb'>landing page</td><td class='cb'>count</td></tr>";
    $r = mysql_query($st." AND nm='l'".$tl,$d_link);
    while($a=mysql_fetch_array($r)) {
        $u = 'http://'.$_GET['d'].$a['vl'];
        echo "\n<tr>";
        echo "\n<td><a href='".$u."' target='_blank'>".mb_substr($a['vl'],0,$ln,'UTF-8')."</a></td>";
        echo "\n<td class='ct'>".$a['c']."</td>";
        echo "\n</tr>";
    }
} elseif($_GET['n']=='rl') {
    $r = mysql_query("SELECT * FROM sts WHERE dm='".$_GET['d']."' AND tm>".(time()-$_GET['t'])." AND nm='l' ORDER BY tm DESC LIMIT 50",$d_link);
    while($a=mysql_fetch_array($r)) {
        $b = Q_select('sts','*','dm',$a['dm'],'ip',$a['ip'],'tm',$a['tm'],'nm','r');
        if(trim($b['vl'])) {
            echo "\n<tr>";
            echo "\n<td class='cg'><a href='".$b['vl']."' target='_blank'>".mb_substr($b['vl'],0,$ln+6,'UTF-8')."</a></td>";
            echo "\n</tr>";
        } else {
            echo "\n<tr><td class='cg'>&nbsp;</td></tr>";
        }
        $u = 'http://'.$_GET['d'].$a['vl'];
        echo "\n<tr>";
        echo "\n<td><a href='".$u."' target='_blank'>".mb_substr($a['vl'],0,$ln+6,'UTF-8')."</a></td>";
        echo "\n</tr>";
    }
} elseif($_GET['n']=='p') {
    echo "\n<tr><td class='cb'>page</td><td class='cb'>count</td></tr>";
    $r = mysql_query($st." AND (nm='l' OR nm='p')".$tl,$d_link);
    while($a=mysql_fetch_array($r)) {
        $u = 'http://'.$_GET['d'].$a['vl'];
        echo "\n<tr>";
        echo "\n<td><a href='".$u."' target='_blank'>".mb_substr($a['vl'],0,$ln,'UTF-8')."</a></td>";
        echo "\n<td class='ct'>".$a['c']."</td>";
        echo "\n</tr>";
    }
    $r = mysql_query("SELECT COUNT(*) AS c FROM sts WHERE dm='".$_GET['d']."' AND tm>".(time()-$_GET['t'])." AND (nm='l' OR nm='p')",$d_link);
    $a = mysql_fetch_array($r);
    echo "\n<tr><td>&nbsp;</td><td class='ct'><b>".$a['c']."</b></td></tr>";
} elseif($_GET['n']=='c') {
    echo "\n<tr><td class='cb'>country</td><td class='cb'>count</td></tr>";
    $r = mysql_query($st." AND nm='c'".$tl,$d_link);
    $n = 0;
    while($a=mysql_fetch_array($r)) {
        echo "\n<tr><td>".$a['vl']."</td><td class='ct'>".$a['c']."</td></tr>";
        $n += $a['c'];
    }
    echo "\n<tr><td>&nbsp;</td><td class='ct'><b>".$n."</b></td></tr>";
}
?>
</table><br></body></html>