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");
77 global $db_host,$db_user,$db_pwd,$db_name;
82 if (!($db_link=@mysql_connect($db_host,$db_user,$db_pwd)))
83 fatal("MySQL connect: ".mysql_error());
84 if (!mysql_select_db($db_name,$db_link))
85 fatal("MySQL database select: ".mysql_error());
88 function db_query($query)
93 if (!($r=mysql_query($query,$db_link)))
94 fatal("MySQL query \"$query\": ".mysql_error());
98 function db_row($query)
101 $r=mysql_fetch_row($q);
102 mysql_free_result($q);
106 function db_item($query)
112 function month_a($year,$month,$month_last=0)
117 $month_last=db_item("select month_last from $tb_obsah where year='$year' and month='$month'");
118 $month_full=sprintf("%02d".($month==$month_last ? "" : "-%02d"),$month,$month_last);
120 $r=array("year"=>$year,"month"=>$month,"month_last"=>$month_last,"month_full"=>$month_full,
121 "name"=>"$year/${month_full}",
122 "img" =>"img/eap-$year-${month_full}.jpg",
123 "icon"=>"img/eap-$year-${month_full}s.jpg",
128 function img_size($width,$height=0)
131 list($width,$height)=getimagesize($width);
132 return("style=\"border:0;width:${width}px;height:${height}px\" width=\"$width\" height=\"$height\"");
137 // deadlock prevention:
138 global $footer_passed;
139 if (isset($footer_passed))
143 global $cvs_id_html,$viewcvs,$viewcvs,$HTTP_SERVER_VARS;
146 <table border="0" width="100%">
147 <tr><td align="left"><span class="cvs-id"><?php print($cvs_id_html); ?></span></td><td align="right"><a
148 href="http://validator.w3.org/check/referer"><img src="http://www.w3.org/Icons/valid-xhtml10"
149 <?php print(img_size(88,31)); ?> alt="Valid XHTML 1.0!" /></a><a
150 href="http://jigsaw.w3.org/css-validator/validator?warning=2&profile=css2&uri=<?php
151 print(addpercents("http://".$HTTP_SERVER_VARS["HTTP_HOST"].$HTTP_SERVER_VARS["REQUEST_URI"]));
152 ?>"><img src="http://jigsaw.w3.org/css-validator/images/vcss"
153 <?php print(img_size(88,31)); ?> alt="Valid CSS!" /></a></td></tr>
162 global $msie_major,$mozilla_major,$title_tail,$head_css,$head;
164 header("Content-type: text/html; charset=iso-8859-2");
165 if (!isset($msie_major) || $msie_major>=4)
166 print('<?xml version="1.0" encoding="iso-8859-2"?>'."\n");
168 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
169 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
170 <head><title>Energie & peníze<?php
171 if (isset($title_tail))
172 print(": $title_tail");
174 <style type="text/css"><!--
175 .cvs-id { font-family: monospace; }
176 .error { color: red; }
177 .quote { font-family: monospace; }
179 background-color: black;
182 :link { color: cyan; }
183 :visited { color: teal; }
184 h1,h2 { color: yellow; }
186 if (isset($head_css))
187 print(trim($head_css)."\n");
188 print("--></style>\n");
191 print("</head><body");
192 if (isset($mozilla_major) && $mozilla_major==4)
193 print(" bgcolor=\"black\" text=\"white\" link=\"cyan\" vlink=\"teal\"");