"comments" field parser/stripper fixed
[www.energie.vellum.cz.git] / common.php
1 <?php // $Id$
2
3         error_reporting(E_ALL);
4
5         $admin_mail="short@ucw.cz";
6         $viewcvs=ereg_replace("^/~short/","\\0cgi-bin/viewcvs/",$HTTP_SERVER_VARS["SCRIPT_NAME"]);
7         if ($viewcvs==$HTTP_SERVER_VARS["SCRIPT_NAME"])
8                 unset($viewcvs);
9         $cvs_id_split=split(" ",$cvs_id);
10         if (count($cvs_id_split)==8) {
11                 $cvs_id_split[1]="<a href=\"$viewcvs\">".$cvs_id_split[1]."</a>";
12                 $cvs_id_split[5]="<a href=\"mailto:".$cvs_id_split[5]."@".$HTTP_SERVER_VARS["HTTP_HOST"]."\">".$cvs_id_split[5]."</a>";
13                 }
14         $cvs_id_html=join(" ",$cvs_id_split);
15
16         $have_js=(isset($HTTP_GET_VARS["have_js"]) || isset($HTTP_POST_VARS["have_js"])
17                         ? "?have_js=1" : "");
18         if (isset($detect_js) && !$have_js)
19                 $head.='<script type="text/javascript" src="have_js.js"></script>'."\n";
20
21 function addpercents($url)
22 {
23         $r=$c="";
24         foreach(preg_split('//', $url, -1, PREG_SPLIT_NO_EMPTY) as $c)
25                 if (ereg("[a-zA-Z0-9]",$c))
26                         $r.=$c;
27                 else
28                         $r.=sprintf("%%%02X",ord($c));
29         return($r);
30 }
31
32 function fatal($msg="UNKNOWN")
33 {
34         global $admin_mail;
35
36         print("\n<br /><h1 class=\"error\">Nastala chyba pøi zpracování: $msg!</h1>\n"
37                         ."<p>Mù¾ete tento problém nahlásit <a href=\"mailto:$admin_mail\">správci tohoto webu</a>.</p>\n");
38         footer();
39 }
40
41 function footer()
42 {
43         // deadlock prevention:
44         global $footer_passed;
45         if (isset($footer_passed))
46                 exit();
47         $footer_passed=true;
48
49         global $cvs_id_html,$viewcvs,$viewcvs,$HTTP_SERVER_VARS;
50         ?>
51 <hr />
52 <table border="0" width="100%">
53 <tr><td align="left"><span class="cvs-id"><?php print($cvs_id_html); ?></span></td><td align="right"><a
54         href="http://validator.w3.org/check/referer"><img src="http://www.w3.org/Icons/valid-xhtml10"
55                 style="border:0;width:88px;height:31px" width="88" height="31" alt="Valid XHTML 1.0!" /></a><a
56         href="http://jigsaw.w3.org/css-validator/validator?warning=2&amp;profile=css2&amp;uri=<?php
57                 print(addpercents("http://".$HTTP_SERVER_VARS["HTTP_HOST"].$HTTP_SERVER_VARS["REQUEST_URI"]));
58                 ?>"><img src="http://jigsaw.w3.org/css-validator/images/vcss"
59                 style="border:0;width:88px;height:31px" width="88" height="31" alt="Valid CSS!" /></a></td></tr>
60 </table>
61 </body></html>
62         <?php
63         exit();
64 }
65
66         header("Content-type: text/html; charset=iso-8859-2");
67 ?>
68 <?xml version="1.0" encoding="iso-8859-2"?>
69 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
70 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
71 <head><title>Energie &amp; peníze<?php
72         if (isset($title_tail))
73                 print(": $title_tail");
74 ?></title>
75 <style type="text/css"><!--
76 .cvs-id { font-family: monospace; }
77 .error  { color: red; }<?php
78         if (isset($head_css))
79                 print($head_css);
80         print("--></style>\n");
81         if (isset($head))
82                 print($head);
83 ?>
84 </head><body>