--- new.php 2001/02/21 15:52:31 1.2 +++ new.php 2001/02/22 09:51:19 1.3 @@ -29,30 +29,42 @@ $sql_where="where visible is true"; -if (isset($id)) { - $sql_where.=" and id=$id "; +function find_html_file($dir,$file) { + $file="./$dir/$file"; + if (is_file("$file") && file_exists("$file")) { return "$file"; } + if (is_file("$file.htm") && file_exists("$file.htm")) { return "$file.htm"; } + if (is_file("$file.html") && file_exists("$file.html")) { return "$file.html"; } + return 0; } -if (! isset($more) || !file_exists("./news/$more")) { +if (file_exists(find_html_file("news",$more))) { -$sth = $dbh->prepare("select id,title,town_date,body,more,pdf from news $sql_where order by id desc"); -$sth->execute(); -while ($row=$sth->fetchrow_hash()) { - $data[]=$row; -} + $main=join('',file(find_html_file("news",$more))); + $back_url=$GLOBALS[HTTP_REFERER]; + +} else { + if (isset($id)) { + $sql_where.=" and id=$id "; + } -$smarty->assign("data",$data); + $sth = $dbh->prepare("select id,title,town_date,body,more,pdf from news $sql_where order by id desc"); + $sth->execute(); + while ($row=$sth->fetchrow_hash()) { + $data[]=$row; + } -$main=$smarty->fetch("new.tpl"); + $smarty->assign("data",$data); - if (isset($id) && $data[0][more]) { - $main=join('',file("./news/".$data[0][more])); + $main=$smarty->fetch("new.tpl"); + if (isset($id) && find_html_file("news",$data[0][more])) { + $main=join('',file(find_html_file("news",$data[0][more]))); + } + + if ($main == "") { + $main = "This news item is no longer available"; } -} else { // display details - $main=join('',file("./news/$more")); - $back_url=$GLOBALS[HTTP_REFERER]; } include("common.inc");