1 | <?php
|
---|
2 |
|
---|
3 | // SQL injection hack protection
|
---|
4 | foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
|
---|
5 | foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
|
---|
6 |
|
---|
7 | session_start();
|
---|
8 | include('config.php');
|
---|
9 | include('database.php');
|
---|
10 | include('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']);
|
---|
14 | include_once('module.php');
|
---|
15 | include_once('forms.php');
|
---|
16 | include_once('page.php');
|
---|
17 |
|
---|
18 | class 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;
|
---|
40 | include_once('user.php');
|
---|
41 | $System->AddModule(new User());
|
---|
42 | $System->Modules['User']->Check();
|
---|
43 | include_once('aktuality/news.php');
|
---|
44 | $System->AddModule(new News());
|
---|
45 | include_once('webcam/webcam.php');
|
---|
46 | $System->AddModule(new Webcam());
|
---|
47 | include_once('log.php');
|
---|
48 | $System->AddModule(new Log());
|
---|
49 | include_once('finance/bills.php');
|
---|
50 | $System->AddModule(new Bill());
|
---|
51 | include_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 |
|
---|
58 | function GetMicrotime()
|
---|
59 | {
|
---|
60 | list($Usec, $Sec) = explode(" ", microtime());
|
---|
61 | return ((float)$Usec + (float)$Sec);
|
---|
62 | }
|
---|
63 |
|
---|
64 | function ShowArray($Pole)
|
---|
65 | {
|
---|
66 | echo('<pre style="font-size: 8pt;">');
|
---|
67 | print_r($Pole);
|
---|
68 | echo('</pre>');
|
---|
69 | }
|
---|
70 |
|
---|
71 | function 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 |
|
---|
83 | function TimeToMysqlDateTime($Time)
|
---|
84 | {
|
---|
85 | return(date('Y-m-d H:i:s', $Time));
|
---|
86 | }
|
---|
87 |
|
---|
88 | function 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 |
|
---|
97 | function MysqlDateToTime($Time)
|
---|
98 | {
|
---|
99 | return(MysqlDateTimeToTime($Time.' 0:0:0'));
|
---|
100 | }
|
---|
101 |
|
---|
102 | function 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 |
|
---|
109 | function 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(' ');
|
---|
115 | }
|
---|
116 |
|
---|
117 | // Zobrazení číselný seznamu stránek
|
---|
118 | function 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"><<</a> ';
|
---|
128 | $Result.= '<a href="'.$URL.($Page-1).'"><</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).'">></a> ';
|
---|
148 | $Result.= '<a href="'.$URL.($Count-1).'">>></a>';
|
---|
149 | }
|
---|
150 | }
|
---|
151 | return($Result);
|
---|
152 | }
|
---|
153 |
|
---|
154 | function 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 |
|
---|
162 | function IsInternetAddr()
|
---|
163 | {
|
---|
164 | $RemoteAddr = GetRemoteAddress();
|
---|
165 | $RemoteAddr = explode('.', $RemoteAddr);
|
---|
166 | return(!(($RemoteAddr[0] == 192) and ($RemoteAddr[1] == 168)));
|
---|
167 | }
|
---|
168 |
|
---|
169 | ?>
|
---|