else if (ereg("[[:<:]]Mozilla/([0-9]+)\\.",$user_agent,$mozilla_major_a))
$mozilla_major=$mozilla_major_a[1];
+ $have_style=!isset($mozilla_major) || $mozilla_major!=4;
+ $have_css=true; // doesn't hurt anybody AFAIK
+
function addpercents($url)
{
$r=$c="";
{
global $admin_mail;
- print("\n<br /><h1 class=\"error\">Nastala chyba pøi zpracování: $msg!</h1>\n"
+ print("\n<p> <br /> </p><hr /><h1 class=\"error\">Nastala chyba pøi zpracování: $msg!</h1>\n"
."<p>Mù¾ete tento problém nahlásit <a href=\"mailto:$admin_mail\">správci tohoto webu</a>.</p>\n");
footer();
}
return($row[0]);
}
-function month_a($year,$month,$month_last=0)
+function num2greg($num)
{
- global $tb_obsah;
+ $r="";
+ $vals=array(1=>"I",5=>"V",10=>"X",50=>"L",100=>"C",500=>"D",1000=>"M");
+ krsort($vals,SORT_NUMERIC);
+ foreach($vals as $val=>$sym) {
+ while ($num<0 && $num+$val<-$num) {
+ $r=substr($r,0,-1).$sym.substr($r,-1,1);
+ $num+=$val;
+ }
+ while (10*$num>=8*$val+(substr($val,0,1)=="1")) {
+ $r=$r.$sym;
+ $num-=$val;
+ }
+ }
+ return($r);
+}
+
+function month_a($year,$month,$month_last=0,$sequential=0)
+{
+ global $tb_obsah,$obsah_year_base;
- if (!$month_last)
- $month_last=db_item("select month_last from $tb_obsah where year='$year' and month='$month'");
+ if (!$month_last || !$sequential)
+ list($month_last,$sequential)=db_row("select month_last,sequential from $tb_obsah where year='$year' and month='$month'");
$month_full=sprintf("%02d".($month==$month_last ? "" : "-%02d"),$month,$month_last);
$r=array("year"=>$year,"month"=>$month,"month_last"=>$month_last,"month_full"=>$month_full,
- "name"=>"$month".($month==$month_last ? "" : "-$month_last")."/$year",
+ "name"=>"$month" .($month==$month_last ? "" : "-$month_last")."/$year",
"img" =>"img/eap-$year-${month_full}.jpeg",
"icon"=>"img/eap-$year-${month_full}s.jpeg",
);
+ $r["name_full"]=$r["name"]
+ ." ($sequential".($month==$month_last ? "" : "-".($sequential+$month_last-$month)).")"
+ ." - ".num2greg($year-$obsah_year_base+1).". roèník";
return($r);
}
-function img_size($width,$height=0)
+function img_size($width,$height)
{
- if (!$height)
- list($width,$height)=getimagesize($width);
- return("style=\"border:0;width:${width}px;height:${height}px\" width=\"$width\" height=\"$height\"");
+ global $have_style;
+
+ return(($have_style ? "style=\"border:0;width:${width}px;height:${height}px\"" : "border=\"0\"")
+ ." width=\"$width\" height=\"$height\"");
+}
+
+function img($file,$alt,$attrs="")
+{
+ list($width,$height)=getimagesize($file);
+ return("<img src=\"$file\" alt=\"".htmlspecialchars($alt)."\" ".img_size($width,$height)
+ .($attrs=="" ? "" : " ".$attrs)." />");
}
function gsm_banking()
{
- return("<img src=\"img/sluzby_bankovni_pggsm.gif\" ".img_size(89,31)." alt=\"Paegas GSM banking\" class=\"img-align\" />");
+ return(img("img/sluzby_bankovni_pggsm.gif","Paegas GSM banking","class=\"img-align\""));
}
function price_a()
{
if (isset($year) && isset($month)) {
$month_a=month_a($year,$month);
- return("Èíslo ".$month_a["name"]);
+ return("Èíslo ".$month_a["name_full"]);
}
else if (isset($year))
return("Roèník $year");
return(""
."<table border=\"0\" width=\"100%\">\n"
."<tr><td align=\"center\"><table border=\"1\" cellpadding=\"10\">\n"
- ."<tr><td align=\"center\"><img src=\"".$month_a["img"]."\" ".img_size($month_a["img"])
- ." alt=\"titulní stránka ".$month_a["name"]."\" /></td></tr>\n"
+ ."<tr><td align=\"center\">".img($month_a["img"],"titulní stránka ".$month_a["name"])."</td></tr>\n"
."</table></td></tr>\n"
."</table>\n"
);
}
-function title_icons_table_month($year,$month,$month_last)
+function title_icons_table_month($year,$month,$month_last,$sequential)
{
- $month_a=month_a($year,$month,$month_last);
+ $month_a=month_a($year,$month,$month_last,$sequential);
print("<a href=\"title.php?year=$year&month=$month\">"
- ."<img src=\"".$month_a["icon"]."\" ".img_size($month_a["icon"])
- ." alt=\"titulní stránka ".$month_a["name"]."\" /></a><br />"
+ .img($month_a["icon"],"titulní stránka ".$month_a["name_full"])."</a><br />"
."<a href=\"obsah.php?year=$year&month=$month\">obsah ".$month_a["name"]."</a>"
);
}
.(isset($year) ? "</a>" : "")
."</h2>\n");
- $result=db_query("select year,month,month_last from $tb_obsah"
+ $result=db_query("select year,month,month_last,sequential from $tb_obsah"
.(isset($year) || isset($month) ? " where" : "")
.(isset($year ) ? " year=$year" : "")
.(isset($year) && isset($month) ? " and" : "")
print("<td align=\"center\""
.($row["month_last"]!=$row["month"] ? " colspan=\"".($row["month_last"]+1-$row["month"])."\"" : "")
.">");
- title_icons_table_month($year,$row["month"]+1,$row["month_last"]+1);
+ title_icons_table_month($year,$row["month"]+1,$row["month_last"]+1,$row["sequential"]);
print("</td>\n");
$month=$row["month_last"];
}
{
global $HTTP_SERVER_VARS;
+ if (!isset($HTTP_SERVER_VARS["HTTP_ACCEPT"]))
+ return(false);
$exp=explode(",",$HTTP_SERVER_VARS["HTTP_ACCEPT"]);
while (($s=array_shift($exp))) {
$s=trim(ereg_replace(";.*","",$s));
return(false);
}
-function footer()
+// PHP dirname() is broken: ("/1/2/3"=>"/1/2", "/1"->"/")
+function dirnameslashed($filename)
+{
+ $r=dirname($filename);
+ if (substr($r,-1)!="/")
+ $r.="/";
+ return($r);
+}
+
+function footer($delimit=true)
{
// deadlock prevention:
global $footer_passed;
$footer_passed=true;
global $cvs_id_html,$viewcvs,$viewcvs,$HTTP_SERVER_VARS;
+ if ($delimit)
+ print("<p> </p>\n");
?>
-<p> </p>
<hr />
<table border="0" width="100%">
<tr><td align="left"><span class="cvs-id"><?php print($cvs_id_html); ?></span></td><td align="right"><a
function heading()
{
- global $msie_major,$mozilla_major,$title_tail,$head_css,$head;
+ global $msie_major,$mozilla_major,$title_tail,$head_css,$have_css,$head;
header("Content-type: text/html; charset=iso-8859-2");
if (!isset($msie_major) || $msie_major>=4)
<head><title>Energie & peníze<?php
if (isset($title_tail))
print(": $title_tail");
-?></title>
-<style type="text/css"><!--
+ print("</title>\n");
+ if ($have_css) {
+?><style type="text/css"><!--
.cvs-id { font-family: monospace; }
.error { color: red; background-color: transparent; }
.quote { font-family: monospace; }
:visited { color: teal; background-color: transparent; }
h1,h2 { color: yellow; background-color: transparent; }
<?php
- if (isset($head_css))
- print(trim($head_css)."\n");
- print("--></style>\n");
+ if (isset($head_css))
+ print(trim($head_css)."\n");
+ print("--></style>\n");
+ }
if (isset($head))
print($head);
print("</head><body");