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