<?php
#==============================================================================================#
#                                   Name  :  Imperial CHAT                                     #
#                               Made by  :  MaZaFaKa (___хакер___)                             #
#                                  MODED :  vipsds  (   BOT  )                                 #
#                                  ICQ  :  350502220 (vipsds)                                  #
#                                E-mai :  vipsds@wapnn.org                                     #
# По всем вопросам и дополнительным модам обращайтесь на выше указанные данные                 #
#==============================================================================================#
error_reporting(7);
include('start.php');
include("config.php");
include("./includes/constants/menu");
include("./includes/".$ver."/banned");

$ttl="Сделайте закладку!";
$old_msgs = 6; //HOURS

$fd = fopen("system/clear.dat", "r");
$clear_time = intval(fgets($fd));
fclose($fd);

if($clear_time < time())
{
    $sql = mysql_query("SELECT `id` FROM `chat_rooms`;");
	while($room = mysql_fetch_array($sql))
	{
	mysql_query("DELETE FROM `chat".$room['id']."` WHERE `seconds` < ".(time() - (3600 * $old_msgs)).";");
	mysql_query("DELETE FROM `chat_intim` WHERE `seconds` < ".(time() - (3600 * $old_msgs)).";");
	}


$fd = fopen("system/clear.dat", "w");
flock($fd, LOCK_EX);
$puts = fputs($fd, (time() + 3600 * $old_msgs));
flock($fd, LOCK_UN);
fclose($fd);
}

list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;

$ref = rand(10000, 99999);

$banner = file("system/banner.dat");
$ssylka = trim($banner[0]);
$img = trim($banner[1]);

switch($ver)
{
////////////////////////////////////////////////////////
//WML VERSION
////////////////////////////////////////////////////////
case 'wml':
header("Content-type: text/vnd.wap.wml; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");


 if ($_SESSION['id'])
 {
 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\">\n<wml>\n";
 echo "<card title=\"$ttl\"><p align=\"left\">\n";
 echo "Сделайте тут закладку!<br/>\n";
 echo "или скопируйте: <input title='text' name='url' value='http://".$_SERVER['SERVER_NAME']."/go/".$ver."/".$_SESSION['id']."/".$_SESSION['password']."'/><br/>\n";
 echo "• <a href=\"/menu/wml\">Прихожая</a><br/>\n";
 echo $close_tag;
 include('banners/other');
 echo"$wmlfoot";
 list($msec, $sec) = explode(chr(32), microtime());
 echo "Speed ".round(($sec+$msec)-$headtime,5)." sec.<br/>\n";
 echo "</p></card></wml>";
 exit();
 }

//AUTH


if($_GET['nickname'])
{

 if($_GET['nickname'])
 {
 $nickname = mysql_escape_string($_GET['nickname']);
 }
 if($_GET['password'])
 {
 $password = mysql_escape_string($_GET['password']);
 }


header("Location: /menu/wml/".$nickname."/".$password."/auth");

}
break;

////////////////////////////////////////////////////////
//HTML VERSION
////////////////////////////////////////////////////////
case 'html':
header("Content-type: text/html; charset=utf-8");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");


   if ($_SESSION['id'])
   {

    echo "$css";
    echo'<title>'.$ttl.'</title>';
    echo'<div class="d3">Закладка</div>';
    echo "<div class=\"d2\">Сделайте тут закладку!</div>\n";
    echo "<div class=\"d2\">или скопируйте:\n";
    echo "<input title='text' value='http://".$_SERVER['SERVER_NAME']."/go/".$ver."/".$_SESSION['id']."/".$_SESSION['password']."'><br/>\n";
    echo "• <a href=\"/menu/html\">Прихожая</a><br/>\n";
    echo "</div>\n";
    echo '<div class="d3">';
    echo "$sitefoot";
    echo '</div>';
    echo "</body></html>";
	exit();
   }

//AUTH
if($_GET['nickname'])
{

 if($_GET['nickname'])
 {
 $nickname = mysql_escape_string($_GET['nickname']);
 }
 if($_GET['password'])
 {
 $password = mysql_escape_string($_GET['password']);
 }


header("Location: /menu/html/".$nickname."/".$password."/auth");

}


break;
}
?>