Размер файла: 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="Ошибка">
<p align="center">
Ошибка подключения к БД<br/>
<a href="/">На главную</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=\"Книга отзывов\">\n";
print "<p align=\"center\">Книга отзывов<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."></a><br/>".
$message."<br/>";
if ($reply!='')
if ($lang=='eng') echo "<br/><b>Reply:</b><br/>".$reply."<br/>";
else echo "<br/><b>ответ:</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\">Написать</a><br/>\n";
if ($numrec > $ppp)
if ($lang=='eng') {
if ($p<$mp) print("<a href=\"browse.php?p=".$np."&lang=eng\" accesskey=\"1\">Next ".$ppp."</a><br/>");
if ($p>0) print("<a href=\"browse.php?p=".$pp."&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=\"/\">На главную</a>\n";
?>
</p>
</card>
</wml>