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