Cosmetic fix of MNGs imagesize detection code (missing regex trailing "$")
[www.energie.vellum.cz.git] / common.php
index 69ffa30..240ad20 100644 (file)
@@ -2,6 +2,7 @@
 
        error_reporting(E_ALL);
        setlocale(LC_ALL,"cs_CZ.iso-8859-2");
+       fixampvars();
 
        include("config.php");
 
@@ -18,7 +19,7 @@
        $have_js=(isset($HTTP_GET_VARS["have_js"]) || isset($HTTP_POST_VARS["have_js"])
                        ? "?have_js=1" : "");
        if (isset($detect_js) && !$have_js)
-               $head.='<script type="text/javascript" src="have_js.js"></script>'."\n";
+               $head.='<script type="text/javascript" src="'.(!isset($energie_base) ? "" : $energie_base).'have_js.js"></script>'."\n";
 
        $user_agent=(!isset($HTTP_SERVER_VARS["HTTP_USER_AGENT"]) ? "" : $HTTP_SERVER_VARS["HTTP_USER_AGENT"]);
        if (ereg("[[:<:]]MSIE ([0-9]+)\\.",$user_agent,$msie_major_a))
        $have_style=!isset($mozilla_major) || $mozilla_major!=4;
        $have_css=true; // doesn't hurt anybody AFAIK
 
+function fixampvars()
+{
+       $ars=array("HTTP_GET_VARS","HTTP_POST_VARS");
+       foreach ($ars as $ar) {
+               foreach ($GLOBALS[$ar] as $key=>$val) {
+                       if (substr($key,0,4)!="amp;")
+                               continue;
+                       unset($GLOBALS[$ar][$key]);
+                       $GLOBALS[$ar][substr($key,4)]=$val;
+                       }
+               }
+}
+
 function addpercents($url)
 {
        $r=$c="";
@@ -168,7 +182,7 @@ function img_size($width,$height)
 
 function img($file,$alt,$attrs="")
 {
-       list($width,$height)=getimagesize($file);
+       list($width,$height)=getimagesize(ereg_replace("\\.mng\$",".gif",$file));
        $alt=htmlspecialchars($alt);
        return("<img src=\"$file\" alt=\"$alt\" title=\"$alt\" ".img_size($width,$height)
                        .($attrs=="" ? "" : " ".$attrs)." />");
@@ -176,7 +190,8 @@ function img($file,$alt,$attrs="")
 
 function gsm_banking()
 {
-       return(img("img/sluzby_bankovni_pggsm.gif","Paegas GSM banking","class=\"img-align\""));
+       return(img("img/sluzby_bankovni_pggsm.".(image_supported("video/x-mng") ? "mng" : "gif"),
+                       "Paegas GSM banking","class=\"img-align\""));
 }
 
 function price_a()
@@ -374,14 +389,15 @@ zvolte pros
 
 <li>
 <table border="0">
-<tr><td><?php print("<a href=\"$base.pdf\">".img("img/adobe-pdficon-alpha.gif","Adobe PDF")."</a>"); ?></td>
+<tr><td><?php print("<a href=\"$base.pdf\">".img("img/adobe-pdficon-alpha.".(image_supported("image/png") ? "png" : "gif"),
+                       "Adobe PDF")."</a>"); ?></td>
        <td><?php print(data_href("$base.pdf","Dokument PDF")); ?></td>
        </tr>
 </table>
 <blockquote>
 <table border="0">
 <tr><td><a href="http://www.adobe.com/products/acrobat/readstep.html"><?php
-       print(img("img/adobe-getacro.gif","Get Adobe Acrobat Reader"));
+       print(img("img/adobe-getacro.".(image_supported("image/png") ? "png" : "gif"),"Get Adobe Acrobat Reader"));
        ?></a></td>
        <td class="smaller">Soubor je ve formátu <span class="italic">Adobe Acrobat</span>,
        pro jeho pøeètení si prosím nainstalujte