Просмотр файла index.php

Размер файла: 10.06Kb
<?php
include 'sys/db.php';
include 'sys/conf.php';
include 'sys/start.php';
include 'sys/functions.php';
$date_j = date("j");
$date_y = date("Y");
$date_m = date("m");
if ($date_m ==1)$date_m ='Января';
elseif ($date_m ==2)$date_m ='Февраля';
elseif ($date_m ==3)$date_m ='Марта';
elseif ($date_m ==4)$date_m ='Апреля';
elseif ($date_m ==5)$date_m ='Мая';
elseif ($date_m ==6)$date_m ='Июня';
elseif ($date_m ==7)$date_m ='Июля';
elseif ($date_m ==8)$date_m ='Августа';
elseif ($date_m ==9)$date_m ='Сентября';
elseif ($date_m ==10)$date_m ='Октября';
elseif ($date_m ==11)$date_m ='Ноября';
elseif ($date_m ==12)$date_m ='Декабря';
$config_title_name = "$date_j $date_m $date_y";
include 'style/head.php';
$act = isset($_GET['act']) ? $_GET['act'] : '';
switch($act){
default:
if (isset($user))mysql_query("DELETE FROM `chat_who` WHERE `id_user` = '$user[id]'");
mysql_query("DELETE FROM `chat_who` WHERE `time` < '".($time-120)."'");
if(isset($user['login'])){
echo "<div class=title>\n";
if(date(H)<=4 || date(H)>=23){echo "<b>Доброй ночи</b> ";}
if(date(H)>=5 && date(H)<=10){echo "<b>Доброе утро</b> ";}
if(date(H)>=11 && date(H)<=17){echo "<b>Добрый день</b> ";}
if(date(H)>=18 && date(H)<=22){echo "<b>Добрый вечер</b> ";}
echo "[<a href='?act=main'><b>".$user['login']."</b></a>] [<a href='?act=exit'>Выход</a>]\n";
echo "</div>\n";
if ($_GET['reg']==1){
$login = htmlspecialchars($_GET['login']);
$pass = htmlspecialchars($_GET['pass']);
echo "<div class=content>\n";
echo "Добро пожаловать в чат <b>$config_title</b><br>\n";
echo "Ваш логин: <b>$login</b><br>\n";
echo "Ваш пароль: <b>$pass</b><br>\n";
echo "Вы можете сделать закладку для быстрого входа:<br>\n";
echo "<input name='' value='$config_home/?act=in&login=$login&pass=$pass' type='text'>\n";
echo "</div>\n";}


if ($_GET['ban']==1){
echo "<div class=content>\n";
echo "Время вашего бана вышло, постарайтесь вести себя достойно и не нарушать правила сайта!\n";
echo "</div>\n";}


echo "<div class=title><div align=center>  ".date("j")." $date_m ".date("Y")."</div></div>\n";
echo "<div class=content>\n";
$rooms = mysql_query("SELECT * FROM `room` ORDER BY `position` ASC");
if(mysql_num_rows($rooms)!=0){
while($room = mysql_fetch_array($rooms)){
echo "<img src='img/ri.gif' alt=''> <a href='room.php?id=".$room['id']."'>".$room['name']."</a>
[".mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_who` WHERE `room` = '$room[id]'"),0)."]<br>\n";}
}else{ echo "Комнаты не созданны\n";}
echo "</div>\n";
echo "<div class=title>Другое: </div>";
echo "<div class=content>\n";
$date_d = date("j");
$date_m = date("m");
echo "<img src='img/ai.gif' alt=''> <a href='birthdays.php'>Именинники</a> [".mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `ank_d_r` = '$date_d' AND `ank_m_r` = '$date_m'"),0)."]<br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='users.php'>Список юзеров</a> [".mysql_result(mysql_query("SELECT COUNT(*) FROM `users`"),0)."]<br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='photo_album.php'>Фотоальбомы</a> [".mysql_result(mysql_query("SELECT COUNT(*) FROM `photo_albums`"),0)." / ".mysql_result(mysql_query("SELECT COUNT(*) FROM `photo_albums` WHERE `pol` = '1'"),0)." / ".mysql_result(mysql_query("SELECT COUNT(*) FROM `photo_albums` WHERE `pol` = '2'"),0)." / ".mysql_result(mysql_query("SELECT COUNT(*) FROM `photo_albums_photos` "),0)."]<br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='exchanger.php'>Обменник</a> [".mysql_result(mysql_query("SELECT COUNT(*) FROM `exchanger` "),0)." /
".mysql_result(mysql_query("SELECT COUNT(*) FROM `exchanger_section` "),0)." /
".mysql_result(mysql_query("SELECT COUNT(*) FROM `exchanger_files` "),0)."]<br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='guess.php'>Угадай число</a><br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='kosti.php'>Кости</a><br>\n";



echo "</div>\n";
if(isset($user['set_new_ank']) && $user['set_new_ank']=='0'){
echo "<div class=title>Новые анкеты: </div>";
echo "<div class=content>\n";
echo "<table align='center' border='0px'><tr>\n";
$newankm = mysql_query("SELECT * FROM `users` WHERE `gender` = '1' ORDER BY `id` DESC LIMIT 1");
while($ankman = mysql_fetch_array($newankm)){
if ($ankman['foto']==NULL){
echo "<td><img src='img/nophoto_man.gif' alt=''  border='1'><br><div align=center>
<a href='anketa.php?id=".$ankman['id']."'>".$ankman['login']."</a></div></td>\n";
}else{
echo "<td><img src='image.php?pic=".$ankman['foto']."&W=50&H=63' alt='' border='1'><br><div align=center><a href='anketa.php?id=".$ankman['id']."'>".$ankman['login']."</a></div></td>\n";}}
$newankg = mysql_query("SELECT * FROM `users` WHERE `gender` = '2' ORDER BY `id` DESC LIMIT 1");
while($ankwoman = mysql_fetch_array($newankg)){
if ($ankwoman['foto']==NULL){
echo "<td><img src='img/nophoto_woman.gif' alt=''  border='1'><br><div align=center><a href='anketa.php?id=".$ankwoman['id']."'>".$ankwoman['login']."</a></div></td>\n";
}else{
echo "<td><img src='image.php?pic=".$ankwoman['foto']."&W=50&H=63' alt='' border='1'><br><div align=center><a href='anketa.php?id=".$ankwoman['id']."'>".$ankwoman['login']."</a></div></td>\n";}}
echo "</tr></table>\n";}
echo "</div>\n";
}else{
echo "<div class=title>\n";
echo "<a href='?act=input'>Вход</a> |";
echo "<a href='reg.php'>Регистрация</a>";
echo "</div>\n";
echo "<div class=stat>\n";
echo "Внимание доступ закрыт для гостей, нужно авторизироваться чтобы попасть в наш дружный чат.\n";
echo "</div>\n";
echo "<div class=content>\n";
if ($_GET['isset']==pass) {echo "Неправильный пароль!\n";}
if ($_GET['isset']==login) {echo "Неправильный логин!\n";}
echo "<form action='?act=inp&' method='post' name='reg'>\n";
echo "Логин: <br><input name='login' type='text'><br>\n";
echo "Пароль: <br><input name='pass' type='password'><br><br>\n";
echo "<a href='reg.php'><input type='button' value='Регистрация'></a>\n";
echo "<input type='submit' value='Вход'></form>\n";
echo "</div>\n";}
break;
case('input'):
echo "<div class=title>\nВход в чат</div>\n";
echo "<div class=content>\n";
if ($_GET['isset']==pass) {echo "Неправильный пароль!\n";}
if ($_GET['isset']==login) {echo "Неправильный логин!\n";}
echo "<form action='?act=inp&' method='post' name='reg'>\n";
echo "Логин: <br><input name='login' type='text'><br>\n";
echo "Пароль: <br><input name='pass' type='password'><br><br>\n";
echo "<a href='reg.php'><input type='button' value='Регистрация'></a>\n";
echo "<input type='submit' value='Вход'></form>\n";
echo "</div>\n";
break;
case('inp'):
$query = mysql_query("SELECT * FROM `users` WHERE `login`='".mysql_real_escape_string($_POST['login'])."';");
if(mysql_num_rows($query)!=0){
$data = mysql_fetch_array($query);
if (md5($_POST['pass'])==$data['pass']){
$_SESSION['login'] = $data['login'];
$_SESSION['pass'] = $data['pass'];
setcookie('login',$data[login],time()+86400*31);
setcookie('pass',$data[pass],time()+86400*31);
header ("Location: index.php"); exit;
} else {header ("Location: ?act=input&isset=pass");  exit;}
} else {header ("Location: ?act=input&isset=login");  exit;}
break;
case('in'):
$query = mysql_query("SELECT * FROM `users` WHERE `login`='".mysql_real_escape_string($_GET['login'])."';");
if(mysql_num_rows($query)!=0){
$data = mysql_fetch_array($query);
if (md5($_GET['pass'])==$data['pass']){
$_SESSION['login'] = $data['login'];
header ("Location: index.php?"); exit;
} else {header ("Location: ?act=input&isset=pass");  exit;}
} else {header ("Location: ?act=input&isset=login");  exit;}
break;
case('inr'):
$query = mysql_query("SELECT * FROM `users` WHERE `login`='".mysql_real_escape_string($_GET['login'])."';");
if(mysql_num_rows($query)!=0){
$data = mysql_fetch_array($query);
if (md5($_GET['pass'])==$data['pass']){
$_SESSION['login'] = $data['login'];
header ("Location: index.php?reg=1&login=".$_GET['login']."&pass=".$_GET['pass']."&"); exit;
} else {header ("Location: ?act=input&isset=pass");  exit;}
} else {header ("Location: ?act=input&isset=login");  exit;}
break;
case('exit'):
$timeexits = time()-700;
$id = $user['id'];
mysql_query("UPDATE `users` SET `time` = '$timeexits' WHERE `id` = '$id'");
$_SESSION['login']='';
unset($_SESSION['id']);
session_unset();
setcookie(session_name(), '');
setcookie('login', '');
setcookie('pass', '');
session_destroy();
header ("Location: /?");  exit;
break;
case('main'):
if(isset($user['login'])){
echo "<div class=content>\n";
$friends = mysql_query("SELECT * FROM `friends` WHERE `user`='$user[id]'");
$friend = mysql_num_rows($friends);
$ignore = mysql_query("SELECT * FROM `ignore` WHERE `user`='$user[id]'");
$ignor = mysql_num_rows($ignore);
if(isset($user['level']) && $user['level']=='1'){
echo "<img src='img/ai.gif' alt=''> <a href='panel/index.php'>Админ-ка</a><br>\n";}
if(isset($user['level']) && $user['level']=='2'){
echo "<img src='img/ai.gif' alt=''> <a href='panel/index.php'>Модер-ка</a><br>\n";}
if(isset($user['level']) && $user['level']=='3'){
echo "<img src='img/ai.gif' alt=''> <a href='panel/index.php'>Модер-ка</a><br>\n";}
echo "<img src='img/ai.gif' alt=''> <a href='anketa.php'>Ваша анкета</a><br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='setting.php'>Ваши настройки</a><br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='photo.php'>Ваше фото</a><br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='mail.php'>Мои письма</a><br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='friends.php'>Мои друзья</a> [$friend]<br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='ignore.php'>Игнор-лист</a> [$ignor]<br>\n";
echo "<img src='img/ai.gif' alt=''> <a href='?'>Прихожая</a><br>\n";
echo "</div>\n";
}else{ header ("Location: index.php"); exit;}
break;}
include 'style/foot.php';
?>