Файл: o5on.ru/html/stat.php
Строк: 650
<?php
if (!defined('_SAPE_USER')){
define('_SAPE_USER', '40e09a759bfada62896caa2b0b7aa652');
}
require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/sape.php');
$sape = new SAPE_client();
?>
<?php
include '../inc/config.inc.php';
include '../inc/wap_tags.inc.php';
include '../inc/functions.inc.php';
connect_to_db();
include "config.php";
// ------------------------------ вывод статистики пользователя ---------------------
//проверка ввода id
if (empty($_GET['uid'])) exit;
$uid=dig((int)$_GET['uid']);
// проверка существования учетной записи
$result = mysql_query("SELECT `site_name`,`link`,`admin`,`info` FROM `users` WHERE `uid`=".$uid.";");
$row=mysql_fetch_array($result);
if (empty($row)) exit;
//проверка ввода action
if (empty($_GET['act'])) $act = "";
else $act = $_GET['act'];
$site_name = htmlspecialchars($row['site_name']);
$link = $row['link'];
$admin = htmlspecialchars($row['admin']);
$info = htmlspecialchars($row['info']);
// прелог
include './inc/head.php';
$week_day = date("w");
$today = date("Ymd");
$downtoday = mktime(0, 0, 0, date("Y") , date("m"), date("d")-1);
// за сегодня
$result = mysql_query("SELECT `host` FROM `weeks` WHERE `uid`=$uid AND `date`=$today LIMIT 1;");
$row = mysql_fetch_array($result);
$host_today = $row['host'];
// за вчера
// $result = mysql_query("SELECT `host` FROM `weeks` WHERE `uid`=$uid AND `date`=$downtoday LIMIT 1;");
// $row = mysql_fetch_array($result);
// $host_downtoday = $row['host'];
//----------------------- Место в топе---------------------------
$result = mysql_query("SELECT * FROM `weeks` WHERE `host` >= ".$host_today." AND `date`=".$today." ORDER BY `host` DESC;");
$top_place = @mysql_num_rows($result);
$page = ceil($top_place/$count_top);
$act = latin($act);
switch ($act)
{
case 'operators':
echo "<a href="/html/outtop/".$uid."/">".str_replace("http://", "", $link)."</a> - Статистика по операторам<br /><br />n";
//print "<a href="charts/oper.php?uid=" . $uid . "">oper.php</a><br /><br />n";
#######################
print "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width=555 height=200 id='charts' align=''>n";
print "<param name='movie' value='/html/charts/charts.swf?library_path=/html/charts/charts_library&xml_source=/html/charts/oper.php%3Fttt%3D".time()."%26uid%3D".$uid."' />n";
print "<param name='quality' value='high' />n";
print "<param name='bgcolor' value='#e5bffa' />n";
print "<embed src='/html/charts/charts.swf?library_path=/html/charts/charts_library&xml_source=/html/charts/oper.php%3Fttt%3D".time()."%26uid%3D".$uid."' quality='high' bgcolor='#b9d4fd' width='100%' height='200' name='charts' aling='' swLiveConnect='true' tipe='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>n";
print "</embed>n";
print "</object><br /><br />n";
#######################
print "<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td background="/xhtml/site.gif">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#000000">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="4"><tr background="/xhtml/tit.gif" align="center">n";
print " <td width="50%" style="color:#ffffff" nowrap><b>Оператор</b></td>n";
print " <td width="50%" style="color:#ffffff"><b>Доля, %</b></td>n";
print "</tr>n";
$result = mysql_query("
SELECT `top_operators`.`name`, `top_operators`.`label`, `top_operators_stat`.`count`
FROM `top_operators_stat`
LEFT JOIN `top_operators`
ON `top_operators`.`id` = `top_operators_stat`.`id_operator`
WHERE `date` = $today AND `day_week` = $week_day AND `uid` = $uid
ORDER BY `top_operators_stat`.`count` DESC
");
$oper_array = array();
$summ = 0;
if (mysql_num_rows($result))
{
while ($row = mysql_fetch_assoc($result))
{
$oper_array[] = $row;
$summ += $row['count'];
}
}
//echo "<b>Статистика по операторам:</b> <br/>n";
foreach ($oper_array AS $position => $row)
{
$vvv = $vvv+1;
$celoe = $vvv/2;
$psps = split(".", $celoe);
if($psps[1] == 5){
echo "<tr background="/xhtml/site.gif">n";
}else{
echo "<tr background="/xhtml/sit.gif">n";
}
echo ((empty($row['name']))? '<td>Другие</td>' : "<td>".$row['name']."</td>").' <td>'.(round($row['count']/$summ*10000)/100).'%</td>';
print "</tr>n";
}
print "</td></tr></table>n";
print "</td></tr></table>n";
print "</td></tr></table>n";
// навигация
//echo "<a href='stat.php?act=telinfo&uid=$uid'>Статистика по маркам телефонов</a> <br/>n";
break;
case "telinfo":
$tel = array(
"Siemens",
"Nokia",
"Samsung",
"Motorola",
"LG",
"Sagem",
"SonyEricsson",
"Alcatel",
"Sharp",
"Pantech",
"Panasonic",
"Другие"
);
// подсчет когад браузер не отределен
$result = mysql_query("SELECT `Siemens`,`Nokia`,`Samsung`,`Motorola`,`LG`,`Sagem`,`SonyEricsson`,`Alcatel`,`Sharp`,`Pantech`,`Panasonic`,`Other` FROM `weeks` WHERE `date`=$today AND `day_week`=$week_day AND `uid`=$uid LIMIT 1");
$tel_data = mysql_fetch_row($result);
if (empty($tel_data)) $tel_data = array (0,0,0,0,0,0,0,0,0,0,0,0);
$hour = date("H");
echo "<a href="/html/outtop/".$uid."/">".str_replace("http://", "", $link)."</a> - Статистика модели телефонов<br /><br />n";
//print "<a href="charts/oper.php?uid=" . $uid . "">oper.php</a><br /><br />n";
#######################
print "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width=555 height=200 id='charts' align=''>n";
print "<param name='movie' value='/html/charts/charts.swf?library_path=/html/charts/charts_library&xml_source=/html/charts/model.php%3Fttt%3D".time()."%26uid%3D".$uid."' />n";
print "<param name='quality' value='high' />n";
print "<param name='bgcolor' value='#b9d4fd' />n";
print "<embed src='/html/charts/charts.swf?library_path=/html/charts/charts_library&xml_source=/html/charts/model.php%3Fttt%3D".time()."%26uid%3D".$uid."' quality='high' bgcolor='#b9d4fd' width='100%' height='200' name='charts' aling='' swLiveConnect='true' tipe='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>n";
print "</embed>n";
print "</object><br /><br />n";
#######################
print "<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#000000">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#000000">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="4"><tr background="/xhtml/tit.gif" align="center">n";
print " <td width="50%" style="color:#ffffff" nowrap><b>Модель тедефона</b></td>n";
print " <td width="50%" style="color:#ffffff"><b>Посещаемость (хиты)</b></td>n";
print "</tr>n";
//echo "<tr><td><img src="graphic_24.php?uid=$uid" alt="tel_models" /></td><td><img src="graphic_tel.php?uid=$uid" alt="tel_models" /></td> </tr>n";
foreach ($tel_data as $index => $value)
{
$vvv = $vvv+1;
$celoe = $vvv/2;
$psps = split(".", $celoe);
if($psps[1] == 5){
echo "<tr background="/xhtml/site.gif">n";
}else{
echo "<tr background="/xhtml/sit.gif">n";
}
print "<td>".$tel[$index]."</td>n";
print "<td>".$value."</td>n";
print "</tr>n";
}
print "</td></tr></table>n";
print "</td></tr></table>n";
print "</td></tr></table>n";
break;
//
//По дням
//
case "day":
echo "<a href="/html/outtop/".$uid."/">".str_replace("http://", "", $link)."</a> - Статистика за 30 дней<br /><br />n";
//print "<a href="charts/day.php?uid=".$uid."">day.php</a><br /><br />n";
#######################
print "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width=555 height=200 id='charts' align=''>n";
print "<param name='movie' value='/html/charts/charts.swf?timeout=200&library_path=/html/charts/charts_library&xml_source=/html/charts/day.php%3Fttt%3D".time()."%26uid%3D".$uid."' />n";
print "<param name='quality' value='high' />n";
print "<param name='bgcolor' value='#b9d4fd' />n";
print "<embed src='/html/charts/charts.swf?timeout=200&library_path=/html/charts/charts_library&xml_source=/html/charts/day.php%3Fttt%3D".time()."%26uid%3D".$uid."' quality='high' bgcolor='#b9d4fd' width='100%' height='200' name='charts' aling='' swLiveConnect='true' tipe='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>n";
print "</embed>n";
print "</object><br /><br />n";
#######################
print "Посещаемость по дням, ". date('j.m.Y') ." - ". date("j.m.Y",mktime(date("H"),date("i"),date("s"),date("m"),date("d")-29,date("Y"))) ."n";
print "<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#000000">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#000000">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="4"><tr background="/xhtml/tit.gif" align="center">n";
print " <td rowspan="2" width="25%" style="color:#ffffff" nowrap><b>Дата</b></td>n";
print " <td colspan="2" width="25%" style="color:#ffffff"><b>Посещаемость</b></td>n";
print "</tr>n";
print "<tr background="/xhtml/tit.gif" align="center">n";
print " <td width="12%" style="color:#ffffff"><b>Хосты</b></td>n";
print " <td width="12%" style="color:#ffffff"><b>Хиты</b></td>n";
print "</tr>n";
$result = mysql_query("SELECT * FROM `weeks` where `uid`='".$uid."' ORDER BY `id` DESC LIMIT 30;");
$stat1 = array();
$stat2 = array();
$stat3 = array();
while(false!==$fetch=mysql_fetch_array($result)){
$stat1[(int)$fetch['date']] = $fetch['host'];
$stat2[(int)$fetch['date']] = $fetch['count'];
$stat3[(int)$fetch['date']] = $fetch['date'];
}
//print $stat3;
for($i=0; $i < 30; $i++){
$vvv = $vvv+1;
$celoe = $vvv/2;
$psps = split(".", $celoe);
if($psps[1] == 5){
echo "<tr background="/xhtml/site.gif">n";
}else{
echo "<tr background="/xhtml/sit.gif">n";
}
$er = date("Ymd",mktime(date("H"),date("i"),date("s"),date("m"),date("d")-$i,date("Y")));
$err = date("Y.m.d",mktime(date("H"),date("i"),date("s"),date("m"),date("d")-$i,date("Y")));
if(!empty($stat3[$er])){
$stat3[$er] = str_replace(date("Y"),date("Y").".",$stat3[$er]);
$stat3[$er] = str_replace(".".date("m"),".".date("m").".",$stat3[$er]);
}
echo "<td>".(isset($stat3[$er])?$stat3[$er]:$err)."</td>n";
echo "<td>".(isset($stat1[$er])?$stat1[$er]:'-')."</td>n";
echo "<td>".(isset($stat2[$er])?$stat2[$er]:'-')."</td>n";
$host_al = $host_al + (int)$stat1[$er];
$count_al = $count_al + (int)$stat2[$er];
$dddd = $dddd+1;
echo "</tr>n";
}
echo "<tr background="/xhtml/tit.gif"><td style="color:#fffff">Всего:</td><td style="color:#ffffff">".$host_al."</td><td style="color:#ffffff">".$count_al."</td></tr> n";
$hour_24 = split(".", ($host_al/$dddd));
$count_24 = split(".", ($count_al/$dddd));
echo "<tr background="/xhtml/tit.gif"><td style="color:#ffffff">В среднем за день:</td><td style="color:#ffffff">".$hour_24[0]."</td><td style="color:#ffffff">".$count_24[0]."</td></tr> n";
print "</td></tr></table>n";
print "</td></tr></table>n";
print "</td></tr></table>n";
break;
//По часам
case "hour":
echo "<a href="/html/outtop/".$uid."/">".str_replace("http://", "", $link)."</a> - Статистика по часам<br /><br />n";
print "График посещаемости по часам, ". date('j.m.Y') ."<br />n";
#######################
print "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width=555 height=200 id='charts' align=''>n";
print "<param name='movie' value='/html/charts/charts.swf?library_path=/html/charts/charts_library&xml_source=/html/charts/hour.php%3Fttt%3D".time()."%26uid%3D".$uid."' />n";
print "<param name='quality' value='high' />n";
print "<param name='bgcolor' value='#b9d4fd' />n";
print "<embed src='/html/charts/charts.swf?library_path=/html/charts/charts_library&xml_source=/html/charts/hour.php%3Fttt%3D".time()."%26uid%3D".$uid."' quality='high' bgcolor='#b9d4fd' width='100%' height='200' name='charts' aling='' swLiveConnect='true' tipe='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>n";
print "</embed>n";
print "</object><br /><br />n";
#######################
print "Таблица посещаемости по часам, ". date('j.m.Y') ."<br />n";
print "<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#000000">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#000000">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="4"><tr background="/xhtml/tit.gif" align="center">n";
print " <td rowspan="2" width="25%" style="color:#ffffff" nowrap><b>Часы</b></td>n";
print " <td colspan="2" width="25%" style="color:#ffffff"><b>Посещаемость</b></td>n";
print "</tr>n";
print "<tr background="/xhtml/tit.gif" align="center">n";
print " <td width="12%" style="color:#ffffff"><b>Хосты</b></td>n";
print " <td width="12%" style="color:#ffffff"><b>Хиты</b></td>n";
print "</tr>n";
$result = mysql_query("SELECT * FROM `count_24` where `uid`=".$uid." and `date`=".$today." ORDER BY `id` DESC;");
$stat1 = array();
$stat2 = array();
while(false!==$fetch=mysql_fetch_array($result)){
$stat1[(int)$fetch['hour']] = $fetch['host'];
$stat2[(int)$fetch['hour']] = $fetch['count'];
}
for($i=0; $i < 24; $i++){
$vvv = $vvv+1;
$celoe = $vvv/2;
$psps = split(".", $celoe);
if($psps[1] == 5){
echo "<tr background="/xhtml/site.gif">n";
}else{
echo "<tr background="/xhtml/sit.gif">n";
}
echo "<td>".$i.":00 - ".($i<23?$i+1:0).":00 </td>n";
if($stat1[$i] != ''){
echo "<td>".$stat1[$i]."</td>n";
}else{
echo "<td> - </td>n";
}
if($stat2[$i] != ''){
echo "<td>".$stat2[$i]."</td>n";
}else{
echo "<td> - </td>n";
}
echo "</tr>n";
$host_al = $host_al + (int)$stat1[$i];
$count_al = $count_al + (int)$stat2[$i];
}
echo "<tr background="/xhtml/tit.gif"><td style="color:#ffffff">Всего:</td><td style="color:#ffffff">".(int)$host_al."</td><td style="color:#ffffff">".(int)$count_al."</td></tr> n";
$hour_24 = split(".", ($host_al/$vvv));
$count_24 = split(".", ($count_al/$vvv));
echo "<tr background="/xhtml/tit.gif"><td style="color:#fffff">В среднем за час:</td><td style="color:#ffffff">".(int)$hour_24[0]."</td><td style="color:#ffffff">".(int)$count_24[0]."</td></tr> n";
print "</td></tr></table>n";
print "</td></tr></table>n";
print "</td></tr></table>n";
break;
default:
// ======================== Статистика участника ======================
$hour = date("H");
$downtoday = date("Ymd",time()-86400);
// за сегодня
$result=mysql_query("SELECT `count`,`host` FROM `weeks` WHERE `uid`=$uid AND `date`=$today LIMIT 1;");
$row = mysql_fetch_array($result);
$count_today = (int)$row['count'];
$host_today = (int)$row['host'];
// за вчера
$result=mysql_query("SELECT `count`,`host` FROM `weeks` WHERE `uid`=$uid AND `date`=$downtoday LIMIT 1;");
$row = mysql_fetch_array($result);
$count_downtoday = (int)$row['count'];
$host_downtoday = (int)$row['host'];
// за 24 часа
$result = mysql_query("SELECT sum(`count`),sum(`host`) FROM `count_24` WHERE ((`date`=".$today."-1 AND `hour`>".$hour.") OR (`date`=".$today." AND `hour`<=".$hour.")) AND `uid`=$uid");
$row = mysql_fetch_row($result);
$count_24 = (int)$row[0];
$host_24 = (int)$row[1];
// данные за текущий час
$result = mysql_query("SELECT `count`,`host` FROM `count_24` WHERE `hour`=".$hour." AND `date`=".$today." AND `uid`=".$uid."");
$row=mysql_fetch_row($result);
// поверка наличия записи в базе
if (empty($row))
{
$hour_count = 0;
$hour_host = 0;
}else{
$hour_count = (int)$row[0];
$hour_host = (int)$row[1];
}
// ---------------------------- посещения за месяц --------------------
$months = array("Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь");
$today = date("Ym");
$index_month = date("m")-1;
// данные за текущий месяц
$result = mysql_query("SELECT `count`,`host` FROM `months` WHERE `date`=".$today." AND `uid`=".$uid.";");
$row=mysql_fetch_row($result);
// поверка наличия записи в базе
if (empty($row[0]))
{
$this_month_count = 0;
$this_month_host = 0;
}else{
$this_month_count = (int)$row[0];
$this_month_host = (int)$row[1];
}
//-------------------------- недельная статистика----------------
$week_day = date("w");
$today = date("Ymd");
// посещений за неделю
$day7 = date("Ymd",(time()-604800));
$result = mysql_query("SELECT sum(count),sum(host) FROM `weeks` WHERE `date`>".$day7." AND `uid`=".$uid."");
$row=mysql_fetch_row($result);
$total_week_count = (int)$row[0];
$total_week_host = (int)$row[1];
// ------------------------ онлайн------------------------
// подсчитываем онлайн посетителей
//$result = mysql_query("SELECT count(ip) FROM online_ip WHERE `uid`=".$uid."");
//$row=mysql_fetch_row($result);
//$online=(int)$row[0];
// -----------------------Всего---------------------------
$result = mysql_query("SELECT sum(count),sum(host) FROM `months` WHERE `uid`=".$uid.";");
$row=mysql_fetch_row($result);
$all_hits = (int)$row[0];
$all_hosts = (int)$row[1];
// -----------------------Пришло Ушло сегодня---------------------------
$week_day = date("w");
$today = date("Ymd");
$counts_in_out = mysql_query("SELECT `in`,`out` FROM `weeks` WHERE `date`=".$today." AND `day_week`=".$week_day." AND `uid`=".$uid." LIMIT 1");
$count_row=mysql_fetch_array($counts_in_out);
$in_count = (int)$count_row['in'];
$out_count = (int)$count_row['out'];
// -----------------------Пришло Ушло вчера---------------------------
$counts_in_out_downtoday = mysql_query("SELECT `in`,`out` FROM `weeks` WHERE `date`=".$downtoday." AND `uid`=".$uid." LIMIT 1");
$count_row_downtoday=mysql_fetch_array($counts_in_out_downtoday);
$in_count_downtoday = (int)$count_row_downtoday['in'];
$out_count_downtoday = (int)$count_row_downtoday['out'];
// -----------------------Пришло Ушло за 7 дней---------------------------
$day7 = date("Ymd",(time()-604800));
$counts_in_out_day7 = mysql_query("SELECT `in`,`out` FROM `weeks` WHERE `date`>".$day7." AND `uid`=".$uid."");
while($count_row_day7=mysql_fetch_array($counts_in_out_day7)){
$total_week_count_in = $total_week_count_in + ((int)$count_row_day7['in']);
$total_week_host_out = $total_week_host_out + ((int)$count_row_day7['out']);
}
echo "<a href="/html/outtop/".$uid."/">".str_replace("http://", "", $link)."</a> - Статистика<br /><br />n";
print "<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td background="/xhtml/tit.gif">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td background="/xhtml/tit.gif">n";
print "<table width="100%" border="0" cellspacing="1" cellpadding="4">n";
print " <tr background="/xhtml/sit.gif">n";
print " <td width="25%">Показатель</td>n";
print " <td width="15%">Сегодня</td>n";
print " <td width="15%">Вчера</td>n";
print " <td width="15%">За 7 дней</td>n";
print " <td width="15%">За 30 дней</td>n";
print " <td width="15%">Всего</td>n";
print " </tr>n";
print " <tr background="/xhtml/site.gif">n";
print " <td>Хосты</td>n";
print " <td>".$host_today."</td>n";
print " <td>".$host_downtoday."</td>n";
print " <td>".$total_week_host."</td>n";
print " <td>".$this_month_host."</td>n";
print " <td>".$all_hosts."</td>n";
print " </tr>n";
print " <tr background="/xhtml/sit.gif">n";
print " <td>Хиты</td>n";
print " <td>".$count_today."</td>n";
print " <td>".$count_downtoday."</td>n";
print " <td>".$total_week_count."</td>n";
print " <td>".$this_month_count."</td>n";
print " <td>".$all_hits."</td>n";
print " </tr>n";
print " <tr background="/xhtml/site.gif">n";
print " <td>Переходов из рейтинга на сайт</td>n";
print " <td>".(($out_count*2)+$in_count)."</td>n";
print " <td>".(($out_count_downtoday*2)+$in_count_downtoday)."</td>n";
print " <td>".(($total_week_host_out*2)+$total_week_count_in)."</td>n";
print " <td>-</td>n";
print " <td>-</td>n";
print " </tr>n";
print " <tr background="/xhtml/sit.gif">n";
print " <td>Переходов с сайта на рейтинг</td>n";
print " <td>".$in_count."</td>n";
print " <td>".$in_count_downtoday."</td>n";
print " <td>".$total_week_count_in."</td>n";
print " <td>-</td>n";
print " <td>-</td>n";
print " </tr>n";
print "</table>n";
print "</td></tr></table>n";
print "</td></tr></table>n";
}
include "./inc/foot.php";
echo $sape->return_links(5);
ob_end_flush();
?>