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 $have_css=!ereg("Mozilla/4\\.[5-7]",$user_agent);
30 function addpercents($url)
33 foreach(preg_split('//', $url, -1, PREG_SPLIT_NO_EMPTY) as $c)
34 if (ereg("[a-zA-Z0-9]",$c))
37 $r.=sprintf("%%%02X",ord($c));
41 function fatal($msg="UNKNOWN")
45 print("\n<br /><h1 class=\"error\">Nastala chyba pøi zpracování: $msg!</h1>\n"
46 ."<p>Mù¾ete tento problém nahlásit <a href=\"mailto:$admin_mail\">správci tohoto webu</a>.</p>\n");
50 function prepvar($name,$regex=".",$require=true)
52 global $HTTP_GET_VARS,$HTTP_POST_VARS;
54 if (isset($HTTP_GET_VARS[$name]))
55 $v=$HTTP_GET_VARS[$name];
56 else if (isset($HTTP_POST_VARS[$name]))
57 $v=$HTTP_POST_VARS[$name];
61 $name_html="Parametr <span class=\"quote\">".htmlspecialchars($name)."</span>";
64 if (isset($v) && !ereg($regex,$v))
65 fatal("$name_html nevyhovuje po¾adovanému regexu <span class=\"quote\">".htmlspecialchars($regex)."</span>");
66 if (!isset($v) && $require)
67 fatal("$name_html je vy¾adován");
78 global $db_host,$db_user,$db_pwd,$db_name;
83 if (!($db_link=mysql_connect($db_host,$db_user,$db_pwd)))
84 fatal("MySQL connect: ".mysql_error());
85 if (!mysql_select_db($db_name,$db_link))
86 fatal("MySQL database select: ".mysql_error());
89 function db_query($query)
94 if (!($r=mysql_query($query,$db_link)))
95 fatal("MySQL query \"$query\": ".mysql_error());
99 function db_row($query)
102 $r=mysql_fetch_row($q);
103 mysql_free_result($q);
107 function db_item($query)
113 function num2greg($num)
116 $vals=array(1=>"I",5=>"V",10=>"X",50=>"L",100=>"C",500=>"D",1000=>"M");
117 krsort($vals,SORT_NUMERIC);
118 foreach($vals as $val=>$sym) {
119 while ($num<0 && $num+$val<-$num) {
120 $r=substr($r,0,-1).$sym.substr($r,-1,1);
123 while (10*$num>=8*$val+(substr($val,0,1)=="1")) {
131 function month_a($year,$month,$month_last=0,$sequential=0)
133 global $tb_obsah,$obsah_year_base;
135 if (!$month_last || !$sequential)
136 list($month_last,$sequential)=db_row("select month_last,sequential from $tb_obsah where year='$year' and month='$month'");
137 $month_full=sprintf("%02d".($month==$month_last ? "" : "-%02d"),$month,$month_last);
139 $r=array("year"=>$year,"month"=>$month,"month_last"=>$month_last,"month_full"=>$month_full,
140 "name"=>"$month" .($month==$month_last ? "" : "-$month_last")."/$year",
141 "img" =>"img/eap-$year-${month_full}.jpeg",
142 "icon"=>"img/eap-$year-${month_full}s.jpeg",
144 $r["name_full"]=$r["name"]
145 ." ($sequential".($month==$month_last ? "" : "-".($sequential+$month_last-$month)).")"
146 ." - ".num2greg($year-$obsah_year_base+1).". roèník";
150 function img_size($width,$height)
152 return("style=\"border:0;width:${width}px;height:${height}px\" width=\"$width\" height=\"$height\"");
155 function img($file,$alt,$attrs="")
157 list($width,$height)=getimagesize($file);
158 return("<img src=\"$file\" alt=\"".htmlspecialchars($alt)."\" ".img_size($width,$height)
159 .($attrs=="" ? "" : " ".$attrs)." />");
162 function gsm_banking()
164 return(img("img/sluzby_bankovni_pggsm.gif","Paegas GSM banking","class=\"img-align\""));
169 if (!($f=fopen("objednavka.js","r")))
170 fatal("Nepodaøilo se naèíst seznam dostupného zbo¾í");
172 while (($s=fgets($f,0x1000))) {
175 if (!(ereg("^want_price\\[ *'([^']*)'\\]=([0-9]*);$",$s,$matched)))
177 $r[$matched[1]]=$matched[2];
183 function title_name($year,$month)
185 if (isset($year) && isset($month)) {
186 $month_a=month_a($year,$month);
187 return("Èíslo ".$month_a["name_full"]);
189 else if (isset($year))
190 return("Roèník $year");
192 return("V¹echny roèníky");
195 function title_month($year,$month)
197 $month_a=month_a($year,$month);
199 ."<table border=\"0\" width=\"100%\">\n"
200 ."<tr><td align=\"center\"><table border=\"1\" cellpadding=\"10\">\n"
201 ."<tr><td align=\"center\">".img($month_a["img"],"titulní stránka ".$month_a["name"])."</td></tr>\n"
202 ."</table></td></tr>\n"
207 function title_icons_table_month($year,$month,$month_last,$sequential)
209 $month_a=month_a($year,$month,$month_last,$sequential);
210 print("<a href=\"title.php?year=$year&month=$month\">"
211 .img($month_a["icon"],"titulní stránka ".$month_a["name_full"])."</a><br />"
212 ."<a href=\"obsah.php?year=$year&month=$month\">obsah ".$month_a["name"]."</a>"
216 function title_icons($year,$month)
221 .(isset($year) ? "<a name=\"year_$year\">" : "")
222 .title_name(&$year,&$month)
223 .(isset($year) ? "</a>" : "")
226 $result=db_query("select year,month,month_last,sequential from $tb_obsah"
227 .(isset($year) || isset($month) ? " where" : "")
228 .(isset($year ) ? " year=$year" : "")
229 .(isset($year) && isset($month) ? " and" : "")
230 .(isset($month) ? " month=$month" : "")
231 ." order by year,month");
234 // $year variable changes its meaning here!!!
241 while ($row=mysql_fetch_array($result)) {
243 $row["month_last"]--;
245 if ($row["year"]!=$year) {
246 print($fin_split.$fin_year);
250 .(!isset($wanted_year) ? "<p><a name=\"year_$year\"> </a></p>" : "")
251 ."<table border=\"0\" width=\"100%\"><tr><td align=\"center\"><table border=\"1\" cellpadding=\"5\">\n"
252 ."<tr><th colspan=\"$split\">Roèník $year (<a href=\"obsah.php?year=$year\">obsahy èísel</a>)</th></tr>\n"
254 $fin_year="</table></td></tr></table>\n";
259 while ($floor<floor($row["month"]/$split)) {
260 print($fin_split."<tr>");
261 $fin_split="</tr>\n";
263 $month=$floor*$split-1;
265 while ($month+1<$row["month"]) {
269 print("<td align=\"center\""
270 .($row["month_last"]!=$row["month"] ? " colspan=\"".($row["month_last"]+1-$row["month"])."\"" : "")
272 title_icons_table_month($year,$row["month"]+1,$row["month_last"]+1,$row["sequential"]);
274 $month=$row["month_last"];
276 mysql_free_result($result);
277 print($fin_split.$fin_year);
280 function title($year,$month)
282 if (isset($year) && isset($month))
283 return(title_month( $year, $month));
285 return(title_icons(&$year,&$month));
288 function image_supported($mime)
290 global $HTTP_SERVER_VARS;
292 if (!isset($HTTP_SERVER_VARS["HTTP_ACCEPT"]))
294 $exp=explode(",",$HTTP_SERVER_VARS["HTTP_ACCEPT"]);
295 while (($s=array_shift($exp))) {
296 $s=trim(ereg_replace(";.*","",$s));
305 // deadlock prevention:
306 global $footer_passed;
307 if (isset($footer_passed))
311 global $cvs_id_html,$viewcvs,$viewcvs,$HTTP_SERVER_VARS;
315 <table border="0" width="100%">
316 <tr><td align="left"><span class="cvs-id"><?php print($cvs_id_html); ?></span></td><td align="right"><a
317 href="http://validator.w3.org/check/referer"><img src="http://www.w3.org/Icons/valid-xhtml10"
318 <?php print(img_size(88,31)); ?> alt="Valid XHTML 1.0!" /></a><a
319 href="http://jigsaw.w3.org/css-validator/validator?warning=2&profile=css2&uri=<?php
320 print(addpercents("http://".$HTTP_SERVER_VARS["HTTP_HOST"].$HTTP_SERVER_VARS["REQUEST_URI"]));
321 ?>"><img src="http://jigsaw.w3.org/css-validator/images/vcss"
322 <?php print(img_size(88,31)); ?> alt="Valid CSS!" /></a></td></tr>
329 // Stolen from: php-manual.html#function.header
332 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
333 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); // always modified
334 header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
335 header("Pragma: no-cache"); // HTTP/1.0
340 global $msie_major,$mozilla_major,$title_tail,$head_css,$have_css,$head;
342 header("Content-type: text/html; charset=iso-8859-2");
343 if (!isset($msie_major) || $msie_major>=4)
344 print('<?xml version="1.0" encoding="iso-8859-2"?>'."\n");
346 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
347 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
348 <head><title>Energie & peníze<?php
349 if (isset($title_tail))
350 print(": $title_tail");
353 ?><style type="text/css"><!--
354 .cvs-id { font-family: monospace; }
355 .error { color: red; background-color: transparent; }
356 .quote { font-family: monospace; }
358 background-color: black;
361 :link { color: aqua; background-color: transparent; }
362 :visited { color: teal; background-color: transparent; }
363 h1,h2 { color: yellow; background-color: transparent; }
365 if (isset($head_css))
366 print(trim($head_css)."\n");
367 print("--></style>\n");
371 print("</head><body");
372 if (isset($mozilla_major) && $mozilla_major==4)
373 print(" bgcolor=\"black\" text=\"white\" link=\"cyan\" vlink=\"teal\"");