<?php
include 'config.php';
include 'guestbook/mylib.php';
if (!checkagent($_SERVER['HTTP_USER_AGENT'])) { noemul(); exit; }
list ($opname, $chatok) = check_op($_SERVER['REMOTE_ADDR']);
if (!$chatok) { unk_op(); exit; }
session_start();
header("Content-type: text/vnd.wap.wml");
$timex=time();
$slogin=htmlspecialchars(trim($_POST['slogin']),ENT_QUOTES);
$semail=htmlspecialchars(trim($_POST['semail']),ENT_QUOTES);
if (($slogin=='')||($semail=='')) {
wmlhd();
print "<p align=\"center\">Enter your nick and e-mail!</p>\n";
print "</card>\n</wml>";
exit;
}
$lang=$_GET['lang'];
if (isset($_SESSION['id'])) exit;
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);
}
if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) {
wmlhd();
print "<p align=\"center\">Error connecting to database</p>\n";
print "</card>\n</wml>";
exit;
}
$res=pg_query($conn,"select id,passwd,lastpwdrem from users where login='$slogin' and email='$semail' and moder=0;");
if (pg_numrows($res)!=1) {
wmlhd();
print "<p align=\"center\">Sorry, user NOT FOUND.</p>\n";
print "</card>\n</wml>";
pg_close($conn);
exit;
}
$id=pg_result($res,0,0);
$passwd=iconv("UTF-8","KOI8-R",pg_result($res,0,1));
$lastpwdrem=pg_result($res,0,2);
$timex=time();
if ($lastpwdrem > ($timex-86400)) {
wmlhd();
print "<p align=\"center\">Sorry, only one password reminder per day is allowed...</p>\n";
print "</card>\n</wml>";
pg_close($conn);
exit;
} else {
pg_query($conn,"update users set lastpwdrem='$timex' where id='$id';");
}
pg_close($conn);
mail($semail,"Your password at wap.katrinka.ru","Thank you for using our password-reminder service at wap.katrinka.ru!\nYour password is: ".$passwd."\nYou can change it in your profile.","From: [email protected]\nMIME-Version: 1.0\nContent-Type: text/plain; charset=koi8-r\nContent-Transfer-Encoding: 8bit");
?>
<?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>
<card id="OK" title="OK">
<p align="center">
Your password has been succesfully e-mailed to you!<br/>
<br/>
<a href="index.php">Main page</a>
</p>
<?php counters(); ?>
</card>
</wml>