--- wap.php 2001/03/01 09:02:03 1.3 +++ wap.php 2002/06/06 11:29:44 1.11 @@ -1,80 +1,94 @@ dbh_do("insert into wap_ua (ua,referer,url,accept) values ('$HTTP_USER_AGENT','$HTTP_REFERER','$QUERY_STRING','$HTTP_ACCEPT')"); -$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"); -if (isset($id)) { - $sql_where.=" and id=$id "; -} +} else { + include("news_type.inc"); + + $on_page=5; -$num_selected=0; +# $sql_where="where visible is true and type<>'p'"; + $sql_where="where visible is true and (type='".join("' or type='",array_keys($wap_pics))."')"; -$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 == $on_page) { - $next=$s+$on_page; -} -if ($s && $s >= $on_page) { - $prev=$s-$on_page; -} + 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; -$smarty->assign( array ( - data=>$data, - body=>$wml_body, - prev=>$prev, next=>$next, - num_selected=>$num_selected, - on_page=>$on_page - ) ); -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; + ?>