1 |
<?php |
2 |
require("Smarty.class.php"); |
3 |
require("conn.inc"); |
4 |
|
5 |
$smarty = new Smarty; |
6 |
|
7 |
$smarty->assign( array ( Title=>"Pliva d.d." ) ); |
8 |
|
9 |
|
10 |
if (isset($from)) { |
11 |
$section=$from; |
12 |
} else { |
13 |
$section="new"; |
14 |
} |
15 |
|
16 |
if ($section == "investor") { |
17 |
$title="INVESTOR'S PAGE"; |
18 |
$lpic="investor"; $lext=".jpg"; |
19 |
$mpic="investors.gif"; |
20 |
$back_url="investor.php"; |
21 |
} else { |
22 |
$title="What's New"; |
23 |
$lpic="new"; $lext=".jpg"; |
24 |
$mpic="new.gif"; |
25 |
$back_url="index.php"; |
26 |
} |
27 |
|
28 |
$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, Section_title=>$title ) ); |
29 |
|
30 |
$sql_where="where visible is true"; |
31 |
|
32 |
function find_html_file($dir,$file) { |
33 |
$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 (file_exists(find_html_file("news",$more))) { |
41 |
|
42 |
$main=join('',file(find_html_file("news",$more))); |
43 |
$back_url=$GLOBALS[HTTP_REFERER]; |
44 |
|
45 |
} else { |
46 |
if (isset($id)) { |
47 |
$sql_where.=" and id=$id "; |
48 |
} |
49 |
|
50 |
$sth = $dbh->prepare("select id,title,town_date,body,more,pdf from news $sql_where order by id desc"); |
51 |
$sth->execute(); |
52 |
while ($row=$sth->fetchrow_hash()) { |
53 |
$data[]=$row; |
54 |
} |
55 |
|
56 |
$smarty->assign("data",$data); |
57 |
|
58 |
$main=$smarty->fetch("new.tpl"); |
59 |
|
60 |
if (isset($id) && find_html_file("news",$data[0][more])) { |
61 |
$main=join('',file(find_html_file("news",$data[0][more]))); |
62 |
} |
63 |
|
64 |
if ($main == "") { |
65 |
$main = "This news item is no longer available"; |
66 |
} |
67 |
|
68 |
} |
69 |
|
70 |
include("common.inc"); |
71 |
$smarty->assign( array(back_url=>$back_url, MAIN=>$main)); |
72 |
|
73 |
$smarty->display("index.tpl"); |
74 |
?> |