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

Размер файла: 3.31Kb
<?php
  include 'mylib.php';
  include '../config.php';
  session_start();
  header("Cache-Control: max-age=30");
  header("Content-type: text/vnd.wap.wml");
  $ppp=3;
  $lang=$_GET['lang'];
  $p=$_GET['p'];
?>
<?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="max-age=30" forua="true"/></head>
<?php
  if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass")))
  { ?>
<card id="BookErr" title="&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;">
<p align="center">
&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430; &#x043F;&#x043E;&#x0434;&#x043A;&#x043B;&#x044E;&#x0447;&#x0435;&#x043D;&#x0438;&#x044F; &#x043A; &#x0411;&#x0414<br/>
<a href="/">&#x041D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;</a>
</p>
</card>
</wml>
<?php
	exit;
    }
if ($lang=='eng') {
		print "<card id=\"Guestbook\" title=\"Browsing\">\n";
		print "<p align=\"center\">Guestbook<br/>---------------</p><p>\n";
	} else {
		print "<card id=\"Guestbook\" title=\"&#x041A;&#x043D;&#x0438;&#x0433;&#x0430; &#x043E;&#x0442;&#x0437;&#x044B;&#x0432;&#x043E;&#x0432;\">\n";
		print "<p align=\"center\">&#x041A;&#x043D;&#x0438;&#x0433;&#x0430; &#x043E;&#x0442;&#x0437;&#x044B;&#x0432;&#x043E;&#x0432;<br/>---------------</p><p>\n";
}
  $res=pg_query($conn,"select count (id) from wapgbk where moder=0;");
  $numrec=pg_result($res,0,0);

  $offset=$p*$ppp;
  $res=pg_query($conn,"select wapgbk.name,wapgbk.message,wapgbk.reply,users.login,users.id,wapgbk.mtime from wapgbk,users where wapgbk.uid=users.id and wapgbk.moder=0 order by wapgbk.id desc limit $ppp offset $offset;");
  $rows=pg_numrows($res);
  $np=$p+1; $pp=$p-1; $mp=floor($numrec/$ppp);

  for ($i=0;$i<$rows;$i++) {
	$reply=uconv(preg_replace("/\n/","<br/>", pg_result($res,$i,2)));
    $message=uconv(preg_replace("/\n/","<br/>",pg_result($res,$i,1)));
	$name=uconv(pg_result($res,$i,3));
	ereg ("([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", pg_result($res,$i,5), $regs);
	$mtime=sprintf("%s:%s", $regs[1], $regs[2]);
	if ($name=='Guest') $name=uconv(pg_result($res,$i,0));
	echo"<a href=\"../user_info.php?id=".pg_result($res,$i,4)."\">". $name." ".$mtime."&gt;</a><br/>".
	$message."<br/>";
	if ($reply!='') 
		if ($lang=='eng') echo "<br/><b>Reply:</b><br/>".$reply."<br/>";
		else echo "<br/><b>&#x043E;&#x0442;&#x0432;&#x0435;&#x0442;:</b><br/>".$reply."<br/>";
	echo "---------------<br/>\n";
  }

  pg_close($conn);

if ($lang=='eng') print "<a href=\"add.php\">Sign</a><br/>\n";
else print "<a href=\"add.php\">&#x041D;&#x0430;&#x043F;&#x0438;&#x0441;&#x0430;&#x0442;&#x044C;</a><br/>\n";

 if ($numrec > $ppp)
	if ($lang=='eng') {
		if ($p<$mp) print("<a href=\"browse.php?p=".$np."&amp;lang=eng\" accesskey=\"1\">Next ".$ppp."</a><br/>");
		if ($p>0) print("<a href=\"browse.php?p=".$pp."&amp;lang=eng\" accesskey=\"2\">Prev ".$ppp."</a><br/>"); 
	} else {
		if ($p<$mp) print("<a href=\"browse.php?p=".$np."\" accesskey=\"1\">Next ".$ppp."</a><br/>");
		if ($p>0) print("<a href=\"browse.php?p=".$pp."\" accesskey=\"2\">Prev ".$ppp."</a><br/>"); 
	}
if ($lang=='eng') print "<a href=\"/english.wml\">Main page</a>\n";
else print "<a href=\"/\">&#x041D;&#x0430; &#x0433;&#x043B;&#x0430;&#x0432;&#x043D;&#x0443;&#x044E;</a>\n";
?>
</p>
</card>
</wml>