File size: 6.2Kb
<?php
//Opredelenie podderjki html
if(!array_key_exists('HTTP_ACCEPT', $_SERVER) || empty($_SERVER['HTTP_ACCEPT'])){
$_GET['ver'] = 'html';
} else {
if(preg_match('/(application|text)\/(vnd\.wap\.wml|vnd\.wap\.wmlc|vnd\.wap\.wmlscript|vnd\.wap\.wmlscriptc|vnd\.wap\.wbxml)/i', $_SERVER['HTTP_ACCEPT']) && !isset($_GET['ver'])) $_GET['ver'] = 'wml';
elseif (preg_match('/(application|text)\/(html|xhtml|xml|xhtml\+xml|xslt\+xml)/i', $_SERVER['HTTP_ACCEPT']) && !isset($_GET['ver'])) $_GET['ver'] = 'html';
elseif(!isset($_GET['ver'])) $_GET['ver'] = 'html';
}
//konec opr. html
list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;
error_reporting(0);
include("config.php");
include("./includes/constants/index");
include("./includes/".$ver."/banned");
$ttl="UPWAP Чат!";
$nocache = rand(1000, 9999);
switch($ver)
{
case 'wml':
///////////////////////////////////////////////////////
//WML VERSION
///////////////////////////////////////////////////////
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");
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";
$chat = file("chat.dat");
$logo = trim($chat[0]);
$message = trim($chat[1]);
$q = mysql_query("SELECT COUNT(`id`) FROM `chat_users` WHERE `time` >= ".time().";");
$online = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(`id`) FROM `chat_users`;");
$users = mysql_result($q, 0);
//Today man and women
$qm = mysql_query("SELECT COUNT(`id`) FROM `chat_users` WHERE `regdate` = '".date('d-m-Y')."' AND `sex` = 0;");
$man = mysql_result($qm, 0);
$qw = mysql_query("SELECT COUNT(`id`) FROM `chat_users` WHERE `regdate` = '".date('d-m-Y')."' AND `sex` = 1;");
$women = mysql_result($qw, 0);
//
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"index\" title=\"".TITLE."\"><p align=\"left\"><small>\n";
echo'<br/>';
echo ONLINE.": $online</small><br/>\n";
echo "<a href=\"./?ver=html\">Цветная версия чата</a><br/>";
echo'<a href="view_wew.php?ver=wml">Умей предвидеть!</a><br/>';
echo'=====<br/>';
echo "<a href=\"rules.php?ver=wml&action=registration\">Регистрация</a><br/>\n";
echo'=====<br/>';
if(!empty($logo)) echo "<img src=\"http://$logo\" alt=\"\" /><br/>\n";
if(!empty($message)) echo "$message<br/>\n";
echo "Ник или ID:<br/>\n";
echo "<input type=\"text\" name=\"nickname$nocache\" maxlength=\"15\"/><br/>\n";
echo "Транслитировать:<br/>\n";
echo "<select name=\"translit$nocache\">\n";
echo "<option value=\"false\">Нет</option>\n";
echo "<option value=\"true\">Да</option>\n";
echo "</select><br/>\n";
echo "Пароль:<br/>\n";
echo "<input type=\"password\" name=\"password$nocache\" maxlength=\"20\"/><br/>\n";
echo "<anchor>Войти<go href=\"menu.php?ver=wml&nocache=$nocache\" method=\"post\">\n";
echo "<postfield name=\"nickname\" value=\"$(nickname$nocache)\"/>\n";
echo "<postfield name=\"translit\" value=\"$(translit$nocache)\"/>\n";
echo "<postfield name=\"password\" value=\"$(password$nocache)\"/>\n";
echo "<postfield name=\"action\" value=\"auth\"/>\n";
echo "</go></anchor><br/>\n";
echo'*********<br/>';
echo'• <a href="rules.php?ver=wml">Правила чата </a><br/>';
echo REG_USERS.": ".$users."<br/>\n";
echo'Сегодня:<br/>';
echo'Девушек: '.$women.'<br/>';
echo'Мужчин: '.$man.'<br/>';
echo'<br/>';
echo "<a href=\"./?ver=html\">XHTML</a> | WML<br/>\n";
echo"$wmlfoot";
echo "</p></card></wml>";
break;
case 'html':
///////////////////////////////////////////////////////
//HTML VERSION
///////////////////////////////////////////////////////
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");
echo"$css";
echo"<title>$ttl</title>";
echo"<div class=\"d1\">";
$chat = file("chat.dat");
$logo = trim($chat[0]);
$message = trim($chat[1]);
$q = mysql_query("SELECT COUNT(`id`) FROM `chat_users` WHERE `time` >= ".time().";");
$online = mysql_result($q, 0);
$q = mysql_query("SELECT COUNT(`id`) FROM `chat_users`;");
$users = mysql_result($q, 0);
//Today man and women
$qm = mysql_query("SELECT COUNT(`id`) FROM `chat_users` WHERE `regdate` = '".date('d-m-Y')."' AND `sex` = 0;");
$man = mysql_result($qm, 0);
$qw = mysql_query("SELECT COUNT(`id`) FROM `chat_users` WHERE `regdate` = '".date('d-m-Y')."' AND `sex` = 1;");
$women = mysql_result($qw, 0);
//
if(!empty($logo)) echo "<img src=\"http://$logo\" alt=\"\" /><br/>\n";
if(!empty($message)) echo "$message<br/>\n";
echo"</div><div class=\"d3\">$ttl</div>";
echo'<div>';
echo ONLINE.": $online<br/>\n";
echo'<a href="view_wew.php?ver=html">Умей предвидеть!</a><br/>';
echo "<a href=\"rules.php?ver=html&action=registration\"><font color=\"red\">Регистрация</font></a><br/>\n";
echo "<form action=\"menu.php?ver=html&nocache=$nocache\" method=\"post\">\n";
echo "Ник или ID:<br/>\n";
echo "<input type=\"text\" name=\"nickname\" maxlength=\"15\" /><br/>\n";
echo "Транслитировать:\n";
echo "<input type=\"checkbox\" name=\"translit\" value=\"yes\" /><br/>\n";
echo "Пароль:<br/>\n";
echo "<input type=\"password\" name=\"password\" maxlength=\"20\" /><br/>\n";
echo "<input type=\"hidden\" name=\"action\" value=\"auth\" />\n";
echo "<input type=\"submit\" value=\"Войти\" /></form>\n";
echo'</div>';
echo "<div class=\"d1\">\n";
echo REG_USERS.": ".$users."<br/>\n";
echo "• <a href=\"rules.php?ver=html\">Правила чата</a><br/>\n";
echo "• <a href=\"rules.php?ver=html&action=registration\">Регистрация</a><br/>\n";
echo 'Сегодня:<br/>';
echo 'Девушек: '.$women.'<br/>';
echo 'Мужчин: '.$man.'<br/>';
echo "<a href=\"./?ver=wml\">WML</a> | XHTML<br/>\n";
list($msec, $sec) = explode(chr(32), microtime());
echo"</div>";
echo"<div class=\"d3\">$sitefoot</div>";
echo "</body></html>";
break;
}
?>