--- wap.php 2001/02/28 09:53:13 1.1 +++ wap.php 2001/07/13 12:27:08 1.10 @@ -1,77 +1,90 @@ dbh_do("insert into wap_ua (ua,referer,url,accept) values ('$HTTP_USER_AGENT','$HTTP_REFERER','$QUERY_STRING','$HTTP_ACCEPT')"); -if (!isset($s)) { - $sql_limit="limit 10"; -} elseif (isset($s)) { - $sql_limit="limit 10,$s"; -} +require("Smarty.class.php"); +$smarty = new Smarty; -if (isset($id)) { - $sql_where.=" and id=$id "; -} +if ($part && file_exists("templates/wap-$part.tpl")) { + include("stocks.inc"); + $smarty->assign(array(stock=>$stock, date=>$date, time=>$time)); + $wml=$smarty->fetch("wap-$part.tpl"); + +} else { + + $on_page=5; -$num_selected=0; + $sql_where="where visible is true and type<>'p'"; -$sql="select - id,title,town_date,body,more,pdf, - (date-now()::date) as comming,type - from news $sql_where order by priority desc,date desc $sql_limit"; -$sth = $dbh->prepare("$sql"); -$sth->execute(); - -function fixup($html) { - if (strip_tags($html)) { - $tmp=strip_tags($html); - } else { - $tmp=$html; + if (!isset($s)) { + $sql_limit="limit $on_page"; + } elseif (isset($s)) { + $sql_limit="limit $on_page,$s"; } - return utf8_encode(htmlspecialchars($tmp)); -} -$smarty = new Smarty; + if (isset($id)) { + $sql_where.=" and id=$id "; + } -while ($row=$sth->fetchrow_hash()) { - $row[title]=fixup($row[title]); - $row[body]=fixup($row[body]); - $row[town_date]=fixup($row[town_date]); - $data[]=$row; + $num_selected=0; - $num_selected++; -} + $sql="select + id,title,town_date,body,more,pdf, + (date-now()::date) as comming,type + from news $sql_where + order by priority desc,date desc $sql_limit"; + $sth = $dbh->prepare("$sql"); + $sth->execute(); + + function fixup($html) { + if (strip_tags($html)) { + $tmp=strip_tags($html); + } else { + $tmp=$html; + } + $tmp=str_replace('$','$$',$tmp); + return utf8_encode(htmlentities($tmp)); + } -if ($num_selected == 10) { - $next=$s+10; -} -if ($s && $s >= 10) { - $prev=$s-10; -} + while ($row=$sth->fetchrow_hash()) { + $row[title]=fixup($row[title]); + $row[body]=fixup($row[body]); + $row[town_date]=fixup($row[town_date]); + $data[]=$row; -$smarty->assign( array ( - data=>$data, - body=>$wml_body, - prev=>$prev, next=>$next, - num_selected=>$num_selected - ) ); -print ' -'; + $num_selected++; + } -$smarty->display("wap.tpl"); -} else { - print "You need wap-enabled device or browser for this page! -
Go back to main site."; + if ($num_selected == $on_page) { + $next=$s+$on_page; + } + if ($s && $s >= $on_page) { + $prev=$s-$on_page; + } + + $smarty->assign( array ( + data=>$data, + body=>$wml_body, + prev=>$prev, next=>$next, + num_selected=>$num_selected, + on_page=>$on_page + ) ); + $wml=$smarty->fetch("wap.tpl"); } + +print ' +'.$wml; + ?>