View file katrinka.ru/user_edit.php

File size: 3.93Kb
<?php
  include 'config.php';
  include 'guestbook/mylib.php';
  session_start();
  header("Cache-Control: no-cache");
  header("Content-type: text/vnd.wap.wml");
  if (ereg("^SIE-.*",$_SERVER['HTTP_USER_AGENT'])) $sie=1; else $sie=0;
  $uid=0;
  $lang=$_GET['lang'];
  $id=htmlspecialchars(trim($_GET['id']),ENT_QUOTES);
  $r=htmlspecialchars(trim($_GET['r']),ENT_QUOTES);
  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"))) 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) {
	$uid=pg_result($res,0,0);
	$access=pg_result($res,0,1);	
	$_SESSION['id']=$uid;
	$_SESSION['access']=$access;
  }
}
	if ($access==4) $auth=1;
	if ($uid==1) $auth=1;
 if (!$auth) { pg_close($conn); exit; }
?>
<?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>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<?php
	$res=pg_query($conn,"select cust_status,moder,login,access,invisible from users where id='$id';");
	$rows=pg_numrows($res);

	if (!$rows) { 
		print "<card id=\"Login\" title=\"Login\">\n";
		print "<p>\n";
		print "Unknown user id\n";
		print "</p></card></wml>";
		exit;

	}
	$cust_status=uconv(pg_result($res,0,0));
	$moder=pg_result($res,0,1);
	$ulogin=uconv(pg_result($res,0,2));
	$uaccess=uconv(pg_result($res,0,3));
	$invisible=uconv(pg_result($res,0,4));

		print "<card id=\"Edit\" title=\"".$ulogin."\" newcontext=\"true\">\n";

		print "<p>\n";

		print "Login:\n";
		print "<input type=\"text\" name=\"ulogin\" title=\"Login\" maxlength=\"15\" value=\"".$ulogin."\" /><br/>\n";

		if ($lang=='eng')
			print "Status:\n";
		else
			print "&#x0421;&#x0442;&#x0430;&#x0442;&#x0443;&#x0441;:\n";
		print "<input type=\"text\" name=\"cust_status\" title=\"Status\" maxlength=\"50\" value=\"".$cust_status."\"/><br/>\n";
	
		print "Invisible:\n";
		print "<select name=\"invisible\" value=\"".$invisible."\">\n";
		print "<option value=\"0\">No</option>\n";
		print "<option value=\"1\">Yes</option>\n";
		print "</select><br/>\n";

		print "Banned:\n";
		if ($moder) $ban=1; else $ban=0;
		print "<select name=\"ban\" value=\"".$ban."\">\n";
		print "<option value=\"0\">No</option>\n";
		print "<option value=\"1\">Yes</option>\n";
		print "</select>\n";
		if ($moder) {
			$res=pg_query($conn,"select login from users where id='$moder';");
			if (pg_numrows($res)==1) print "(".uconv(pg_result($res,0,0)).")\n";
		}
		pg_close($conn);
		print "<br/>Access level:\n";
		print "<select name=\"uaccess\" value=\"".$uaccess."\">\n";
		print "<option value=\"0\">User</option>\n";
		print "<option value=\"1\">VIP</option>\n";
		print "<option value=\"2\">Moderator</option>\n";
		print "<option value=\"3\">Super Moderator</option>\n";
		print "<option value=\"4\">Administrator</option>\n";
		print "</select><br/>\n";

?>
<anchor title="Ok">Ok<go href="user_edit_exec.php" method="post">
<postfield name="ulogin" value="$(ulogin)"/>
<postfield name="cust_status" value="$(cust_status)"/>
<postfield name="ban" value="$(ban)"/>
<postfield name="uaccess" value="$(uaccess)"/>
<postfield name="invisible" value="$(invisible)"/>
<?php print "<postfield name=\"lang\" value=\"".$lang."\"/>\n";
	  print "<postfield name=\"r\" value=\"".$r."\"/>\n";
	  print "<postfield name=\"id\" value=\"".$id."\"/>\n";
      print "<postfield name=\"moder\" value=\"".$moder."\"/>\n"; ?>
</go></anchor>
</p>
</card>
</wml>