View file katrinka.ru/user_ignore.php

File size: 3.7Kb
<?php
  include 'config.php';
  include 'guestbook/mylib.php';
  if (!checkagent($_SERVER['HTTP_USER_AGENT'])) { noemul(); exit; }
  $uid=0;
  session_start();
  $lang=$_GET['lang'];
  $r=htmlspecialchars(trim($_GET['r']),ENT_QUOTES);
  if (!$r) $r=htmlspecialchars(trim($_POST['r']),ENT_QUOTES);
  $id=htmlspecialchars(trim($_GET['id']),ENT_QUOTES);
  $act=htmlspecialchars(trim($_GET['act']),ENT_QUOTES);
  if (!$id) $id=htmlspecialchars(trim($_POST['id']),ENT_QUOTES);
  if ($id==0) 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);
	$nocookie=1;
  }
  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;");
	$rows=pg_numrows($res);

	if (!$rows) {
		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>
<card id="Login" title="Login">
<p align="center">
Login: 
<input type="text" name="login" title="Login" maxlength="10"/><br/>
Password:
<input type="password" name="pass" title="Password" maxlength="15"/><br/>
<anchor title="Add">Add<go href="user_ignore.php" method="post">
<postfield name="login" value="$(login)"/>
<postfield name="pass" value="$(pass)"/>
<?php print "<postfield name=\"lang\" value=\"".$_GET['lang']."\"/>\n";
print "<postfield name=\"id\" value=\"".$id."\"/>\n";
print "<postfield name=\"act\" value=\"".$act."\"/>\n";
print "<postfield name=\"r\" value=\"".$r."\"/>\n"; ?>
</go></anchor>
</p>
</card>
</wml>
<?php
		pg_close($conn);
		exit;
	}
	$uid=pg_result($res,0,0);
	$access=pg_result($res,0,1);
	$_SESSION['id']=$uid;
	$_SESSION['access']=$access;
}

	if (($access > 1)||($uid==$id)||($uid==0)) {
		pg_close($conn);
		header("Location: /");
	}
	

	$res=pg_query($conn, "select access,moder,login from users where id='$id';");
	if (!pg_numrows($res)) {
		pg_close($conn);
		header("Location: /");
	}

	if ((pg_result($res,0,0) > 1)||(pg_result($res,0,1))) {
		pg_close($conn);
		header("Location: /");
	}
	$login=uconv(pg_result($res,0,2));
	if ($act==0) {
		pg_query($conn,"delete from users_ignore where uid='$uid' and who='$id';");
		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 print "<card id=\"IgnDel\" title=\"Removed\" ontimer=\"chat.php?r=".$r."&amp;".SID."&amp;lang=".$lang."\">\n"; ?>
<timer value="10"/>
<p align="center">
<?php print "User ".$login." removed from your ignore list\n"; ?>
</p>
</card>
</wml>
<?php
	} else {
		$res=pg_query($conn,"select who from users_ignore where who='$id' and uid='$uid';");
		if (!pg_numrows($res)) {
			$res=pg_query($conn,"insert into users_ignore (uid,who) values ('$uid','$id');");
		}
		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 print "<card id=\"Ignor\" title=\"Ignore\" ontimer=\"chat.php?r=".$r."&amp;".SID."&amp;lang=".$lang."\">\n"; ?>
<timer value="10"/>
<p align="center">
<?php print "User ".$login." added to your ignore list\n"; ?>
</p>
</card>
</wml>
<?php
	}
	pg_close($conn);
	exit;
?>