1 | <?php
|
---|
2 |
|
---|
3 | class IndexPage extends Page
|
---|
4 | {
|
---|
5 | var $Dependencies = array('News');
|
---|
6 | var $FullTitle = 'Zděchovský rozcestník';
|
---|
7 | var $ShortTitle = '';
|
---|
8 |
|
---|
9 | function ShowLinks($GroupId)
|
---|
10 | {
|
---|
11 | global $Database;
|
---|
12 |
|
---|
13 | $DbResult = $Database->query('SELECT * FROM `HyperlinkGroup` WHERE `Id`='.$GroupId);
|
---|
14 | $HyperlinkGroup = $DbResult->fetch_assoc();
|
---|
15 |
|
---|
16 | $Output = '';
|
---|
17 | $DbResult = $Database->query('SELECT * FROM `Hyperlink` WHERE (`Group`='.$GroupId.') AND (`Enable` = 1)');
|
---|
18 | while($HyperLink = $DbResult->fetch_assoc())
|
---|
19 | {
|
---|
20 | if($HyperLink['IconFile'] == '') $HyperLink['IconFile'] = 'clear.png';
|
---|
21 | if(substr($HyperLink['URL'], 0, 4) != 'http') $HyperLink['URL'] = $this->System->Config['Web']['RootFolder'].$HyperLink['URL'];
|
---|
22 | if(($HyperLink['PermissionModule'] == '') or (($HyperLink['PermissionModule'] != '') and $this->System->Models['User']->CheckPermission($HyperLink['PermissionModule'], $HyperLink['PermissionOperation'])))
|
---|
23 | $Output .= '<img alt="'.$HyperLink['Name'].'" src="images/favicons/'.$HyperLink['IconFile'].'" width="16" height="16" /> <a href="'.$HyperLink['URL'].'">'.$HyperLink['Name'].'</a><br />';
|
---|
24 | }
|
---|
25 | return($this->Panel($HyperlinkGroup['Name'], $Output));
|
---|
26 | }
|
---|
27 |
|
---|
28 | function InfoBar()
|
---|
29 | {
|
---|
30 | global $Config;
|
---|
31 |
|
---|
32 | $this->Database->select_db($Config['Database']['Database']);
|
---|
33 |
|
---|
34 | $Output2 = '';
|
---|
35 |
|
---|
36 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDeviceType.ShowOnline = 1');
|
---|
37 | $DbRow = $DbResult->fetch_array();
|
---|
38 | $TotalComputers = $DbRow[0];
|
---|
39 |
|
---|
40 | $DbResult = $this->Database->query('SELECT COUNT(*) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE (NetworkDeviceType.ShowOnline = 1) AND (NetworkDevice.Online = 1)');
|
---|
41 | $DbRow = $DbResult->fetch_array();
|
---|
42 | $OnlineComputers = $DbRow[0];
|
---|
43 |
|
---|
44 | $Output = '<img alt="" src="images/favicons/comp.png" width="16" height="16" /> '.$OnlineComputers.' / '.$TotalComputers.' ';
|
---|
45 |
|
---|
46 | $DbResult = $this->Database->select('Member', 'COUNT(*)', 'MemberState=0');
|
---|
47 | $DbRow = $DbResult->fetch_array();
|
---|
48 | $TotalUser = $DbRow[0];
|
---|
49 |
|
---|
50 | $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDeviceType.ShowOnline = 1 AND NetworkDevice.Online = 1');
|
---|
51 | $DbRow = $DbResult->fetch_array();
|
---|
52 | $OnlineUser = $DbRow[0];
|
---|
53 |
|
---|
54 | $Output .= '<img alt="" src="images/favicons/house.png" width="16" height="16" /> '.$OnlineUser.' / '.$TotalUser.' ';
|
---|
55 |
|
---|
56 | $NetworkUsage = 0;
|
---|
57 | $Output .= '<img alt="" src="images/favicons/usage.png" width="16" height="16" /> '.$NetworkUsage.' % ';
|
---|
58 |
|
---|
59 | //$Output .= 'Server běží: '.$this->GetServerUptime().' ';
|
---|
60 |
|
---|
61 | if($this->System->Models['User']->CheckPermission('Finance', 'DisplaySubjectState'))
|
---|
62 | {
|
---|
63 | $DbResult = $this->Database->select('Subject', 'Money', 'Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$this->System->Models['User']->User['Id'].'))');
|
---|
64 | if($DbResult->num_rows > 0)
|
---|
65 | {
|
---|
66 | $DbRow = $DbResult->fetch_assoc();
|
---|
67 | $Output2 .= ' <img alt="" src="images/favicons/money.png" width="16" height="16" /> '.$DbRow['Money'].' Kč';
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | $Output = '<div class="Navigation"><span class="MenuItem">'.$Output.'</span><div class="MenuItem2"> '.$Output2.'</div></div>';
|
---|
72 | return($Output);
|
---|
73 | }
|
---|
74 |
|
---|
75 | function UserPanel()
|
---|
76 | {
|
---|
77 | $Output = '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Profil</a><br />';
|
---|
78 | if($this->System->Models['User']->CheckPermission('Finance', 'MemberOptions'))
|
---|
79 | $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'?Action=MemberOptions">Domácnost</a><br />';
|
---|
80 | if($this->System->Models['User']->CheckPermission('Finance', 'DisplaySubjectState'))
|
---|
81 | $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/finance/user_state.php">Finance</a><br />';
|
---|
82 | if($this->System->Models['User']->CheckPermission('Network', 'RegistredHostList'))
|
---|
83 | $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/network/user_hosts.php">Počítače</a><br />';
|
---|
84 | if($this->System->Models['User']->CheckPermission('News', 'Insert'))
|
---|
85 | $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/aktuality/?action=add">Vložení aktuality</a><br />';
|
---|
86 | if($this->System->Models['User']->CheckPermission('EatingPlace', 'Edit'))
|
---|
87 | $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/jidelna/menuedit.php">Editace jídelníčků</a><br />';
|
---|
88 | if($this->System->Models['User']->CheckPermission('Finance', 'Manage'))
|
---|
89 | $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/finance/manage.php">Správa financí</a><br />';
|
---|
90 | if($this->System->Models['User']->CheckPermission('Network', 'Administration'))
|
---|
91 | $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/network/administration.php">Správa sítě</a><br />';
|
---|
92 | return($Output);
|
---|
93 | }
|
---|
94 |
|
---|
95 | function WebcamPanel()
|
---|
96 | {
|
---|
97 | $Output = $this->System->Modules['WebCam']->ShowImage();
|
---|
98 | return($Output);
|
---|
99 | }
|
---|
100 |
|
---|
101 | function OnlineHostList()
|
---|
102 | {
|
---|
103 | $Output = '<span style="font-size: smaller;">';
|
---|
104 | $DbResult = $this->Database->query('SELECT NetworkDevice.Name FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE (NetworkDeviceType.ShowOnline = 1) AND (NetworkDevice.Online = 1) ORDER BY NetworkDevice.Name');
|
---|
105 | while($Device = $DbResult->fetch_array())
|
---|
106 | {
|
---|
107 | $Output .= $Device['Name'].'<br />';
|
---|
108 | }
|
---|
109 | $Output .= '</span>';
|
---|
110 | return($Output);
|
---|
111 | }
|
---|
112 |
|
---|
113 | function ShowBadPayerList()
|
---|
114 | {
|
---|
115 | $Output .= '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">';
|
---|
116 | $DbResult = $Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money');
|
---|
117 | while($Row = $DbResult->fetch_array())
|
---|
118 | {
|
---|
119 | $Output .= $Row['Name'].'<br />';
|
---|
120 | }
|
---|
121 | $Output .= '</span>';
|
---|
122 | return($Output);
|
---|
123 | }
|
---|
124 |
|
---|
125 | function Panel($Title, $Content, $Menu = array())
|
---|
126 | {
|
---|
127 | if(count($Menu) > 0)
|
---|
128 | foreach($Menu as $Item)
|
---|
129 | $Title .= '<div class="Action">'.$Item.'</div>';
|
---|
130 | return('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');
|
---|
131 | }
|
---|
132 |
|
---|
133 | function Show()
|
---|
134 | {
|
---|
135 | global $Database, $Config, $User;
|
---|
136 |
|
---|
137 | $Output = '';
|
---|
138 | if(array_key_exists('Action', $_GET))
|
---|
139 | {
|
---|
140 | if($_GET['Action'] == 'CustomizeNewsSave')
|
---|
141 | {
|
---|
142 | $Output .= $this->System->Modules['News']->CustomizeSave();
|
---|
143 | } else
|
---|
144 | if($_GET['Action'] == 'LoginForm')
|
---|
145 | {
|
---|
146 | $Form = new Form('UserLogin');
|
---|
147 | $Form->OnSubmit = '?Action=Login';
|
---|
148 | $Output .= $Form->ShowEditForm();
|
---|
149 | $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '.
|
---|
150 | '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
|
---|
151 | } else
|
---|
152 | if($_GET['Action'] == 'Login')
|
---|
153 | {
|
---|
154 | $Form = new Form('UserLogin');
|
---|
155 | $Form->OnSubmit = '?Action=Login';
|
---|
156 | $Result = $this->System->Models['User']->Login($_POST['Username'], $_POST['Password']);
|
---|
157 | $Output .= $this->SystemMessage('Přihlášení', $Result);
|
---|
158 | if($Result <> USER_LOGGED_IN)
|
---|
159 | {
|
---|
160 | $Form->LoadValuesFromForm();
|
---|
161 | $Form->Values['Password'] = '';
|
---|
162 | $Output .= $Form->ShowEditForm();
|
---|
163 | $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '.
|
---|
164 | '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
|
---|
165 | }
|
---|
166 | } else
|
---|
167 | if($_GET['Action'] == 'Logout')
|
---|
168 | {
|
---|
169 | $Output .= $this->SystemMessage('Odhlášení', $this->System->Models['User']->Logout());
|
---|
170 | } else
|
---|
171 | if($_GET['Action'] == 'UserOptions')
|
---|
172 | {
|
---|
173 | $UserOptions = new Form('UserOptions');
|
---|
174 | $UserOptions->LoadValuesFromDatabase($this->System->Models['User']->User['Id']);
|
---|
175 | $UserOptions->OnSubmit = '?Action=UserOptionsSave';
|
---|
176 | $Output .= $UserOptions->ShowEditForm();
|
---|
177 | } else
|
---|
178 | if($_GET['Action'] == 'UserOptionsSave')
|
---|
179 | {
|
---|
180 | $UserOptions = new Form('UserOptions', array());
|
---|
181 | $UserOptions->LoadValuesFromForm();
|
---|
182 | $UserOptions->SaveValuesToDatabase($this->System->Models['User']->User['Id']);
|
---|
183 | $Output .= $this->SystemMessage('Nastavení', 'Nastavení uloženo.');
|
---|
184 | $this->System->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $UserOptions->Values['Name']);
|
---|
185 | $UserOptions->LoadValuesFromDatabase($this->System->Models['User']->User['Id']);
|
---|
186 | $UserOptions->OnSubmit = '?Action=UserOptionsSave';
|
---|
187 | $Output .= $UserOptions->ShowEditForm();
|
---|
188 | }
|
---|
189 | if($_GET['Action'] == 'UserRegister')
|
---|
190 | {
|
---|
191 | $Form = new Form('UserRegister');
|
---|
192 | $Form->LoadValuesFromForm();
|
---|
193 | $Form->OnSubmit = '?Action=UserRegisterSave';
|
---|
194 | $Output .= $Form->ShowEditForm();
|
---|
195 | } else
|
---|
196 | if($_GET['Action'] == 'UserRegisterConfirm')
|
---|
197 | {
|
---|
198 | $Output .= $this->SystemMessage('Potvrzení registrace', $this->System->Models['User']->RegisterConfirm($_GET['User'], $_GET['H']));
|
---|
199 | } else
|
---|
200 | if($_GET['Action'] == 'PasswordRecovery')
|
---|
201 | {
|
---|
202 | $Form = new Form('PasswordRecovery');
|
---|
203 | $Form->OnSubmit = '?Action=PasswordRecovery2';
|
---|
204 | $Output .= $Form->ShowEditForm();
|
---|
205 | } else
|
---|
206 | if($_GET['Action'] == 'PasswordRecovery2')
|
---|
207 | {
|
---|
208 | $Form = new Form('PasswordRecovery');
|
---|
209 | $Form->LoadValuesFromForm();
|
---|
210 | $Result = $this->System->Models['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
|
---|
211 | $Output .= $this->SystemMessage('Obnova hesla', $Result);
|
---|
212 | if($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
|
---|
213 | {
|
---|
214 | $Output .= $Form->ShowEditForm();
|
---|
215 | }
|
---|
216 | } else
|
---|
217 | if($_GET['Action'] == 'PasswordRecoveryConfirm')
|
---|
218 | {
|
---|
219 | $Output .= $this->SystemMessage('Obnova hesla', $this->System->Models['User']->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
|
---|
220 | } else
|
---|
221 | if($_GET['Action'] == 'UserRegisterSave')
|
---|
222 | {
|
---|
223 | $Form = new Form('UserRegister', array());
|
---|
224 | $Form->LoadValuesFromForm();
|
---|
225 | $Result = $this->System->Models['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'], $Form->Values['PhoneNumber'], $Form->Values['ICQ']);
|
---|
226 | $Output .= $this->SystemMessage('Registrace nového účtu', $Result);
|
---|
227 | if($Result <> USER_REGISTRATED)
|
---|
228 | {
|
---|
229 | $Form->OnSubmit = '?Action=UserRegisterSave';
|
---|
230 | $Output .= $Form->ShowEditForm();
|
---|
231 | }
|
---|
232 | } else
|
---|
233 | if($_GET['Action'] == 'MemberOptions')
|
---|
234 | {
|
---|
235 | $UserOptions = new Form('MemberOptions');
|
---|
236 | $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Models['User']->User['Member']);
|
---|
237 | $DbRow = $DbResult->fetch_array();
|
---|
238 | foreach($UserOptions->Definition['Items'] as $Index => $Item)
|
---|
239 | {
|
---|
240 | $UserOptions->Values[$Index] = $DbRow[$Index];
|
---|
241 | }
|
---|
242 | $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
|
---|
243 | $Output .= $UserOptions->ShowEditForm();
|
---|
244 | } else
|
---|
245 | if($_GET['Action'] == 'MemberOptionsSave')
|
---|
246 | {
|
---|
247 | $UserOptions = new Form('MemberOptions');
|
---|
248 | $UserOptions->LoadValuesFromForm();
|
---|
249 | if($UserOptions->Values['FamilyMemberCount'] < 0)
|
---|
250 | $UserOptions->Values['FamilyMemberCount'] = 0;
|
---|
251 | if($UserOptions->Values['BillingPeriodNext'] < 2)
|
---|
252 | $UserOptions->Values['BillingPeriodNext'] = 2;
|
---|
253 |
|
---|
254 | $DbResult = $this->Database->update('Member', 'Id='.$this->System->Models['User']->User['Member'], array('InternetTariffNextMonth' => $UserOptions->Values['InternetTariffNextMonth'], 'FamilyMemberCount' => $UserOptions->Values['FamilyMemberCount'], 'BillingPeriodNext' => $UserOptions->Values['BillingPeriodNext']));
|
---|
255 | $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->Models['User']->User['Member']);
|
---|
256 | $Member = $DbResult->fetch_assoc();
|
---|
257 | $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'], array('Name' => $UserOptions->Values['Name'], 'AddressStreet' => $UserOptions->Values['AddressStreet'], 'AddressTown' => $UserOptions->Values['AddressTown'], 'AddressPSC' => $UserOptions->Values['AddressPSC'], 'IC' => $UserOptions->Values['IC'], 'DIC' => $UserOptions->Values['DIC']));
|
---|
258 | $Output .= $this->SystemMessage('Nastavení', 'Nastavení domácnosti uloženo.');
|
---|
259 | $this->System->Modules['Log']->NewRecord('Member+Subject', 'Nastavení člena/subjektu změněno', $UserOptions->Values['Name']);
|
---|
260 | $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Models['User']->User['Member']);
|
---|
261 | $DbRow = $DbResult->fetch_array();
|
---|
262 | foreach($UserOptions->Definition['Items'] as $Index => $Item)
|
---|
263 | {
|
---|
264 | $UserOptions->Values[$Index] = $DbRow[$Index];
|
---|
265 | }
|
---|
266 | $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
|
---|
267 | $Output .= $UserOptions->ShowEditForm();
|
---|
268 | }
|
---|
269 | }
|
---|
270 |
|
---|
271 | $Database->select_db($Config['Database']['Database']);
|
---|
272 |
|
---|
273 | // Show pannels
|
---|
274 | //if(IsInternetAddr()) echo('Internet'); else echo('LAN');
|
---|
275 | //$Output .= $this->InfoBar();
|
---|
276 | $Output .= '<table id="MainTable"><tr>';
|
---|
277 | $DbResult = $Database->select('PanelColumn', '*');
|
---|
278 | while($PanelColumn = $DbResult->fetch_assoc())
|
---|
279 | {
|
---|
280 | if($PanelColumn != '') $Width = ' width="'.$PanelColumn['Width'].'"';
|
---|
281 | else $Width = '';
|
---|
282 | $Output .= '<td valign="top"'.$Width.'>';
|
---|
283 | $DbResult2 = $Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`');
|
---|
284 | while($Panel = $DbResult2->fetch_assoc())
|
---|
285 | {
|
---|
286 | if($Panel['Module'] == 'HyperlinkGroup') $Output .= $this->ShowLinks($Panel['Parameters']);
|
---|
287 | else if($Panel['Module'] == 'OnlineHostList') $Output .= $this->Panel('Online počítače', $this->OnlineHostList());
|
---|
288 | else if($Panel['Module'] == 'UserOptions')
|
---|
289 | {
|
---|
290 | if($this->System->Models['User']->User['Id'] != $this->System->Models['User']->AnonymousUserId)
|
---|
291 | $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
|
---|
292 | } else
|
---|
293 | if(($Panel['Module'] == 'Webcam') and (array_key_exists('WebCam', $this->System->Modules)))
|
---|
294 | $Output .= $this->Panel('Kamery', $this->WebcamPanel());
|
---|
295 | else if($Panel['Module'] == 'NewsGroupList') $Output .= $this->Panel('Aktuality', $this->System->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));
|
---|
296 | }
|
---|
297 | $Output .= '</td>';
|
---|
298 | }
|
---|
299 | $Output .= '</table>';
|
---|
300 | return($Output);
|
---|
301 | }
|
---|
302 | }
|
---|
303 |
|
---|
304 | class ModuleFrontPage extends Module
|
---|
305 | {
|
---|
306 | function __construct($Database, $System)
|
---|
307 | {
|
---|
308 | parent::__construct($Database, $System);
|
---|
309 | $this->Name = 'FrontPage';
|
---|
310 | $this->Version = '1.0';
|
---|
311 | $this->Creator = 'Chronos';
|
---|
312 | $this->License = 'GNU/GPL';
|
---|
313 | $this->Description = 'Main page of community network portal';
|
---|
314 | $this->Dependencies = array('User', 'News', 'TV', 'Map', 'Chat', 'WebCam');
|
---|
315 | $this->Models = array();
|
---|
316 | }
|
---|
317 |
|
---|
318 | function Init()
|
---|
319 | {
|
---|
320 | $this->System->Pages[''] = 'IndexPage';
|
---|
321 | }
|
---|
322 |
|
---|
323 | function Install()
|
---|
324 | {
|
---|
325 | parent::Install();
|
---|
326 | }
|
---|
327 |
|
---|
328 | function UnInstall()
|
---|
329 | {
|
---|
330 | parent::UnInstall();
|
---|
331 | }
|
---|
332 | }
|
---|
333 |
|
---|
334 | ?>
|
---|