--- wap.php 2001/02/28 09:53:13 1.1
+++ wap.php 2001/03/17 16:40:55 1.8
@@ -1,77 +1,89 @@
-require("Smarty.class.php");
-
-// hdml;version=3.0"
-if (strstr(strtolower($HTTP_ACCEPT), "text/vnd.wap.wml")) {
+#$accept=strtolower($HTTP_ACCEPT);
+#if ($WAP || strstr($accept,"text/vnd.wap.wml") || strstr($accept,"hdml;version=3.0")) {
+# header("Content-Type: text/vnd.wap.wml");
+#}
+header("Content-Type: text/vnd.wap.wml");
global $WAP;
$WAP=1;
require("conn.inc");
-header("Content-Type: text/vnd.wap.wml");
-$sql_where="where visible is true";
+$dbh->dbh_do("insert into wap_ua (ua,referer,url,accept) values ('$HTTP_USER_AGENT','$HTTP_REFERER','$QUERY_STRING','$HTTP_ACCEPT')");
-if (!isset($s)) {
- $sql_limit="limit 10";
-} elseif (isset($s)) {
- $sql_limit="limit 10,$s";
-}
+require("Smarty.class.php");
+$smarty = new Smarty;
-if (isset($id)) {
- $sql_where.=" and id=$id ";
-}
+if ($part && file_exists("templates/wap-$part.tpl")) {
+ include("stocks.inc");
+ $smarty->assign(array(stock=>$stock, date=>$date, time=>$time));
+ $wml=$smarty->fetch("wap-$part.tpl");
+
+} else {
+
+ $on_page=5;
-$num_selected=0;
+ $sql_where="where visible is true";
-$sql="select
- id,title,town_date,body,more,pdf,
- (date-now()::date) as comming,type
- from news $sql_where order by priority desc,date desc $sql_limit";
-$sth = $dbh->prepare("$sql");
-$sth->execute();
-
-function fixup($html) {
- if (strip_tags($html)) {
- $tmp=strip_tags($html);
- } else {
- $tmp=$html;
+ if (!isset($s)) {
+ $sql_limit="limit $on_page";
+ } elseif (isset($s)) {
+ $sql_limit="limit $on_page,$s";
}
- return utf8_encode(htmlspecialchars($tmp));
-}
-$smarty = new Smarty;
+ if (isset($id)) {
+ $sql_where.=" and id=$id ";
+ }
-while ($row=$sth->fetchrow_hash()) {
- $row[title]=fixup($row[title]);
- $row[body]=fixup($row[body]);
- $row[town_date]=fixup($row[town_date]);
- $data[]=$row;
+ $num_selected=0;
- $num_selected++;
-}
+ $sql="select
+ id,title,town_date,body,more,pdf,
+ (date-now()::date) as comming,type
+ from news $sql_where
+ order by priority desc,date desc $sql_limit";
+ $sth = $dbh->prepare("$sql");
+ $sth->execute();
+
+ function fixup($html) {
+ if (strip_tags($html)) {
+ $tmp=strip_tags($html);
+ } else {
+ $tmp=$html;
+ }
+ return utf8_encode(htmlspecialchars($tmp));
+ }
-if ($num_selected == 10) {
- $next=$s+10;
-}
-if ($s && $s >= 10) {
- $prev=$s-10;
-}
+ while ($row=$sth->fetchrow_hash()) {
+ $row[title]=fixup($row[title]);
+ $row[body]=fixup($row[body]);
+ $row[town_date]=fixup($row[town_date]);
+ $data[]=$row;
-$smarty->assign( array (
- data=>$data,
- body=>$wml_body,
- prev=>$prev, next=>$next,
- num_selected=>$num_selected
- ) );
-print '
-';
+ $num_selected++;
+ }
-$smarty->display("wap.tpl");
-} else {
- print "You need wap-enabled device or browser for this page!
-
Go back to main site.";
+ if ($num_selected == $on_page) {
+ $next=$s+$on_page;
+ }
+ if ($s && $s >= $on_page) {
+ $prev=$s-$on_page;
+ }
+
+ $smarty->assign( array (
+ data=>$data,
+ body=>$wml_body,
+ prev=>$prev, next=>$next,
+ num_selected=>$num_selected,
+ on_page=>$on_page
+ ) );
+ $wml=$smarty->fetch("wap.tpl");
}
+
+print '
+'.$wml;
+
?>