/[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.7 - (show annotations)
Sat Mar 17 16:17:07 2001 UTC (23 years ago) by dpavlin
Branch: MAIN
Changes since 1.6: +70 -48 lines
stocks for 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 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
32 $smarty->assign(array(stock=>$stock, date=>$date, time=>$time));
33 $wml=$smarty->fetch("wap-$part.tpl");
34
35 } 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
47 if (isset($id)) {
48 $sql_where.=" and id=$id ";
49 }
50
51 $num_selected=0;
52
53 $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 }
69
70
71 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
80
81 if ($num_selected == $on_page) {
82 $next=$s+$on_page;
83 }
84 if ($s && $s >= $on_page) {
85 $prev=$s-$on_page;
86 }
87
88 $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 }
97
98 print '<?xml version="1.0"?>
99 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">'.$wml;
100
101 ?>

  ViewVC Help
Powered by ViewVC 1.1.26