View file katrinka.ru/guestbook/sign.php

File size: 4.15Kb
<?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="&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;">
<p align="center">
&#x041D;&#x0435; &#x0432;&#x0441;&#x0435; &#x043F;&#x043E;&#x043B;&#x044F; &#x0437;&#x0430;&#x043F;&#x043E;&#x043B;&#x043D;&#x0435;&#x043D;&#x044B;<br/>
<a href="/">&#x041D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;</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="/">&#x041D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;</a>
</p>
</card>
</wml>
<?php
	exit;
    }

  if (!$uid)
  { ?>
<card id="SignErr" title="&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;">
<p align="center">
Bad login or password.
<a href="/">&#x041D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;</a>
</p>
</card>
</wml>
<?php
	exit;
    }
  
    if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass")))
  { ?>
<card id="SignErr" title="&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;">
<p align="center">
&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430; &#x043F;&#x043E;&#x0434;&#x043A;&#x043B;&#x044E;&#x0447;&#x0435;&#x043D;&#x0438;&#x044F; &#x043A; &#x0411;&#x0414<br/>
<a href="/">&#x041D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;</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="&#x041D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;" ontimer="http://wap.katrinka.ru">
<timer value="20"/>
<p align="center">
<a href="/">&#x041D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;</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="&#x0421;&#x043F;&#x0430;&#x0441;&#x0438;&#x0431;&#x043E;!" ontimer="http://wap.katrinka.ru/guestbook/browse.php" onenterbackward="http://wap.katrinka.ru/">
<timer value="20"/>
<p align="center">
&#x0412;&#x0430;&#x0448;&#x0430; &#x0437;&#x0430;&#x043F;&#x0438;&#x0441;&#x044C; &#x0434;&#x043E;&#x0431;&#x0430;&#x0432;&#x043B;&#x0435;&#x043D;&#x0430;<br/>
<a href="browse.php">&#x041F;&#x0440;&#x043E;&#x0441;&#x043C;&#x043E;&#x0442;&#x0440;</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");
?>