+function usersize($size in bytes) -> $size as user string
[www.energie.vellum.cz.git] / common.php
index 59f046a..016e546 100644 (file)
@@ -324,6 +324,21 @@ function dirnameslashed($filename)
        return($r);
 }
 
+function usersize($size)
+{
+       $suffix_a=array("","k","M","G","T");
+       while ($size>=1000 && sizeof($suffix_a)>=2) {
+               $size/=1000;
+               array_shift($suffix_a);
+               }
+       return(round($size)." ".$suffix_a[0]."B");
+}
+
+function data_href($filename,$text)
+{
+       return("<a href=\"$filename\">$text (".usersize(filesize($filename)).")</a>");
+}
+
 function footer($delimit=true)
 {
        // deadlock prevention:
@@ -360,7 +375,7 @@ function no_cache()
        header("Pragma: no-cache");                                // HTTP/1.0
 }
 
-function heading()
+function heading($title=false)
 {
        global $msie_major,$mozilla_major,$title_tail,$head_css,$have_css,$head;
 
@@ -376,10 +391,11 @@ function heading()
        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; }
-.nowrap  { white-space: nowrap; }
+.cvs-id   { font-family: monospace; }
+.error    { color: red;   background-color: transparent; }
+.quote    { font-family: monospace; }
+.nowrap   { white-space: nowrap; }
+.centered { text-align: center; }
 body {
                background-color: black;
                color: white;
@@ -398,5 +414,9 @@ h1,h2    { color: yellow; background-color: transparent; }
        if (isset($mozilla_major) && $mozilla_major==4)
                print(" bgcolor=\"black\" text=\"white\" link=\"cyan\" vlink=\"teal\"");
        print(">\n");
+       if ($title)
+               print("<h1 class=\"centered\">"
+                               .img("img/eap-title.".(image_supported("image/png") ? "png" : "gif"),"Energie & Peníze")
+                               ."</h1>\n");
 }
 ?>