/[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

Annotation of /wap.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Thu Mar 1 12:56:52 2001 UTC (23 years ago) by dpavlin
Branch: MAIN
Changes since 1.3: +1 -1 lines
force wap with http:////....wap.php?WAP=1

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

  ViewVC Help
Powered by ViewVC 1.1.26