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

Diff of /wap.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Thu Mar 1 09:02:03 2001 UTC revision 1.7 by dpavlin, Sat Mar 17 16:17:07 2001 UTC
# Line 1  Line 1 
1  <?  <?
2    
3  require("Smarty.class.php");  #$accept=strtolower($HTTP_ACCEPT);
4    #if ($WAP || strstr($accept,"text/vnd.wap.wml") || strstr($accept,"hdml;version=3.0")) {
5  $accept=strtolower($HTTP_ACCEPT);  #       header("Content-Type: text/vnd.wap.wml");
6  if (strstr($accept,"text/vnd.wap.wml") || strstr($accept,"hdml;version=3.0")) {  #}
7    header("Content-Type: text/vnd.wap.wml");
8    
9  global $WAP;  global $WAP;
10  $WAP=1;  $WAP=1;
11  require("conn.inc");  require("conn.inc");
 header("Content-Type: text/vnd.wap.wml");  
12    
13  $on_page=5;  $dbh->dbh_do("insert into wap_ua (ua,referer,url,accept) values ('$HTTP_USER_AGENT','$HTTP_REFERER','$QUERY_STRING','$HTTP_ACCEPT')");
14    
15  $sql_where="where visible is true";  require("Smarty.class.php");
16    $smarty = new Smarty;
17    
18  if (!isset($s)) {  if ($part && file_exists("templates/wap-$part.tpl")) {
19          $sql_limit="limit $on_page";          $dbh->dbh_do("set datestyle='german'");
 } elseif (isset($s)) {  
         $sql_limit="limit $on_page,$s";  
 }  
20    
21  if (isset($id)) {          $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          $sql_where.=" and id=$id ";          $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  $num_selected=0;          $smarty->assign(array(stock=>$stock, date=>$date, time=>$time));
33            $wml=$smarty->fetch("wap-$part.tpl");
34    
35    } else {
36    
37  $sql="select          $on_page=5;
38                  id,title,town_date,body,more,pdf,  
39                  (date-now()::date) as comming,type          $sql_where="where visible is true";
40          from news $sql_where order by priority desc,date desc $sql_limit";  
41  $sth = $dbh->prepare("$sql");          if (!isset($s)) {
42  $sth->execute();                  $sql_limit="limit $on_page";
43            } elseif (isset($s)) {
44  function fixup($html) {                  $sql_limit="limit $on_page,$s";
         if (strip_tags($html)) {  
                 $tmp=strip_tags($html);  
         } else {  
                 $tmp=$html;  
45          }          }
         return utf8_encode(htmlspecialchars($tmp));  
 }  
46    
47  $smarty = new Smarty;          if (isset($id)) {
48                    $sql_where.=" and id=$id ";
49            }
50    
51  while ($row=$sth->fetchrow_hash()) {          $num_selected=0;
         $row[title]=fixup($row[title]);  
         $row[body]=fixup($row[body]);  
         $row[town_date]=fixup($row[town_date]);  
         $data[]=$row;  
52    
53          $num_selected++;          $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  if ($num_selected == $on_page) {          while ($row=$sth->fetchrow_hash()) {
72          $next=$s+$on_page;                  $row[title]=fixup($row[title]);
73  }                  $row[body]=fixup($row[body]);
74  if ($s && $s >= $on_page) {                  $row[town_date]=fixup($row[town_date]);
75          $prev=$s-$on_page;                  $data[]=$row;
 }  
76    
77  $smarty->assign( array (                  $num_selected++;
78          data=>$data,          }
         body=>$wml_body,  
         prev=>$prev, next=>$next,  
         num_selected=>$num_selected,  
         on_page=>$on_page  
         ) );  
 print '<?xml version="1.0"?>  
 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">';  
79    
 $smarty->display("wap.tpl");  
80    
81  } else {          if ($num_selected == $on_page) {
82          print "You need wap-enabled device or browser for this page!                  $next=$s+$on_page;
83          <br>Go <a href=\"index.php\">back to main site</a>.";          }
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  ?>  ?>

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.26