source: www/global.php@ 167

Last change on this file since 167 was 167, checked in by george, 16 years ago
  • Přidáno: Stránka pro rozeslání emailů s počátečními hesly.
  • Upraveno: Konfigurační skripty pro nastavení síťových zařízení se systémem RouterOS doplněny o podporu zápisu konfigurace do více samostatných zařízení. Změna se týká konfigurace DHCP serveru a sledování net_watch.
  • Opraveno: Některé nefunkční odkazy na hlavní stránce.
  • Upraveno: Tabulka finance_operations nově převedena na tabulky FinanceOperation a FinanceClaimsLiabilities. Upraveny související stránky.
  • Property svn:executable set to *
File size: 4.9 KB
Line 
1<?php
2
3$ScriptTimeStart = GetMicrotime();
4
5// SQL injection hack protection
6foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
7foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
8
9if(!isset($SessionDisable)) session_start();
10include('config.php');
11include('database.php');
12include('error.php');
13include_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']);
17include_once('module.php');
18include_once('forms.php');
19include_once('page.php');
20
21class 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;
43include_once('log.php');
44$System->AddModule(new Log());
45include_once('user.php');
46$System->AddModule(new User());
47$System->Modules['User']->Check();
48include_once('aktuality/news.php');
49$System->AddModule(new News());
50include_once('webcam/webcam.php');
51$System->AddModule(new Webcam());
52include_once('finance/bills.php');
53$System->AddModule(new Bill());
54include_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
64function 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
77function GetMicrotime()
78{
79 list($Usec, $Sec) = explode(' ', microtime());
80 return ((float)$Usec + (float)$Sec);
81}
82
83function ShowArray($Pole)
84{
85 echo('<pre style="font-size: 8pt;">');
86 print_r($Pole);
87 echo('</pre>');
88}
89
90function 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
102function TimeToMysqlDateTime($Time)
103{
104 return(date('Y-m-d H:i:s', $Time));
105}
106
107function 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
116function MysqlDateToTime($Time)
117{
118 return(MysqlDateTimeToTime($Time.' 0:0:0'));
119}
120
121function 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
128function 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('&nbsp;');
134}
135
136// Zobrazení číselný seznamu stránek
137function 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">&lt;&lt;</a> ';
147 $Result.= '<a href="'.$URL.($Page-1).'">&lt;</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).'">&gt;</a> ';
167 $Result.= '<a href="'.$URL.($Count-1).'">&gt;&gt;</a>';
168 }
169 }
170 return($Result);
171}
172
173function 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
181function IsInternetAddr()
182{
183 $RemoteAddr = GetRemoteAddress();
184 $RemoteAddr = explode('.', $RemoteAddr);
185 return(!(($RemoteAddr[0] == 192) and ($RemoteAddr[1] == 168)));
186}
187
188function 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?>
Note: See TracBrowser for help on using the repository browser.