/[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.6 - (show annotations)
Mon Mar 5 18:49:13 2001 UTC (23 years, 1 month ago) by dpavlin
Branch: MAIN
Changes since 1.5: +6 -5 lines
force wap

1 <?
2
3 #$accept=strtolower($HTTP_ACCEPT);
4 #if ($WAP || strstr($accept,"text/vnd.wap.wml") || strstr($accept,"hdml;version=3.0")) {
5 # header("Content-Type: text/vnd.wap.wml");
6 #}
7 header("Content-Type: text/vnd.wap.wml");
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 require("Smarty.class.php");
48 $smarty = new Smarty;
49
50 while ($row=$sth->fetchrow_hash()) {
51 $row[title]=fixup($row[title]);
52 $row[body]=fixup($row[body]);
53 $row[town_date]=fixup($row[town_date]);
54 $data[]=$row;
55
56 $num_selected++;
57 }
58
59
60 if ($num_selected == $on_page) {
61 $next=$s+$on_page;
62 }
63 if ($s && $s >= $on_page) {
64 $prev=$s-$on_page;
65 }
66
67 $smarty->assign( array (
68 data=>$data,
69 body=>$wml_body,
70 prev=>$prev, next=>$next,
71 num_selected=>$num_selected,
72 on_page=>$on_page
73 ) );
74 $wml=$smarty->fetch("wap.tpl");
75
76 print '<?xml version="1.0"?>
77 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">'.$wml;
78
79 ?>

  ViewVC Help
Powered by ViewVC 1.1.26