/[corp_html]/new.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /new.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (hide annotations)
Thu Apr 5 11:54:08 2001 UTC (21 years, 9 months ago) by dpavlin
Branch: MAIN
Changes since 1.12: +23 -4 lines
select news by number of last days

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 dpavlin 1.9 $sql_where="where visible is true";
17    
18 dpavlin 1.1 if ($section == "investor") {
19     $title="INVESTOR'S PAGE";
20     $lpic="investor"; $lext=".jpg";
21     $mpic="investors.gif";
22     $back_url="investor.php";
23 dpavlin 1.10 if (! isset($type)) {
24     $sql_where .= " and type='i'";
25     }
26 dpavlin 1.9 $title.=" : Investors News";
27 dpavlin 1.8 } elseif ($section == "about") {
28     $title="ABOUT US";
29     $lpic="about"; $lext=".gif";
30     $mpic="about.gif";
31 dpavlin 1.1 } else {
32     $title="What's New";
33     $lpic="new"; $lext=".jpg";
34     $mpic="new.gif";
35     $back_url="index.php";
36     }
37    
38 dpavlin 1.7 $smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, ) );
39 dpavlin 1.1
40    
41 dpavlin 1.3 function find_html_file($dir,$file) {
42     $file="./$dir/$file";
43     if (is_file("$file") && file_exists("$file")) { return "$file"; }
44     if (is_file("$file.htm") && file_exists("$file.htm")) { return "$file.htm"; }
45     if (is_file("$file.html") && file_exists("$file.html")) { return "$file.html"; }
46     return 0;
47 dpavlin 1.1 }
48    
49 dpavlin 1.3 if (file_exists(find_html_file("news",$more))) {
50 dpavlin 1.1
51 dpavlin 1.3 $main=join('',file(find_html_file("news",$more)));
52     $back_url=$GLOBALS[HTTP_REFERER];
53    
54     } else {
55     if (isset($id)) {
56     $sql_where.=" and id=$id ";
57     }
58    
59 dpavlin 1.5 if (isset($type)) {
60     if ($type == "n") {
61 dpavlin 1.9 $sql_where .= " and (type='n' or type='i')";
62 dpavlin 1.7 $title.=" : News";
63 dpavlin 1.6 } elseif ($type == "e") {
64     $sql_where .= " and type='e'";
65 dpavlin 1.7 $title.=" : Events";
66 dpavlin 1.8 } elseif ($type == "c") {
67     $sql_where .= " and type='c'";
68     $title.=" : Community";
69 dpavlin 1.5 }
70     }
71    
72     if (! isset($show) && !isset($start)) {
73     $sql_limit="limit 10";
74     } elseif (isset($start)) {
75     $sql_limit="limit 10,$start";
76     }
77    
78    
79 dpavlin 1.13 if (isset($days)) {
80     if ($days != 0) {
81     $sql_where.=" and date(now())-date(date) > 0 and date(now())-date(date) < $days";
82     $title.=" : News in last $days days";
83     }
84     $smarty->assign("days",$days);
85     $smarty->assign("last_days",array(14,30,160,240,365));
86     $smarty->assign("last_desc",array("two week","one month","four months","six months","one year"));
87     }
88    
89 dpavlin 1.5 $num_selected=0;
90     $sql="select
91     id,upper(title) as title,town_date,body,more,pdf,
92 dpavlin 1.7 (date-now()::date) as comming,type,title as title_lc
93 dpavlin 1.6 from news $sql_where order by priority desc,date desc $sql_limit";
94 dpavlin 1.7 # print "$sql";
95 dpavlin 1.5 $sth = $dbh->prepare("$sql");
96 dpavlin 1.3 $sth->execute();
97     while ($row=$sth->fetchrow_hash()) {
98     $data[]=$row;
99 dpavlin 1.5 $num_selected++;
100     }
101    
102     if ($num_selected == 10) {
103     $smarty->assign(array(
104     "multi_page_show" => 1,
105     "multi_page_next" => "$PHP_SELF?start=".($start+10),
106     ));
107     }
108     if ($start && $start >= 10) {
109     $smarty->assign(array(
110     "multi_page_show" => 1,
111     "multi_page_prev" => "$PHP_SELF?start=".($start-10),
112     ));
113 dpavlin 1.3 }
114 dpavlin 1.1
115 dpavlin 1.7 if (isset($id) && $num_selected == 1) {
116     if ($data[0][type] == "n") {
117     $title.=" : News : ".$data[0][title_lc];
118     } elseif ($data[0][type] == "e") {
119     $title.=" : Event : ".$data[0][title_lc];
120     } elseif ($data[0][type] == "c") {
121     $title.=" : Community : ".$data[0][title_lc];
122     } elseif ($data[0][type] == "r") {
123     $title.=" : Result : ".$data[0][title_lc];
124 dpavlin 1.11 } elseif ($data[0][type] == "i") {
125     $title.=" : Investors News : ".$data[0][title_lc];
126 dpavlin 1.12 } elseif ($data[0][type] == "a") {
127     $title.=" : Annual Report : ".$data[0][title_lc];
128 dpavlin 1.7 }
129     }
130    
131 dpavlin 1.13
132     if (isset($days) && $num_selected == 0) {
133     $warning = "There are no news for last $days days.";
134     }
135    
136     if ($main == "" && $num_selected == 0) {
137     $warning = "This news item is no longer available";
138     }
139    
140     $smarty->assign(array(
141     data=>$data,
142     warning=>$warning
143     ));
144 dpavlin 1.1
145 dpavlin 1.3 $main=$smarty->fetch("new.tpl");
146 dpavlin 1.1
147 dpavlin 1.3 if (isset($id) && find_html_file("news",$data[0][more])) {
148     $main=join('',file(find_html_file("news",$data[0][more])));
149     }
150 dpavlin 1.1
151    
152     }
153    
154     include("common.inc");
155 dpavlin 1.7 $smarty->assign( array(back_url=>$back_url, MAIN=>$main,
156     Section_title=>$title ) );
157 dpavlin 1.1
158     $smarty->display("index.tpl");
159     ?>

  ViewVC Help
Powered by ViewVC 1.1.26