View file top-elena/top.php

File size: 15.71Kb
<?php
Error_Reporting(E_ALL & ~E_NOTICE);
header ("Content-type:text/vnd.wap.wml; charset=utf-8");

header("Pragma: no-cache");
@include "config.php";

//&#x43F;&#x440;&#x43E;&#x432;&#x435;&#x440;&#x43A;&#x430;  &#x432;&#x432;&#x43E;&#x434;&#x430; page
if (empty($_GET['p'])) $page = 1;
else $page=$_GET['p'];

if (empty($_GET['uid'])) $action = "";
else $action="view";

switch ($action) {
	case "view":
		// ------------------------------ &#x432;&#x44B;&#x432;&#x43E;&#x434; &#x441;&#x442;&#x430;&#x442;&#x438;&#x441;&#x442;&#x438;&#x43A;&#x438; &#x43F;&#x43E;&#x43B;&#x44C;&#x437;&#x43E;&#x432;&#x430;&#x442;&#x435;&#x43B;&#x44F; ---------------------
		//&#x43F;&#x440;&#x43E;&#x432;&#x435;&#x440;&#x43A;&#x430;  &#x432;&#x432;&#x43E;&#x434;&#x430; id
		if (empty($_GET['uid'])) exit;
		$uid=(int)$_GET['uid'];
		
		// &#x43F;&#x440;&#x43E;&#x432;&#x435;&#x440;&#x43A;&#x430; &#x441;&#x443;&#x449;&#x435;&#x441;&#x442;&#x432;&#x43E;&#x432;&#x430;&#x43D;&#x438;&#x44F; &#x443;&#x447;&#x435;&#x442;&#x43D;&#x43E;&#x439; &#x437;&#x430;&#x43F;&#x438;&#x441;&#x438;
		$result = mysql_query("SELECT site_name,link FROM users WHERE uid=$uid");
		$row=mysql_fetch_row($result);
		if (empty($row[0])) exit;
		
		$site = $row[0];
		$link = $row[1];
		
 $today = date("Ymd", time()+3600);
		$hour = date("H");

		// &#x437;&#x430; &#x441;&#x435;&#x433;&#x43E;&#x434;&#x43D;&#x44F;
		$result = mysql_query("SELECT sum(count),sum(host) FROM count_24 WHERE date=$today AND uid=$uid");
		$row = mysql_fetch_row($result);
		$count_today = (int)$row[0];
		$host_today = (int)$row[1];
		// &#x437;&#x430; 24 &#x447;&#x430;&#x441;&#x430;
		$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];
		// &#x434;&#x430;&#x43D;&#x43D;&#x44B;&#x435; &#x437;&#x430; &#x442;&#x435;&#x43A;&#x443;&#x449;&#x438;&#x439; &#x447;&#x430;&#x441;
		$result = mysql_query("SELECT count,host FROM count_24 WHERE hour=$hour AND date=$today AND uid=$uid");
		$row=mysql_fetch_row($result);
		// &#x43F;&#x43E;&#x432;&#x435;&#x440;&#x43A;&#x430; &#x43D;&#x430;&#x43B;&#x438;&#x447;&#x438;&#x44F; &#x437;&#x430;&#x43F;&#x438;&#x441;&#x438; &#x432; &#x431;&#x430;&#x437;&#x435;
		if (empty($row[0]))
		{
			$hour_count = 0;
			$hour_host = 0;
		}else{
			$hour_count = (int)$row[0];
			$hour_host = (int)$row[1];
		}
		// ---------------------------- &#x43F;&#x43E;&#x441;&#x435;&#x449;&#x435;&#x43D;&#x438;&#x44F; &#x437;&#x430; &#x43C;&#x435;&#x441;&#x44F;&#x446; --------------------
		$months = array("&#x42F;&#x43D;&#x432;&#x430;&#x440;&#x44C;","&#x424;&#x435;&#x432;&#x440;&#x430;&#x43B;&#x44C;","&#x41C;&#x430;&#x440;&#x442;","&#x410;&#x43F;&#x440;&#x435;&#x43B;&#x44C;","&#x41C;&#x430;&#x439;","&#x418;&#x44E;&#x43D;&#x44C;","&#x418;&#x44E;&#x43B;&#x44C;","&#x410;&#x432;&#x433;&#x443;&#x441;&#x442;","&#x421;&#x435;&#x43D;&#x442;&#x44F;&#x431;&#x440;&#x44C;","&#x41E;&#x43A;&#x442;&#x44F;&#x431;&#x440;&#x44C;","&#x41D;&#x43E;&#x44F;&#x431;&#x440;&#x44C;","&#x414;&#x435;&#x43A;&#x430;&#x431;&#x440;&#x44C;");
		$today = date("Ym");
		$index_month = date("m")-1;
		// &#x434;&#x430;&#x43D;&#x43D;&#x44B;&#x435; &#x437;&#x430; &#x442;&#x435;&#x43A;&#x443;&#x449;&#x438;&#x439; &#x43C;&#x435;&#x441;&#x44F;&#x446;
		$result = mysql_query("SELECT count,host FROM months WHERE date=$today AND uid=$uid");
		$row=mysql_fetch_row($result);
		// &#x43F;&#x43E;&#x432;&#x435;&#x440;&#x43A;&#x430; &#x43D;&#x430;&#x43B;&#x438;&#x447;&#x438;&#x44F; &#x437;&#x430;&#x43F;&#x438;&#x441;&#x438; &#x432; &#x431;&#x430;&#x437;&#x435;
		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];
			}
		//-------------------------- &#x43D;&#x435;&#x434;&#x435;&#x43B;&#x44C;&#x43D;&#x430;&#x44F; &#x441;&#x442;&#x430;&#x442;&#x438;&#x441;&#x442;&#x438;&#x43A;&#x430;----------------
		$week_day = date("w");
        $today = date("Ymd", time()+3600);
		// &#x43F;&#x43E;&#x441;&#x435;&#x449;&#x435;&#x43D;&#x438;&#x439; &#x437;&#x430; &#x43D;&#x435;&#x434;&#x435;&#x43B;&#x44E;
		$result = mysql_query("SELECT sum(count),sum(host) FROM weeks WHERE uid=$uid");
		$row=mysql_fetch_row($result);
		$total_week_count = (int)$row[0];
		$total_week_host = (int)$row[1];

		// ------------------------ &#x43E;&#x43D;&#x43B;&#x430;&#x439;&#x43D;------------------------
		// &#x43F;&#x43E;&#x434;&#x441;&#x447;&#x438;&#x442;&#x44B;&#x432;&#x430;&#x435;&#x43C; &#x43E;&#x43D;&#x43B;&#x430;&#x439;&#x43D; &#x43F;&#x43E;&#x441;&#x435;&#x442;&#x438;&#x442;&#x435;&#x43B;&#x435;&#x439;
		$result = mysql_query("SELECT count(ip) FROM online_ip WHERE uid=$uid");
		$row=mysql_fetch_row($result);
		$online=(int)$row[0];
		
		// -----------------------&#x412;&#x441;&#x435;&#x433;&#x43E;---------------------------
		$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];
		//----------------------- &#x41C;&#x435;&#x441;&#x442;&#x43E; &#x432; &#x442;&#x43E;&#x43F;&#x435;---------------------------
		$result=mysql_query("SELECT count(*) FROM weeks WHERE host >= $host_today and date=$today ORDER BY host DESC");
		$row=mysql_fetch_row($result);
		$top_place = (int)$row[0];
		//
		$user_data = mysql_query("SELECT date FROM users WHERE uid=$uid");
		$user_data_row = mysql_fetch_array($user_data);
	    $date_reg = date("d.m.y",$user_data_row['date']);
        /*
		-----------------------------------------------------------------
		$top_place - &#x43C;&#x435;&#x441;&#x442;&#x43E; &#x432; &#x442;&#x43E;&#x43F;&#x435;
		$count_today - &#x445;&#x438;&#x442;&#x43E;&#x432; &#x441;&#x435;&#x433;&#x43E;&#x434;&#x43D;&#x44F;
		$host_today - &#x445;&#x43E;&#x441;&#x442;&#x43E;&#x432; &#x441;&#x435;&#x433;&#x43E;&#x434;&#x43D;&#x44F;
		$count_24 - &#x445;&#x438;&#x442;&#x43E;&#x432; &#x437;&#x430; 24 &#x447;&#x430;&#x441;&#x430;
		$host_24 - &#x445;&#x43E;&#x441;&#x442;&#x43E;&#x432; &#x437;&#x430; 24 &#x447;&#x430;&#x441;&#x430;
		$hour_count - &#x445;&#x438;&#x442;&#x43E;&#x432; &#x437;&#x430; &#x44D;&#x442;&#x43E;&#x442; &#x447;&#x430;&#x441;
		$hour_host - &#x445;&#x43E;&#x441;&#x442;&#x43E;&#x432; &#x437;&#x430; &#x44D;&#x442;&#x43E;&#x442; &#x447;&#x430;&#x441;
		$this_month_count - &#x445;&#x438;&#x442;&#x43E;&#x432; &#x437;&#x430; &#x44D;&#x442;&#x43E;&#x442; &#x43C;&#x435;&#x441;&#x44F;&#x446;
		$this_month_host - &#x445;&#x43E;&#x441;&#x442;&#x43E;&#x432; &#x437;&#x430; &#x44D;&#x442;&#x43E;&#x442; &#x43C;&#x435;&#x441;&#x44F;&#x446;
		$total_week_count - &#x445;&#x438;&#x442;&#x43E;&#x432; &#x437;&#x430; &#x44D;&#x442;&#x443; &#x43D;&#x435;&#x434;&#x435;&#x43B;&#x44E;
		$total_week_host - &#x445;&#x43E;&#x441;&#x442;&#x43E;&#x432; &#x437;&#x430; &#x44D;&#x442;&#x443; &#x43D;&#x435;&#x434;&#x435;&#x43B;&#x44E;
		$online - &#x43E;&#x43D;&#x43B;&#x430;&#x439;&#x43D; &#x43F;&#x43E;&#x441;&#x435;&#x442;&#x438;&#x442;&#x435;&#x43B;&#x435;&#x439;
		$all_hits - &#x432;&#x441;&#x435;&#x433;&#x43E; &#x445;&#x438;&#x442;&#x43E;&#x432;
		$all_hosts - &#x432;&#x441;&#x435;&#x433;&#x43E; &#x445;&#x43E;&#x441;&#x442;&#x43E;&#x432;
		-----------------------------------------------------------------
		*/
		$page=ceil($top_place/$count_top);
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
        echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
        echo "<wml><card title=\"&#x421;&#x442;&#x430;&#x442;&#x438;&#x441;&#x442;&#x438;&#x43A;&#x430;\"><p>";


		echo "<b><a href=\"$link\">$site</a></b><br/>";
		echo "&#x421;&#x442;&#x430;&#x442;&#x438;&#x441;&#x442;&#x438;&#x43A;&#x430; &#x443;&#x447;&#x430;&#x441;&#x442;&#x43D;&#x438;&#x43A;&#x430; &#x422;&#x41E;&#x41F;&#x430;<br/>";

		

		echo "<b>&#x421;&#x435;&#x433;&#x43E;&#x434;&#x43D;&#x44F;</b><br/> &#x425;&#x43E;&#x441;&#x442;&#x43E;&#x432; $host_today<br/> &#x425;&#x438;&#x442;&#x43E;&#x432; $count_today\n
			 <br/> <b>&#x417;&#x430; &#x44D;&#x442;&#x43E;&#x442; &#x447;&#x430;&#x441;</b><br/>  &#x425;&#x43E;&#x441;&#x442;&#x43E;&#x432; $hour_host<br/> &#x425;&#x438;&#x442;&#x43E;&#x432; $hour_count\n
			 <br/> <b>&#x417;&#x430; &#x43D;&#x435;&#x434;&#x435;&#x43B;&#x44E;</b><br/> &#x425;&#x43E;&#x441;&#x442;&#x43E;&#x432; $total_week_host<br/> &#x425;&#x438;&#x442;&#x43E;&#x432; $total_week_count\n
			 <br/> <b>&#x412; &#x44D;&#x442;&#x43E;&#x43C; &#x43C;&#x435;&#x441;&#x44F;&#x446;&#x435; (".$months[$index_month].")</b><br/>&#x425;&#x43E;&#x441;&#x442;&#x43E;&#x432; $this_month_host<br/> &#x425;&#x438;&#x442;&#x43E;&#x432; $this_month_count \n
			 <br/> <b>&#x412;&#x441;&#x435;&#x433;&#x43E; &#x441; &#x43C;&#x43E;&#x43C;&#x435;&#x43D;&#x442;&#x430; &#x440;&#x435;&#x433;&#x438;&#x441;&#x442;&#x440;&#x430;&#x446;&#x438;&#x438; ($date_reg)</b><br/> &#x425;&#x43E;&#x441;&#x442;&#x43E;&#x432; $all_hosts<br/> &#x425;&#x438;&#x442;&#x43E;&#x432; $all_hits \n
			 <br/> &#x421;&#x435;&#x439;&#x447;&#x430;&#x441; &#x43D;&#x430; &#x441;&#x430;&#x439;&#x442;&#x435; &#x43D;&#x430;&#x445;&#x43E;&#x434;&#x438;&#x442;&#x441;&#x44F; $online &#x43F;&#x43E;&#x441;&#x435;&#x442;&#x438;&#x442;&#x435;&#x43B;&#x435;&#x439;. 
			 <br/> &#x41C;&#x435;&#x441;&#x442;&#x43E; &#x432; &#x422;&#x41E;&#x41F;&#x435;: $top_place  ";

			echo "<br/><b>&#x413;&#x440;&#x430;&#x444;&#x438;&#x43A; &#x437;&#x430; &#x43D;&#x435;&#x434;&#x435;&#x43B;&#x44E;</b><br/>";
			echo "<img src=\"graphic_7.php?uid=$uid\" alt=\"&#x43D;&#x435;&#x434;&#x435;&#x43B;&#x44F;\" /> <br/>";
			echo "<b>&#x413;&#x440;&#x430;&#x444;&#x438;&#x43A; &#x437;&#x430; 24 &#x447;&#x430;&#x441;&#x430;</b><br/>";
			echo "<img src=\"graphic_24.php?uid=$uid\" alt=\"24 &#x447;&#x430;&#x441;&#x430;\" /> <br/>";
			echo "\n";

  			echo "<a href=\"24.php?uid=$uid&amp;page=1\">&#x423;&#x43D;&#x438;&#x43A;&#x430;&#x43B;&#x44C;&#x43D;&#x44B;&#x435; &#x43F;&#x43E;&#x441;&#x435;&#x442;&#x438;&#x442;&#x435;&#x43B;&#x438;</a><br/>";
			$time=date("H");
			if ($time >=23) {
			echo "&#x421;&#x43C;&#x43E;&#x442;&#x440;&#x435;&#x442;&#x44C; &#x422;&#x41E;&#x41F; &#x441; &#x43D;&#x430;&#x447;&#x430;&#x43B;&#x430;<br/>
			&#x421;&#x43C;&#x43E;&#x442;&#x440;&#x435;&#x442;&#x44C; &#x422;&#x41E;&#x41F; &#x441; &#x43F;&#x43E;&#x437;&#x438;&#x446;&#x438;&#x438; &#x441;&#x430;&#x439;&#x442;&#x430;<br/>";
			     } 
			else {
			echo "<a href=\"top.php\">&#x421;&#x43C;&#x43E;&#x442;&#x440;&#x435;&#x442;&#x44C; &#x422;&#x41E;&#x41F; &#x441; &#x43D;&#x430;&#x447;&#x430;&#x43B;&#x430;</a><br/>";
			echo "<a href=\"top.php?p=$page\">&#x421;&#x43C;&#x43E;&#x442;&#x440;&#x435;&#x442;&#x44C; &#x422;&#x41E;&#x41F; &#x441; &#x43F;&#x43E;&#x437;&#x438;&#x446;&#x438;&#x438; &#x441;&#x430;&#x439;&#x442;&#x430;</a><br/>";
                }
			echo "<a href=\"help/help.wml\">FAQ</a><br/>\n";
			echo "<a href=\"admin.php\">&#x41F;&#x440;&#x43E;&#x444;&#x438;&#x43B;&#x44C;</a><br/>";
			echo "<a href=\"registration.php\">&#x420;&#x435;&#x433;&#x438;&#x441;&#x442;&#x440;&#x430;&#x446;&#x438;&#x44F;</a><br/>\n";
			echo "<a href=\"http://elena.nsk.ru\">elena.nsk.ru</a>\n";

		echo "</p></card></wml>\n";

		break;
	default:
        echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
        echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
        echo "<wml><card title=\"&#x420;&#x435;&#x439;&#x442;&#x438;&#x43D;&#x433;\"><p>";


	
		//and date=$today ------------------------------ &#x422;&#x41E;&#x41F; &#x432;&#x441;&#x435;&#x445; &#x443;&#x447;&#x430;&#x441;&#x442;&#x43D;&#x438;&#x43A;&#x43E;&#x432; -------------------------------
 $today = date("Ymd", time()+3600);
		$start=$count_top*($page-1);
		$end=$count_top;
		
		// &#x43F;&#x43E;&#x43B;&#x443;&#x447;&#x430;&#x435;&#x43C; &#x43A;&#x43E;&#x43B; &#x432;&#x43E; &#x443;&#x447;&#x430;&#x441;&#x442;&#x43D;&#x438;&#x43A;&#x43E;&#x432;
		$result=mysql_query("SELECT count(uid) FROM weeks WHERE host > 0 and date=$today");
		$cntData=mysql_fetch_row($result);
		$count_users=$cntData[0];
		// &#x43F;&#x43E;&#x43B;&#x443;&#x447;&#x430;&#x435;&#x43C; uid &#x443;&#x447;&#x430;&#x441;&#x442;&#x43D;&#x438;&#x43A;&#x43E;&#x432; 
		$result=mysql_query("SELECT DISTINCT uid,count,host FROM weeks WHERE host > 0 and date=$today ORDER BY host DESC LIMIT $start,$end");
		$count_users_on_page = mysql_num_rows($result);
		$r=mysql_query("SELECT * FROM users");
		echo "&#x421;&#x435;&#x433;&#x43E;&#x434;&#x43D;&#x44F; &#x432; &#x440;&#x435;&#x439;&#x442;&#x438;&#x43D;&#x433;&#x435; &#x443;&#x447;&#x430;&#x441;&#x442;&#x432;&#x443;&#x44E;&#x442; $count_users &#x438;&#x437; ".mysql_num_rows($r)."<br/>\n";
		echo "&#x41F;&#x43E;&#x43A;&#x430;&#x437;&#x430;&#x43D;&#x44B; &#x43C;&#x435;&#x441;&#x442;&#x430; &#x441; ".($start+1)."&#x43F;&#x43E;  ".($start+$count_top)."<br/>\n";
		for($i = 0;$i < $count_users_on_page;$i++)
		{
				$row = mysql_fetch_array($result);
				$uid = $row['uid'];
				$hits = $row['count'];
				$hosts = $row['host'];
				// &#x434;&#x430;&#x43D;&#x43D;&#x44B;&#x435; &#x443;&#x447;&#x430;&#x441;&#x442;&#x43D;&#x438;&#x43A;&#x430;
				$user_data = mysql_query("SELECT site_name,link,admin,info,date FROM users WHERE uid=$uid");
				$user_data_row = mysql_fetch_array($user_data);
				$site_name = $user_data_row['site_name'];
				$link = $user_data_row['link'];
				$admin = $user_data_row['admin'];
				$info = $user_data_row['info'];
				$date_reg = date("d.m.Y",$user_data_row['date']);
				// -----------------------&#x412;&#x441;&#x435;&#x433;&#x43E;---------------------------
				$res_count = mysql_query("SELECT sum(count),sum(host) FROM months WHERE uid=$uid");
				$count_row=mysql_fetch_row($res_count);
				$all_hits = (int)$count_row[0];
				$all_hosts = (int)$count_row[1];
				//
                $today = date("Ymd", time()+3600);
		        $hour = date("H");
				$resultt = mysql_query("SELECT sum(count),sum(host) FROM count_24 WHERE date=$today AND uid=$uid");
				$roww = mysql_fetch_row($resultt);
				$count_today = (int)$roww[0];
				$host_today = (int)$roww[1];

					echo "<b>".(($i+1)+($count_top*($page-1))).". $site_name <a href=\"top.php?uid=$uid\">*</a></b><br/>\n";

					echo "&#x41E;&#x43F;&#x438;&#x441;&#x430;&#x43D;&#x438;&#x435;:<br/>".$info."<br/>\n";
					echo "<a href=\"$link\">$link</a><br/>\n";
					echo "&#x410;&#x434;&#x43C;&#x438;&#x43D;: $admin<br/>\n";
					echo "&#x414;&#x430;&#x442;&#x430; &#x440;&#x435;&#x433;&#x438;&#x441;&#x442;&#x440;&#x430;&#x446;&#x438;&#x438;: $date_reg <br/>\n";
					echo "&#x421;&#x435;&#x433;&#x43E;&#x434;&#x43D;&#x44F; &#x445;&#x438;&#x442;&#x43E;&#x432;: $count_today<br/>\n";
					echo "&#x421;&#x435;&#x433;&#x43E;&#x434;&#x43D;&#x44F; &#x445;&#x43E;&#x441;&#x442;&#x43E;&#x432;: $host_today<br/>\n";
					echo "&#x412;&#x441;&#x435;&#x433;&#x43E; &#x445;&#x438;&#x442;&#x43E;&#x432;: $all_hits<br/>\n";
					echo "&#x412;&#x441;&#x435;&#x433;&#x43E; &#x445;&#x43E;&#x441;&#x442;&#x43E;&#x432;: $all_hosts<br/><br/>\n";

		}
		//Page control

			if ($page>1){
				$prev=$page-1;
				echo "<a href='top.php?p=$prev'>&#x41F;&#x440;&#x435;&#x434;.</a> ";
			}
			else echo "&#x41F;&#x440;&#x435;&#x434;.";
			echo " | ";
			if (!($end*$page>=$count_users)){
				$next=$page+1;
				echo "<a href='top.php?p=$next'>&#x421;&#x43B;&#x435;&#x434;.</a>";
			}
			else echo "&#x421;&#x43B;&#x435;&#x434;.";

			echo "<br/><a href=\"help/help.wml\">FAQ</a><br/>\n";
			echo "<a href=\"admin.php\">&#x41F;&#x440;&#x43E;&#x444;&#x438;&#x43B;&#x44C;</a><br/>";
			echo "<a href=\"registration.php\">&#x420;&#x435;&#x433;&#x438;&#x441;&#x442;&#x440;&#x430;&#x446;&#x438;&#x44F;</a><br/>\n";
			echo "<a href=\"http://elena.nsk.ru\">elena.nsk.ru</a>\n";

		echo "</p></card></wml>";

}
?>