/[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.11 by dpavlin, Thu Jun 6 11:29:44 2002 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;
 $sql_where="where visible is true";  
17    
18  if (!isset($s)) {  if ($part && file_exists("templates/wap-$part.tpl")) {
19          $sql_limit="limit $on_page";          include("stocks.inc");
20  } elseif (isset($s)) {          $smarty->assign(array(stock=>$stock, date=>$date, time=>$time));
21          $sql_limit="limit $on_page,$s";          $wml=$smarty->fetch("wap-$part.tpl");
22  }  
23    } else {
24            include("news_type.inc");
25    
26            $on_page=5;
27    
28    #       $sql_where="where visible is true and type<>'p'";
29            $sql_where="where visible is true and (type='".join("' or type='",array_keys($wap_pics))."')";
30    
31            if (!isset($s)) {
32                    $sql_limit="limit $on_page";
33            } elseif (isset($s)) {
34                    $sql_limit="limit $on_page,$s";
35            }
36    
37  if (isset($id)) {          if (isset($id)) {
38          $sql_where.=" and id=$id ";                  $sql_where.=" and id=$id ";
39  }          }
40    
41  $num_selected=0;          $num_selected=0;
42    
43  $sql="select          $sql="select
44                  id,title,town_date,body,more,pdf,                          id,title,town_date,body,more,pdf,
45                  (date-now()::date) as comming,type                          (date-now()::date) as comming,type
46          from news $sql_where order by priority desc,date desc $sql_limit";                  from news $sql_where
47  $sth = $dbh->prepare("$sql");                  order by priority desc,date desc $sql_limit";
48  $sth->execute();          $sth = $dbh->prepare("$sql");
49            $sth->execute();
50  function fixup($html) {  
51          if (strip_tags($html)) {          function fixup($html) {
52                  $tmp=strip_tags($html);                  if (strip_tags($html)) {
53          } else {                          $tmp=strip_tags($html);
54                  $tmp=$html;                  } else {
55                            $tmp=$html;
56                    }
57                    $tmp=str_replace('$','$$',$tmp);
58                    return utf8_encode(htmlentities($tmp));
59          }          }
         return utf8_encode(htmlspecialchars($tmp));  
 }  
60    
 $smarty = new Smarty;  
61    
62  while ($row=$sth->fetchrow_hash()) {          while ($row=$sth->fetchrow_hash()) {
63          $row[title]=fixup($row[title]);                  $row[title]=fixup($row[title]);
64          $row[body]=fixup($row[body]);                  $row[body]=fixup($row[body]);
65          $row[town_date]=fixup($row[town_date]);                  $row[town_date]=fixup($row[town_date]);
66          $data[]=$row;                  $row[pic]=$wap_pics{$row[type]};
67                    $row[alt]=$news_type{$row[type]};
68                    $data[]=$row;
69    
70          $num_selected++;                  $num_selected++;
71  }          }
72    
73    
74  if ($num_selected == $on_page) {          if ($num_selected == $on_page) {
75          $next=$s+$on_page;                  $next=$s+$on_page;
76  }          }
77  if ($s && $s >= $on_page) {          if ($s && $s >= $on_page) {
78          $prev=$s-$on_page;                  $prev=$s-$on_page;
79  }          }
80    
81  $smarty->assign( array (          $smarty->assign( array (
82          data=>$data,                  data=>$data,
83          body=>$wml_body,                  body=>$wml_body,
84          prev=>$prev, next=>$next,                  prev=>$prev, next=>$next,
85          num_selected=>$num_selected,                  num_selected=>$num_selected,
86          on_page=>$on_page                  on_page=>$on_page,
87          ) );                  ) );
88  $wml=$smarty->fetch("wap.tpl");          $wml=$smarty->fetch("wap.tpl");
89    }
90    
91  print '<?xml version="1.0"?>  print '<?xml version="1.0"?>
92  <!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.11

  ViewVC Help
Powered by ViewVC 1.1.26