Просмотр файла click_club/stats.php

Размер файла: 2.92Kb
<?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";
include "header/enter.inc.php";
include "header/ban.php";

@mysql_query("update `".prefix."users` set `mesto`='В статистике по кликам' where `id` = '".$_USER['id']."'");

$q = ''; $q2=''; $q3='';
$z = 'stats.php'.$_zapros;
$fs_from = 0; 

if(isset($_GET['year']) && ctype_digit($_GET['year']) && $_GET['year']>2000 && $_GET['year']<2015)
$q = " AND YEAR(`ts`)=".$_GET['year']." ";
else
{
	echo '<div class="header_rek"><b>Общая статистика</b></div>';
	if(!isset($_GET['today'])) 	echo  '<a href="index.php?mode=r_day">'."Лучшие сегодня</a><br/>";
	echo "Выберите год: ";
	$fs_years = mysql_query("SELECT DISTINCT(YEAR(`ts`)) as 'y' FROM `cclub_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 "Статистика за <b>".$_GET['year']." год</b> <br/> Выберите месяц: ";
	$fs_years = mysql_query("SELECT DISTINCT(MONTH(`ts`)) as 'y' FROM `cclub_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'].'&amp;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 "Статистика за <b>".$_GET['month'].".".$_GET['year']."</b> <br/> Выберите день: ";
	$fs_years = mysql_query("SELECT DISTINCT(DAYOFMONTH(`ts`)) as 'y' FROM `cclub_stats` WHERE YEAR(`ts`)=".mysql_escape_string($_GET['year']) ." AND MONTH(`ts`)=".mysql_escape_string($_GET['month'])."  ORDER BY `ts`");
		while( $fs_year = mysql_fetch_assoc($fs_years) ) 
			echo '<a href="'.$z.'year='.$_GET['year'].'&amp;month='.$_GET['month'].'&amp;day='.$fs_year['y'].'">'.$fs_year['y'].'</a> ';
}

if($q3!="") echo "Статистика за <b>".$_GET['day'].".".$_GET['month'].".".$_GET['year']."</b> ";

if(isset($_GET['today'])) 

$fs_query = mysql_query("SELECT *,COUNT(`cn`) AS cn FROM `".prefix."stats` 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 30"); 

echo '<br/><div class="contur_rek"><b>Top '.mysql_num_rows($fs_query).':</b></div>';

echo mysql_error();
$fs_i = 0;
while( $fs_user = mysql_fetch_assoc($fs_query) )
	{	$fs_i++;	echo '<b>'.$fs_i.'</b>. '.$fs_user['who'].'  <b>['.$fs_user['cn'].']</b><br/>';		}

include "header/end.inc.php";
?>