View file katrinka.ru/index.php

File size: 5.71Kb
<?php
  include 'guestbook/mylib.php';
  include 'config.php';
  session_start();
  header("Cache-Control: no-cache");
  header("Content-type: text/vnd.wap.wml");
  $reg=0;
  $lang=$_GET['lang'];
  $agent=$_SERVER['HTTP_USER_AGENT'];
  if (($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) {
	if (isset($_SESSION['id'])) {
		$uid=$_SESSION['id'];
		$id=$uid;
		$reg=1;
		$res=pg_query($conn,"select moder from users where id='$uid';");
		$moder=pg_result($res,0,0);
	} else {
  		if ((trim($_COOKIE['Login'])!='')&&(trim($_COOKIE['Password'])!='')) {
			$login=htmlspecialchars(trim($_COOKIE['Login']),ENT_QUOTES);
			$pass=htmlspecialchars(trim($_COOKIE['Password']),ENT_QUOTES);
		}
		if (($login=='')||($pass=='')) {
			$login=htmlspecialchars(trim($_GET['login']),ENT_QUOTES);
			$pass=htmlspecialchars(trim($_GET['pass']),ENT_QUOTES);
			$uid=htmlspecialchars(trim($_GET['uid']),ENT_QUOTES);
		}
		if (($login!='')&&($pass!='')) {
			$res=pg_query($conn,"select id,moder from users where login='$login' and passwd='$pass';");
			if (pg_numrows($res)==1) {
				$reg=1;
				$id=pg_result($res,0,0);	
				$_SESSION['id']=$id;
				$moder=pg_result($res,0,1);
				$timex=time();
				pg_query($conn,"update users set lastact='$timex',lastagent='$agent' where id='$id';");
			}
		}
		if (($uid!='')&&($pass!='')) {
			$res=pg_query($conn,"select moder from users where id='$uid' and passwd='$pass';");
			if (pg_numrows($res)==1) {
				$reg=1;
				$id=$uid;
				$_SESSION['id']=$id;
				$moder=pg_result($res,0,0);
				$timex=time();
				pg_query($conn,"update users set lastact='$timex',lastagent='$agent' where id='$id';");
			}
		}
	}
	$res=pg_query($conn,"select v_num from site_var where id=2;");	
	$numusers=pg_result($res,0,0);
	$timex=time()-300;
	$res_chat=pg_query($conn,"select distinct fr_u from chat where time > '$timex';");
	$numchat=pg_numrows($res_chat);
	if ($reg) {
		$res_pmsg=pg_query($conn,"select count(*) from messages where to_u='$id';");
		$pmsg=pg_result($res_pmsg,0,0);
		$res_pmsg=pg_query($conn,"select count(*) from messages where to_u='$id' and flag=0;");
		$npmsg=pg_result($res_pmsg,0,0);
	}
	pg_close($conn);
  }
?>
<?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>
<card id="MainCard" title="wap.katrinka.ru">
<p align="center">
<?php if (color_phone($agent)) { ?>
  <img src="katrinka_1.gif" alt="" /><br/>
<?php } else { ?>
  <img src="img/logo.wbmp" alt="" /><br/>
<?php } ?>
<?php if ($lang=='eng') { ?>
<a href="index.php">Russian Version</a><br/>
<br/>
<b>Welcome!</b><br/>
<?php if (!$reg) {
	loginform(0);
	print "<a href=\"regform.php?lang=eng\">FREE Registration</a><br/>\n";
	print "<a href=\"passremind.php?lang=eng\">Forgot your password?</a><br/>\n";
}
?>
*******<br/>
<a href="/midi.php?lang=eng" accesskey="1">Polyphonic Ringtones For Nokia Mobile Phones</a><br/>
<?php if ($gbenable) { ?>
<a href="guestbook/english.wml" accesskey="4">Guestbook</a><br/>
<?php }
print "<a href=\"chat.php\" accesskey=\"5\">Chat (".$numchat.")</a><br/>\n";
print "<a href=\"forum.php\" accesskey=\"3\">Forum</a><br/>\n";
print "<a href=\"messages.php\" accesskey=\"6\">Private messages (".$npmsg."/".$pmsg.")</a><br/>\n";
?>
<a href="user_pref.php?lang=eng" accesskey="8">Your Profile</a><br/>
<a href="faq/" accesskey="9">FAQ</a><br/>
<br/>
<?php } else { ?>
<a href="index.php?lang=eng">English Version</a><br/>
<br/>
<?php if (!$reg) {
	loginform(0);
	print "<a href=\"regform.php\">&#x0420;&#x0435;&#x0433;&#x0438;&#x0441;&#x0442;&#x0440;&#x0430;&#x0446;&#x0438;&#x044F;</a><br/>\n";
	print "<a href=\"passremind.php\">&#x0417;&#x0430;&#x0431;&#x044B;&#x043B;&#x0438; &#x043F;&#x0430;&#x0440;&#x043E;&#x043B;&#x044C;?</a><br/>\n";
} ?>
<a href="user_pref.php">&#x0412;&#x0430;&#x0448; &#x041F;&#x0440;&#x043E;&#x0444;&#x0430;&#x0439;&#x043B;</a><br/>
<br/>
<a href="nokia.php" accesskey="1">Nokia</a><br/>
<a href="users/index.php" accesskey="2">&#x041F;&#x043E;&#x043B;&#x044C;&#x0437;&#x043E;&#x0432;&#x0430;&#x0442;&#x0435;&#x043B;&#x0438;</a><br/>
<?php if ($gbenable) { ?>
<a href="guestbook/" accesskey="4">&#x041A;&#x043D;&#x0438;&#x0433;&#x0430; &#x043E;&#x0442;&#x0437;&#x044B;&#x0432;&#x043E;&#x0432;</a><br/>
<?php }
print "<a href=\"chat.php\" accesskey=\"5\">&#x0427;&#x0430;&#x0442; (".$numchat.")</a><br/>\n";
print "<a href=\"forum.php\" accesskey=\"3\">&#x0424;&#x043E;&#x0440;&#x0443;&#x043C;</a><br/>\n";
print "<a href=\"messages.php\" accesskey=\"6\">&#x041B;&#x0438;&#x0447;&#x043D;&#x044B;&#x0435; &#x0441;&#x043E;&#x043E;&#x0431;&#x0449;&#x0435;&#x043D;&#x0438;&#x044F; (".$npmsg."/".$pmsg.")</a><br/>\n";
print "<a href=\"links.wml\" accesskey=\"7\">&#x041F;&#x043E;&#x043B;&#x0435;&#x0437;&#x043D;&#x044B;&#x0435; &#x0441;&#x0441;&#x044B;&#x043B;&#x043A;&#x0438;</a><br/>\n";
print "<a href=\"search.php\" accesskey=\"8\">&#x041F;&#x043E;&#x0438;&#x0441;&#x043A; &#x043F;&#x043E; WAP</a><br/>\n";
?>
<a href="bbs/">&#x041E;&#x0431;&#x044A;&#x044F;&#x0432;&#x043B;&#x0435;&#x043D;&#x0438;&#x044F;</a><br/>
<a href="faq/" accesskey="9">FAQ</a><br/>
<?php } ?>
<br/>
<?php if ($lang=='eng') print "Registered users: <a href=\"users/user_search.php?lang=eng\">".$numusers."</a><br/>\n";
else print "&#x0417;&#x0430;&#x0440;&#x0435;&#x0433;&#x0438;&#x0441;&#x0442;&#x0440;&#x0438;&#x0440;&#x043E;&#x0432;&#x0430;&#x043D;&#x043E; &#x043F;&#x043E;&#x043B;&#x044C;&#x0437;&#x043E;&#x0432;&#x0430;&#x0442;&#x0435;&#x043B;&#x0435;&#x0439;: <a href=\"users/user_search.php\">".$numusers."</a><br/>\n"; ?>
<br/>
<a href="http://petr.putel.org"><img src="http://petr.putel.org/counters/counter.php?xking" alt="Petr`s Counters"/></a><br/>
</p>
<?php counters(); ?>
</card>
</wml>