<?php
include 'mylib.php';
include '../config.php';
if (!checkagent($_SERVER['HTTP_USER_AGENT'])) { noemul(); exit; }
session_start();
$message=htmlspecialchars(trim($_POST['message']),ENT_QUOTES);
$agent=$_SERVER['HTTP_USER_AGENT'];
$addr=$_SERVER['REMOTE_ADDR'];
$uid=0;
$lang=$_GET['lang'];
if ((trim($_COOKIE['Login'])!='')&&(trim($_COOKIE['Password'])!='')) {
$login=htmlspecialchars(trim($_COOKIE['Login']),ENT_QUOTES);
$pass=htmlspecialchars(trim($_COOKIE['Password']),ENT_QUOTES);
} else {
$login=htmlspecialchars(trim($_POST['login']),ENT_QUOTES);
$pass=htmlspecialchars(trim($_POST['pass']),ENT_QUOTES);
}
$uid=uauth($login,$pass);
if ($uid) {
setcookie("Login", $login, time()+864000, "/");
setcookie("Password", $pass, time()+864000, "/");
}
header("Content-type: text/vnd.wap.wml");
?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.dtd">
<wml>
<?php
if ($message=="")
{ ?>
<card id="SignErr" title="Ошибка">
<p align="center">
Не все поля заполнены<br/>
<a href="/">На главную</a>
</p>
</card>
</wml>
<?php
exit;
}
if (!$gbenable)
{ ?>
<card id="SignErr" title="Sorry">
<p align="center">
Sorry, guestbook is temporary closed. Please come there later!<br/>
<a href="/">На главную</a>
</p>
</card>
</wml>
<?php
exit;
}
if (!$uid)
{ ?>
<card id="SignErr" title="Ошибка">
<p align="center">
Bad login or password.
<a href="/">На главную</a>
</p>
</card>
</wml>
<?php
exit;
}
if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass")))
{ ?>
<card id="SignErr" title="Ошибка">
<p align="center">
Ошибка подключения к БД<br/>
<a href="/">На главную</a>
</p>
</card>
</wml>
<?php
exit;
}
$res=pg_query($conn,"select message from wapgbk where id=(select max(id) from wapgbk where uid='$uid');");
if (pg_numrows($res)) {
if ($message==pg_result($res,0,0)) {
?>
<card id="SignDup" title="На главную" ontimer="http://wap.katrinka.ru">
<timer value="20"/>
<p align="center">
<a href="/">На главную</a>
</p>
</card>
</wml>
<?php
pg_close($conn);
exit;
}
}
$timex=time();
pg_query($conn,"update users set lastact='$timex' where id='$uid';");
$res=pg_query($conn,"insert into wapgbk (mdate,mtime,uid,message,ip,agent) values ('now','now','$uid','$message','$addr','$agent');");
if (!$res) { pg_close($conn); exit; }
# pg_query($conn,"SET CLIENT_ENCODING TO 'KOI8';");
# $res=pg_query($conn,"select name,message from wapgbk where id=(select max(id) from wapgbk);");
# $name=pg_result($res,0,0);
# $message=pg_result($res,0,1);
pg_close($conn);
?>
<card id="SignOk" title="Спасибо!" ontimer="http://wap.katrinka.ru/guestbook/browse.php" onenterbackward="http://wap.katrinka.ru/">
<timer value="20"/>
<p align="center">
Ваша запись добавлена<br/>
<a href="browse.php">Просмотр</a>
</p>
</card>
</wml>
<?php
#mail("[email protected], [email protected]", "дПВБЧМЕОП УППВЭЕОЙЕ Ч ЗПУФЕЧПК ЛОЙЗЕ WAP УБКФБ", "пФ: $name\nE-mail: $email\nHost: ".gethostbyaddr($addr)." [$addr]\nAgent: $agent\nфЕЛУФ:\n$message","From: зПУФЕЧБС ЛОЙЗБ WAP УБКФБ <[email protected]>\nReply-To: $email\nContent-Type: text/plain; charset=KOI8-r");
?>