source: devel/www/global.php@ 87

Last change on this file since 87 was 87, checked in by george, 17 years ago

Přidáno: Nová vývojová větev webu sítě. Všechny stránky jsou předělávány na objektový přístup a stránky samotné nevypisují výstup přímo přes echo, ale vracejí zobrazovaná data přes návratovou hodnotu funkce.

  • Property svn:executable set to *
File size: 4.2 KB
Line 
1<?php
2
3// SQL injection hack protection
4foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
5foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
6
7session_start();
8include('config.php');
9include('database.php');
10include('error.php');
11$Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
12$Database->Prefix = $Config['Database']['Prefix'];
13$Database->charset($Config['Database']['Charset']);
14include_once('module.php');
15include_once('forms.php');
16include_once('page.php');
17
18class System extends Module
19{
20 var $Modules = array();
21
22 function ModulePresent($Name)
23 {
24 return(array_key_exists($Name, $this->Modules));
25 }
26
27 function AddModule($Module)
28 {
29 global $Database;
30
31 //echo('Přidávám modul '.get_class($Module).'<br>');
32 $Module->System = &$this;
33 $Module->Database = &$Database;
34 $this->Modules[get_class($Module)] = $Module;
35 }
36}
37
38$System = new System();
39$System->Config = $Config;
40include_once('user.php');
41$System->AddModule(new User());
42$System->Modules['User']->Check();
43include_once('aktuality/news.php');
44$System->AddModule(new News());
45include_once('webcam/webcam.php');
46$System->AddModule(new Webcam());
47include_once('log.php');
48$System->AddModule(new Log());
49include_once('finance/bills.php');
50$System->AddModule(new Bill());
51include_once('finance/finance.php');
52$System->AddModule(new Finance());
53
54$MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
55
56$MaxSubnet = $Config['Network']['MaxSubnetCount'];
57
58function GetMicrotime()
59{
60 list($Usec, $Sec) = explode(" ", microtime());
61 return ((float)$Usec + (float)$Sec);
62}
63
64function ShowArray($Pole)
65{
66 echo('<pre style="font-size: 8pt;">');
67 print_r($Pole);
68 echo('</pre>');
69}
70
71function ToVpnIp($Host)
72{
73 if($Host['external_ip'] == '')
74 {
75 $Parts = explode('.', $Host['IP']);
76 return('172.16.'.$Parts[2].'.'.$Parts[3]);
77 } else
78 {
79 return($Host['external_ip']);
80 }
81}
82
83function TimeToMysqlDateTime($Time)
84{
85 return(date('Y-m-d H:i:s', $Time));
86}
87
88function MysqlDateTimeToTime($Time)
89{
90 $Parts = explode(' ', $Time);
91 $DateParts = explode('-', $Parts[0]);
92 $TimeParts = explode(':', $Parts[1]);
93 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
94 return($Result);
95}
96
97function MysqlDateToTime($Time)
98{
99 return(MysqlDateTimeToTime($Time.' 0:0:0'));
100}
101
102function ToCzfreeIp($Host)
103{
104 $Parts = explode('.', $Host['external_ip']);
105 if($Host['name'] == 'CENTRALA') return('10.144.1.1');
106 else return('10.144.200.'.$Parts[3]);
107}
108
109function HumanDate($Time)
110{
111 $Date = explode(' ', $Time);
112 $Parts = explode('-', $Date[0]);
113 if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
114 else return('&nbsp;');
115}
116
117// Zobrazení číselný seznamu stránek
118function PagesList($URL,$Page,$TotalCount,$CountPerPage)
119{
120 $Count = ceil($TotalCount/$CountPerPage);
121 $Around = 10;
122 $Result = '';
123 if($Count>1)
124 {
125 if($Page>0)
126 {
127 $Result.= '<a href="'.$URL.'0">&lt;&lt;</a> ';
128 $Result.= '<a href="'.$URL.($Page-1).'">&lt;</a> ';
129 }
130 $PagesMax = $Count-1;
131 $PagesMin = 0;
132 if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
133 if($PagesMin<($Page-$Around))
134 {
135 $Result.= ' .. ';
136 $PagesMin = $Page-$Around;
137 }
138 for($i=$PagesMin;$i<=$PagesMax;$i++)
139 {
140 if($i==$Page) $Result.= '<strong>';
141 $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
142 if($i==$Page) $Result.= '</strong>';
143 }
144 if($PagesMax<($Count-1)) $Result .= ' .. ';
145 if($Page<($Count-1))
146 {
147 $Result.= '<a href="'.$URL.($Page+1).'">&gt;</a> ';
148 $Result.= '<a href="'.$URL.($Count-1).'">&gt;&gt;</a>';
149 }
150 }
151 return($Result);
152}
153
154function GetRemoteAddress()
155{
156 if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
157 else $IP = $_SERVER['REMOTE_ADDR'];
158 //if($IP == '127.0.0.1')
159 return($IP);
160}
161
162function IsInternetAddr()
163{
164 $RemoteAddr = GetRemoteAddress();
165 $RemoteAddr = explode('.', $RemoteAddr);
166 return(!(($RemoteAddr[0] == 192) and ($RemoteAddr[1] == 168)));
167}
168
169?>
Note: See TracBrowser for help on using the repository browser.