View file public_html/vipadz/stats.php

File size: 5.46Kb
<?php

/************************************

Script : Adnetwork
Website : http://facebook.com/pranto007

Script is created and provided by Pranto (http://facebook.com/pranto007)
**************************************/

include '../db.php';
include '../functions.php';

headtag("$SiteName - Stats");

if($adminlog==1){

$date=date("d-m-Y");
$month=date("m-Y");
$monthly=date("F"); 
$yesterday=date("d-m-Y", time()-86400);

$total_clicks=mysql_fetch_array(mysql_query("SELECT count(id) FROM clicks"));
$total_clicks=$total_clicks[0];

$month_clicks=mysql_fetch_array(mysql_query("SELECT count(id) FROM clicks WHERE month='$month'"));
$month_clicks=$month_clicks[0];

$yesterday_clicks=mysql_fetch_array(mysql_query("SELECT count(id) FROM clicks WHERE time='$yesterday'"));
$yesterday_clicks=$yesterday_clicks[0];

$today_clicks=mysql_fetch_array(mysql_query("SELECT count(id) FROM clicks WHERE time='$date'"));
$today_clicks=$today_clicks[0];

$paid = mysql_query("SELECT SUM(earned) FROM clicks")or die("Oopss ! Contact EarnBuzz".mysql_error());
$paid2 = mysql_fetch_array($paid);
$pay = $paid2["SUM(earned)"];
$tearn = $pay;
$a=$tearn;
$pos=strpos($a,'.');
$totalearn=substr($a,0,$pos+4);

$paid = mysql_query("SELECT SUM(earned) FROM clicks WHERE month='$month'")or die("Oopss ! Contact EarnBuzz".mysql_error());
$paid2 = mysql_fetch_array($paid);
$pay = $paid2["SUM(earned)"];
$mearn = $pay;
$a=$mearn;
$pos=strpos($a,'.');
$monthearn=substr($a,0,$pos+4);

$paid = mysql_query("SELECT SUM(earned) FROM clicks WHERE time='$yesterday'")or die("Oopss ! Contact EarnBuzz".mysql_error());
$paid2 = mysql_fetch_array($paid);
$pay = $paid2["SUM(earned)"];
$dearn = $pay;
$a=$dearn;
$pos=strpos($a,'.');
$yesterdayearn=substr($a,0,$pos+4);

$paid = mysql_query("SELECT SUM(earned) FROM clicks WHERE time='$date'")or die("Oopss ! Contact EarnBuzz".mysql_error());
$paid2 = mysql_fetch_array($paid);
$pay = $paid2["SUM(earned)"];
$dearn = $pay;
$a=$dearn;
$pos=strpos($a,'.');
$todayearn=substr($a,0,$pos+4);


echo '<div class="title">Statistics</div>';
echo '<div class="form" align="center"><table><tr><td><div class="ad" style="padding:5px;margin:5px;"><div style="background:#ececec;padding:2px;margin:2px;" align="center"><b>Total:</b></div><div class="ad" style="padding:3.5px">Total Clicks: '.$total_clicks.'<br/>Total Earnings: '.$totalearn.'$</div></td>

<td><div class="ad" style="padding:5px;margin:5px;"><div style="background:#ececec;padding:2px;margin:2px;" align="center"><b>'.$monthly.':</b></div><div class="ad" style="padding:3.5px">'.$monthly.' Clicks: '.$month_clicks.'<br/>'.$monthly.' Earnings: '.$monthearn.'$</div></td>

<td><div class="ad" style="padding:5px;margin:5px;"><div style="background:#ececec;padding:2px;margin:2px;" align="center"><b>Yesterday:</b></div><div class="ad" style="padding:3.5px">Yesterday Clicks: '.$yesterday_clicks.'<br/>Yesterday Earnings: '.$yesterdayearn.'$</div></td>

<td><div class="ad" style="padding:5px;margin:5px;"><div style="background:#ececec;padding:2px;margin:2px;" align="center"><b>Today:</b></div><div class="ad" style="padding:3.5px">Today Clicks: '.$today_clicks.'<br/>Today Earnings: '.$todayearn.'$</div></td></tr></table></div>';

echo '<div class="title">Statistic Report</div>';

// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);

// how many rows to show per page
$rowsPerPage = 50;
// by default we show first page
$pageNum = 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
    $pageNum = $_GET['page'];
}

// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;

$sql = " SELECT country,time,ip,ua,os,host,status,siteid FROM clicks ORDER BY id DESC" . 
         " LIMIT $offset, $rowsPerPage ";
$result=mysql_query($sql);


echo '<div class="form"><table style="border-collapse: collapse;" align="center">
<tr>
<th class="tbl2">Date</th>
<th class="tbl2">IP</th>
<th class="tbl2">User-Agent</th>
<th class="tbl2">OS</th>
<th class="tbl2">Country</th>
<th class="tbl2">From</th>
<th class="tbl2">Status</th>
<th class="tbl2">Site</th>
</tr>';

while($rows=mysql_fetch_array($result)){ // Start looping table row
if(empty($rows["country"])) 
{
$country='Unknown';
}
else
{
$country=$rows["country"];
}
  echo '<tr>
<td class="tbl">'.$rows["time"].'</td>
<td class="tbl">'.$rows["ip"].'</td>
<td class="tbl">'.strstr(urldecode($rows["ua"]),'(',true).'</td>
<td class="tbl">'.$rows["os"].'</td>
<td class="tbl">'.$country.'</td>
<td class="tbl"><a href="'.$rows["host"].'">'.strstr(str_replace('http://',null,$rows["host"]),'/',true).'</a></td>
<td class="tbl">'.$rows["status"].'</td>
<td class="tbl"><a href="site.php?id='.$rows["siteid"].'">'.$rows["siteid"].'</a></td>
</tr>';


}

echo '



</table></div>';

if ($pageNum > 1)
{
   $page  = $pageNum - 1;
   $prev  = " || <a href=\"$self?page=$page\">Prev</a> || ";

   $first = " <a href=\"$self?page=1\">First Page</a> ";
}

else
{
   $prev  = '&nbsp;'; // we're on page one, don't print previous link
   $first = '&nbsp;'; // nor the first page link
}

if ($pageNum < 1000)
{
   $page = $pageNum + 1;
   $next = " <a href=\"$self?page=$page\">Next</a> ";

   $last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
   $next = '&nbsp;'; // we're on the last page, don't print next link
   $last = '&nbsp;'; // nor the last page link
}

// print the navigation link
echo '<div class="ad">'.$first.' '.$prev.' '.$nav.' '.$next.'</div>';
mysql_close();

echo '<a href="index.php"><div class="ua">HOME</div></a>';
include '../foot.php';
}
else{
header('Location:index.php');
}
?>