3 error_reporting(E_ALL);
7 // $viewcvs prepared by "config.php"
8 if ($viewcvs==$HTTP_SERVER_VARS["SCRIPT_NAME"])
10 $cvs_id_split=split(" ",$cvs_id);
11 if (count($cvs_id_split)==8) {
12 $cvs_id_split[1]="<a href=\"$viewcvs\">".$cvs_id_split[1]."</a>";
13 $cvs_id_split[5]="<a href=\"mailto:".$cvs_id_split[5]."@".$HTTP_SERVER_VARS["HTTP_HOST"]."\">".$cvs_id_split[5]."</a>";
15 $cvs_id_html=join(" ",$cvs_id_split);
17 $have_js=(isset($HTTP_GET_VARS["have_js"]) || isset($HTTP_POST_VARS["have_js"])
19 if (isset($detect_js) && !$have_js)
20 $head.='<script type="text/javascript" src="have_js.js"></script>'."\n";
22 $user_agent=$HTTP_SERVER_VARS["HTTP_USER_AGENT"];
23 if (ereg("[[:<:]]MSIE ([0-9]+)\\.",$user_agent,$msie_major_a))
24 $msie_major=$msie_major_a[1];
25 else if (ereg("[[:<:]]Mozilla/([0-9]+)\\.",$user_agent,$mozilla_major_a))
26 $mozilla_major=$mozilla_major_a[1];
28 function addpercents($url)
31 foreach(preg_split('//', $url, -1, PREG_SPLIT_NO_EMPTY) as $c)
32 if (ereg("[a-zA-Z0-9]",$c))
35 $r.=sprintf("%%%02X",ord($c));
39 function fatal($msg="UNKNOWN")
43 print("\n<br /><h1 class=\"error\">Nastala chyba pøi zpracování: $msg!</h1>\n"
44 ."<p>Mù¾ete tento problém nahlásit <a href=\"mailto:$admin_mail\">správci tohoto webu</a>.</p>\n");
48 function prepvar($name,$regex=".",$require=true)
50 global $HTTP_GET_VARS,$HTTP_POST_VARS;
52 if (isset($HTTP_GET_VARS[$name]))
53 $v=$HTTP_GET_VARS[$name];
54 else if (isset($HTTP_POST_VARS[$name]))
55 $v=$HTTP_POST_VARS[$name];
59 $name_html="Parametr <span class=\"quote\">".htmlspecialchars($name)."</span>";
62 if (isset($v) && !ereg($regex,$v))
63 fatal("$name_html nevyhovuje po¾adovanému regexu <span class=\"quote\">".htmlspecialchars($regex)."</span>");
64 if (!isset($v) && $require)
65 fatal("$name_html je vy¾adován");
76 global $db_host,$db_user,$db_pwd,$db_name;
81 if (!($db_link=mysql_connect($db_host,$db_user,$db_pwd)))
82 fatal("MySQL connect: ".mysql_error());
83 if (!mysql_select_db($db_name,$db_link))
84 fatal("MySQL database select: ".mysql_error());
87 function db_query($query)
92 if (!($r=mysql_query($query,$db_link)))
93 fatal("MySQL query \"$query\": ".mysql_error());
97 function db_row($query)
100 $r=mysql_fetch_row($q);
101 mysql_free_result($q);
105 function db_item($query)
111 function month_a($year,$month,$month_last=0)
116 $month_last=db_item("select month_last from $tb_obsah where year='$year' and month='$month'");
117 $month_full=sprintf("%02d".($month==$month_last ? "" : "-%02d"),$month,$month_last);
119 $r=array("year"=>$year,"month"=>$month,"month_last"=>$month_last,"month_full"=>$month_full,
120 "name"=>"$year/${month_full}",
121 "img" =>"img/eap-$year-${month_full}.jpeg",
122 "icon"=>"img/eap-$year-${month_full}s.jpeg",
127 function img_size($width,$height=0)
130 list($width,$height)=getimagesize($width);
131 return("style=\"border:0;width:${width}px;height:${height}px\" width=\"$width\" height=\"$height\"");
134 function gsm_banking()
136 return("<img src=\"img/sluzby_bankovni_pggsm.gif\"".img_size(89,31)." alt=\"Paegas GSM banking\" class=\"img-align\" />");
141 if (!($f=fopen("objednavka.js","r")))
142 fatal("Nepodaøilo se naèíst seznam dostupného zbo¾í");
144 while (($s=fgets($f,0x1000))) {
147 if (!(ereg("^want_price\\[ *'([^']*)'\\]=([0-9]*);$",$s,$matched)))
149 $r[$matched[1]]=$matched[2];
155 function title_name($year,$month)
157 if (isset($year) && isset($month)) {
158 $month_a=month_a($year,$month);
159 return("Titulní strana èísla ".$month_a["name"]);
161 else if (isset($year))
162 return("Titulní strany roèníku $year");
164 return("Titulní strany");
167 function title_month($year,$month)
169 $month_a=month_a($year,$month);
171 ."<table border=\"0\" width=\"100%\">\n"
172 ."<tr><td align=\"center\"><table border=\"1\" cellpadding=\"10\">\n"
173 ."<tr><th align=\"center\">".title_name($year,$month)."</th></tr>\n"
174 ."<tr><td align=\"center\"><img src=\"".$month_a["img"]."\" ".img_size($month_a["img"])
175 ." alt=\"titulní stránka ".$month_a["name"]."\" /></td></tr>\n"
176 ."</table></td></tr>\n"
181 function title_icons_table_month($year,$month,$month_last)
183 $month_a=month_a($year,$month,$month_last);
184 print("<a href=\"title.php?year=$year&month=$month\">"
185 ."<img src=\"".$month_a["icon"]."\" ".img_size($month_a["icon"])
186 ." alt=\"titulní stránka ".$month_a["name"]."\" /></a><br />"
187 ."<a href=\"obsah.php?year=$year&month=$month\">obsah ".$month_a["name"]."</a>"
191 function title_icons($year,$month)
196 .(isset($year) ? "<a name=\"year_$year\">" : "")
197 .title_name(&$year,&$month)
198 .(isset($year) ? "</a>" : "")
201 $result=db_query("select year,month,month_last from $tb_obsah"
202 .(isset($year) || isset($month) ? " where" : "")
203 .(isset($year ) ? " year=$year" : "")
204 .(isset($year) && isset($month) ? " and" : "")
205 .(isset($month) ? " month=$month" : "")
206 ." order by year,month");
209 // $year variable changes its meaning here!!!
216 while ($row=mysql_fetch_array($result)) {
218 $row["month_last"]--;
220 if ($row["year"]!=$year) {
221 print($fin_split.$fin_year);
225 .(!isset($wanted_year) ? "<p><a name=\"year_$year\"> </a></p>" : "")
226 ."<table border=\"0\" width=\"100%\"><tr><td align=\"center\"><table border=\"1\" cellpadding=\"5\">\n"
227 ."<tr><th colspan=\"$split\">Roèník $year (<a href=\"obsah.php?year=$year\">obsahy èísel</a>)</th></tr>\n"
229 $fin_year="</table></td></tr></table>\n";
234 while ($floor<floor($row["month"]/$split)) {
235 print($fin_split."<tr>");
236 $fin_split="</tr>\n";
238 $month=$floor*$split-1;
240 while ($month+1<$row["month"]) {
244 print("<td align=\"center\""
245 .($row["month_last"]!=$row["month"] ? " colspan=\"".($row["month_last"]+1-$row["month"])."\"" : "")
247 title_icons_table_month($year,$row["month"]+1,$row["month_last"]+1);
249 $month=$row["month_last"];
251 mysql_free_result($result);
252 print($fin_split.$fin_year);
255 function title($year,$month)
257 if (isset($year) && isset($month))
258 return(title_month( $year, $month));
260 return(title_icons(&$year,&$month));
263 function image_supported($mime)
265 global $HTTP_SERVER_VARS;
267 $exp=explode(",",$HTTP_SERVER_VARS["HTTP_ACCEPT"]);
268 while (($s=array_shift($exp))) {
269 $s=trim(ereg_replace(";.*","",$s));
278 // deadlock prevention:
279 global $footer_passed;
280 if (isset($footer_passed))
284 global $cvs_id_html,$viewcvs,$viewcvs,$HTTP_SERVER_VARS;
288 <table border="0" width="100%">
289 <tr><td align="left"><span class="cvs-id"><?php print($cvs_id_html); ?></span></td><td align="right"><a
290 href="http://validator.w3.org/check/referer"><img src="http://www.w3.org/Icons/valid-xhtml10"
291 <?php print(img_size(88,31)); ?> alt="Valid XHTML 1.0!" /></a><a
292 href="http://jigsaw.w3.org/css-validator/validator?warning=2&profile=css2&uri=<?php
293 print(addpercents("http://".$HTTP_SERVER_VARS["HTTP_HOST"].$HTTP_SERVER_VARS["REQUEST_URI"]));
294 ?>"><img src="http://jigsaw.w3.org/css-validator/images/vcss"
295 <?php print(img_size(88,31)); ?> alt="Valid CSS!" /></a></td></tr>
302 // Stolen from: php-manual.html#function.header
305 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
306 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); // always modified
307 header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
308 header("Pragma: no-cache"); // HTTP/1.0
313 global $msie_major,$mozilla_major,$title_tail,$head_css,$head;
315 header("Content-type: text/html; charset=iso-8859-2");
316 if (!isset($msie_major) || $msie_major>=4)
317 print('<?xml version="1.0" encoding="iso-8859-2"?>'."\n");
319 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
320 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
321 <head><title>Energie & peníze<?php
322 if (isset($title_tail))
323 print(": $title_tail");
325 <style type="text/css"><!--
326 .cvs-id { font-family: monospace; }
327 .error { color: red; background-color: transparent; }
328 .quote { font-family: monospace; }
330 background-color: black;
333 :link { color: aqua; background-color: transparent; }
334 :visited { color: teal; background-color: transparent; }
335 h1,h2 { color: yellow; background-color: transparent; }
337 if (isset($head_css))
338 print(trim($head_css)."\n");
339 print("--></style>\n");
342 print("</head><body");
343 if (isset($mozilla_major) && $mozilla_major==4)
344 print(" bgcolor=\"black\" text=\"white\" link=\"cyan\" vlink=\"teal\"");