Implemented $have_ent detection (enabled by $detect_ent, default)
authorshort <>
Thu, 25 Apr 2002 16:18:41 +0000 (16:18 +0000)
committershort <>
Thu, 25 Apr 2002 16:18:41 +0000 (16:18 +0000)
 - specifies the ability to decode entities in tag attributes
-function addpercents()
 - calls replaced by standard urlencode()
Fixed missing <img> "title" attribute in footer_img()
 - function not used now
+function a_href($url,$contents)
w3.org footer images are now stored as local
w3.org footer referenced by $have_ent-detected optional redirect.php

common.php

index 240ad20..4acad91 100644 (file)
@@ -2,7 +2,6 @@
 
        error_reporting(E_ALL);
        setlocale(LC_ALL,"cs_CZ.iso-8859-2");
-       fixampvars();
 
        include("config.php");
 
                }
        $cvs_id_html=join(" ",$cvs_id_split);
 
+       if (!isset($head))
+               $head="";
+
+       unset($have_ent);
+       if (isset($HTTP_GET_VARS[    "have_ent"]))
+               $have_ent=true;
+       if (isset($HTTP_GET_VARS["amp;have_ent"]))
+               $have_ent=false;
+       if ((!isset($detect_ent) || $detect_ent) && !isset($have_ent) && $HTTP_SERVER_VARS["REQUEST_METHOD"]=="GET")
+               $head.='<meta http-equiv="Refresh" content="0; URL='
+                               .htmlspecialchars("http://".$HTTP_SERVER_VARS["HTTP_HOST"].$HTTP_SERVER_VARS["PHP_SELF"]
+                                               ."?".(strlen($HTTP_SERVER_VARS["QUERY_STRING"]) ? $HTTP_SERVER_VARS["QUERY_STRING"] : "detect_ent_glue=1")
+                                                               ."&have_ent=detect")
+                               .'">'."\n";
+       fixampvars();
+
        $have_js=(isset($HTTP_GET_VARS["have_js"]) || isset($HTTP_POST_VARS["have_js"])
                        ? "?have_js=1" : "");
        if (isset($detect_js) && !$have_js)
@@ -43,17 +58,6 @@ function fixampvars()
                }
 }
 
-function addpercents($url)
-{
-       $r=$c="";
-       foreach(preg_split('//', $url, -1, PREG_SPLIT_NO_EMPTY) as $c)
-               if (ereg("[a-zA-Z0-9]",$c))
-                       $r.=$c;
-               else
-                       $r.=sprintf("%%%02X",ord($c));
-       return($r);
-}
-
 function fatal($msg="UNKNOWN")
 {
        global $admin_mail;
@@ -615,11 +619,21 @@ function footer_img($url,$text,$size)
 {
        global $footer_LOCAL;
        if (!isset($footer_LOCAL))
-               return("<img src=\"$url\" $size alt=\"$text\" />");
+               return("<img src=\"$url\" $size alt=\"$text\" title=\"$text\" />");
        else
                return($text);
 }
 
+function a_href($url,$contents)
+{
+       global $have_ent;
+
+       print("<a href=\"");
+       if (ereg("^[a-z]+://",$url) && !$have_ent)
+               $url="redirect.php?location=".urlencode($url);
+       print(htmlspecialchars($url)."\">$contents</a>");
+}
+
 function footer($delimit=true)
 {
        // deadlock prevention:
@@ -631,18 +645,18 @@ function footer($delimit=true)
        global $cvs_id_html,$viewcvs,$viewcvs,$HTTP_SERVER_VARS;
        if ($delimit)
                print("<p>&nbsp;</p>\n");
-       $uri="uri=".addpercents("http://".$HTTP_SERVER_VARS["HTTP_HOST"].$HTTP_SERVER_VARS["REQUEST_URI"]);
+       $uri="uri=".urlencode("http://".$HTTP_SERVER_VARS["HTTP_HOST"].$HTTP_SERVER_VARS["REQUEST_URI"]);
        ?>
 <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
-       href="http://validator.w3.org/check?<?php
-               print($uri); ?>"><?php
-                               print footer_img("http://www.w3.org/Icons/valid-xhtml11","Valid XHTML 1.1!",img_size(88,31));
-                               ?></a><a href="http://jigsaw.w3.org/css-validator/validator?warning=2&amp;profile=css2&amp;<?php
-               print($uri); ?>"><?php
-                               print footer_img("http://jigsaw.w3.org/css-validator/images/vcss","Valid CSS!",img_size(88,31));
-                               ?></a></td></tr>
+<tr><td align="left"><span class="cvs-id"><?php print($cvs_id_html); ?></span></td><td align="right"><?php
+                       print(""
+                                       .a_href("http://validator.w3.org/check?$uri",
+                                                       img("img/valid-xhtml11.".(image_supported("image/png") ? "png" : "gif"),"Valid XHTML 1.1!"))
+                                       .a_href("http://jigsaw.w3.org/css-validator/validator?warning=2&profile=css2&$uri",
+                                                       img("img/vcss."         .(image_supported("image/png") ? "png" : "gif"),"Valid CSS!"))
+                                       );
+                       ?></td></tr>
 </table>
 </body></html>
 <?php
@@ -664,7 +678,7 @@ function heading($title=false)
 
        if (isset($heading_done))
                return;
-       $heading_done=1;
+       $heading_done=true;
 
        if (isset($force_charset))
                $client_charset=$force_charset;