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