/[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.11 - (hide annotations)
Thu Jun 6 11:29:44 2002 UTC (17 years ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +6 -2 lines
new pictures for wap, wap integration with inc/news_type.inc

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 dpavlin 1.11 include("news_type.inc");
25 dpavlin 1.7
26     $on_page=5;
27    
28 dpavlin 1.11 # $sql_where="where visible is true and type<>'p'";
29     $sql_where="where visible is true and (type='".join("' or type='",array_keys($wap_pics))."')";
30 dpavlin 1.7
31     if (!isset($s)) {
32     $sql_limit="limit $on_page";
33     } elseif (isset($s)) {
34     $sql_limit="limit $on_page,$s";
35     }
36 dpavlin 1.1
37 dpavlin 1.7 if (isset($id)) {
38     $sql_where.=" and id=$id ";
39     }
40 dpavlin 1.1
41 dpavlin 1.7 $num_selected=0;
42 dpavlin 1.1
43 dpavlin 1.7 $sql="select
44     id,title,town_date,body,more,pdf,
45     (date-now()::date) as comming,type
46     from news $sql_where
47     order by priority desc,date desc $sql_limit";
48     $sth = $dbh->prepare("$sql");
49     $sth->execute();
50    
51     function fixup($html) {
52     if (strip_tags($html)) {
53     $tmp=strip_tags($html);
54     } else {
55     $tmp=$html;
56     }
57 dpavlin 1.10 $tmp=str_replace('$','$$',$tmp);
58     return utf8_encode(htmlentities($tmp));
59 dpavlin 1.1 }
60    
61    
62 dpavlin 1.7 while ($row=$sth->fetchrow_hash()) {
63     $row[title]=fixup($row[title]);
64     $row[body]=fixup($row[body]);
65     $row[town_date]=fixup($row[town_date]);
66 dpavlin 1.11 $row[pic]=$wap_pics{$row[type]};
67     $row[alt]=$news_type{$row[type]};
68 dpavlin 1.7 $data[]=$row;
69    
70     $num_selected++;
71     }
72 dpavlin 1.1
73    
74 dpavlin 1.7 if ($num_selected == $on_page) {
75     $next=$s+$on_page;
76     }
77     if ($s && $s >= $on_page) {
78     $prev=$s-$on_page;
79     }
80 dpavlin 1.1
81 dpavlin 1.7 $smarty->assign( array (
82     data=>$data,
83     body=>$wml_body,
84     prev=>$prev, next=>$next,
85     num_selected=>$num_selected,
86 dpavlin 1.11 on_page=>$on_page,
87 dpavlin 1.7 ) );
88     $wml=$smarty->fetch("wap.tpl");
89 dpavlin 1.1 }
90 dpavlin 1.5
91 dpavlin 1.1 print '<?xml version="1.0"?>
92 dpavlin 1.5 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">'.$wml;
93 dpavlin 1.1
94     ?>

  ViewVC Help
Powered by ViewVC 1.1.26