View file katrinka.ru/user_edit_exec.php

File size: 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&amp;r=".$r."&amp;".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=&amp;r=".$r."&amp;".SID."\">\n";
?>
<timer value="20"/>
<p>&#x0421;&#x043F;&#x0430;&#x0441;&#x0438;&#x0431;&#x043E; &#x0437;&#x0430; &#x043E;&#x0431;&#x043D;&#x043E;&#x0432;&#x043B;&#x0435;&#x043D;&#x0438;&#x0435; &#x0412;&#x0430;&#x0448;&#x0438;&#x0445; &#x0434;&#x0430;&#x043D;&#x043D;&#x044B;&#x0445;, &#x043C;&#x044B; &#x0432;&#x043E;&#x0437;&#x0432;&#x0440;&#x0430;&#x0449;&#x0430;&#x0435;&#x043C; &#x0412;&#x0430;&#x0441; &#x043D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;...</p>
</card>
</wml> 
<?php }
}
pg_close($conn);
?>