Extension for seamless compatibility with "kewensis" project
authorshort <>
Mon, 28 Jan 2002 21:45:40 +0000 (21:45 +0000)
committershort <>
Mon, 28 Jan 2002 21:45:40 +0000 (21:45 +0000)
common.php
config.php

index e4587c1..118f447 100644 (file)
@@ -43,6 +43,7 @@ function fatal($msg="UNKNOWN")
 {
        global $admin_mail;
 
 {
        global $admin_mail;
 
+       heading(false/*title*/); // it is always safe
        print("\n<p>&nbsp;<br />&nbsp;</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();
        print("\n<p>&nbsp;<br />&nbsp;</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();
@@ -70,7 +71,7 @@ function prepvar($name,$regex=".",$require=true)
        if (!isset($v))
                return(0);
 
        if (!isset($v))
                return(0);
 
-       $globals[$name]=$v;
+       $GLOBALS[$name]=$v;
        return($v);
 }
 
        return($v);
 }
 
@@ -97,7 +98,7 @@ function db_query($query)
        return($r);
 }
 
        return($r);
 }
 
-function db_row($query)
+function db_row($query) // pure indexes
 {
        $q=db_query($query);
        $r=mysql_fetch_row($q);
 {
        $q=db_query($query);
        $r=mysql_fetch_row($q);
@@ -105,7 +106,7 @@ function db_row($query)
        return($r);
 }
 
        return($r);
 }
 
-function db_array($query)
+function db_array($query) // field-names associative
 {
        $q=db_query($query);
        $r=mysql_fetch_array($q);
 {
        $q=db_query($query);
        $r=mysql_fetch_array($q);
@@ -347,6 +348,15 @@ function data_href($filename,$text)
        return("<a href=\"$filename\">$text (".usersize(filesize($filename)).")</a>");
 }
 
        return("<a href=\"$filename\">$text (".usersize(filesize($filename)).")</a>");
 }
 
+function footer_img($url,$text,$size)
+{
+       global $footer_LOCAL;
+       if (!isset($footer_LOCAL))
+               return("<img src=\"$url\" $size alt=\"$text\" />");
+       else
+               return($text);
+}
+
 function footer($delimit=true)
 {
        // deadlock prevention:
 function footer($delimit=true)
 {
        // deadlock prevention:
@@ -364,11 +374,12 @@ function footer($delimit=true)
 <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
 <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); ?>"><img src="http://www.w3.org/Icons/valid-xhtml11"
-               <?php print(img_size(88,31)); ?> alt="Valid XHTML 1.1!" /></a><a
-       href="http://jigsaw.w3.org/css-validator/validator?warning=2&amp;profile=css2&amp;<?php
-               print($uri); ?>"><img src="http://jigsaw.w3.org/css-validator/images/vcss"
-               <?php print(img_size(88,31)); ?> alt="Valid CSS!" /></a></td></tr>
+               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>
 </table>
 </body></html>
 <?php
 </table>
 </body></html>
 <?php
@@ -386,16 +397,27 @@ function no_cache()
 
 function heading($title=false)
 {
 
 function heading($title=false)
 {
-       global $HTTP_SERVER_VARS,$msie_major,$mozilla_major,$title_tail,$head_css,$have_css,$head;
+       global $HTTP_SERVER_VARS,$msie_major,$mozilla_major,$title_tail,$head_css,$have_css,$head,$heading_done,$title_prefix,$force_charset;
 
 
-       header("Content-type: text/html");
+       if (isset($heading_done))
+               return;
+       $heading_done=1;
+
+       if (isset($force_charset))
+               $client_charset=$force_charset;
+       else
+               $client_charset=(!isset($HTTP_SERVER_VARS["CLIENT_CHARSET"]) ? "iso-8859-2" : $HTTP_SERVER_VARS["CLIENT_CHARSET"]);
+       // When "CLIENT_CHARSET" is set we MUST NOT explicitely specify our "charset"
+       header("Content-type: text/html".(isset($HTTP_SERVER_VARS["CLIENT_CHARSET"]) ? "" : "; charset=$client_charset"));
        header("Content-Style-Type: text/css");
        header("Content-Style-Type: text/css");
-       if (!isset($msie_major) || $msie_major>=4)
-               print('<?xml version="1.0" encoding="'.$HTTP_SERVER_VARS["CLIENT_CHARSET"].'"?>'."\n");
+       if (!isset($msie_major) || $msie_major>=4) {
+               print('<?xml version="1.0" encoding="'.$client_charset.'"?>'."\n");
+               }
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs">
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs">
-<head><title>Energie &amp; peníze<?php
+<head><?php
+       print("<title>$title_prefix");
        if (isset($title_tail))
                print(": ".htmlspecialchars($title_tail));
        print("</title>\n");
        if (isset($title_tail))
                print(": ".htmlspecialchars($title_tail));
        print("</title>\n");
index f852f91..61e9dfd 100644 (file)
@@ -4,6 +4,7 @@
        $cvs_mailhost="vellum.cz";
        $mail_to="short@ucw.cz,karel.kratochvil@centrum.cz";
        $viewcvs=ereg_replace("^/","http://short.vellum.cz/cgi-bin/viewcvs/energie/",$HTTP_SERVER_VARS["SCRIPT_NAME"]);
        $cvs_mailhost="vellum.cz";
        $mail_to="short@ucw.cz,karel.kratochvil@centrum.cz";
        $viewcvs=ereg_replace("^/","http://short.vellum.cz/cgi-bin/viewcvs/energie/",$HTTP_SERVER_VARS["SCRIPT_NAME"]);
+       $title_prefix="Energie &amp; peníze";
 
        $file_cenik_inzerce_pdf="data/eap-cenik-inzerce.pdf";
 
 
        $file_cenik_inzerce_pdf="data/eap-cenik-inzerce.pdf";