Просмотр файла katrinka.ru/chat_add.php

Размер файла: 3.72Kb
<?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();
  $reg=0;
  $lang=$_GET['lang'];
  $to=htmlspecialchars(trim($_GET['to']),ENT_QUOTES);
  $n=htmlspecialchars(trim($_GET['n']),ENT_QUOTES);
  $r=htmlspecialchars(trim($_GET['r']),ENT_QUOTES);
  if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) { exit; }
  if (isset($_SESSION['id'])) {
	$reg=1;
    $id=$_SESSION['id'];
	if (!isset($_SESSION['translit'])) {
		$res=pg_query($conn,"select translit,access from users where id='$id';");
		$_SESSION['translit']=pg_result($res,0,0);
		$_SESSION['access']=pg_result($res,0,1);
	}
	$translit=$_SESSION['translit'];
	$access=$_SESSION['access'];
		
  } else {
  if ((trim($_COOKIE['Login'])!='')&&(trim($_COOKIE['Password'])!='')) {
	$login=htmlspecialchars(trim($_COOKIE['Login']),ENT_QUOTES);
	$pass=htmlspecialchars(trim($_COOKIE['Password']),ENT_QUOTES);
	$res=pg_query($conn,"select id,translit,access from users where login='$login' and passwd='$pass';");
	if (pg_numrows($res)==1) {
		$id=pg_result($res,0,0);
		$translit=pg_result($res,0,1);
		$access=pg_result($res,0,2);
		$reg=1;
		$_SESSION['id']=$id;
		$_SESSION['translit']=$translit;
		$_SESSION['access']=$access;
	}
  }
  }
# header("Cache-Control: no-cache");
 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
	if ($lang=='eng')
		print "<card id=\"Sign\" title=\"Sign\" newcontext=\"true\">\n";
	else
		print "<card id=\"Sign\" title=\"&#x041D;&#x0430;&#x043F;&#x0438;&#x0441;&#x0430;&#x0442;&#x044C;\" newcontext=\"true\">\n";
	print "<p>\n";
	if ($to) {
		$res=pg_query($conn,"select login from users where id='$to';");
		if (pg_numrows($res)==1) {
			$nick=uconv(pg_result($res,0,0));
		}
		if (!$n) print "Private message to: ".$nick."<br/>\n";
		else print "Address to: ".$nick."<br/>\n";
	}
	pg_close($conn);
	if (!$reg) {
			print "Login:\n";
			print "<input name=\"login\" title=\"Login\" maxlength=\"15\"/><br/>\n";
			print "Password: <input name=\"pass\" type=\"password\" title=\"Password\" emptyok=\"false\" maxlength=\"15\"/><br/>\n";
	}
	if (!$translit) {
?>
Convert from translit:
<select name="tr" value="0">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
<br/>
<?php
	}
	if (($r==18)&&($to==0)) {
		if ($lang=='eng') {
			print "To:\n";
		} else {
			print "&#x041A;&#x043E;&#x043C;&#x0443;:\n";
		}
		print "<input type=\"text\" name=\"tto\" title=\"To\" value=\"\" maxlength=\"15\" /><br/>\n";
	}
	if ($lang=='eng')
		print "Your message:\n";
	else
		print "&#x0421;&#x043E;&#x043E;&#x0431;&#x0449;&#x0435;&#x043D;&#x0438;&#x0435;:\n";
	if (($access==4)||($id==1)) {
		print "<input type=\"text\" name=\"message\" title=\"Text\" value=\"\"/><br/>\n";
	} else {
		print "<input type=\"text\" name=\"message\" title=\"Text\" maxlength=\"150\" value=\"\"/><br/>\n";
	}
?>
<anchor title="Ok">Ok<go href="chat_sign.php" method="post">
<?php if (!$reg) {
	print "<postfield name=\"login\" value=\"$(login)\"/>\n";
	print "<postfield name=\"pass\" value=\"$(pass)\"/>\n";
} 
print "<postfield name=\"lang\" value=\"".$_GET['lang']."\"/>\n";
print "<postfield name=\"r\" value=\"".$r."\"/>\n";
print "<postfield name=\"to\" value=\"".$to."\"/>\n";
print "<postfield name=\"n\" value=\"".$n."\"/>\n";
if (!$translit) print "<postfield name=\"tr\" value=\"$(tr)\"/>\n";
if ($r==18) print "<postfield name=\"tto\" value=\"$(tto)\"/>\n";
?>
<postfield name="message" value="$(message)"/>
</go></anchor>
</p>
</card>
</wml>