Fixed W3C CSS Validator compliance
[www.energie.vellum.cz.git] / common.php
index 94e1a70..7957a9a 100644 (file)
        if (isset($detect_js) && !$have_js)
                $head.='<script type="text/javascript" src="have_js.js"></script>'."\n";
 
-       if (ereg("[[:<:]]MSIE ([0-9]+)\\.",$HTTP_SERVER_VARS["HTTP_USER_AGENT"],$msie_major_a))
+       $user_agent=$HTTP_SERVER_VARS["HTTP_USER_AGENT"];
+       if (ereg("[[:<:]]MSIE ([0-9]+)\\.",$user_agent,$msie_major_a))
                $msie_major=$msie_major_a[1];
+       else if (ereg("[[:<:]]Mozilla/([0-9]+)\\.",$user_agent,$mozilla_major_a))
+               $mozilla_major=$mozilla_major_a[1];
 
 function addpercents($url)
 {
@@ -106,17 +109,26 @@ function db_item($query)
        return($row[0]);
 }
 
-function month_full($year,$month,$month_last=0)
+function month_a($year,$month,$month_last=0)
 {
        global $tb_obsah;
 
        if (!$month_last)
                $month_last=db_item("select month_last from $tb_obsah where year='$year' and month='$month'");
-       return(sprintf("%02d".($month==$month_last ? "" : "-%02d"),$month,$month_last));
+       $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"=>"$year/${month_full}",
+                       "img" =>"img/eap-$year-${month_full}.jpg",
+                       "icon"=>"img/eap-$year-${month_full}s.jpg",
+                       );
+       return($r);
 }
 
-function img_size($width,$height)
+function img_size($width,$height=0)
 {
+       if (!$height)
+               list($width,$height)=getimagesize($width);
        return("style=\"border:0;width:${width}px;height:${height}px\" width=\"$width\" height=\"$height\"");
 }
 
@@ -147,7 +159,7 @@ function footer()
 
 function heading()
 {
-       global $msie_major,$title_tail,$head_css,$head;
+       global $msie_major,$mozilla_major,$title_tail,$head_css,$head;
 
        header("Content-type: text/html; charset=iso-8859-2");
        if (!isset($msie_major) || $msie_major>=4)
@@ -160,15 +172,25 @@ function heading()
                print(": $title_tail");
 ?></title>
 <style type="text/css"><!--
-.cvs-id { font-family: monospace; }
-.error  { color: red; }
-.quote  { font-family: monospace; }
+.cvs-id  { font-family: monospace; }
+.error   { color: red;    background-color: transparent; }
+.quote   { font-family: monospace; }
+body {
+               background-color: black;
+               color: white;
+               }
+:link    { color: aqua;   background-color: transparent; }
+: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))
                print($head);
-       print("</head><body>\n");
+       print("</head><body");
+       if (isset($mozilla_major) && $mozilla_major==4)
+               print(" bgcolor=\"black\" text=\"white\" link=\"cyan\" vlink=\"teal\"");
+       print(">\n");
 }
 ?>