/[corp_html]/wap.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /wap.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations)
Mon Mar 5 12:02:11 2001 UTC (23 years ago) by dpavlin
Branch: MAIN
Changes since 1.4: +7 -9 lines
update, now works

1 <?
2
3 require("Smarty.class.php");
4
5 if ($WAP || strstr($accept,"text/vnd.wap.wml") || strstr($accept,"hdml;version=3.0")) {
6 header("Content-Type: text/vnd.wap.wml");
7 }
8
9 global $WAP;
10 $WAP=1;
11 require("conn.inc");
12
13 $dbh->dbh_do("insert into wap_ua (ua,referer,url,accept) values ('$HTTP_USER_AGENT','$HTTP_REFERER','$QUERY_STRING','$HTTP_ACCEPT')");
14
15 $on_page=5;
16
17 $sql_where="where visible is true";
18
19 if (!isset($s)) {
20 $sql_limit="limit $on_page";
21 } elseif (isset($s)) {
22 $sql_limit="limit $on_page,$s";
23 }
24
25 if (isset($id)) {
26 $sql_where.=" and id=$id ";
27 }
28
29 $num_selected=0;
30
31 $sql="select
32 id,title,town_date,body,more,pdf,
33 (date-now()::date) as comming,type
34 from news $sql_where order by priority desc,date desc $sql_limit";
35 $sth = $dbh->prepare("$sql");
36 $sth->execute();
37
38 function fixup($html) {
39 if (strip_tags($html)) {
40 $tmp=strip_tags($html);
41 } else {
42 $tmp=$html;
43 }
44 return utf8_encode(htmlspecialchars($tmp));
45 }
46
47 $smarty = new Smarty;
48
49 while ($row=$sth->fetchrow_hash()) {
50 $row[title]=fixup($row[title]);
51 $row[body]=fixup($row[body]);
52 $row[town_date]=fixup($row[town_date]);
53 $data[]=$row;
54
55 $num_selected++;
56 }
57
58
59 if ($num_selected == $on_page) {
60 $next=$s+$on_page;
61 }
62 if ($s && $s >= $on_page) {
63 $prev=$s-$on_page;
64 }
65
66 $smarty->assign( array (
67 data=>$data,
68 body=>$wml_body,
69 prev=>$prev, next=>$next,
70 num_selected=>$num_selected,
71 on_page=>$on_page
72 ) );
73 $wml=$smarty->fetch("wap.tpl");
74
75 print '<?xml version="1.0"?>
76 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">'.$wml;
77
78 ?>

  ViewVC Help
Powered by ViewVC 1.1.26