27 |
|
|
28 |
$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, Section_title=>$title ) ); |
$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, Section_title=>$title ) ); |
29 |
|
|
30 |
$sql_where=""; |
$sql_where="where visible is true"; |
31 |
|
|
32 |
if (isset($id)) { |
function find_html_file($dir,$file) { |
33 |
$sql_where.=" where id=$id "; |
$file="./$dir/$file"; |
34 |
|
if (is_file("$file") && file_exists("$file")) { return "$file"; } |
35 |
|
if (is_file("$file.htm") && file_exists("$file.htm")) { return "$file.htm"; } |
36 |
|
if (is_file("$file.html") && file_exists("$file.html")) { return "$file.html"; } |
37 |
|
return 0; |
38 |
} |
} |
39 |
|
|
40 |
if (! isset($more) || !file_exists("./news/$more")) { |
if (file_exists(find_html_file("news",$more))) { |
41 |
|
|
42 |
$sth = $dbh->prepare("select id,title,date,body,more,pdf from news $sql_where order by id desc"); |
$main=join('',file(find_html_file("news",$more))); |
43 |
$sth->execute(); |
$back_url=$GLOBALS[HTTP_REFERER]; |
44 |
while ($row=$sth->fetchrow_hash()) { |
|
45 |
$data[]=$row; |
} else { |
46 |
} |
if (isset($id)) { |
47 |
|
$sql_where.=" and id=$id "; |
48 |
|
} |
49 |
|
|
50 |
$smarty->assign("data",$data); |
if (isset($type)) { |
51 |
|
if ($type == "n") { |
52 |
|
$sql_where .= " and type='n'"; |
53 |
|
} |
54 |
|
} |
55 |
|
|
56 |
$main=$smarty->fetch("new.tpl"); |
if (! isset($show) && !isset($start)) { |
57 |
|
$sql_limit="limit 10"; |
58 |
|
} elseif (isset($start)) { |
59 |
|
$sql_limit="limit 10,$start"; |
60 |
|
} |
61 |
|
|
|
if (isset($id) && $data[0][more]) { |
|
|
$main=join('',file("./news/".$data[0][more])); |
|
62 |
|
|
63 |
|
$num_selected=0; |
64 |
|
$sql="select |
65 |
|
id,upper(title) as title,town_date,body,more,pdf, |
66 |
|
(date-now()::date) as comming |
67 |
|
from news $sql_where order by date desc $sql_limit"; |
68 |
|
# print "$sql"; |
69 |
|
$sth = $dbh->prepare("$sql"); |
70 |
|
$sth->execute(); |
71 |
|
while ($row=$sth->fetchrow_hash()) { |
72 |
|
$data[]=$row; |
73 |
|
$num_selected++; |
74 |
|
} |
75 |
|
|
76 |
|
if ($num_selected == 10) { |
77 |
|
$smarty->assign(array( |
78 |
|
"multi_page_show" => 1, |
79 |
|
"multi_page_next" => "$PHP_SELF?start=".($start+10), |
80 |
|
)); |
81 |
|
} |
82 |
|
if ($start && $start >= 10) { |
83 |
|
$smarty->assign(array( |
84 |
|
"multi_page_show" => 1, |
85 |
|
"multi_page_prev" => "$PHP_SELF?start=".($start-10), |
86 |
|
)); |
87 |
|
} |
88 |
|
|
89 |
|
$smarty->assign("data",$data); |
90 |
|
|
91 |
|
$main=$smarty->fetch("new.tpl"); |
92 |
|
|
93 |
|
if (isset($id) && find_html_file("news",$data[0][more])) { |
94 |
|
$main=join('',file(find_html_file("news",$data[0][more]))); |
95 |
|
} |
96 |
|
|
97 |
|
if ($main == "") { |
98 |
|
$main = "This news item is no longer available"; |
99 |
} |
} |
100 |
|
|
|
} else { // display details |
|
|
$main=join('',file("./news/$more")); |
|
|
$back_url=$GLOBALS[HTTP_REFERER]; |
|
101 |
} |
} |
102 |
|
|
103 |
include("common.inc"); |
include("common.inc"); |