/[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.7 - (hide annotations)
Sat Mar 17 16:17:07 2001 UTC (21 years, 2 months ago) by dpavlin
Branch: MAIN
Changes since 1.6: +70 -48 lines
stocks for wap

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     $dbh->dbh_do("set datestyle='german'");
20    
21     $sql="select date(date),time(date),type,current,change,high,low,open from stocks order by stocks.date desc,stocks.insert_date asc limit 2";
22     $sth = $dbh->prepare("$sql");
23     $sth->execute();
24     while ($row=$sth->fetchrow_hash()) {
25     $stock[]=$row;
26     $time=$row[time];
27     $date=$row[date];
28     }
29    
30     if ($time == "23:23:23") $time="CLOSE";
31 dpavlin 1.2
32 dpavlin 1.7 $smarty->assign(array(stock=>$stock, date=>$date, time=>$time));
33     $wml=$smarty->fetch("wap-$part.tpl");
34 dpavlin 1.1
35 dpavlin 1.7 } else {
36    
37     $on_page=5;
38    
39     $sql_where="where visible is true";
40    
41     if (!isset($s)) {
42     $sql_limit="limit $on_page";
43     } elseif (isset($s)) {
44     $sql_limit="limit $on_page,$s";
45     }
46 dpavlin 1.1
47 dpavlin 1.7 if (isset($id)) {
48     $sql_where.=" and id=$id ";
49     }
50 dpavlin 1.1
51 dpavlin 1.7 $num_selected=0;
52 dpavlin 1.1
53 dpavlin 1.7 $sql="select
54     id,title,town_date,body,more,pdf,
55     (date-now()::date) as comming,type
56     from news $sql_where
57     order by priority desc,date desc $sql_limit";
58     $sth = $dbh->prepare("$sql");
59     $sth->execute();
60    
61     function fixup($html) {
62     if (strip_tags($html)) {
63     $tmp=strip_tags($html);
64     } else {
65     $tmp=$html;
66     }
67     return utf8_encode(htmlspecialchars($tmp));
68 dpavlin 1.1 }
69    
70    
71 dpavlin 1.7 while ($row=$sth->fetchrow_hash()) {
72     $row[title]=fixup($row[title]);
73     $row[body]=fixup($row[body]);
74     $row[town_date]=fixup($row[town_date]);
75     $data[]=$row;
76    
77     $num_selected++;
78     }
79 dpavlin 1.1
80    
81 dpavlin 1.7 if ($num_selected == $on_page) {
82     $next=$s+$on_page;
83     }
84     if ($s && $s >= $on_page) {
85     $prev=$s-$on_page;
86     }
87 dpavlin 1.1
88 dpavlin 1.7 $smarty->assign( array (
89     data=>$data,
90     body=>$wml_body,
91     prev=>$prev, next=>$next,
92     num_selected=>$num_selected,
93     on_page=>$on_page
94     ) );
95     $wml=$smarty->fetch("wap.tpl");
96 dpavlin 1.1 }
97 dpavlin 1.5
98 dpavlin 1.1 print '<?xml version="1.0"?>
99 dpavlin 1.5 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">'.$wml;
100 dpavlin 1.1
101     ?>

  ViewVC Help
Powered by ViewVC 1.1.26