+EaP 4/2010 (164)
[www.energie.vellum.cz.git] / clanek.php
1 <?php $cvs_id='$Id$';
2
3         include("common.php");
4
5         $head_css="
6 th,td { padding: 3px }
7 h3,h4,h5,h6 { color: aqua; background-color: transparent; }
8 caption     { color: aqua; background-color: transparent; }
9 ";
10
11         prepvar("year" ,"[0-9]+");
12         prepvar("month","[0-9]+");
13         prepvar("id"   ,"[0-9]+",false/*required*/);
14
15         $title_tail=title_name($year,$month);
16         $result=db_query("select name,contents from $tb_clanek where year=$year and month=$month"
17                         .(isset($id) ? " and id=$id" : "")." order by id");
18         if (isset($id) && 1==mysql_num_rows($result)) {
19                 $row=mysql_fetch_array($result);
20                 $title_tail.=" - ".$row["name"];
21                 }
22
23         heading();
24         print("<h1>".title_name($year,$month)."</h1>\n");
25
26         if (isset($id) && 1!=mysql_num_rows($result))
27                 fatal("Zadaný èlánek nebyl nalezen");
28
29 function print_article($row)
30 {
31         print("<h2>".htmlspecialchars(ereg_replace("\\|.*\$","",$row["name"]))."</h2>\n".$row["contents"]);
32 }
33
34         if (isset($id))
35                 print_article($row);
36         else
37                 while (($row=mysql_fetch_array($result)))
38                         print_article($row);
39         mysql_free_result($result);
40
41         footer();
42 ?>