/[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.10 - (hide annotations)
Fri Jul 13 12:27:08 2001 UTC (20 years, 10 months ago) by dpavlin
Branch: MAIN
Changes since 1.9: +2 -1 lines
fix dollar sign

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

  ViewVC Help
Powered by ViewVC 1.1.26