View file katrinka.ru/user_sup.php

File size: 3.89Kb
<?php
  include 'config.php';
  include 'guestbook/mylib.php';
  header("Content-type: text/vnd.wap.wml");
  $timex=time();
  session_start();

  $invisible=htmlspecialchars(trim($_POST['invisible']),ENT_QUOTES);
  $translit=htmlspecialchars(trim($_POST['translit']),ENT_QUOTES);
  $refresh=htmlspecialchars(trim($_POST['refresh']),ENT_QUOTES);
  $ppp=htmlspecialchars(trim($_POST['ppp']),ENT_QUOTES);
  $ftpp=htmlspecialchars(trim($_POST['ftpp']),ENT_QUOTES);
  $fppp=htmlspecialchars(trim($_POST['fppp']),ENT_QUOTES);
  $fnewtop=htmlspecialchars(trim($_POST['fnewtop']),ENT_QUOTES);
  $showemail=htmlspecialchars(trim($_POST['showemail']),ENT_QUOTES);
  $showpics=htmlspecialchars(trim($_POST['showpics']),ENT_QUOTES);

  if ($refresh > 999) $refresh=999;
  if ($refresh < 10) $refresh=10;
  if ($ppp > 99) $ppp=99;
  if ($ppp < 1) $ppp=1;
  if ($ftpp > 99) $ftpp=99;
  if ($ftpp < 1) $ftpp=1;
  if ($fppp > 99) $fppp=99;
  if ($fppp < 1) $fppp=1;
  if ($fnewtop=='') $fnewtop='f';
  if ($showemail=='') $showemail=0;
  if ($showpics=='') $showpics=0;

  $_SESSION['ppp']=$ppp;
  $_SESSION['refresh']=$refresh;
  $_SESSION['translit']=$translit;
  $_SESSION['showpics']=$showpics;
  $_SESSION['ftpp']=$ftpp;
  $_SESSION['fppp']=$fppp;
  $_SESSION['fnewtop']=$fnewtop;

  $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']))) {
	$id=$_SESSION['id'];
	$res=pg_query($conn,"select posts from users where id='$id';");
	$posts=pg_result($res,0,0);
	$access=$_SESSION['access'];
} else {
$res=pg_query($conn,"select id,access,posts 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;
}
$id=pg_result($res,0,0);
$access=pg_result($res,0,1);
$posts=pg_result($res,0,2);
$_SESSION['id']=$id;
$_SESSION['access']=$access;
}

if (($access < 1)&&($posts<9000)) $invisible=0;

$res=pg_query($conn,"update users set invisible='$invisible',refresh='$refresh',ppp='$ppp',lastact='$timex',translit='$translit',showemail='$showemail',showpics='$showpics',ftpp='$ftpp',fppp='$fppp',fnewtop='$fnewtop' where id='$id';");
pg_close($conn);

if (!$res) {
	wmlhd();
	print "<p align=\"center\">Error updating user</p>\n";
	print "</card>\n</wml>";
	exit;
} else {
	setcookie("Login", $login, time()+864000, "/");	
	setcookie("Password", $pass, time()+864000, "/");	
?>
<?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') { ?>
<card id="UpdOk" title="Thanks!" ontimer="http://wap.katrinka.ru/chat.php?lang=eng">
<timer value="20"/>
<p>Thank you for updating! We are taking you back to main page...</p>
</card>
</wml> 
<?php } else { ?>
<card id="UpdOk" title="&#x0421;&#x043F;&#x0430;&#x0441;&#x0438;&#x0431;&#x043E;!" ontimer="http://wap.katrinka.ru/chat.php">
<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 }
}
?>