--- wap.php 2001/03/05 18:49:13 1.6 +++ wap.php 2002/06/06 11:29:44 1.11 @@ -12,66 +12,81 @@ $dbh->dbh_do("insert into wap_ua (ua,referer,url,accept) values ('$HTTP_USER_AGENT','$HTTP_REFERER','$QUERY_STRING','$HTTP_ACCEPT')"); -$on_page=5; - -$sql_where="where visible is true"; +require("Smarty.class.php"); +$smarty = new Smarty; -if (!isset($s)) { - $sql_limit="limit $on_page"; -} elseif (isset($s)) { - $sql_limit="limit $on_page,$s"; -} +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 { + include("news_type.inc"); + + $on_page=5; + +# $sql_where="where visible is true and type<>'p'"; + $sql_where="where visible is true and (type='".join("' or type='",array_keys($wap_pics))."')"; + + if (!isset($s)) { + $sql_limit="limit $on_page"; + } elseif (isset($s)) { + $sql_limit="limit $on_page,$s"; + } -if (isset($id)) { - $sql_where.=" and id=$id "; -} + if (isset($id)) { + $sql_where.=" and id=$id "; + } -$num_selected=0; + $num_selected=0; -$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; + $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)); } - return utf8_encode(htmlspecialchars($tmp)); -} -require("Smarty.class.php"); -$smarty = new Smarty; -while ($row=$sth->fetchrow_hash()) { - $row[title]=fixup($row[title]); - $row[body]=fixup($row[body]); - $row[town_date]=fixup($row[town_date]); - $data[]=$row; + while ($row=$sth->fetchrow_hash()) { + $row[title]=fixup($row[title]); + $row[body]=fixup($row[body]); + $row[town_date]=fixup($row[town_date]); + $row[pic]=$wap_pics{$row[type]}; + $row[alt]=$news_type{$row[type]}; + $data[]=$row; - $num_selected++; -} + $num_selected++; + } -if ($num_selected == $on_page) { - $next=$s+$on_page; -} -if ($s && $s >= $on_page) { - $prev=$s-$on_page; -} + 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"); + $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;