source: trunk/www/jirihajda/global.php@ 6

Last change on this file since 6 was 1, checked in by george, 17 years ago
File size: 4.9 KB
Line 
1<?
2
3$Version = '0.1';
4//include_once('error.php');
5include_once('config.php');
6include_once('db.php');
7DB_Init($Options['DB_Host'],$Options['DB_User'],$Options['DB_Password'], $Options['DB_Database']);
8
9function IconedLink($Link, $Text)
10{
11 global $Options;
12 $Extension = strtolower(substr($Link, strrpos($Link, '.')+1));
13 $IconFile = 'images/icons/'.$Extension.'.gif';
14 //echo($IconFile."<br>\n");
15 if(!file_exists($IconFile))
16 {
17 $Extension = 'blank';
18 $IconFile = 'images/icons/'.$Extension.'.gif';
19 }
20 $Icon = '<img src="'.$Options['RootPath'].$IconFile.'" alt="'.$Extension.'"> ';
21 return($Icon.'<a href="'.$Link.'">'.$Text.'</a>');
22}
23
24function ShowArray($Pole)
25{
26 echo('<pre style="font-size: 8pt;">');
27 print_r($Pole);
28 echo('</pre>');
29}
30
31function GetMicrotime()
32{
33 list($Usec, $Sec) = explode(" ",microtime());
34 return ((float)$Usec + (float)$Sec);
35}
36
37function ShowHeader($Path, $Title)
38{
39 global $Time_Start, $refresh, $Charset, $Options, $Output;
40 $Time_Start = GetMicrotime(); // Zjisti poèáteèní èas
41 $Cesty = array(
42 );
43 $Output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
44<html><head>
45 <meta http-equiv="Content-Language" content="cs">
46 <meta http-equiv="Content-Type" content="text/html; charset=';
47 if(isset($Charset)) $Output .= 'windows-1250';
48 else $Output .= 'iso-8859-2';
49 $Output .= '">';
50 if (isset($refresh)) $Output .= '<meta http-equiv="Refresh" content="'.$refresh."\">\n";
51 // <link href="style.css" rel="stylesheet" type="text/css">
52 $Output .= '<title>'.$Options['Title'].' - '.$Title.'</title>'.
53 '<link rel="stylesheet" type="text/css" href="'.$Options['RootPath'].'style.css">'.
54 '<link rel="alternate" title="RSS aktuality SPS" href="'.$Options['RootPath'].'rss.php" type="application/rss+xml">'.
55 '</head><body>'.
56 '<div id="PageTitle">'.$Title.'</div>'.
57 '<div id="Navigation"><strong>Navigace &gt;&gt; </strong>';
58 $I = 1;
59 foreach($Path as $Index => $Item)
60 {
61 $Item = substr($Options['RootPath'],0,-1).$Item;
62 $Output .= '<a href="'.$Item.'">'.$Index.'</a>';
63 if(count($Path) > $I) $Output .= ' &gt; ';
64 $I++;
65 }
66 $Output .= '</div>';
67}
68
69function ShowFooter()
70{
71 global $Time_Start, $Version, $Output;
72 $Time = floor((GetMicrotime() - $Time_Start)*100)/100;
73 $Output .= '<div id="AdminInfo">| Web mistr: Jiøí Hajda | e-mail: robie@centrum.cz | ICQ: 277158770 | Vygenerováno za '.$Time.' s | Verze: '.$Version.' | Naposledy aktualizováno: '.date('j.n.Y',filemtime($_SERVER['SCRIPT_FILENAME'])).' |</div>';
74 //ShowArray($GLOBALS);
75 $Output .= '</body></html>';
76 echo($Output);
77 //echo(FormatOutput($Output));
78}
79
80
81$MonthNames = array('','Leden','Únor','Bøezen','Duben','Kvìten','Èerven','Èervenec','Srpen','Záøí','Øíjen','Listopad','Prosinec');
82
83function HumanDate($Date)
84{
85 $Parts = explode('-',$Date);
86 if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
87 else return('&nbsp;');
88}
89
90// Zobrazení èíselný seznamu stránek
91function PagesList($URL, $Page, $TotalCount, $CountPerPage)
92{
93 $Count = ceil($TotalCount/$CountPerPage);
94 $Around = 10;
95 $Result = '';
96 if($Count>1)
97 {
98 if($Page>0)
99 {
100 $Result.= '<a href="'.$URL.'0">&lt;&lt;</a> ';
101 $Result.= '<a href="'.$URL.($Page-1).'">&lt;</a> ';
102 }
103 $PagesMax = $Count-1;
104 $PagesMin = 0;
105 if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
106 if($PagesMin<($Page-$Around))
107 {
108 $Result.= ' .. ';
109 $PagesMin = $Page-$Around;
110 }
111 for($i=$PagesMin;$i<=$PagesMax;$i++)
112 {
113 if($i==$Page) $Result.= '<strong>';
114 $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
115 if($i==$Page) $Result.= '</strong>';
116 }
117 if($PagesMax<($Count-1)) $Result .= ' .. ';
118 if($Page<($Count-1))
119 {
120 $Result.= '<a href="'.$URL.($Page+1).'">&gt;</a> ';
121 $Result.= '<a href="'.$URL.($Count-1).'">&gt;&gt;</a>';
122 }
123 }
124 return($Result);
125}
126
127function GetRemoteAddress()
128{
129 $IP = $_SERVER['REMOTE_ADDR'];
130 if($IP == '127.0.0.1') $IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
131 return($IP);
132}
133
134// Funkce formatovani vystupu
135function FormatOutput($s)
136{
137 $out = '';
138 $nn = 0;
139 $n = 0;
140 while($s!='')
141 {
142 $start = strpos($s,'<');
143 $end = strpos($s,'>');
144 if($start != 0)
145 {
146 $end = $start-1;
147 $start = 0;
148 }
149 $line = trim(substr($s,$start,$end+1));
150 if(strlen($line)>0)
151 if($line[0] == '<')
152 {
153 if($s[$start+1] == '/')
154 {
155 $n = $n - 2;
156 $nn = $n;
157 } else
158 {
159 if(strpos($line,' ')) $cmd = substr($line,1,strpos($line,' ')-1);
160 else $cmd = substr($line,1,strlen($line)-2);
161 //echo('['.$cmd.']');
162 if(strpos($s,'</'.$cmd.'>')) $n = $n + 2;
163 }
164 }// else $line = '['.$line.']';
165 //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
166 if($line != '') $out .= (str_repeat(' ',$nn).$line."\n");
167 $s = substr($s,$end+1,strlen($s));
168 $nn = $n;
169 }
170 return($out);
171 }
172
173//phpinfo();
174
175?>
Note: See TracBrowser for help on using the repository browser.