<?
list($msec,$sec)=explode(chr(32),microtime());
$HeadTime=$sec+$msec;
header("Cache-Control:no-cache,no-store,must-revalidate");
header("Pragma:no-cache");
header("Content-type:text/vnd.wap.wml; charset=utf-8");
$ref=rand(10000,1000000);
require("conf.inc.php");
require("filtro.php");
$link=mysql_connect($MySQL_Hostname, $MySQL_Username, $MySQL_Password)
or die ("<wml>
<card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">Can not connect to MySQL<br/>".mysql_error()."</p>
</card>
</wml>");
mysql_select_db($MySQLDatabasename) or die ("<wml>
<card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">error select the database...<br/>".mysql_error()."</p>
</card>
</wml>");
$timeoutseconds = 60480000;
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
$tol = 60*15;
$timeb=$timestamp-$tol;
$timeoutnline = 60*5;
$timekik=$timestamp-$timeoutnline;
mysql_query("DELETE FROM nline WHERE time<$timekik");
$id=intval($_GET['id']);
$result=mysql_query("select * from users2 where id='$id' limit 1;");
if(mysql_affected_rows() == 0){
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";
echo "<wml>";
echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"http://wapsoft.org.ru\"><timer value=\"15\"/>";
echo "<p align=\"center\"><small>";
echo "Извините, но гостевой книги не существует!";
echo "</small></p></card></wml>";
exit;
mysql_close($link);
}
require "functions.php";
$data=mysql_fetch_array($result);
$num_msgs=$data['msgs'];
$title=$data['title'];
$id=$data['id'];
$razdel=$data['razdel'];
$link=$data['link'];
$sitename=$data['sitename'];
$komp=$data['komp'];
$verh=$data['verh'];
$niz=$data['niz'];
$agent=filtro($_SERVER['HTTP_USER_AGENT']);
$addr=filtro($_SERVER['REMOTE_ADDR']);
if(empty($sitename)) $sitename="На главную";
if (empty($num_msgs)) $num_msgs="9";
if (empty($title)) $title="Гостевая";
if ($komp==1){
if ((strpos ($agent,"M3Gate") !== false)||(strpos ($agent,"Opera") !== false)||(strpos ($agent,"emulator") !== false)||(strpos ($agent,"WinWAP") !== false)||(strpos ($agent,"Wapsilon") !== false)||(strpos ($agent,"M3GATE") !== false)||(strpos ($agent,"Mozilla") !== false))
{
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";
echo "<wml>";
echo "<card id=\"error\" title=\"Ошибка!\">";
echo "<p align=\"center\"><small>";
echo "Извините, но в данную гостевую доступ с компьютера и OperaMini закрыт!<br/><anchor>Назад<prev/></anchor>";
echo "</small></p></card></wml>";
exit;
mysql_close($link);
}
}
mysql_query ("Select * from ban WHERE gid='".$id."' and ip='".$addr."' and brows='".$agent."' LIMIT 1;");
if (mysql_affected_rows()!=0)
{
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";
echo "<wml>";
echo "<card id=\"ban\" title=\"Облом!\">";
echo "<p align=\"center\"><small>";
echo "Вы забанены по связке ip+soft!!!<br/><anchor>Назад<prev/></anchor>";
echo "</small></p></card></wml>";
exit;
mysql_close($link);
}
echo'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd"><wml>
<card id="main" title="'.$title.'">
<do type="options" name="update" label="Обновить"><go href="index.php?id='.$id.'&ref='.$ref.'" method="get"/></do>
<do type="options" name="say" label="Написать"><go href="#say" method="get"/></do>
<do type="options" name="home" label="'.$sitename.'"><go href="'.$link.'" method="get"/></do>
<do type="options" name="trans" label="Транслит"><go href="translit.php?id='.$id.'" method="get"/></do><do type="options" name="servis" label="Сервис гостевых"><go href="http://wapsoft.org.ru/gbs/in.php" method="get"/></do>';
$onco=mysql_query ("SELECT id FROM nline WHERE (gid='$id' and ip='$addr' and brows='$agent' and time>=$timekik) LIMIT 1");
if(mysql_affected_rows()==0)
{
mysql_query("Insert into nline set gid='".$id."', ip='".$addr."', brows='".$agent."', time='".time()."'");
}
$r = mysql_query ("select count(id) as num from nline WHERE (gid = '".$id."')and(time >= '".$timekik."')");
$a = mysql_fetch_array($r);
$inb = $a["num"];
if (!empty($verh))
{
echo'<p align="center">';
echo $verh;
echo'</p>';
}
echo'<p align="left">';
$msg=$_POST['msg'];
$login=filtro($_POST['login']);
$email=filtro($_POST['email']);
$login=substr($login,0,16);
$msg=substr($msg,0,350);
$email=substr($email,0,32);
if(!empty($msg) && !empty($login)){
$r=mysql_query("SELECT msg FROM recs order by id desc LIMIT 1");
$a=mysql_fetch_array($r);
$translit=$_POST['translit'];
if($translit=="toall") $msg=latrus($msg);
$msg=filtro($msg);
if($translit != "toall"){$msg = eregi_replace("((http://))((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z;]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:;\?\.-]*)*)", "<a href=\"\\0\">\\3</a>", $msg);
require "convert_to_smiles.php";}
if ($a["msg"] !== $msg)
{
$daten=date("d M H:i");
mysql_query ("Insert into recs set gid='".$id."', login='".$login."', msg='".$msg."', email='".$email."', ip='".$addr."', brows='".$agent."', time='".$daten."', time2='".time()."'");
}
}
$r = mysql_query("select count(*) as num from recs where gid = '".$id."'");
$a = mysql_fetch_array($r);
$num = $a["num"];
$s=intval($_GET['s']);
if(!isset($s))$s=1;
$mx=round(($num/$num_msgs)+0.45);
if($s>$mx)$s=$mx;
if($s==0)$s=1;
$ot=(($s-1)*$num_msgs)+1;
$do=$s*$num_msgs;
if($do>$num)$do=$num;
$o=$ot-1;
$n=$ot;
if($do==0)$n=$o;
echo "<small>Посты с $n-$do всего $num</small><br/>\n";
if($data['fsize'] == "small") { $fsize1 = "<small>"; $fsize2 = "</small>"; }
elseif($data['fsize'] == "big") { $fsize1 = "<big>"; $fsize2 = "</big>"; }
else { $fsize1 = ""; $fsize2 = ""; }
echo $fsize1;
echo "<anchor>Написать<go href=\"#say\" method=\"get\"/></anchor><br/>";
echo "<a href=\"index.php?id=$id&ref=$ref\">Обновить</a>";
$r = mysql_query ("Select * from recs WHERE gid = '".$id."' order by id desc LIMIT $o,$do");
for ($i=$ot;$i<=$do;$i++){
$a = mysql_fetch_array($r);
$gid=$a['gid'];
$email=$a['email'];
$login=$a['login'];
$dbmsg=$a['msg'];
$dbotvet=$a['otvet'];
$dbtime=$a['time'];
$dbbrows=$a['brows'];
$dbip=$a['ip'];
$kdbb = substr($dbbrows,0,strpos($dbbrows,"/"));
if (empty($kdbb)) $kdbb="UnKnown";
echo "<br/><a href=\"index.php?id=$id&lgn=$login,&ref=$ref#say\">$login</a> $dbtime<br/>$dbmsg";
if (!empty($email)) echo "<br/><small>email:$email</small>";
echo "<br/><small><u>$kdbb</u> ($dbip)</small>";
if (!empty($dbotvet)) echo "<br/><b>Ответ: $dbotvet </b>";
echo "<br/>$razdel";
}
$next=$s+1;
$prev=$s-1;
if ($num>$do) {
$ot=(($next-1)*$num_msgs)+1;
$do=$next*$num_msgs;
if($do>$num)$do=$num;
echo "<br/><a href=\"index.php?id=$id&s=$next&ref=$ref\">$ot-$do</a>";
}
if($s>1) {
$ot=(($prev-1)*$num_msgs)+1;
$do=$prev*$num_msgs;
echo "<br/><a href=\"index.php?id=$id&s=$prev&ref=$ref\">$ot-$do</a><br/>";
}
echo $fsize2;
echo "</p>";
echo "<p align=\"center\">";
if (!empty($niz)) echo "$niz<br/>";
echo "<small>";
echo "<br/>OnLine: $inb";
echo "<br/><a href=\"$link\">$sitename</a>";
echo "<br/><a href=\"smiles.php?id=$id&ref=$ref\">Смайлы</a>";
echo "<br/><a href=\"translit.php?id=$id\">Транслит</a>";
list($msec,$sec)=explode(chr(32),microtime());
echo "<br/>[". round(($sec+$msec)-$HeadTime,4)."]";
echo "</small>";
?>
</p>
</card>
<card id="say" title="Написать">
<p align="left">
Ник
<br/>
<?
$l = mysql_query("SELECT login FROM recs where ip='".$addr."' and brows='".$agent."' and time2>'".$timeb."' order by id desc");
$lf = mysql_fetch_array($l);
$entered=$lf["login"];
?>
<input name="login<? echo $ref; ?>" value="<? echo $entered; ?>" maxlength="16" emptyok="false"/><br/>
Сообщение
<br/>
<input name="msg<? echo $ref; ?>" value="<? echo $_GET['lgn']; ?>" maxlength="200" emptyok="false"/><br/>
E-mail
<br/>
<input name="email" maxlength="32" emptyok="true"/><br/>
Транслит:
<br/>
<select multiple="true" name="translit">
<option value="toall">Включить</option>
</select>
<br/>
<anchor>Написать<go href="index.php?id=<? echo $id; ?>&ref=<? echo $ref; ?>" method="post">
<postfield name="id" value="<? echo $id; ?>"/>
<postfield name="login" value="$(login<? echo $ref; ?>)"/>
<postfield name="email" value="$(email)"/>
<postfield name="msg" value="$(msg<? echo $ref; ?>)"/>
<postfield name="translit" value="$(translit)"/>
</go></anchor>
<?
echo "<br/><a href=\"index.php?id=$id&ref=$ref\">В гостевую</a><br/>";
?>
</p>
</card>
</wml>
<?
exit;
mysql_close($link);
?>