/[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.5 by dpavlin, Mon Mar 5 12:02:11 2001 UTC revision 1.8 by dpavlin, Sat Mar 17 16:40:55 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  if ($WAP || strstr($accept,"text/vnd.wap.wml") || strstr($accept,"hdml;version=3.0")) {  #       header("Content-Type: text/vnd.wap.wml");
6          header("Content-Type: text/vnd.wap.wml");  #}
7  }  header("Content-Type: text/vnd.wap.wml");
8    
9  global $WAP;  global $WAP;
10  $WAP=1;  $WAP=1;
# 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            include("stocks.inc");
20            $smarty->assign(array(stock=>$stock, date=>$date, time=>$time));
21            $wml=$smarty->fetch("wap-$part.tpl");
22    
23  if (!isset($s)) {  } else {
         $sql_limit="limit $on_page";  
 } elseif (isset($s)) {  
         $sql_limit="limit $on_page,$s";  
 }  
24    
25  if (isset($id)) {          $on_page=5;
         $sql_where.=" and id=$id ";  
 }  
26    
27  $num_selected=0;          $sql_where="where visible is true";
28    
29  $sql="select          if (!isset($s)) {
30                  id,title,town_date,body,more,pdf,                  $sql_limit="limit $on_page";
31                  (date-now()::date) as comming,type          } elseif (isset($s)) {
32          from news $sql_where order by priority desc,date desc $sql_limit";                  $sql_limit="limit $on_page,$s";
 $sth = $dbh->prepare("$sql");  
 $sth->execute();  
   
 function fixup($html) {  
         if (strip_tags($html)) {  
                 $tmp=strip_tags($html);  
         } else {  
                 $tmp=$html;  
33          }          }
         return utf8_encode(htmlspecialchars($tmp));  
 }  
34    
35  $smarty = new Smarty;          if (isset($id)) {
36                    $sql_where.=" and id=$id ";
37            }
38    
39  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;  
40    
41          $num_selected++;          $sql="select
42  }                          id,title,town_date,body,more,pdf,
43                            (date-now()::date) as comming,type
44                    from news $sql_where
45                    order by priority desc,date desc $sql_limit";
46            $sth = $dbh->prepare("$sql");
47            $sth->execute();
48    
49            function fixup($html) {
50                    if (strip_tags($html)) {
51                            $tmp=strip_tags($html);
52                    } else {
53                            $tmp=$html;
54                    }
55                    return utf8_encode(htmlspecialchars($tmp));
56            }
57    
58    
59  if ($num_selected == $on_page) {          while ($row=$sth->fetchrow_hash()) {
60          $next=$s+$on_page;                  $row[title]=fixup($row[title]);
61  }                  $row[body]=fixup($row[body]);
62  if ($s && $s >= $on_page) {                  $row[town_date]=fixup($row[town_date]);
63          $prev=$s-$on_page;                  $data[]=$row;
64  }  
65                    $num_selected++;
66            }
67    
68  $smarty->assign( array (  
69          data=>$data,          if ($num_selected == $on_page) {
70          body=>$wml_body,                  $next=$s+$on_page;
71          prev=>$prev, next=>$next,          }
72          num_selected=>$num_selected,          if ($s && $s >= $on_page) {
73          on_page=>$on_page                  $prev=$s-$on_page;
74          ) );          }
75  $wml=$smarty->fetch("wap.tpl");  
76            $smarty->assign( array (
77                    data=>$data,
78                    body=>$wml_body,
79                    prev=>$prev, next=>$next,
80                    num_selected=>$num_selected,
81                    on_page=>$on_page
82                    ) );
83            $wml=$smarty->fetch("wap.tpl");
84    }
85    
86  print '<?xml version="1.0"?>  print '<?xml version="1.0"?>
87  <!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.5  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.26