/[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.6 by dpavlin, Mon Mar 5 18:49:13 2001 UTC revision 1.7 by dpavlin, Sat Mar 17 16:17:07 2001 UTC
# Line 12  require("conn.inc"); Line 12  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')");  $dbh->dbh_do("insert into wap_ua (ua,referer,url,accept) values ('$HTTP_USER_AGENT','$HTTP_REFERER','$QUERY_STRING','$HTTP_ACCEPT')");
14    
15  $on_page=5;  require("Smarty.class.php");
16    $smarty = new Smarty;
17    
18  $sql_where="where visible is true";  if ($part && file_exists("templates/wap-$part.tpl")) {
19            $dbh->dbh_do("set datestyle='german'");
20    
21  if (!isset($s)) {          $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_limit="limit $on_page";          $sth = $dbh->prepare("$sql");
23  } elseif (isset($s)) {          $sth->execute();
24          $sql_limit="limit $on_page,$s";          while ($row=$sth->fetchrow_hash()) {
25  }                  $stock[]=$row;
26                    $time=$row[time];
27                    $date=$row[date];
28            }
29    
30  if (isset($id)) {          if ($time == "23:23:23") $time="CLOSE";
31          $sql_where.=" and id=$id ";  
32  }          $smarty->assign(array(stock=>$stock, date=>$date, time=>$time));
33            $wml=$smarty->fetch("wap-$part.tpl");
34    
35  $num_selected=0;  } 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  require("Smarty.class.php");          if (isset($id)) {
48  $smarty = new Smarty;                  $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                    $num_selected++;
78            }
79    
80  $smarty->assign( array (  
81          data=>$data,          if ($num_selected == $on_page) {
82          body=>$wml_body,                  $next=$s+$on_page;
83          prev=>$prev, next=>$next,          }
84          num_selected=>$num_selected,          if ($s && $s >= $on_page) {
85          on_page=>$on_page                  $prev=$s-$on_page;
86          ) );          }
87  $wml=$smarty->fetch("wap.tpl");  
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"?>  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;  <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">'.$wml;

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

  ViewVC Help
Powered by ViewVC 1.1.26