File size: 3.23Kb
<?php
include "header/config.inc.php";
include "header/function.inc.php";
include "header/header.inc.php";
include "header/connect.inc.php";
include "header/click-club.class.php";
$q = ''; $q1 = ''; $q2=''; $q3='';
$z = 'stats.php?';
$fs_from = 0;
$fs_to = 0;
if(isset($_GET['year']) && ctype_digit($_GET['year']) && $_GET['year']>2000 && $_GET['year']<2015)
$q = " AND YEAR(`ts`)=".$_GET['year']." ";
else
{
echo "Общая статистика. <br/> ";
if(!isset($_GET['today'])) echo '<a href="'.$z.'today">'."Просмотр статистики за сегодня.</a><br/> ";
echo "Выберите год: ";
$fs_years = mysql_query("SELECT DISTINCT(YEAR(`ts`)) as 'y' FROM `wpcc_stats` ORDER BY `ts`");
while( $fs_year = mysql_fetch_assoc($fs_years) )
echo '<a href="'.$z.'year='.$fs_year['y'].'">'.$fs_year['y'].'</a> ';
}
if(isset($_GET['month']) && ctype_digit($_GET['month']) && $_GET['month']>0 && $_GET['month']<13 && $q!="")
{ $q .= " AND MONTH(`ts`)=".$_GET['month']." "; $q2=' '; }
elseif($q!="")
{
echo "Статистика за ".$_GET['year']." год. <br/> Выберите месяц: ";
$fs_years = mysql_query("SELECT DISTINCT(MONTH(`ts`)) as 'y' FROM `wpcc_stats` WHERE YEAR(`ts`)=".mysql_escape_string($_GET['year'])." ORDER BY `ts`");
while( $fs_year = mysql_fetch_assoc($fs_years) )
echo '<a href="'.$z.'year='.$_GET['year'].'&month='.$fs_year['y'].'">'.$fs_year['y'].'</a> ';
}
if(isset($_GET['day']) && ctype_digit($_GET['day']) && $_GET['day']>0 && $_GET['day']<32 && $q!="" && $q2!="")
{ $q .= " AND DAYOFMONTH(`ts`)=".$_GET['day']." "; $q3 = " ";}
elseif($q2!="")
{
echo "Статистика за ".$_GET['month'].".".$_GET['year'].". <br/> Выберите день: ";
$fs_years = mysql_query("SELECT DISTINCT(DAYOFMONTH(`ts`)) as 'y' FROM `wpcc_stats` WHERE YEAR(`ts`)=".mysql_escape_string($_GET['year']) ." AND MONTH(`ts`)=".mysql_escape_string($_GET['month'])." ORDER BY `ts`");
#echo '1';
while( $fs_year = mysql_fetch_assoc($fs_years) )
echo '<a href="'.$z.'year='.$_GET['year'].'&month='.$_GET['month'].'&day='.$fs_year['y'].'">'.$fs_year['y'].'</a> ';
}
if($q3!="") echo "Статистика за ".$_GET['day'].".".$_GET['month'].".".$_GET['year'].". ";
/*
if($q=="") { $fs_from = $_USER['cfrom']; $fs_to = $_USER['cto']; }
else
{
$fs_query = mysql_query("SELECT `cn` FROM `".prefix."stats` WHERE 1 ".$q." AND `to`='".$_USER['login']."'");
$fs_to = mysql_result($fs_query,0,0);
$fs_query = mysql_query("SELECT `cn` FROM `".prefix."stats` WHERE 1 ".$q." AND `who`='".$_USER['login']."'");
$fs_from = mysql_result($fs_query,0,0);
}
echo '<br/><br/>
Ваших переходов всего: '.$fs_from.'<br/>
Всего переходов по вашей ссылке: '.$fs_to.'<br/><br/>';*/
#echo "SELECT *,SUM(`cn`) AS sum FROM `".prefix."stats` WHERE 1 ".$q." GROUP BY `who` ORDER BY sum DESC ";
if(isset($_GET['today']))
$fs_query = mysql_query("SELECT `who`,COUNT(*) AS cn FROM `".prefix."clicks` WHERE `ts`=CURDATE() GROUP BY `who` ORDER BY cn DESC LIMIT 50");
else
$fs_query = mysql_query("SELECT *,SUM(`cn`) AS cn FROM `".prefix."stats` WHERE 1 ".$q.
" GROUP BY `who` ORDER BY cn DESC LIMIT 50");
echo '<br/><br/>Top '.mysql_num_rows($fs_query).':<br/>';
echo mysql_error();
$fs_i = 0;
while( $fs_user = mysql_fetch_assoc($fs_query) )
{ $fs_i++; echo $fs_i.'. '.$fs_user['who'].' ['.$fs_user['cn'].']<br/>'; }
include "header/end.inc.php";
?>