<?

header("Cache-Control: no-store, no-cache, must-revalidate");
if ($ver=="wml") header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else if ($ver=="xhtml") header("Content-Type:text/html; charset=UTF-8");
else header ("Content-type:text/vnd.wap.wml; charset=utf-8");
$ref=rand(10000,1000000);
require("inc.php");
$link = connect_db();

$setting = @mysql_query ("Select * from setting where klu4='1'");
$set = mysql_fetch_array ($setting);

if (($ver!="wml")&&($ver!="xhtml")){
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"index\" title=\"Лучший чат\">\n";
echo "<p align=\"center\">";
echo "<small>";
echo "Привет!<br/>";
echo "Выберите версию загрузки чата:<br/>";
echo "---<br/>"; //разделитель
echo "[ <b><a href=\"index.php?ver=wml\">WML</a></b> | ";
echo "<b><a href=\"index.php?ver=xhtml\">xHTML</a></b> ]<br/>";
echo "---<br/>";
echo "<b>WML</b> - Черно-белая версия, экономит траффик.<br/>";
echo "<b>xHTML</b> - Цветная версия, улучшает настроение.<br/>";
echo "---<br/>";
if($set["link1"]!="") echo "<small><a href=\"http://".$set["link1"]."\">".$set["link1_name"]."</a></small><br/>\n";
if($set["link2"]!="") echo "<small><a href=\"http://".$set["link2"]."\">".$set["link2_name"]."</a></small><br/>\n";
if($set["link3"]!="") echo "<small><a href=\"http://".$set["link3"]."\">".$set["link3_name"]."</a></small><br/>\n";
echo "---<br/>";
echo "&#169; WAB.WML.KZ<br/>";
echo "</small>";
echo "</p></card></wml>";
mysql_close ($link);
exit;
}

if (($ver=="wml")||($ver=="xhtml")){
for ($n = 0; $n <= 22; $n++){
$room = "room".$n;
$tm = time()-300;
$r = @mysql_query ("Select id from $room WHERE id > '".$tm."' group by usid order by id desc");
$asnum = mysql_affected_rows();
@$kol = $kol + $asnum;
}

if ($ver=="wml"){
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"index\" title=\"Чат Казахстана\">\n";
echo "<p align=\"center\" mode=\"wrap\">\n";
}else if ($ver=="xhtml"){
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Чат Казахстана</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\" mode=\"wrap\">";
}
echo "<img src=\"logo.gif\" alt=\"logo\"/><br/>\n";
echo "<small>Добро пожаловать!</small><br/>";
$chl = "человек";
if ((($kol%10==2)||($kol%10==3)||($kol%10==4))&&($kol/10)!=1)$chl = "человека";
if ($ver=="wml"){
echo "<small>В чате: <a href=\"online.php?ver=$ver\">".$kol."</a>&nbsp;".$chl."</small><br/>";
} else if ($ver=="xhtml") {
echo "<small><div class=\"d1\">В чате: <a href=\"online.php?ver=$ver\">".$kol."</a>&nbsp;".$chl."</div></small><br/>\n";
}
echo "<small>\n";
echo $divide;
echo "</small>\n";
if ($ver=="xhtml") echo "<form method=\"POST\" action=\"enter.php?ver=$ver&amp;ref=$ref\" name=\"auth\">\n";
echo "<small><b>Ник или ID:</b></small><br/>\n";
echo "<input name=\"us\" maxlength=\"20\" title=\"nick\"/><br/>\n";
echo "<small>Транслитировать:<a href=\"trunhelp.php?ver=$ver\">(?)</a></small><br/>\n";
echo "<select name=\"trun\">\n";
echo "<option value=\"0\">Нет</option>\n";
echo "<option value=\"1\">Да</option>\n";
echo "</select><br/>\n";
echo "<small><b>Пароль:</b></small><br/>\n";
echo "<input type=\"password\" name=\"ps\" maxlength=\"20\" title=\"password\"/><br/>\n";
echo "<small>";
if ($ver=="wml"){
echo "[ <anchor title=\"go\">Вход<go href=\"enter.php?ver=$ver&amp;ref=$ref\" method=\"post\">";
echo "<postfield name=\"us\" value=\"$(us)\"/>";
echo "<postfield name=\"ps\" value=\"$(ps)\"/>";
echo "<postfield name=\"trun\" value=\"$(trun)\"/>\n";
echo "</go></anchor> |";
}else if ($ver=="xhtml"){
echo "[<input type=\"submit\" value=\"Вход\" name=\"enter\"> | ";
}
echo "<a href=\"reg.php?ver=$ver&amp;mod=reghelp\">Регистрация</a>]<br/>";
echo "[<a href=\"ustav.php?ver=$ver\">Правила чата</a>]<br/>";
echo $divide;
echo "[<a href=\"index.php?ver=wml\">WML</a>\n|\n";
echo "<a href=\"index.php?ver=xhtml\">XHTML</a>]<br/>";
echo $divide;
echo "[<a href=\"lost_pass.php?ver=$ver\">Забыл пароль?</a>]<br/>";
echo $divide;
echo "</small>";
$num = mysql_fetch_array(mysql_query("select count(id) as num from users"));
$usersm=mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM users where sex='М'"));
$usersj=mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM users where sex='Ж'"));
echo "<small>Регистраций: ".$num[0]."</small><br/>\n";
echo "<small><small>Парней: ".$usersm[0]."</small></small><br/>\n";
echo "<small><small>Девушек: ".$usersj[0]."</small></small><br/>\n";
echo "<small>\n";
echo $divide;
echo "</small>\n";
if ($ver=="wml"){
if($set["link1"]!="") echo "<small><a href=\"http://".$set["link1"]."?ver=".$ver."\">".$set["link1_name"]."</a></small><br/>\n";
if($set["link2"]!="") echo "<small><a href=\"http://".$set["link2"]."?ver=".$ver."\">".$set["link2_name"]."</a></small><br/>\n";
if($set["link3"]!="") echo "<small><a href=\"http://".$set["link3"]."?ver=".$ver."\">".$set["link3_name"]."</a></small><br/>\n";
}else if ($ver=="xhtml"){
if($set["link1"]!="") {echo "<div class=\"d1\"><a href=\"http://".$set["link1"]."?ver=".$ver."\">".$set["link1_name"]."</a></div>\n";}
if($set["link2"]!="") {echo "<div class=\"d1\"><a href=\"http://".$set["link2"]."?ver=".$ver."\">".$set["link2_name"]."</a></div>\n";}
if($set["link3"]!="") {echo "<div class=\"d1\"><a href=\"http://".$set["link3"]."?ver=".$ver."\">".$set["link3_name"]."</a></div>\n";}
}
echo "<small>\n";
echo $divide;
echo "&#169; wab.wml.kz<br/>";
echo "</small>\n";
if ($ver=="wml")echo "</p></card></wml>";
else if ($ver=="xhtml") echo "</div></body></html>";
mysql_close ($link);
}
?>
