Файл: o5on.ru/xhtml/index.php
Строк: 121
<?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';
ob_start('make_page');
// ---------------------------------------------------------------
connect_to_db();
// ---------------------------------------------------------------
include "config.php";
// проверка ввода page
if (empty($_GET['p']))
$page = 1;
else
$page = dig($_GET['p']);
// проверка ввода id
if (!empty($_GET['uid'])) {
$uid = dig((int)$_GET['uid']);
// проверка существования учетной записи
$result = mysql_query("SELECT `site_name`,`link`,`admin`,`info`,`cat_id` FROM `users` WHERE `uid`=".$uid.";");
$row = mysql_fetch_array($result);
if (!empty($row)) {
$cat_id = $row[4];
// ====================== пришло
$week_day = date("w");
$today = date("Ymd");
// подсчет
$result = mysql_query("SELECT `in` FROM `weeks` WHERE `date`=".$today." AND `uid`=".$uid." LIMIT 1;");
$row = mysql_fetch_array($result);
if (empty($row)) {
$nextMonday=date("Ymd",mktime(0,0,0,date("m"),date("d")+32));
@mysql_query("INSERT INTO `weeks` VALUES ('',".$uid.",".$nextMonday.",".$today.",".$week_day.",0,0,0,0,".$cat_id.");");
$in_count = 0;
} else {
$in_count = $row['in'];
}
$in_count++;
// сохранение
@mysql_query("UPDATE `weeks` SET `in`=".$in_count.",`cat_id`=".$cat_id." WHERE `date`=".$today." AND `uid`=".$uid." LIMIT 1;");
$today = date("Ymd");
$hour = date("H");
// за сегодня
$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 * 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);
if ($page <= 0) $page = 1;
}
}
// прелог
include './inc/head.php';
if(empty($_GET["day"])){
$today = date("Ymd");
$doday = date("Ymd",mktime(date("H"),date("i"),date("s"),date("m"),date("d")-1,date("Y")));
}else{
$doday = date("Ymd",mktime(date("H"),date("i"),date("s"),date("m"),date("d")-2,date("Y")));
$today=date("Ymd",mktime(date("H"),date("i"),date("s"),date("m"),date("d")-1,date("Y")));}
// получаем uid участников
$cid = dig((int)$_GET['cid']);
if($cat_id == 3 && empty($_GET['cid']))$cid = 3;
if($cat_id == 4 && empty($_GET['cid']))$cid = 4;
if (($cid == "")or($cid == "0"))
{
$cat_name = "ТОП-100";
$result = mysql_query("SELECT count(`uid`) FROM `weeks` WHERE `host` > 0 AND `date`=".$today." AND `uid` != '1' AND `cat_id` != '3' AND `cat_id` != '4';"); //Изменил из-за сообщения в госте
$cntData = mysql_fetch_row($result);
$count_users = $cntData[0];
$max_page = ceil ($count_users / $count_top);
$page = ($page > $max_page) ? (($max_page == 0)? $page : $max_page) : $page;
$start = $count_top * ($page-1);
$end = $count_top;
$result = mysql_query("SELECT DISTINCT `uid`,`count`,`host`,`in`,`out` FROM `weeks` WHERE `host` > 0 AND `date`=".$today." AND `uid` != '1' AND `cat_id` != '3' AND `cat_id` != '4' ORDER BY `host` DESC LIMIT ".$start.",".$end.";"); //Изменил из-за сообщения в госте
$count_users_on_page = mysql_num_rows($result);
}
else
{
$reza = mysql_query ("SELECT * FROM `cat` WHERE `id`='" . $cid . "';");
if (mysql_affected_rows() == 0) {
} else {
$raw = mysql_fetch_array ($reza);
$cat_name = $raw["name"];
}
$result = mysql_query("SELECT count(`uid`) FROM `weeks` WHERE `host` > '0' AND `cat_id`=".$cid." AND `date`=".$today." AND `uid` != '1';");
$cntData = mysql_fetch_row($result);
$count_users = $cntData[0];
$max_page = ceil ($count_users / $count_top);
$page = ($page > $max_page) ? (($max_page == 0)? $page : $max_page) : $page;
$start = $count_top * ($page-1);
$end = $count_top;
$result = mysql_query("SELECT DISTINCT `uid`,`count`,`host`,`in`,`out` FROM `weeks` WHERE `host` > '0' AND `date`=".$today." AND `cat_id`=".$cid." ORDER BY `host` DESC LIMIT ".$start.",".$end.";");
$count_users_on_page = mysql_num_rows($result);
}
echo "<div class="rh"><a href="/xhtml/category.xhtml">Категория</a> | ".$cat_name." | <a href="/xhtml/search.xhtml">Поиск</a></div>n";
//Начало вывода сайтов
for($i = 0;$i < $count_users_on_page;$i++) {
$row = mysql_fetch_array($result);
$uid = $row['uid'];
$hits = $row['count'];
$hosts = $row['host'];
// данные участника
echo "<div class="tit">";
echo "<div class="rang">";
echo "<div class="site">";
$user_data = mysql_query("SELECT `site_name`,`link`,`info` FROM `users` WHERE `uid`=".$uid."");
$user_data_row = mysql_fetch_array($user_data);
$site_name = htmlspecialchars($user_data_row['site_name']);
$link = htmlspecialchars($user_data_row['link']);
$info = htmlspecialchars($user_data_row['info']);
echo (($i + 1) + ($count_top * ($page-1))) . ". <a href="/xhtml/outtop/".$uid."/">".str_replace("http://", "", $link)."</a> <span class="g">(".$hosts."/".$hits.")</span> <a href="/xhtml/stat/".$uid."/"><strong><span style="color:#ff0000">инф</span></strong></a> <br />n".$info."<br />n";
echo "</div></div></div>";
}
print "<div class="rb">n";
for($k = 0;$k < ($max_page);$k++) {
if (($k == 0)or(($k + 1) == $max_page)or(3 >= ($page - $k))and(-3 <= ($page - $k))) {
$kira = $k + 1;
if ($k == ($page-1)) {
$otvet = "".$kira." | ";
} else {
$otvet = "<a href="/xhtml".$categorii[$cid]."/".$kira."/">".$kira."</a> | ";
}
print $otvet;
}
}
print "(".($start+1)."-".($start+$i)." из ".$count_users.")n";
print "</div>n";
print "<div class="rh"><a href="/xhtml".$categorii[$cid]."/">".$cat_name."</a> | <a href="/xhtml/category.xhtml">Категории</a> | <a href="/xhtml/search.xhtml">Поиск</a></div>n";
include "./inc/foot.php";
// ---------------------------------------------------------------
// вывод буфера
ob_end_flush();
?>