<?php
error_reporting(0);
//----------
include ('inc/config.inc.php.php');
//----------
session_name('sid');
session_start();
//----------
connect_to_db();
include ('inc/autorize.php.php');
include ('inc/online.php.php');
include ('inc/pages.php.php');
//----------
$time = time() - ONLINE_USER;
// Все
$qa = mysql_query("SELECT COUNT(`id`) FROM `love_user` WHERE `time` > ".$time.";");
$on_users_all = mysql_result($qa, 0);
// Парни
$qp = mysql_query("SELECT COUNT(`id`) FROM `love_user` WHERE `pol` = 1 AND `time` > ".$time.";");
$on_users_p = mysql_result($qp, 0);
// Девушки
$qd = mysql_query("SELECT COUNT(`id`) FROM `love_user` WHERE `pol` = 2 AND `time` > ".$time.";");
$on_users_d = mysql_result($qd, 0);
// Анонимные
$arr_an_us = mysql_query("select * from `love_anonim`;");
$online_users_an = mysql_num_rows($arr_an_us);
//----------
$partner = intval($_GET['partner']); if ($partner == 0) $partner = 1;
//----------
$arr = mysql_query("SELECT COUNT(*) FROM `love_partner`;");
$part_users = mysql_result($arr, 0);
if($partner > $part_users) $partner = 1;
//----------
$partner_arr = @mysql_query("SELECT * FROM `love_partner` WHERE `partner` = ".intval($partner)." LIMIT 1;");
$row = @mysql_fetch_array($partner_arr);
$partner_site = $row['site'];
$partner_name = $row['name'];
//----------
$title = 'Сейчас на сайте';
include ('header.php');
echo $header;
if($mod == '1') echo '<p align="center"><small>';
if(isset($_GET['up'])) $up = $_GET['up']; else $up = "0";
switch ($up) {

case "0":
echo $class_d2;
echo 'Сейчас на сайте<br/>';
echo $class_divz.$class_d1;
if($mod == '1') echo '</small></p><p align="left"><small>';
echo '-&#187; <a href="'.$PHP_SELF.'?up=1&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Парни и девушки ('.$on_users_all.')</a><br/>';
echo '-&#187; <a href="'.$PHP_SELF.'?up=2&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Только парни ('.$on_users_p.')</a><br/>';
echo '-&#187; <a href="'.$PHP_SELF.'?up=3&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Только девушки ('.$on_users_d.')</a><br/>';
echo '-&#187; <a href="'.$PHP_SELF.'?up=4&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Анонимные ('.$online_users_an.')</a><br/>';
echo $class_divz;
break;

case "1":
$sql = mysql_query("SELECT * FROM `love_user` WHERE `time` > ".$time.";");
echo $class_d2;
echo 'Сейчас на сайте: Парни и Девушки<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
if(mysql_affected_rows() == 0) {
echo $class_d3;
echo 'В данный момент никого нет!<br/>';
echo $class_divz;
}
else
{
$url = ''.$PHP_SELF.'?up=1&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'&amp;';
$wf = ONPAGE_USER;
$tp = mysql_num_rows($sql);
$mp = ceil($tp/$wf);
$page = (int)$_GET['page'];
if($page < 1) $page = 1;
if($page > $mp) $page = $mp;
$start = $page * $wf - $wf;
if(!preg_match('#^[0-9]{1,3}$#i',$page)) $page = 1;
//----------
$arr = mysql_query("SELECT * FROM `love_user` WHERE `time` > ".$time." ORDER BY `golos` DESC LIMIT ".intval($start).",".intval($wf).";");
while($info_user = mysql_fetch_array($arr)) {
$id = $info_user['id'];
$name = $info_user['name'];
$vozrast = $info_user['vozrast'];
$strana = $info_user['strana'];
$gorod = $info_user['gorod'];
$pol = $info_user['pol'];
if ($pol == 1) $pol = '[М]'; else $pol = '[Ж]';
$ts = htmlspecialchars($gorod);
$g = htmlspecialchars($strana);
include ('inc/function.php');
echo $class_d1;
echo '<strong><a href="/info_user.php?user_id='.$id.'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">'.$name.'</a></strong> '.$vozrast.', '.$g.', '.$ts.', '.$pol.'<br/>';
echo $class_divz;
}
if ($tp > ONPAGE_USER) {echo $class_d0; page($tp, $page, $wf, $url); echo $class_divz; if($mod == '1') echo '<br/>';}
}
break;

case "2":
$sql = mysql_query("SELECT * FROM `love_user` WHERE `time` > ".$time." AND `pol` = '1';");
echo $class_d2;
echo 'Сейчас на сайте: Только парни<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
if(mysql_affected_rows() == 0) {
echo $class_d3;
echo 'В данный момент никого нет!<br/>';
echo $class_divz;
}
else
{
$url = ''.$PHP_SELF.'?up=2&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'&amp;';
$wf = ONPAGE_USER;
$tp = mysql_num_rows($sql);
$mp = ceil($tp/$wf);
$page = (int)$_GET['page'];
if($page < 1) $page = 1;
if($page > $mp) $page = $mp;
$start = $page * $wf - $wf;
if(!preg_match('#^[0-9]{1,3}$#i',$page)) $page = 1;
//----------
$arr = mysql_query("SELECT * FROM `love_user` WHERE `time` > ".$time." AND `pol` = '1' ORDER BY `golos` DESC LIMIT ".intval($start).",".intval($wf).";");
while($info_user = mysql_fetch_array($arr)) {
$id = $info_user['id'];
$name = $info_user['name'];
$vozrast = $info_user['vozrast'];
$strana = $info_user['strana'];
$gorod = $info_user['gorod'];
$pol = $info_user['pol'];
if ($pol == 1) $pol = '[М]';
$ts = htmlspecialchars($gorod);
$g = htmlspecialchars($strana);
include ('inc/function.php');
echo $class_d1;
echo '<strong><a href="/info_user.php?user_id='.$id.'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">'.$name.'</a></strong> '.$vozrast.', '.$g.', '.$ts.', '.$pol.'<br/>';
echo $class_divz;
}
if ($tp > ONPAGE_USER) {echo $class_d0; page($tp, $page, $wf, $url); echo $class_divz; if($mod == '1') echo '<br/>';}
}
break;

case "3":
$sql = mysql_query("SELECT * FROM `love_user` WHERE `time` > ".$time." AND `pol` = '2';");
echo $class_d2;
echo 'Сейчас на сайте: Только девушки<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
if(mysql_affected_rows() == 0) {
echo $class_d3;
echo 'В данный момент никого нет!<br/>';
echo $class_divz;
}
else
{
$url = ''.$PHP_SELF.'?up=3&amp;partner='.$partner.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'&amp;';
$wf = ONPAGE_USER;
$tp = mysql_num_rows($sql);
$mp = ceil($tp/$wf);
$page = (int)$_GET['page'];
if($page < 1) $page = 1;
if($page > $mp) $page = $mp;
$start = $page * $wf - $wf;
if(!preg_match('#^[0-9]{1,3}$#i',$page)) $page = 1;
//----------
$arr = mysql_query("SELECT * FROM `love_user` WHERE `time` > ".$time." AND `pol` = '2' ORDER BY `golos` DESC LIMIT ".intval($start).",".intval($wf).";");
while($info_user = mysql_fetch_array($arr)) {
$id = $info_user['id'];
$name = $info_user['name'];
$vozrast = $info_user['vozrast'];
$strana = $info_user['strana'];
$gorod = $info_user['gorod'];
$pol = $info_user['pol'];
if ($pol == 2) $pol = '[Ж]';
$ts = htmlspecialchars($gorod);
$g = htmlspecialchars($strana);
include ('inc/function.php');
echo $class_d1;
echo '<strong><a href="/info_user.php?user_id='.$id.'&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">'.$name.'</a></strong> '.$vozrast.', '.$g.', '.$ts.', '.$pol.'<br/>';
echo $class_divz;
}
if ($tp > ONPAGE_USER) {echo $class_d0; page($tp, $page, $wf, $url); echo $class_divz; if($mod == '1') echo '<br/>';}
}
break;

case "4":
$sql = mysql_query("select * from `love_anonim`;");
echo $class_d2;
echo 'Сейчас на сайте: Анонимные<br/>';
echo $class_divz;
if($mod == '1') echo '</small></p><p align="left"><small>';
if(mysql_affected_rows() == 0) {
echo $class_d3;
echo 'В данный момент никого нет!<br/>';
echo $class_divz;
}
else
{
$url = ''.$PHP_SELF.'?up=4&amp;partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'&amp;';
$wf = ONPAGE_USER;
$tp = mysql_num_rows($sql);
$mp = ceil($tp/$wf);
$page = (int)$_GET['page'];
if($page < 1) $page = 1;
if($page > $mp) $page = $mp;
$start = $page * $wf - $wf;
if(!preg_match('#^[0-9]{1,3}$#i',$page)) $page = 1;
//-----------
$arr = mysql_query("SELECT * FROM `love_anonim` ORDER BY id DESC LIMIT ".intval($start).", ".intval($wf).";");
while($anonim = mysql_fetch_array($arr)) {
$ip = $anonim['ip'];
$ua = $anonim['ua'];
$ua = strtok($ua, ' ');
echo $class_d1;
echo $ua.' ['.$ip.']<br/>';
echo $class_divz;
}
if ($tp > ONPAGE_USER) {echo $class_d0; page($tp, $page, $wf, $url); echo $class_divz; if($mod == '1') echo '<br/>';}
}
break;
}
if($mod == '1') echo '---<br/>';
echo $class_d0;
echo '&#171;- <a href="index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.$srand.'='.$r_rand.'&amp;'.session_name().'='.session_id().'">Назад</a><br/>';
echo $class_divz.$class_d1;
if($mod == '1') echo '---<br/>';
if (!$autorize) {
echo '[7] <a href="http://'.$_SERVER['HTTP_HOST'].'/index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="7">Поиск</a> [8] <a href="http://'.$_SERVER['HTTP_HOST'].'/auth.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Вход</a> [9] <a href="http://'.$_SERVER['HTTP_HOST'].'/reg.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="9">Регистрация</a><br/>';
}
else
{
echo '[7] <a href="http://'.$_SERVER['HTTP_HOST'].'/index.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="7">Поиск</a> [8] <a href="http://'.$_SERVER['HTTP_HOST'].'/menu.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="8">Личное меню</a> [9] <a href="http://'.$_SERVER['HTTP_HOST'].'/out.php?partner='.$partner.'&amp;mod='.$mod.'&amp;'.session_name().'='.session_id().'" accesskey="9">Выход</a><br/>';
}
if($mod == '1') echo '</small></p><p align="center"><small>';
echo $class_divz.$class_d2;
echo $class_divz.$class_d2.$class_version.$class_divz.$class_div;
echo $class_endpage;
?>