Размер файла: 3.48Kb
<?php
include 'config.php';
include 'guestbook/mylib.php';
session_start();
header("Content-type: text/vnd.wap.wml");
# $timex=time();
$id=htmlspecialchars(trim($_POST['id']),ENT_QUOTES);
$r=htmlspecialchars(trim($_POST['r']),ENT_QUOTES);
$ulogin=htmlspecialchars(trim($_POST['ulogin']),ENT_QUOTES);
$uaccess=htmlspecialchars(trim($_POST['uaccess']),ENT_QUOTES);
$invisible=htmlspecialchars(trim($_POST['invisible']),ENT_QUOTES);
$cust_status=htmlspecialchars(trim($_POST['cust_status']),ENT_QUOTES);
$moder=htmlspecialchars(trim($_POST['moder']),ENT_QUOTES);
$ban=htmlspecialchars(trim($_POST['ban']),ENT_QUOTES);
$agent=$_SERVER['HTTP_USER_AGENT'];
$addr=$_SERVER['REMOTE_ADDR'];
$lang=$_POST['lang'];
if (!$id) exit;
if ($id==2) { $ulogin='xKing'; $uaccess=4; }
$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);
}
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;
}
if ((isset($_SESSION['id']))&&(isset($_SESSION['access']))) {
$uid=$_SESSION['id'];
$access=$_SESSION['access'];
} else {
$res=pg_query($conn,"select id,access from users where login='$login' and passwd='$pass' and moder=0;");
if (pg_numrows($res)!=1) {
wmlhd();
print "<p align=\"center\">Sorry, BAD login</p>\n";
print "</card>\n</wml>";
pg_close($conn);
exit;
}
$uid=pg_result($res,0,0);
$access=pg_result($res,0,1);
$_SESSION['id']=$uid;
$_SESSION['access']=$access;
}
$res=pg_query($conn,"select id from users where login='$ulogin';");
if (pg_numrows($res)==1) {
$did=pg_result($res,0,0);
if ($id!=$did) {
pg_close($conn);
wmlhd();
print "<p align=\"center\">Sorry, this nickname already exists</p>\n";
print "</card>\n</wml>";
exit;
}
}
if (($ban==1)&&(!$moder)) $moder=$uid;
if (!$ban) $moder=0;
$res=pg_query($conn,"update users set login='$ulogin',moder='$moder',cust_status='$cust_status',access='$uaccess',invisible='$invisible' where id='$id';");
if (!$res) {
wmlhd();
print "<p align=\"center\">Error updating user</p>\n";
print "</card>\n</wml>";
pg_close($conn);
exit;
} else {
?>
<?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 ($lang=='eng') {
print "<card id=\"UpdOk\" title=\"Thanks!\" ontimer=\"http://wap.katrinka.ru/chat.php?lang=eng&r=".$r."&".SID."\">\n";
?>
<timer value="20"/>
<p>Thank you for updating! We are taking you back to main page...</p>
</card>
</wml>
<?php } else {
print "<card id=\"UpdOk\" title=\"Thanks!\" ontimer=\"http://wap.katrinka.ru/chat.php?lang=&r=".$r."&".SID."\">\n";
?>
<timer value="20"/>
<p>Спасибо за обновление Ваших данных, мы возвращаем Вас на главную...</p>
</card>
</wml>
<?php }
}
pg_close($conn);
?>