source: trunk/global.php

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