Вход Регистрация
Файл: o5on.ru/html/stats.php
Строк: 615
<?php
include '../inc/config.inc.php';
include 
'../inc/wap_tags.inc.php';
include 
'../inc/functions.inc.php';

connect_to_db();


    include 
"config.php";

            
// ------------------------------ вывод статистики пользователя ---------------------



            //проверка  ввода 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(000date("Y")  , date("m"), date("d")-1);
    
// за сегодня
    
$result     mysql_query("SELECT sum(`host`) FROM `weeks` WHERE `date`=".$today.";");
    
$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="outtop.php?uid=$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='charts/charts.swf?library_path=charts/charts_library&xml_source=charts/oper.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='charts/charts.swf?library_path=charts/charts_library&xml_source=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 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";

        
$result mysql_query("
            SELECT `top_operators`.`name`, `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` != 1
            ORDER BY `top_operators_stat`.`count` DESC
        "
);
        
$oper_array = array();
        
$summ        0;
        if (
mysql_num_rows($result))
        {
            while (
$row mysql_fetch_assoc($result))
            {
        
//print_r ($row);
                
$oper_array[]     = $row;
                
$summ             += $row['count'];
//echo $summ;
            
}
        }
        
//print_r ($oper_array);
        //printf ($row);
        //echo $row;
        //echo "<b>Статистика по операторам:</b> <br/>n";
        
foreach ($oper_array AS $position => $row)
        {
           
print_r ($row);
           echo 
"<br />n";
           
//echo "$row[name]=>$row[count] <br />";
                        /*
                            $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";


        break;
        case 
"telinfo":
            
$tel = array(
                
"Siemens",
                
"Nokia",
                
"Samsung",
                
"Motorola",
                
"LG",
                
"Sagem",
                
"SonyEricsson",
                
"Alcatel",
                
"Sharp",
                
"Pantech",
                
"Panasonic",
                
"Другие"
            
);
            
// подсчет когад браузер не отределен
            
$result mysql_query("SELECT sum(`Siemens`),sum(`Nokia`),sum(`Samsung`),sum(`Motorola`),sum(`LG`),sum(`Sagem`),sum(`SonyEricsson`),sum(`Alcatel`),sum(`Sharp`),sum(`Pantech`),sum(`Panasonic`),sum(`Other`) FROM `weeks` WHERE `date`=".$today." AND `day_week`=".$week_day." AND `uid`!=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");
#######################
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='charts/charts.swf?library_path=charts/charts_library&xml_source=charts/models.php%3Fttt%3D".time()."' />n";
print 
"<param name='quality' value='high' />n";
print 
"<param name='bgcolor' value='#b9d4fd' />n";
print 
"<embed src='charts/charts.swf?library_path=charts/charts_library&xml_source=charts/models.php%3Fttt%3D".time()."' 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":
print 
"График посещаемости за 30 дней, "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='charts/charts.swf?timeout=200&library_path=charts/charts_library&xml_source=charts/days.php%3Fttt%3D".time()."' />n";
print 
"<param name='quality' value='high' />n";
print 
"<param name='bgcolor' value='#b9d4fd' />n";
print 
"<embed src='charts/charts.swf?timeout=200&library_path=charts/charts_library&xml_source=charts/days.php%3Fttt%3D".time()."' 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'time()-3600*24*30) ."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";

for (
$i=0$i <= 30$i++) {
    
$iii $i*86400;
    
$today date("Ymd"time()-$iii);
    
$result mysql_query("SELECT sum(`host`), sum(`count`) FROM `weeks` WHERE `uid`!='1' AND `date`='".$today."' ORDER BY `id` DESC;");
    
$fetch_row=mysql_fetch_row($result);

        
$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";
        }
    
$erer date("Y.m.d",mktime(date("H"),date("i"),date("s"),date("m"),date("d")-$i,date("Y")));
    echo 
"<td>".$erer."</td>n";

    if(
$fetch_row[0] != ''){
    echo 
"<td>".$fetch_row[0]."</td>n";
    }else{
    echo 
"<td> - </td>n";
    }

    if(
$fetch_row[1] != ''){
    echo 
"<td>".$fetch_row[1]."</td>n";
    }else{
    echo 
"<td> - </td>n";
    }
    echo 
"</tr>n";

$host_al $host_al+$fetch_row[0];
$count_al $count_al $fetch_row[1];
$dddd $dddd+1;
}
echo 
"<tr background="/xhtml/tit.gif"><td style="color:#ffffff">Всего:</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":

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='charts/charts.swf?library_path=charts/charts_library&xml_source=charts/hours.php%3Fttt%3D".time()."' />n";
print 
"<param name='quality' value='high' />n";
print 
"<param name='bgcolor' value='#ebcefd' />n";
print 
"<embed src='charts/charts.swf?library_path=charts/charts_library&xml_source=charts/hours.php%3Fttt%3D".time()."' 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";

$zend=24;
for (
$i=0$i <= 23$i++) {
    
$result mysql_query("SELECT sum(`count`),sum(`host`)  FROM `count_24` WHERE `uid`!=1 AND `date`=".$today." AND `hour` = ".$i.";");
    
$fetch_row=mysql_fetch_row($result);

        
$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";
        }

    
$ii $ii 1;
    if(
$ii 23)$ii 0;
    echo 
"<td>".$i.":00 - ".$ii.":00</td>n";
    if(
$fetch_row[1] != ''){
    echo 
"<td>".$fetch_row[1]."</td>n";
    }else{
    echo 
"<td> - </td>n";
    }

    if(
$fetch_row[0] != ''){
    echo 
"<td>".$fetch_row[0]."</td>n";
    }else{
    echo 
"<td> - </td>n";
    }
    echo 
"</tr>n";

$host_al $host_al+$fetch_row[1];
$count_al $count_al $fetch_row[0];
$dddd $dddd+1;
}

echo 
"<tr background="/xhtml/tit.gif"><td style="color:#ffffff">Всего:</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;

        default:
        
// ======================== Статистика участника ======================
            
$hour date("H");
            
$downtoday  date("Ymd",time()-86400);

            
// за сегодня
            
$result=mysql_query("SELECT sum(`count`),sum(`host`) FROM `weeks` WHERE `date`=".$today." AND `uid` != '1';");
            
$row mysql_fetch_row($result);
            
$count_today = (int)$row[0];
            
$host_today = (int)$row[1];
            
// за вчера
            
$result=mysql_query("SELECT sum(`count`),sum(`host`) FROM `weeks` WHERE `date`=".$downtoday." AND `uid` != '1';");
            
$row mysql_fetch_row($result);
            
$count_downtoday = (int)$row[0];
            
$host_downtoday = (int)$row[1];
            
// за 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` != '1';");
            
$row mysql_fetch_row($result);
            
$count_24 = (int)$row[0];
            
$host_24 = (int)$row[1];
            
// данные за текущий час
            
$result mysql_query("SELECT sum(`count`),sum(`host`) FROM `count_24` WHERE `hour`=".$hour." AND `date`=".$today." AND `uid` != '1';");
            
$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 sum(`count`),sum(`host`) FROM `months` WHERE `date`=".$today." AND `uid` != '1';");
            
$result mysql_query("SELECT sum(`count`),sum(`host`) FROM `weeks` WHERE `uid` != '1';");
            
$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");
            
// посещений за mecyac
            
$day7  date("Ymd",(time()-604800));
            
$result mysql_query("SELECT sum(count),sum(host) FROM `weeks` WHERE `date`>".$day7." AND `uid` != '1';");
            
$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` != '1';");
            
$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 sum(`in`),sum(`out`) FROM `weeks` WHERE `date`=".$today." AND `day_week`=".$week_day." AND `uid` != '1';");
            
$count_row=mysql_fetch_row($counts_in_out);
            
$in_count = (int)$count_row[0];
            
$out_count = (int)$count_row[1];
            
// -----------------------Пришло  Ушло вчера---------------------------
            
$counts_in_out_downtoday mysql_query("SELECT sum(`in`),sum(`out`) FROM `weeks` WHERE `date`=".$downtoday." AND `uid` != '1';");
            
$count_row_downtoday=mysql_fetch_row($counts_in_out_downtoday);
            
$in_count_downtoday = (int)$count_row_downtoday[0];
            
$out_count_downtoday = (int)$count_row_downtoday[1];
            
// -----------------------Пришло  Ушло за 7 дней---------------------------
            
$day7  date("Ymd",(time()-604800));
            
$counts_in_out_day7 mysql_query("SELECT sum(`in`),sum(`out`) FROM `weeks` WHERE `date`>".$day7." AND `uid` != '1';");
            
$count_row_day7=mysql_fetch_row($counts_in_out_day7);
            
$total_week_count_in = (int)$count_row_day7[0];
            
$total_week_host_out = (int)$count_row_day7[1];
            
//}

echo "Глобальная статистика рейтинга<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/site.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/sit.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/site.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/sit.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/site.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";

ob_end_flush();

?>
Онлайн: 0
Реклама