1 |
dpavlin |
1.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 |
dpavlin |
1.7 |
$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, ) ); |
29 |
dpavlin |
1.1 |
|
30 |
dpavlin |
1.2 |
$sql_where="where visible is true"; |
31 |
dpavlin |
1.1 |
|
32 |
dpavlin |
1.3 |
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 |
dpavlin |
1.1 |
} |
39 |
|
|
|
40 |
dpavlin |
1.3 |
if (file_exists(find_html_file("news",$more))) { |
41 |
dpavlin |
1.1 |
|
42 |
dpavlin |
1.3 |
$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 |
dpavlin |
1.5 |
if (isset($type)) { |
51 |
|
|
if ($type == "n") { |
52 |
|
|
$sql_where .= " and type='n'"; |
53 |
dpavlin |
1.7 |
$title.=" : News"; |
54 |
dpavlin |
1.6 |
} elseif ($type == "e") { |
55 |
|
|
$sql_where .= " and type='e'"; |
56 |
dpavlin |
1.7 |
$title.=" : Events"; |
57 |
dpavlin |
1.5 |
} |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
if (! isset($show) && !isset($start)) { |
61 |
|
|
$sql_limit="limit 10"; |
62 |
|
|
} elseif (isset($start)) { |
63 |
|
|
$sql_limit="limit 10,$start"; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
|
67 |
|
|
$num_selected=0; |
68 |
|
|
$sql="select |
69 |
|
|
id,upper(title) as title,town_date,body,more,pdf, |
70 |
dpavlin |
1.7 |
(date-now()::date) as comming,type,title as title_lc |
71 |
dpavlin |
1.6 |
from news $sql_where order by priority desc,date desc $sql_limit"; |
72 |
dpavlin |
1.7 |
# print "$sql"; |
73 |
dpavlin |
1.5 |
$sth = $dbh->prepare("$sql"); |
74 |
dpavlin |
1.3 |
$sth->execute(); |
75 |
|
|
while ($row=$sth->fetchrow_hash()) { |
76 |
|
|
$data[]=$row; |
77 |
dpavlin |
1.5 |
$num_selected++; |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
if ($num_selected == 10) { |
81 |
|
|
$smarty->assign(array( |
82 |
|
|
"multi_page_show" => 1, |
83 |
|
|
"multi_page_next" => "$PHP_SELF?start=".($start+10), |
84 |
|
|
)); |
85 |
|
|
} |
86 |
|
|
if ($start && $start >= 10) { |
87 |
|
|
$smarty->assign(array( |
88 |
|
|
"multi_page_show" => 1, |
89 |
|
|
"multi_page_prev" => "$PHP_SELF?start=".($start-10), |
90 |
|
|
)); |
91 |
dpavlin |
1.3 |
} |
92 |
dpavlin |
1.1 |
|
93 |
dpavlin |
1.7 |
if (isset($id) && $num_selected == 1) { |
94 |
|
|
if ($data[0][type] == "n") { |
95 |
|
|
$title.=" : News : ".$data[0][title_lc]; |
96 |
|
|
} elseif ($data[0][type] == "e") { |
97 |
|
|
$title.=" : Event : ".$data[0][title_lc]; |
98 |
|
|
} elseif ($data[0][type] == "c") { |
99 |
|
|
$title.=" : Community : ".$data[0][title_lc]; |
100 |
|
|
} elseif ($data[0][type] == "r") { |
101 |
|
|
$title.=" : Result : ".$data[0][title_lc]; |
102 |
|
|
} |
103 |
|
|
} |
104 |
|
|
|
105 |
dpavlin |
1.3 |
$smarty->assign("data",$data); |
106 |
dpavlin |
1.1 |
|
107 |
dpavlin |
1.3 |
$main=$smarty->fetch("new.tpl"); |
108 |
dpavlin |
1.1 |
|
109 |
dpavlin |
1.3 |
if (isset($id) && find_html_file("news",$data[0][more])) { |
110 |
|
|
$main=join('',file(find_html_file("news",$data[0][more]))); |
111 |
|
|
} |
112 |
dpavlin |
1.1 |
|
113 |
dpavlin |
1.3 |
if ($main == "") { |
114 |
|
|
$main = "This news item is no longer available"; |
115 |
dpavlin |
1.1 |
} |
116 |
|
|
|
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
include("common.inc"); |
120 |
dpavlin |
1.7 |
$smarty->assign( array(back_url=>$back_url, MAIN=>$main, |
121 |
|
|
Section_title=>$title ) ); |
122 |
dpavlin |
1.1 |
|
123 |
|
|
$smarty->display("index.tpl"); |
124 |
|
|
?> |