Changeset 738 for trunk/Modules
- Timestamp:
- Apr 14, 2015, 10:20:16 PM (10 years ago)
- Location:
- trunk/Modules
- Files:
-
- 88 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Chat/Chat.php
r586 r738 10 10 $this->ParentClass = 'PagePortal'; 11 11 } 12 12 13 13 function dechexr($Num) 14 14 { … … 20 20 { 21 21 global $MonthNames; 22 22 23 23 if(!$this->System->User->CheckPermission('Chat', 'Display')) return('Nemáte oprávnění'); 24 24 25 if(array_key_exists('date', $_GET)) $Date = $_GET['date']; 25 if(array_key_exists('date', $_GET)) $Date = $_GET['date']; 26 26 else $Date = date('Y-m-d'); 27 27 $DateParts = explode('-', $Date); … … 56 56 if(($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1; 57 57 if(($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year)); 58 for($Day = $StartDay; $Day <= $EndDay; $Day++) 59 { 58 for($Day = $StartDay; $Day <= $EndDay; $Day++) 59 { 60 60 $Text = '<a href="?date='.$Year.'-'.$Month.'-'.$Day.'">'.$Day.'</a> '; 61 61 if(($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>'; … … 76 76 { 77 77 $Text = $Row['Text'];; 78 // StrTr($Row['text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 78 // StrTr($Row['text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 79 79 $Output .= '['.date('d.m.Y H:i:s',$Row['UNIX_TIMESTAMP(Time)']).'] <span style="color: #'.$this->dechexr($Row['Color']).'"><strong><'.$Row['Nick'].'></strong> '.(htmlspecialchars($Text)).'</span><br>'; 80 80 } … … 97 97 $this->Dependencies = array(); 98 98 } 99 99 100 100 function DoStart() 101 101 { 102 102 $this->System->Pages['chat'] = 'PageChatHistory'; 103 } 103 } 104 104 } -
trunk/Modules/Chat/irc_bot.php
r577 r738 13 13 var $File; 14 14 15 function __construct() 15 function __construct() 16 16 { 17 17 $this->Jokes = file($this->JokeFileName); … … 74 74 $Line = substr($Line, strlen($Commands[0])); 75 75 $Commands[1] = substr($Line, 0, strpos($Line, ':') + 1); 76 $Commands[2] = substr($Line, strlen($Commands[1])); 76 $Commands[2] = substr($Line, strlen($Commands[1])); 77 77 //print_r($Commands); 78 78 … … 89 89 } 90 90 91 91 92 92 explode(':', $Line); 93 93 foreach($Commands as $Index => $Item) … … 185 185 186 186 // hjoke - Posle nahodny vtip 187 if($Command == 'hjoke') 187 if($Command == 'hjoke') 188 188 { 189 189 $Joke = ($this->Jokes[rand(0, (sizeof($this->Jokes) - 1))]); -
trunk/Modules/Customer/Customer.php
r727 r738 13 13 $this->Dependencies = array('User'); 14 14 } 15 15 16 16 function DoStart() 17 17 { … … 36 36 'Consumption' => array('Type' => 'TCustomerStockSerialNumber', 'Caption' => 'Spotřeba zařízení', 'Default' => ''), 37 37 ), 38 39 38 'ItemActions' => array( 39 array('Caption' => 'Klientská sekce', 'URL' => '/finance/platby/?i=#RowId'), 40 40 ), 41 )); 41 )); 42 42 $this->System->FormManager->RegisterClass('MemberPayment', array( 43 43 'Title' => 'Placení zákazníků', … … 56 56 )); 57 57 $this->System->FormManager->RegisterFormType('TMember', array( 58 59 60 61 62 58 'Type' => 'Reference', 59 'Table' => 'Member', 60 'Id' => 'Id', 61 'Name' => 'Name', 62 'Filter' => '1', 63 63 )); 64 64 $this->System->FormManager->RegisterClass('Service', array( 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 65 'Title' => 'Služby', 66 'Table' => 'Service', 67 'DefaultSortColumn' => 'Name', 68 'Items' => array( 69 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 70 'Category' => array('Type' => 'TServiceCategory', 'Caption' => 'Skupina', 'Default' => '', 'Null' => true), 71 'Price' => array('Type' => 'Integer', 'Caption' => 'Cena', 'Default' => '0', 'Suffix' => 'Kč'), 72 'VAT' => array('Type' => 'TFinanceVATType', 'Caption' => 'Sazba DPH', 'Default' => '0', 'Suffix' => ''), 73 'CustomerCount' => array('Type' => 'Integer', 'Caption' => 'Počet zákazníků', 'Default' => '', 'ReadOnly' => true, 74 'SQL' => '(SELECT COUNT(*) FROM `ServiceCustomerRel` LEFT JOIN `Member` ON `Member`.`Id`=`ServiceCustomerRel`.`Customer` WHERE (`ServiceCustomerRel`.`Service`=#Id) AND (`Member`.`Blocked`=0))'), 75 'Public' => array('Type' => 'Boolean', 'Caption' => 'Veřejné', 'Default' => ''), 76 'InternetSpeedMin' => array('Type' => 'Integer', 'Caption' => 'Min. rychlost internetu', 'Default' => '0', 'Suffix' => 'kbit/s'), 77 'InternetSpeedMax' => array('Type' => 'Integer', 'Caption' => 'Max. rychlost internetu', 'Default' => '0', 'Suffix' => 'kbit/s'), 78 'UploadAsymmetry' => array('Type' => 'Integer', 'Caption' => 'Asymetrie odesílání', 'Default' => '1'), 79 'Memory' => array('Type' => 'Integer', 'Caption' => 'Paměť', 'Default' => '0', 'Suffix' => 'GB'), 80 'MemorySwap' => array('Type' => 'Integer', 'Caption' => 'Odkládací oddíl', 'Default' => '0', 'Suffix' => 'GB'), 81 'Storage' => array('Type' => 'Integer', 'Caption' => 'Úložiště', 'Default' => '0', 'Suffix' => 'GB'), 82 'CPUCount' => array('Type' => 'Integer', 'Caption' => 'Počet jader', 'Default' => '0', 'Suffix' => ''), 83 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true), 84 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true), 85 'ChangeReplaceId' => array('Type' => 'TService', 'Caption' => 'Změna - položka', 'Default' => '', 'Null' => true), 86 'CustomerRel' => array('Type' => 'TServiceCustomerRelListService', 'Caption' => 'Placení zákazníky', 'Default' => ''), 87 ), 88 88 )); 89 89 $this->System->FormManager->RegisterClass('ServiceCategory', array( 90 91 92 93 94 95 90 'Title' => 'Kategorie služeb', 91 'Table' => 'ServiceCategory', 92 'Items' => array( 93 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 94 'Items' => array('Type' => 'TServiceListServiceCategory', 'Caption' => 'Služby', 'Default' => ''), 95 ), 96 96 )); 97 97 $this->System->FormManager->RegisterClass('ServiceCustomerRel', array( … … 102 102 'Customer' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => ''), 103 103 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true), 104 105 104 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true), 105 'ChangeReplaceId' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Změna - položka', 'Default' => '', 'Null' => true), 106 106 ), 107 107 )); 108 108 $this->System->FormManager->RegisterFormType('TServiceCategory', array( 109 110 111 112 113 109 'Type' => 'Reference', 110 'Table' => 'ServiceCategory', 111 'Id' => 'Id', 112 'Name' => 'Name', 113 'Filter' => '1', 114 114 )); 115 115 $this->System->FormManager->RegisterFormType('TService', array( 116 117 118 119 120 116 'Type' => 'Reference', 117 'Table' => 'Service', 118 'Id' => 'Id', 119 'Name' => 'Name', 120 'Filter' => '1', 121 121 )); 122 122 $this->System->FormManager->RegisterFormType('TServiceCustomerRel', array( 123 124 125 126 127 128 )); 123 'Type' => 'Reference', 124 'Table' => 'ServiceCustomerRel', 125 'Id' => 'Id', 126 'Name' => 'Id', 127 'Filter' => '1', 128 )); 129 129 $this->System->FormManager->RegisterFormType('TServiceCustomerRelListCustomer', array( 130 130 'Type' => 'ManyToOne', … … 148 148 'Filter' => '1', 149 149 )); 150 } 150 } 151 151 } -
trunk/Modules/EmailQueue/EmailQueue.php
r689 r738 52 52 'Title' => 'Fronta e-mailů', 53 53 'Table' => 'EmailQueue', 54 55 54 'DefaultSortColumn' => 'Time', 55 'DefaultSortOrder' => 1, 56 56 'Items' => array( 57 57 'Time' => array('Type' => 'DateTime', 'Caption' => 'Vytvořeno'), -
trunk/Modules/Employee/Employee.php
r736 r738 37 37 'Contract' => array('Type' => 'TContract', 'Caption' => 'Smlouva', 'Default' => ''), 38 38 ), 39 )); 40 39 )); 40 $this->System->FormManager->RegisterFormType('TEmployee', array( 41 41 'Type' => 'Reference', 42 43 44 45 46 )); 42 'Table' => 'Employee', 43 'Id' => 'Id', 44 'Name' => 'CONCAT_WS(" ", NULLIF(`FirstName`, ""), NULLIF(`SecondName`, ""))', 45 'Filter' => '1', 46 )); 47 47 $this->System->FormManager->RegisterFormType('TEmployeeSalaryList', array( 48 49 50 51 52 48 'Type' => 'ManyToOne', 49 'Table' => 'EmployeeSalary', 50 'Id' => 'Id', 51 'Ref' => 'Employee', 52 'Filter' => '1', 53 53 )); 54 54 } -
trunk/Modules/Error/Error.php
r682 r738 32 32 function DoStart() 33 33 { 34 34 $this->ShowError = $this->System->Config['Web']['ShowPHPError']; 35 35 set_error_handler(array($this, 'ErrorHandler')); 36 36 set_exception_handler(array($this, 'ExceptionHandler')); … … 39 39 function Stop() 40 40 { 41 42 43 41 restore_error_handler(); 42 restore_exception_handler(); 43 parent::Stop(); 44 44 } 45 45 … … 128 128 '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n". 129 129 'Došlo k vnitřní chybě!<br/> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br/><br/>'); 130 echo('<pre>'.$Error.'</pre><br/>'); 130 echo('<pre>'.$Error.'</pre><br/>'); // V případě ladění chybu i zobraz 131 131 echo('</body></html>'); 132 132 } else 133 133 { 134 134 echo($Error); 135 135 } 136 136 } -
trunk/Modules/File/File.php
r737 r738 43 43 function DetectMimeType($FileName) 44 44 { 45 45 global $MimeTypes; 46 46 47 47 $Result = $MimeTypes[pathinfo($FileName, PATHINFO_EXTENSION)][0]; … … 140 140 'Parent' => array('Type' => 'TDirectory', 'Caption' => 'Nadřazený adresář', 'Default' => '', 'Null' => true), 141 141 'Subdirectories' => array('Type' => 'TDirectoryList', 'Caption' => 'Podadresáře', 'Default' => ''), 142 142 'Files' => array('Type' => 'TFileList', 'Caption' => 'Soubory', 'Default' => ''), 143 143 ), 144 144 )); … … 151 151 )); 152 152 $this->System->FormManager->RegisterFormType('TFile', array( 153 154 155 156 157 153 'Type' => 'Reference', 154 'Table' => 'File', 155 'Id' => 'Id', 156 'Name' => 'Name', 157 'Filter' => '1', 158 158 )); 159 159 $this->System->FormManager->RegisterFormType('TFileList', array( 160 161 162 163 164 160 'Type' => 'ManyToOne', 161 'Table' => 'File', 162 'Id' => 'Id', 163 'Ref' => 'Directory', 164 'Filter' => '1', 165 165 )); 166 166 $this->System->FormManager->RegisterFormType('TDirectoryList', array( 167 168 169 170 171 167 'Type' => 'ManyToOne', 168 'Table' => 'FileDirectory', 169 'Id' => 'Id', 170 'Ref' => 'Parent', 171 'Filter' => '1', 172 172 )); 173 173 } -
trunk/Modules/File/MimeTypes.php
r548 r738 43 43 'jpe' => array('image/jpeg', 'image/pjpeg'), 44 44 'js' => array('application/x-javascript'), 45 'json' => array('application/json'), 45 'json' => array('application/json'), 46 46 'lha' => array('application/octet-stream'), 47 47 'log' => array('text/plain', 'text/x-log'), -
trunk/Modules/Finance/Bill.php
r727 r738 4 4 { 5 5 var $SpecificSymbol = 1; // počítačová sít 6 var $Checked; 7 6 var $Checked; 7 8 8 function GenerateHTML() 9 9 { … … 21 21 function HtmlToPdf($HtmlCode) 22 22 { 23 24 25 26 27 28 23 $Encoding = new Encoding(); 24 if($this->Checked == false) { 25 if(CommandExist('htmldoc')) { 26 $this->Checked = true; 27 } else throw new Exception('htmldoc is not installed.'); 28 } 29 29 $Output = shell_exec('echo "'.addslashes($Encoding->FromUTF8($HtmlCode)). 30 30 '"|htmldoc --no-numbered --webpage --no-embedfonts --charset 8859-2 -t pdf -'); … … 39 39 function ShowSubjectInfo($Subject) 40 40 { 41 42 41 $BooleanText = array('Ne', 'Ano'); 42 $Output = $Subject['Name'].'<br>'. 43 43 $Subject['AddressStreet'].'<br>'. 44 44 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; … … 47 47 if($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>'; 48 48 if($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>'; 49 49 return($Output); 50 50 } 51 51 … … 81 81 if($Invoice['Direction'] == -1) 82 82 { 83 84 85 83 $Subject = $SubjectTo; 84 $SubjectTo = $SubjectFrom; 85 $SubjectFrom = $Subject; 86 86 } 87 87 -
trunk/Modules/Finance/Finance.php
r737 r738 159 159 function GetVATByType($TypeId) 160 160 { 161 162 161 $Time = time(); 162 $DbResult = $this->Database->select('FinanceVAT', 'Value', '(Type='.$TypeId. 163 163 ') AND (ValidFrom <= "'.TimeToMysqlDate($Time).'") AND ((ValidTo >= "'. 164 164 TimeToMysqlDate($Time).'") OR (ValidTo IS NULL)) LIMIT 1'); … … 204 204 'DefaultSortOrder' => 1, 205 205 'Items' => array( 206 207 206 'Direction' => array('Type' => 'TFinanceOperationDirection', 'Caption' => 'Směr', 'Default' => '1'), 207 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 208 208 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 209 209 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''), … … 274 274 'DefaultSortOrder' => 1, 275 275 'Items' => array( 276 277 276 'Direction' => array('Type' => 'TFinanceInvoiceDirection', 'Caption' => 'Směr', 'Default' => '1'), 277 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 278 278 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 279 279 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''), … … 286 286 'PeriodFrom' => array('Type' => 'Date', 'Caption' => 'Období od', 'Default' => '', 'Null' => true), 287 287 'PeriodTo' => array('Type' => 'Date', 'Caption' => 'Období do', 'Default' => '', 'Null' => true), 288 288 'Cash' => array('Type' => 'Boolean', 'Caption' => 'Platit hotově', 'Default' => ''), 289 289 'Items' => array('Type' => 'TFinanceInvoiceItemListInvoice', 'Caption' => 'Položky', 'Default' => ''), 290 290 'OperationRel' => array('Type' => 'TFinanceInvoiceOperationRelListInvoice', 'Caption' => 'Platba', 'Default' => ''), … … 314 314 315 315 $this->System->FormManager->RegisterFormType('TFinanceInvoiceDirection', array( 316 317 316 'Type' => 'Enumeration', 317 'States' => array(-1 => 'Příjem', 1 => 'Výdej'), 318 318 )); 319 319 … … 323 323 'Items' => array( 324 324 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => '0'), 325 325 'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => '0'), 326 326 ), 327 327 )); … … 353 353 )); 354 354 $this->System->FormManager->RegisterFormType('TFinanceTreasury', array( 355 356 357 358 359 355 'Type' => 'Reference', 356 'Table' => 'FinanceTreasury', 357 'Id' => 'Id', 358 'Name' => 'Name', 359 'Filter' => '1', 360 360 )); 361 361 $this->System->FormManager->RegisterClass('FinanceBankAccount', array( … … 374 374 'LoginPassword' => array('Type' => 'String', 'Caption' => 'Přihlašovací heslo', 'Default' => ''), 375 375 'Operations' => array('Type' => 'TFinanceOperationListAccount', 'Caption' => 'Operace', 'Default' => ''), 376 376 'Use' => array('Type' => 'Boolean', 'Caption' => 'Používat', 'Default' => '0'), 377 377 'LastImportDate' => array('Type' => 'Date', 'Caption' => 'Datum posledního importu', 'Default' => ''), 378 378 'LastImportId' => array('Type' => 'String', 'Caption' => 'Id posledního importu', 'Default' => ''), … … 380 380 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`FinanceOperation`.`Value` * `FinanceOperation`.`Direction`) FROM `FinanceOperation` '. 381 381 'WHERE `FinanceOperation`.`BankAccount`=#Id)'), 382 382 'AutoImport' => array('Type' => 'Boolean', 'Caption' => 'Automaticky stahovat z banky', 'Default' => ''), 383 383 ), 384 384 'ItemActions' => array( … … 388 388 )); 389 389 $this->System->FormManager->RegisterFormType('TFinanceBankAccount', array( 390 391 392 393 394 390 'Type' => 'Reference', 391 'Table' => 'FinanceBankAccount', 392 'Id' => 'Id', 393 'Name' => 'Comment', 394 'Filter' => '1', 395 395 )); 396 396 $this->System->FormManager->RegisterClass('FinanceBank', array( … … 433 433 'TopTariffPrice' => array('Type' => 'Integer', 'Caption' => 'Nejvyšší cena tarifu', 'Default' => '0', 'Suffix' => 'Kč'), 434 434 'ChangeAction' => array('Type' => 'TActionEnum', 'Caption' => 'Změna - akce', 'Default' => '', 'Null' => true), 435 436 435 'ChangeTime' => array('Type' => 'DateTime', 'Caption' => 'Změna - čas', 'Default' => '', 'Null' => true), 436 'ChangeReplaceId' => array('Type' => 'TFinanceCharge', 'Caption' => 'Změna - položka', 'Default' => '0', 'Null' => true), 437 437 ), 438 438 )); … … 475 475 )); 476 476 $this->System->FormManager->RegisterFormType('TFinanceVAT', array( 477 478 479 480 481 477 'Type' => 'Reference', 478 'Table' => 'FinanceVAT', 479 'Id' => 'Id', 480 'Name' => 'Name', 481 'Filter' => '1', 482 482 )); 483 483 $this->System->FormManager->RegisterFormType('TFinanceVATType', array( 484 485 486 487 488 484 'Type' => 'Reference', 485 'Table' => 'FinanceVATType', 486 'Id' => 'Id', 487 'Name' => 'Name', 488 'Filter' => '1', 489 489 )); 490 490 $this->System->FormManager->RegisterFormType('TBankAccount', array( 491 492 493 494 495 496 491 'Type' => 'Reference', 492 'Table' => 'FinanceBankAccount', 493 'Id' => 'Id', 494 'Name' => 'CONCAT(`Comment`, " (", `Number`, "/", '. 495 '(SELECT `FinanceBank`.`Code` FROM `FinanceBank` WHERE `FinanceBank`.`Id`=`FinanceBankAccount`.`Bank`), ")")', 496 'Filter' => '1', 497 497 )); 498 498 … … 509 509 function BeforeInsertFinanceOperation($Form) 510 510 { 511 512 511 if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 512 else $Year = date("Y", $Form->Values['ValidFrom']); 513 513 $DocumentLine = $Form->Values['DocumentLine']; 514 514 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); -
trunk/Modules/Finance/Import.php
r719 r738 25 25 } 26 26 } 27 27 28 28 function Prepare() 29 { 29 { 30 30 $Finance = $this->System->Modules['Finance']; 31 31 $Finance->LoadMonthParameters(0); … … 39 39 { 40 40 if(substr($Data[$Key][$Key2], 0, 2) == '\"') 41 $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2); 41 $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2); 42 42 } 43 43 } 44 44 $Header = array( 45 0 => 'datum zaúčtování', 45 0 => 'datum zaúčtování', 46 46 1 => 'částka', 47 47 2 => 'měna', … … 60 60 //print_r($_POST['Source']); 61 61 //print_r($Data); 62 62 63 63 if($Header != $Data[0]) $Output = 'Nekompatibilní struktura CSV'; 64 else 64 else 65 65 { 66 66 array_shift($Data); … … 85 85 $Subject = '? ('.$Value[5].')'; 86 86 } 87 if(!is_numeric($Subject)) 87 if(!is_numeric($Subject)) 88 88 { 89 89 $Mode = 'Ručně'; 90 90 $Style = 'style="background-color: LightPink;" '; 91 } else 91 } else 92 92 { 93 93 $Mode = 'Automaticky'; 94 94 $Style = ''; 95 95 } 96 96 97 97 if($Money < 0) $Text = 'Platba převodem'; 98 98 else $Text = 'Přijatá platba'; … … 106 106 '<td><input type="text" name="Taxable'.$I.'" value="1"/></td>'. 107 107 '<td><input type="text" name="Network'.$I.'" value="1"/></td>'. 108 '</tr><tr><td colspan="7">'.implode(', ', $Value).'</td></tr>'; 108 '</tr><tr><td colspan="7">'.implode(', ', $Value).'</td></tr>'; 109 109 $I++; 110 110 } … … 114 114 '<th>Datum</th><th>Var. symbol</th><th>Protiúčet</th><th>Částka [Kč]</th><th>Text</th><th>Zdanitelné</th><th>Síť</th></tr>'; 115 115 $Output .= $Automatic.'</table>'; 116 $Output .= '<input type="hidden" name="ItemCount" value="'.$I.'"/>'; 117 $Output .= '<input type="submit" value="Zpracovat"/></form>'; 116 $Output .= '<input type="hidden" name="ItemCount" value="'.$I.'"/>'; 117 $Output .= '<input type="submit" value="Zpracovat"/></form>'; 118 118 } 119 119 return($Output); 120 120 } 121 121 122 122 function InsertMoney($Subject, $Value, $Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine) 123 123 { … … 125 125 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); 126 126 // TODO: Fixed BankAccount=1, allow to select bank account for import 127 $this->Database->insert('FinanceOperation', array('Text' => $Text, 128 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Direction' => $Direction, 127 $this->Database->insert('FinanceOperation', array('Text' => $Text, 128 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Direction' => $Direction, 129 129 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode, 130 130 'BankAccount' => 1)); … … 136 136 $Finance->LoadMonthParameters(0); 137 137 $Output = ''; 138 138 139 139 for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 140 140 { 141 141 // TODO: Use links to database records instead of contants 142 142 if($_POST['Money'.$I] < 0) { 143 144 143 $DocumentLine = 4; 144 $Direction = -1; 145 145 } else { 146 147 146 $DocumentLine = 3; 147 $Direction = 1; 148 148 } 149 149 $Date = explode('-', $_POST['Date'.$I]); -
trunk/Modules/Finance/Manage.php
r727 r738 109 109 $SumValue = 0; 110 110 foreach($Items as $Item) 111 $SumValue = $SumValue + ceil($Item['Price'] * $Item['Quantity']); 111 $SumValue = $SumValue + ceil($Item['Price'] * $Item['Quantity']); 112 112 $this->Database->insert('FinanceInvoice', array( 113 113 'Subject' => $Subject, 'Time' => TimeToMysqlDateTime($TimeCreation), 114 'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue, 115 114 'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue, 115 'Direction' => $Direction, 'BillCode' => $BillCode, 116 116 'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo), 117 117 'Generate' => 1, 'DocumentLine' => $DocumentLine)); … … 163 163 $MonthlyTotal += $Service['Price']; 164 164 } 165 $PayPerPeriod = $MonthlyTotal * $Period['MonthCount']; 165 $PayPerPeriod = $MonthlyTotal * $Period['MonthCount']; 166 166 // We can't produce negative invoice except storno invoice. 167 // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction 168 // Other subject should invoice only possitive items. Negative items should be somehow removed. 167 // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction 168 // Other subject should invoice only possitive items. Negative items should be somehow removed. 169 169 if($MonthlyTotal >= 0) { 170 $DocumentLine = DOC_LINE_INVOICE_OUT;171 170 $DocumentLine = DOC_LINE_INVOICE_OUT; 171 $Direction = 1; // Standard out invoice 172 172 } else { 173 173 $DocumentLine = DOC_LINE_INVOICE_IN; 174 174 $Direction = -1; // In case of negative total value generate reverse invoice for other subject 175 175 foreach($InvoiceItems as $Index => $Item) 176 177 } 178 176 $InvoiceItems[$Index]['Price'] = -$Item['Price']; 177 } 178 179 179 if($PayPerPeriod != 0) 180 180 { … … 195 195 function TableUpdateChanges($Table) 196 196 { 197 197 $Time = time(); 198 198 $DbResult = $this->Database->select($Table, '*', '(`ChangeAction` IS NOT NULL) AND '. 199 199 '(`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'") ORDER BY `ChangeTime` ASC'); 200 200 while($Service = $DbResult->fetch_array()) 201 201 { … … 225 225 function ProcessTableUpdates() 226 226 { 227 228 229 230 231 232 233 234 235 236 237 238 239 240 } 241 227 // Update finance charge 228 $Output = 'Měním aktuální parametry sítě...<br>'; 229 $this->TableUpdateChanges('FinanceCharge'); 230 231 // Update services 232 $Output .= 'Aktualizuji služby....<br>'; 233 $this->TableUpdateChanges('Service'); 234 235 // Update customer service selections 236 $Output .= 'Aktualizuji výběr služeb zákazníků....<br>'; 237 $this->TableUpdateChanges('ServiceCustomerRel'); 238 239 return($Output); 240 } 241 242 242 function ProcessMonthlyPayment() 243 243 { … … 246 246 247 247 $Output .= $this->ProcessTableUpdates(); 248 248 249 249 $Finance = &$this->System->Modules['Finance']; 250 250 $Finance->LoadMonthParameters(0); … … 282 282 $Output .= 'Odečítám měsíční poplatek...<br />'; 283 283 $Output .= $this->ProduceInvoices(); 284 284 285 285 $Output .= 'Přidávám měsíční přehled...<br />'; 286 286 $DbResult = $this->Database->query('SELECT * FROM `FinanceCharge` WHERE (`ChangeAction` IS NULL) LIMIT 1'); … … 327 327 328 328 $DbResult = $this->Database->query('SELECT `FinanceBankAccount`.*, '. 329 329 'CONCAT(`FinanceBankAccount`.`Number`, "/", `FinanceBank`.`Code`) AS `NumberFull` FROM `FinanceBankAccount` '. 330 330 'JOIN `FinanceBank` ON `FinanceBank`.`Id`=`FinanceBankAccount`.`Bank` '. 331 331 'WHERE (`FinanceBankAccount`.`Subject`='.$Config['Finance']['MainSubjectId'].') '. 332 332 'AND (`FinanceBankAccount`.`Use`=1)'); 333 333 $MainSubjectAccount = $DbResult->fetch_assoc(); 334 334 … … 356 356 $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT `Text`, `Time`, (`Value`*`Direction`) AS `Value`, `File` FROM `FinanceOperation` WHERE (`Subject`='.$Member['Subject'].')) UNION ALL '. 357 357 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ", ") FROM `FinanceInvoiceItem` '. 358 359 358 'WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`) AS `Text`, '. 359 '`Time`, -(`Value`*`Direction`) AS `Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='. 360 360 $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")'); 361 361 while($DbRow = $DbResult->fetch_assoc()) -
trunk/Modules/Finance/UserState.php
r728 r738 9 9 function ShowFinanceOperation($Subject) 10 10 { 11 12 13 14 11 $UserOperationTableQuery = '((SELECT `Text`, `Time`, (`Value`*`Direction`) AS `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo` '. 12 'FROM `FinanceOperation` WHERE (`Subject`='.$Subject['Id'].')) UNION ALL '. 13 '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '. 14 '`Time`, -(`Value`*`Direction`) AS `Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo` FROM `FinanceInvoice` WHERE (`Subject`='.$Subject['Id'].')))'; 15 15 16 16 $Output = '<div style="text-align:center">Výpis finančních operací</div>'; 17 18 19 17 $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$UserOperationTableQuery.' AS `T1`'); 18 $DbRow = $DbResult->fetch_row(); 19 $PageList = GetPageList($DbRow[0]); 20 20 21 22 21 $Output .= $PageList['Output']; 22 $Output .= '<table class="WideTable" style="font-size: small;">'; 23 23 24 25 26 27 28 29 30 31 32 33 24 $TableColumns = array( 25 array('Name' => 'Time', 'Title' => 'Datum'), 26 array('Name' => 'Text', 'Title' => 'Popis'), 27 array('Name' => 'Value', 'Title' => 'Změna [Kč]'), 28 array('Name' => 'State', 'Title' => 'Zůstatek [Kč]'), 29 array('Name' => 'PeriodFrom', 'Title' => 'Období'), 30 array('Name' => 'BillCode', 'Title' => 'Doklad'), 31 ); 32 $Order = GetOrderTableHeader($TableColumns, 'Time', 1); 33 $Output .= $Order['Output']; 34 34 35 36 37 35 $StateQuery = 'SELECT SUM(`T2`.`Value`) FROM '.$UserOperationTableQuery. 36 ' AS `T2` WHERE `T2`.`Time` <= `T1`.`Time` '; 37 $Query = 'SELECT *, ('.$StateQuery.') AS `State` FROM '.$UserOperationTableQuery.' AS `T1` '.$Order['SQL'].$PageList['SQLLimit']; 38 38 39 39 $DbResult = $this->Database->query($Query); 40 40 $SumValue = 0; 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 41 while($Row = $DbResult->fetch_assoc()) 42 { 43 $Row['State'] = round($Row['State'], 2); 44 if($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>'; 45 if($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>'; 46 if($Row['Value'] == -0) $Row['Value'] = 0; 47 if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 48 if($Row['BillCode'] == '') $Row['BillCode'] = 'PDF'; 49 if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillCode'].'</a>'; 50 else $Invoice = NotBlank($Row['BillCode']); 51 if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); 52 else $Period = ' '; 53 $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'. 54 '<td style="text-align: left;">'.$Row['Text'].'</td>'. 55 '<td style="text-align: right;">'.round($Row['Value'], 2).'</td>'. 56 '<td style="text-align: right;">'.$Row['State'].'</td>'. 57 '<td>'.$Period.'</td>'. 58 '<td>'.$Invoice.'</td></tr>'; 59 $SumValue = $SumValue + $Row['Value']; 60 } 61 $Output .= '</table>'; 62 $Output .= $PageList['Output']; 63 return($Output); 64 64 } 65 65 … … 85 85 } else return($this->SystemMessage('Chyba', 'Nejste zákazníkem')); 86 86 } 87 87 88 88 // Load customer info 89 89 $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId); 90 90 if($DbResult->num_rows == 1) 91 91 { 92 $Customer = $DbResult->fetch_assoc();92 $Customer = $DbResult->fetch_assoc(); 93 93 } else return($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen')); 94 95 94 95 96 96 // Load subject info 97 97 $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']); 98 98 if($DbResult->num_rows == 1) 99 { 100 $Subject = $DbResult->fetch_assoc(); 99 { 100 $Subject = $DbResult->fetch_assoc(); 101 101 } else return($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen')); 102 103 104 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 102 103 104 $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">'; 105 105 106 106 // Account state … … 120 120 121 121 $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, CONCAT(FinanceBankAccount.Number, "/", FinanceBank.Code) AS NumberFull FROM FinanceBankAccount '. 122 123 122 'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '. 123 'WHERE (FinanceBankAccount.`Subject`='.$this->System->Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)'); 124 124 $SubjectFromAccount = $DbResult->fetch_assoc(); 125 125 $Account = $SubjectFromAccount['NumberFull']; … … 138 138 while($DbRow = $DbResult->fetch_assoc()) 139 139 { 140 140 $Output .= '<tr><td>'.$DbRow['Name'].'</td><td>'.$DbRow['Price'].'</td></tr>'; 141 141 $Total += $DbRow['Price']; 142 142 } -
trunk/Modules/Finance/Zivnost.php
r724 r738 50 50 $Balance['SmallAssets']['End'] = $Row[0] + 0; 51 51 return($Balance); 52 } 52 } 53 53 54 54 function Show() … … 142 142 $Output .= '<strong>Příjmy za rok '.$Year['Year'].'</strong>'; 143 143 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 144 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 144 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 145 145 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '. 146 146 'WHERE (Direction = 1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); … … 172 172 $Output .= '<strong>Výdaje za rok '.$Year['Year'].'</strong>'; 173 173 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 174 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 174 $Output .= '<tr><th>Čas</th><th>Kód</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 175 175 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject '. 176 176 'WHERE (Direction = -1) AND (FinanceOperation.Time >= "'.$Year['DateStart'].'") AND (FinanceOperation.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); … … 197 197 $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$_GET['year']); 198 198 $Year = $DbResult->fetch_assoc(); 199 199 200 200 $Total = 0; 201 201 $Output .= '<strong>Pohledávky za rok '.$Year['Year'].'</strong>'; … … 234 234 $Row['Value'] = $Row['Value'] * -1; 235 235 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode']. 236 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['Direction']).'</td></tr>'; 236 '</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.($Row['Value'] * $Row['Direction']).'</td></tr>'; 237 237 $Total += $Row['Value']; 238 238 } … … 288 288 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>'; 289 289 $DbResult = $this->Database->select('FinanceInvoice', '*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") '. 290 'FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text',291 290 'FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text', 291 'Subject='.$_GET['Id'].' ORDER BY Time'); 292 292 while($Row = $DbResult->fetch_array()) 293 293 { … … 317 317 'WHERE (FinanceInvoice.Subject = Subject.Id) AND (FinanceInvoice.Direction = -1) '. 318 318 'AND (TimePayment IS NULL)) AS OpenedLiabilities, '. 319 319 '(SELECT SUM(FinanceOperation.Value*FinanceOperation.Direction) '. 320 320 'FROM FinanceOperation WHERE FinanceOperation.Subject = Subject.Id AND FinanceOperation.Direction = 1) '. 321 321 'AS Gains, (SELECT SUM(FinanceOperation.Value*FinanceOperation.Direction) FROM FinanceOperation WHERE '. … … 341 341 $Output .= '<strong>Roční přehledy</strong><br/>'; 342 342 $Output .= $this->ShowFinanceYears(); 343 if(array_key_exists('year', $_GET)) 343 if(array_key_exists('year', $_GET)) 344 344 { 345 345 $Year = $_GET['year'] * 1; … … 353 353 return($Output); 354 354 } 355 355 356 356 function ShowFinanceYears() 357 357 { -
trunk/Modules/FinanceBankAPI/FileImport.php
r719 r738 8 8 var $Database; 9 9 var $BankAccount; 10 10 11 11 function __construct($System) 12 12 { … … 14 14 $this->System = &$System; 15 15 } 16 16 17 17 function Import() 18 18 { 19 19 } 20 20 21 21 function ImportFile($Content, $Ext) 22 { 22 { 23 23 } 24 24 25 25 function PairOperations() 26 26 { … … 32 32 $DbResult2 = $this->Database->select('Subject', 'Id', 'Id='.$DbRow['VariableSymbol']); 33 33 if($DbResult2->num_rows == 1) 34 { 34 { 35 35 $DbRow2 = $DbResult2->fetch_assoc(); 36 // TODO: Replace constants by links to real database numbers 36 // TODO: Replace constants by links to real database numbers 37 37 if($DbRow['Value'] >= 0) { 38 39 $Direction = 1;38 $DocumentLine = 3; // Receive money 39 $Direction = 1; 40 40 } else { 41 42 41 $DocumentLine = 4; // Send money 42 $Direction = -1; 43 43 } 44 44 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 45 45 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); 46 $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 46 $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 47 47 'Value' => Abs($DbRow['Value']), 'Direction' => $Direction, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 48 48 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'DocumentLine' => $DocumentLine)); … … 61 61 62 62 function Show() 63 { 63 { 64 64 $Output = ''; 65 65 if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění'); 66 66 67 67 $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$_GET['i']); 68 68 $BankAccount = $DbResult->fetch_assoc(); 69 69 70 70 $DbResult = $this->Database->select('FinanceBank', '*', 'Id='.$BankAccount['Bank']); 71 71 $Bank = $DbResult->fetch_assoc(); 72 72 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'; 73 73 74 74 if($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 75 75 else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System); … … 80 80 $Output .= $Import->Import(); 81 81 $Import->PairOperations(); 82 } 82 } 83 83 return($Output); 84 84 } 85 85 } 86 86 87 87 class PageImportFile extends Page 88 88 { … … 90 90 var $ShortTitle = 'Import plateb ze souboru'; 91 91 var $ParentClass = 'PageFinance'; 92 92 93 93 function Show() 94 94 { … … 103 103 return($Output); 104 104 } 105 105 106 106 function ShowForm() 107 107 { … … 113 113 return($Output); 114 114 } 115 115 116 116 function Prepare() 117 { 117 { 118 118 $Form = new Form($this->System->FormManager); 119 119 $Form->SetClass('ImportBankFile'); … … 125 125 $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$Form->Values['BankAccount']); 126 126 $BankAccount = $DbResult->fetch_assoc(); 127 127 128 128 $DbResult = $this->Database->select('FinanceBank', '*', 'Id='.$BankAccount['Bank']); 129 129 $Bank = $DbResult->fetch_assoc(); 130 130 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'; 131 131 132 132 if($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 133 133 else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System); … … 135 135 $Import->BankAccount = $BankAccount; 136 136 $Output .= $Import->ImportFile($File->GetContent(), $File->GetExt()); 137 137 138 138 return($Output); 139 139 } 140 140 141 141 function InsertMoney($Subject, $Value, $Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine) 142 142 { 143 $Year = date('Y', $Time); 143 $Year = date('Y', $Time); 144 144 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); 145 $this->Database->insert('FinanceOperation', array('Text' => $Text, 146 147 145 $this->Database->insert('FinanceOperation', array('Text' => $Text, 146 'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Direction' => $Direction, 147 'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode)); 148 148 } 149 149 … … 152 152 $Finance = $this->System->Modules['Finance']; 153 153 $Output = ''; 154 154 155 155 for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 156 156 { 157 157 // TODO: Use links to database records instead of contants 158 158 if($_POST['Money'.$I] < 0) { 159 160 159 $DocumentLine = 4; 160 $Direction = -1; 161 161 } else { 162 163 162 $DocumentLine = 3; 163 $Direction = 1; 164 164 } 165 165 $Date = explode('-', $_POST['Date'.$I]); 166 166 $Date = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]); 167 167 $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $Direction, 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine); -
trunk/Modules/FinanceBankAPI/FinanceBankAPI.php
r735 r738 59 59 60 60 $this->System->RegisterPage(array('finance', 'import-api'), 'PageImportAPI'); 61 $this->System->RegisterPage(array('finance', 'import-soubor'), 'PageImportFile'); 61 $this->System->RegisterPage(array('finance', 'import-soubor'), 'PageImportFile'); 62 62 } 63 63 … … 79 79 'presetBankAccount' => $Item['BankAccount'], 80 80 'presetDocumentLine' => $DocumentLine); 81 81 return($Preset); 82 82 } 83 83 } … … 85 85 class ScheduleBankImport extends SchedulerTask 86 86 { 87 88 89 90 $DbResult = $this->Database->select('FinanceBankAccount', 'Id, Comment', 91 92 93 { 94 95 96 97 98 99 87 function Execute() 88 { 89 $Output = ''; 90 $DbResult = $this->Database->select('FinanceBankAccount', 'Id, Comment', 91 '(`AutoImport`=1) AND ((`TimeEnd` IS NULL) OR (`TimeEnd` > NOW()))'); 92 while($DbRow = $DbResult->fetch_assoc()) 93 { 94 echo($DbRow['Comment']."\n"); 95 $Page = new PageImportAPI($this->System); 96 $Output .= $Page->Show(); 97 } 98 return($Output); 99 } 100 100 } -
trunk/Modules/FinanceBankAPI/Fio.php
r550 r738 1 1 <?php 2 2 3 3 include('GPC.php'); 4 5 class Fio 4 5 class Fio 6 6 { 7 7 var $UserName; 8 8 var $Password; 9 var $Account; 10 9 var $Account; 10 11 11 function Import($TimeFrom, $TimeTo) 12 12 { … … 14 14 if($this->Password == '') throw new Exception('Missing value for Password property.'); 15 15 if(!is_numeric($this->Account)) throw new Exception('Missing or not numeric value for Account property.'); 16 16 17 17 $fp = fsockopen('ssl://www.fio.cz', 443, $errno, $errstr, 30); 18 if(!$fp) 18 if(!$fp) 19 19 { 20 20 throw new Exception('Connection error: '.$errstr); 21 } else 21 } else 22 22 { 23 23 // Send request … … 32 32 $Request .= "Connection: Close\r\n\r\n"; 33 33 fwrite($fp, $Request); 34 34 35 35 // Read response 36 36 $Response = array(); 37 while(!feof($fp)) 37 while(!feof($fp)) 38 38 { 39 39 $Response[] = trim(fgets($fp, 1024)); 40 40 } 41 41 fclose($fp); 42 42 43 43 // Strip HTTP header 44 44 while($Response[0] != '') array_shift($Response); 45 45 array_shift($Response); // Remove empty line 46 46 //echo(implode("\n", $Response)); 47 47 48 48 // Parse all GPC lines 49 49 $GPC = new GPC(); … … 58 58 } 59 59 } 60 60 61 61 function NoValidDataError($Response) 62 62 { 63 63 // Try to get error message 64 64 // If something go wrong fio show HTML login page and display error message 65 65 $Response = implode('', $Response); 66 66 $ErrorMessageStart = '<div id="oldform_warning">'; 67 if(strpos($Response, $ErrorMessageStart) !== false) 68 69 70 71 72 67 if(strpos($Response, $ErrorMessageStart) !== false) 68 { 69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); 70 $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>'))); 71 } else $ErrorMessage = ''; 72 throw new Exception('No valid GPC data: '.$ErrorMessage); 73 73 } 74 74 } -
trunk/Modules/FinanceBankAPI/FioAPI.php
r628 r738 1 1 <?php 2 2 3 3 // Specifikace API: http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf 4 4 … … 10 10 else return($Text); 11 11 } 12 12 13 13 class FioAPI 14 14 { … … 16 16 var $Encoding; 17 17 var $Format; 18 18 19 19 function __construct() 20 20 { … … 22 22 $this->Format = 'csv'; 23 23 } 24 24 25 25 function Import($TimeFrom, $TimeTo) 26 26 { 27 27 if($this->Token == '') throw new Exception('Missing value for Token property.'); 28 28 29 29 // URL format: https://www.fio.cz/ib_api/rest/periods/{token}/{datum od}/{datum do}/transactions.{format} 30 30 // Send request … … 32 32 date('Y-m-d', $TimeFrom).'/'.date('Y-m-d', $TimeTo).'/transactions.'.$this->Format; 33 33 $Response = file_get_contents('https://www.fio.cz'.$RequestURL); 34 if($Response == FALSE) 34 if($Response == FALSE) 35 35 { 36 36 throw new Exception('Connection error'); 37 } else 37 } else 38 38 { 39 39 if($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response); 40 40 $Response = explode("\n", $Response); 41 41 42 42 if($this->Format == 'gpc') 43 { 43 { 44 44 // Parse all GPC lines 45 45 $GPC = new GPC(); … … 57 57 'Items' => array(), 58 58 ); 59 59 60 60 // CVS header 61 while($Response[0] != '') 61 while($Response[0] != '') 62 62 { 63 63 $Line = explode(';', $Response[0]); 64 64 if($Line[0] == 'accountId') $Result['AccountNumber'] = $Line[0]; 65 else if($Line[0] == 'bankId') $Result['BankId'] = $Line[0]; 65 else if($Line[0] == 'bankId') $Result['BankId'] = $Line[0]; 66 66 else if($Line[0] == 'currency') $Result['Currency'] = $Line[0]; 67 67 else if($Line[0] == 'iban') $Result['IBAN'] = $Line[0]; … … 72 72 else if($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0]; 73 73 else if($Line[0] == 'idFrom') $Result['IdFrom'] = $Line[0]; 74 else if($Line[0] == 'idTo') $Result['IdTo'] = $Line[0]; 74 else if($Line[0] == 'idTo') $Result['IdTo'] = $Line[0]; 75 75 array_shift($Response); 76 76 } … … 86 86 $Date = explode('.', $Line[1]); 87 87 $Date = mktime(0, 0, 0, $Date[1], $Date[0], $Date[2]); 88 $NewRecord = array('ID' => $Line[0], 'Date' => $Date, 'Value' => $Line[2], 'CurrencyCode' => $Line[3], 88 $NewRecord = array('ID' => $Line[0], 'Date' => $Date, 'Value' => $Line[2], 'CurrencyCode' => $Line[3], 89 89 'OffsetAccount' => $Line[4], 'OffsetAccountName' => $Line[5], 'BankCode' => $Line[6], 'BankName' => RemoveComma($Line[7]), 90 90 'ConstantSymbol' => $Line[8], 'VariableSymbol' => $Line[9], 'SpecificSymbol' => $Line[10], 91 'UserIdent' => RemoveComma($Line[11]), 'Message' => RemoveComma($Line[12]), 'Type' => RemoveComma($Line[13]), 92 'User' => RemoveComma($Line[14]), 'Details' => RemoveComma($Line[15]), 'Comment' => RemoveComma($Line[16]), 91 'UserIdent' => RemoveComma($Line[11]), 'Message' => RemoveComma($Line[12]), 'Type' => RemoveComma($Line[13]), 92 'User' => RemoveComma($Line[14]), 'Details' => RemoveComma($Line[15]), 'Comment' => RemoveComma($Line[16]), 93 93 'BIC' => $Line[17], 'OrderID' => $Line[18]); 94 $Result['Items'][] = $NewRecord; 94 $Result['Items'][] = $NewRecord; 95 95 } 96 96 } … … 98 98 } 99 99 } 100 100 101 101 function NoValidDataError($Response) 102 102 { … … 105 105 $Response = implode('', $Response); 106 106 $ErrorMessageStart = '<div id="oldform_warning">'; 107 if(strpos($Response, $ErrorMessageStart) !== false) 107 if(strpos($Response, $ErrorMessageStart) !== false) 108 108 { 109 109 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); -
trunk/Modules/FinanceBankAPI/FioDemo.php
r548 r738 1 1 <?php 2 2 3 3 include('FioAPI.php'); 4 4 5 5 $Fio = new FioAPI(); 6 6 $Fio->Token = ''; … … 14 14 { 15 15 echo('<tr>'); 16 if($Record['Type'] == GPC_TYPE_REPORT) 16 if($Record['Type'] == GPC_TYPE_REPORT) 17 17 { 18 18 echo('<td>Jméno účtu: '.$Record['AccountName'].'</td>'); … … 22 22 echo('<td>Suma příjmů: '.$Record['CreditValue'].' Kč</td>'); 23 23 echo('<td>Suma výdajů: '.$Record['DebitValue'].' Kč</td>'); 24 24 25 25 echo('</tr></table><br><br>'); 26 26 echo('<table border="1"><tr>'); 27 27 28 28 echo('<th>Datum</th>'); 29 29 echo('<th>Částka</th>'); … … 35 35 echo('<th>Uživatelská identifikace</th>'); 36 36 } else 37 if($Record['Type'] == GPC_TYPE_ITEM) 37 if($Record['Type'] == GPC_TYPE_ITEM) 38 38 { 39 39 echo('<td>'.date('j.n.Y', $Record['DueDate']).'</td>'); … … 45 45 echo('<td>'.$Record['SpecificSymbol'].'</td>'); 46 46 echo('<td>'.$Record['ClientName'].'</td>'); 47 } 47 } 48 48 echo('</tr>'); 49 49 50 50 } 51 51 echo('</table>'); -
trunk/Modules/FinanceBankAPI/GPC.php
r550 r738 1 1 <?php 2 2 3 3 define('GPC_TYPE_REPORT', '074'); 4 4 define('GPC_TYPE_ITEM', '075'); 5 5 6 6 class GPC 7 7 { 8 8 function ParseLine($Line) 9 { 9 { 10 10 $Line = ' '.$Line; 11 $Type = mb_substr($Line, 1, 3); 12 11 $Type = mb_substr($Line, 1, 3); 12 13 13 if($Type == GPC_TYPE_REPORT) 14 14 { … … 19 19 'AccountName' => trim(mb_substr($Line, 20, 20)), 20 20 'OldBalanceDate' => mktime(0, 0, 0, mb_substr($Line, 42, 2), mb_substr($Line, 40, 2), '20'.mb_substr($Line, 44, 2)), 21 'OldBalanceValue' => (mb_substr($Line, 60, 1).mb_substr($Line, 46, 14)) / 100, 21 'OldBalanceValue' => (mb_substr($Line, 60, 1).mb_substr($Line, 46, 14)) / 100, 22 22 'NewBalanceValue' => (mb_substr($Line, 75, 1).mb_substr($Line, 61, 14)) / 100, 23 'DebitValue' => (mb_substr($Line, 90, 1).mb_substr($Line, 76, 14)) / 100, 24 'CreditValue' => (mb_substr($Line, 105, 1).mb_substr($Line, 91, 14)) / 100, 23 'DebitValue' => (mb_substr($Line, 90, 1).mb_substr($Line, 76, 14)) / 100, 24 'CreditValue' => (mb_substr($Line, 105, 1).mb_substr($Line, 91, 14)) / 100, 25 25 'SequenceNumber' => intval(mb_substr($Line, 106, 3)), 26 26 'Date' => mktime(0, 0, 0, mb_substr($Line, 111, 2), mb_substr($Line, 109, 2), '20'.mb_substr($Line, 113, 2)), … … 28 28 'CheckSum' => sha1(md5($Line).$Line), 29 29 ); 30 } else 30 } else 31 31 if($Type == GPC_TYPE_ITEM) 32 { 32 { 33 33 $GPCLine = array 34 34 ( 35 35 'Type' => GPC_TYPE_ITEM, 36 36 'AccountNumber' => mb_substr($Line, 4, 16), 37 'OffsetAccount' => mb_substr($Line, 20, 16), 38 'RecordNumber' => mb_substr($Line, 36, 13), 37 'OffsetAccount' => mb_substr($Line, 20, 16), 38 'RecordNumber' => mb_substr($Line, 36, 13), 39 39 'Value' => mb_substr($Line, 49, 12) / 100, 40 'Code' => mb_substr($Line, 61, 1), 40 'Code' => mb_substr($Line, 61, 1), 41 41 'VariableSymbol' => intval(mb_substr($Line, 62, 10)), 42 42 'BankCode' => mb_substr($Line, 74, 4), 43 43 'ConstantSymbol' => intval(mb_substr($Line, 78, 4)), 44 'SpecificSymbol' => intval(mb_substr($Line, 82, 10)), 44 'SpecificSymbol' => intval(mb_substr($Line, 82, 10)), 45 45 'Valut' => mb_substr($Line, 92, 6), 46 'ClientName' => mb_substr($Line, 98, 20), 46 'ClientName' => mb_substr($Line, 98, 20), 47 47 //'Zero' => substr($Line, 118, 1), 48 48 'CurrencyCode' => mb_substr($Line, 119, 4), … … 50 50 'CheckSum' => sha1(md5($Line).$Line), 51 51 ); 52 } else 52 } else 53 53 $GPCLine = NULL; 54 54 55 55 return($GPCLine); 56 56 } -
trunk/Modules/FinanceBankAPI/ImportFio.php
r715 r738 1 1 <?php 2 2 3 3 include('FioAPI.php'); 4 4 5 5 class ImportFio extends BankImport 6 6 { 7 7 function Import() 8 { 8 { 9 9 $Fio = new FioAPI(); 10 10 $Fio->Token = $this->BankAccount['LoginName']; … … 20 20 //$Output .= '<td>Ke dni '.date('j.n.Y', $Records['DateEnd']).' je stav účtu '.$Records['ClosingBalance'].' Kč</td>'; 21 21 //$Output .= '<td>Suma příjmů: '.$Records['CreditValue'].' Kč</td>'; 22 //$Output .= '<td>Suma výdajů: '.$Records['DebitValue'].' Kč</td>'; 22 //$Output .= '<td>Suma výdajů: '.$Records['DebitValue'].' Kč</td>'; 23 23 //$Output .= '</tr>'; 24 24 foreach($Records['Items'] as $Record) … … 26 26 $DbResult = $this->Database->select('FinanceBankImport', 'ID', 'Identification='.$Record['ID']); 27 27 if($DbResult->num_rows == 0) 28 { 28 { 29 29 $Output .= '<tr>'; 30 30 $this->Database->insert('FinanceBankImport', array('Time' => TimeToMysqlDate($Record['Date']), 31 'BankAccount' => $this->BankAccount['Id'], 'Value' => $Record['Value'], 31 'BankAccount' => $this->BankAccount['Id'], 'Value' => $Record['Value'], 32 32 'SpecificSymbol' => $Record['SpecificSymbol'], 'VariableSymbol' => $Record['VariableSymbol'], 33 33 'ConstantSymbol' => $Record['ConstantSymbol'], 'Currency' => $this->BankAccount['Currency'], … … 41 41 } 42 42 } 43 $Output .= '</table>'; 44 $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'], 45 43 $Output .= '</table>'; 44 $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'], 45 array('LastImportDate' => TimeToMysqlDate($PeriodEnd))); 46 46 return($Output); 47 47 } -
trunk/Modules/FinanceBankAPI/ImportPS.php
r550 r738 14 14 $Data = explode("\n", $Content); 15 15 } 16 16 17 17 function ImportCVS($Content) 18 18 { 19 19 $Finance = &$this->System->Modules['Finance']; 20 20 21 21 $Data = explode("\n", $Content); 22 22 foreach($Data as $Key => $Value) … … 45 45 11 => '', 46 46 ); 47 47 48 48 if($Header != $Data[0]) $Output = 'Nekompatibilní struktura CSV'; 49 49 else … … 79 79 $Style = ''; 80 80 } 81 81 82 82 if($Money < 0) $Text = 'Platba převodem'; 83 83 else $Text = 'Přijatá platba'; … … 102 102 $Output .= '<input type="submit" value="Zpracovat"/></form>'; 103 103 } 104 } 104 } 105 105 } -
trunk/Modules/IS/IS.php
r736 r738 32 32 if(array_key_exists('t', $_GET)) $Table = $_GET['t']; 33 33 else $Table = ''; 34 // i - index of item 34 // i - index of item 35 35 if(array_key_exists('i', $_GET)) $ItemId = $_GET['i']; 36 36 else $ItemId = 0; 37 // fc - preset colum 37 // fc - preset colum 38 38 if(array_key_exists('fn', $_GET)) $FilterName = $_GET['fn']; 39 39 else $FilterName = ''; … … 46 46 47 47 if($Action == 'list') { 48 49 48 if($FilterName == '') $Content = $this->ShowList($Table); 49 else $Content = $this->ShowList($Table, '', '', $FilterName, $FilterValue); 50 50 } 51 51 else if($Action == 'select') $Content = $this->ShowSelect($Table); … … 84 84 $DbRow = $DbResult->fetch_row(); 85 85 $Output .= 'Nedokončených úkolů: '.$DbRow['0'].'<br/>'; 86 86 87 87 $DbResult = $this->Database->select('Member', 'COUNT(*)', '1'); 88 88 $DbRow = $DbResult->fetch_row(); 89 89 $Output .= 'Zákazníků: '.$DbRow['0'].'<br/>'; 90 90 91 91 $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1'); 92 92 $DbRow = $DbResult->fetch_row(); 93 93 $Output .= 'Subjektů: '.$DbRow['0'].'<br/>'; 94 94 95 95 $DbResult = $this->Database->select('User', 'COUNT(*)', '1'); 96 96 $DbRow = $DbResult->fetch_row(); 97 97 $Output .= 'Uživatelů: '.$DbRow['0'].'<br/>'; 98 98 99 99 $DbResult = $this->Database->select('NetworkDevice', 'COUNT(*)', '1'); 100 100 $DbRow = $DbResult->fetch_row(); 101 101 $Output .= 'Registrovaných zařízení: '.$DbRow['0'].'<br/>'; 102 102 103 103 $DbResult = $this->Database->select('FinanceOperation', 'SUM(`Value` * `Direction`)', '1'); 104 104 $DbRow = $DbResult->fetch_row(); 105 105 $Output .= 'Stav placení: '.$DbRow['0'].'<br/>'; 106 106 107 107 $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL'); 108 108 $DbRow = $DbResult->fetch_row(); … … 142 142 function LogChange($Form, $Action, $NewId, $OldId) 143 143 { 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 144 $Values = $Form->Definition['Table'].' (Id: '.$OldId.' => '.$NewId.'):'."\n"; 145 // Compare old values loaded from database with new values in Form variable 146 $NewValues = $Form->Values; 147 if($OldId != 0) 148 { 149 $FormOld = new Form($this->System->FormManager); 150 $FormOld->SetClass($Form->Definition['Table']); 151 $FormOld->LoadValuesFromDatabase($OldId); 152 $OldValues = $FormOld->Values; 153 // Keep only changes values 154 foreach($NewValues as $Index => $Value) 155 { 156 if($OldValues[$Index] != $NewValues[$Index]) 157 { 158 $Values .= $Index.': '.$FormOld->GetValue($Index); 159 if($NewId != 0) $Values .= ' => '.$Form->GetValue($Index); 160 $Values .= "\n"; 161 } 162 } 163 } else { 164 foreach($NewValues as $Index => $Value) 165 { 166 $Values .= $Index.': '.$Form->GetValue($Index)."\n"; 167 } 168 } 169 $this->System->ModuleManager->Modules['Log']->NewRecord('IS', $Action, $Values); 170 170 } 171 171 … … 179 179 if($_GET['o'] == 'save') 180 180 { 181 if(!array_key_exists('submit', $_POST))182 181 if(!array_key_exists('submit', $_POST)) 182 return($this->SystemMessage('Formulář', 'Formulář nebyl řádně odeslán. Vraťte se zpět a odešlete formulář znovu.')); 183 183 $Form = new Form($this->System->FormManager); 184 184 $Form->SetClass($Table); … … 193 193 } catch (Exception $E) 194 194 { 195 195 $Output .= $this->SystemMessage('Úprava položky', 'Položku se nepodařilo uložit. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 196 196 $Form->OnSubmit = '?a=edit&t='.$Table.'&i='.$_GET['i'].'&o=save'; 197 197 $Output .= $Form->ShowEditForm(); … … 230 230 $Output = ''; 231 231 if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write')) 232 return('Nemáte oprávnění'); 232 return('Nemáte oprávnění'); 233 233 $DbResult = $this->Database->select($Table, '*', '`Id`='.$Id); 234 234 if($DbResult->num_rows > 0) 235 235 { 236 237 236 $DbRow = $DbResult->fetch_assoc(); 237 try { 238 238 $Form = new Form($this->System->FormManager); 239 239 $this->ShortTitle .= ' - '.$Form->Definition['Title'].' odstranění'; … … 244 244 } catch (Exception $E) 245 245 { 246 246 $Output .= $this->SystemMessage('Smazání položky', 'Položku se nepodařilo smazat. Pravděpodobně na ni závisejí další položky.'); 247 247 } 248 248 } else $Output .= $this->SystemMessage('Smazání položky', 'Položka nenalezena'); … … 301 301 } catch (Exception $E) 302 302 { 303 304 303 $Output .= $this->SystemMessage('Přidání položky', 'Položku se nepodařilo přidat. Opravte problém a opakujte akci.<br/>'.$E->getMessage()); 304 $Form->OnSubmit = '?a=add&t='.$Table.'&o=save'; 305 305 $Output .= $Form->ShowEditForm(); 306 306 $Actions[] = '<a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. … … 353 353 if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read')) 354 354 return('Nemáte oprávnění'); 355 355 356 356 $FormClass = $this->System->FormManager->Classes[$Table]; 357 357 if(array_key_exists('BaseTable', $FormClass)) $TableModify = $FormClass['BaseTable']; 358 358 else $TableModify = $Table; 359 359 360 360 $Form = new Form($this->System->FormManager); 361 361 $Form->SetClass($Table); … … 407 407 function ShowTable($Table, $Filter = '', $Title = '', $RowActions = array(), $ExcludeColumn = '') 408 408 { 409 409 if($Table != '') $FormClass = $this->System->FormManager->Classes[$Table]; 410 410 else return($this->SystemMessage('Chyba', 'Tabulka nenalezena')); 411 411 … … 416 416 // Build form type filter 417 417 $TypeFilter = ''; 418 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 418 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 419 419 if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or 420 420 (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and … … 422 422 if(array_key_exists('Filter', $FormItem) and ($FormItem['Filter'] == true)) 423 423 { 424 if($TypeFilter != '') $TypeFilter .= ' AND ';425 426 } 424 if($TypeFilter != '') $TypeFilter .= ' AND '; 425 $TypeFilter .= '('.$ItemIndex.' = "'.$FormItem['Default'].'")'; 426 } 427 427 if($TypeFilter != '') 428 428 { 429 430 431 } 432 429 if($Filter != '') $Filter = ' AND'; 430 $Filter .= ' '.$TypeFilter; 431 } 432 433 433 // Build user filter 434 434 $UserFilter = ''; … … 470 470 if($Filter != '') $Filter = ' HAVING '.$Filter; 471 471 472 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 472 foreach($FormClass['Items'] as $ItemIndex => $FormItem) 473 473 if(!array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) or 474 474 (array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes) and 475 475 ($this->System->FormManager->FormTypes[$FormItem['Type']]['Type'] != 'ManyToOne'))) 476 476 { 477 478 477 if($ExcludeColumn != $ItemIndex) 478 if(!array_key_exists('Hidden', $FormItem) or ($FormItem['Hidden'] == false)) 479 479 $TableColumns[] = array('Name' => $ItemIndex, 'Title' => $FormItem['Caption']); 480 480 $UseType = $UseType = $FormItem['Type']; … … 563 563 ($ExcludeColumn != $ItemIndex)) 564 564 { 565 565 //$Output .= '<td>'.$Row[$ItemIndex].'</td>'; 566 566 $UseType = $UseType = $FormItem['Type']; 567 567 if(array_key_exists($FormItem['Type'], $this->System->FormManager->FormTypes)) … … 632 632 if(array_key_exists('BaseTable', $FormClass)) $TableModify = $FormClass['BaseTable']; 633 633 else $TableModify = $Table; 634 634 635 635 $RowActions = '<a href="?a=view&t='.$Table.'&i=#RowId"><img alt="Ukázat" title="Ukázat" src="'. 636 636 $this->System->Link('/images/view.png').'"/></a>'. … … 755 755 $Confirm = ' onclick="return confirmAction(\''.$Confirm.'\');"'; 756 756 $Output = '<a href="'.$Target.'"'.$Confirm.'>'.$Output.'</a>'; 757 757 return($Output); 758 758 } 759 759 } -
trunk/Modules/Map/Map.php
r721 r738 15 15 if(count($this->System->PathItems) > 1) 16 16 { 17 if($this->System->PathItems[1] == 'show-position') return($this->ShowPosition()); 17 if($this->System->PathItems[1] == 'show-position') return($this->ShowPosition()); 18 18 else return(PAGE_NOT_FOUND); 19 19 } else return($this->ShowMain()); 20 20 } 21 21 22 22 function ShowPosition() 23 23 { … … 37 37 } else return('Položka nenalezena'); 38 38 } 39 39 40 40 function ShowMain() 41 41 { … … 49 49 var tinyIcon; 50 50 51 function initialize() 52 { 53 if (GBrowserIsCompatible()) 51 function initialize() 52 { 53 if (GBrowserIsCompatible()) 54 54 { 55 55 map = new GMap2(document.getElementById("map_canvas")); … … 58 58 map.setUIToDefault(); 59 59 map.addControl(new GOverviewMapControl(new GSize(128, 96))); 60 60 61 61 62 62 // Create our "tiny" marker icon … … 68 68 tinyIcon.iconAnchor = new GPoint(5, 5); 69 69 tinyIcon.infoWindowAnchor = new GPoint(5, 1); 70 71 72 73 74 $Output .= ' 75 } 76 } 77 78 function toggleLabel(id) 79 { 80 81 82 83 } 84 85 function UpdateNetworkLinks() 86 { 87 if ((document.getElementById("NetworkLinks")).checked == true) 88 { 89 70 71 toggleLabel(\'NetworkLinks\'); 72 toggleLabel(\'NetworkDevices\');'; 73 74 $Output .= ' 75 } 76 } 77 78 function toggleLabel(id) 79 { 80 var ele = document.getElementById(id); 81 ele.checked = !ele.checked; 82 ele.onclick( ); 83 } 84 85 function UpdateNetworkLinks() 86 { 87 if ((document.getElementById("NetworkLinks")).checked == true) 88 { 89 NetworkLinks = ['; 90 90 $DbResult = $this->Database->query('SELECT * FROM NetworkLink WHERE Interface1 <> 0 AND Interface2 <> 0'); 91 91 while($Link = $DbResult->fetch_assoc()) … … 114 114 } 115 115 116 117 118 { 119 120 121 122 123 } 124 125 function toggleLabel(id) 126 { 127 128 129 130 } 131 132 function UpdateNetworkDevices() 133 { 134 if ((document.getElementById("NetworkDevices")).checked == true) 135 { 136 116 } else { //checkbox turned off 117 for (var i in NetworkLinks) 118 { 119 map.removeOverlay(NetworkLinks[i]); 120 NetworkLinks[i] = null; 121 } 122 } 123 } 124 125 function toggleLabel(id) 126 { 127 var ele = document.getElementById(id); 128 ele.checked = !ele.checked; 129 ele.onclick( ); 130 } 131 132 function UpdateNetworkDevices() 133 { 134 if ((document.getElementById("NetworkDevices")).checked == true) 135 { 136 NetworkDevices = ['; 137 137 138 138 $DbResult = $this->Database->query('SELECT GROUP_CONCAT(NetworkDevice.Name SEPARATOR ",") AS Name, '. … … 153 153 } 154 154 155 156 157 { 158 159 160 161 } 155 } else { //checkbox turned off 156 for (var i in NetworkDevices) 157 { 158 map.removeOverlay(NetworkDevices[i]); 159 NetworkDevices[i] = null; 160 } 161 } 162 162 } 163 163 … … 165 165 $Output .= '<table style="margin-left: auto; margin-right: auto; width: 100%; height: 80%;"> 166 166 <tr> 167 <td style="width: 80%; height: 100%;"> 167 <td style="width: 80%; height: 100%;"> 168 168 <div id="map_canvas" style="width: 100%; height: 100%;"></div></td> 169 169 <td style="width: 20%"> … … 208 208 $this->SupportedModels = array(); 209 209 } 210 210 211 211 function DoStart() 212 212 { … … 225 225 )); 226 226 $this->System->FormManager->RegisterFormType('TMapPosition', array( 227 228 229 230 231 227 'Type' => 'Reference', 228 'Table' => 'MapPosition', 229 'Id' => 'Id', 230 'Name' => 'Name', 231 'Filter' => '1', 232 232 )); 233 234 } 235 } 233 234 } 235 } -
trunk/Modules/Map/MapAPI.php
r574 r738 1 1 <?php 2 2 3 class MapApi extends Model 3 class MapApi extends Model 4 4 { 5 5 var $Position; … … 9 9 var $ShowMarker; 10 10 var $MarkerText; 11 11 12 12 function __construct($System) 13 13 { 14 14 parent::__construct($System); 15 $this->Zoom = 2; 15 $this->Zoom = 2; 16 16 $this->Position = array('Lat' => 40.178873, 'Lng' => 65.039062); 17 17 $this->Key = ''; 18 18 $this->ShowMarker = false; 19 $this->MarkerText = ''; 19 $this->MarkerText = ''; 20 20 } 21 21 22 22 function Show() 23 23 { … … 39 39 </script>'; 40 40 $Output .= '<script type="text/javascript"> 41 41 42 42 var map; 43 43 var tinyIcon; 44 44 45 45 function initialize() 46 46 { … … 52 52 map.setUIToDefault(); 53 53 map.addControl(new GOverviewMapControl(new GSize(128, 96))); 54 54 55 55 GEvent.addListener(map,"click",function(overlay, point) 56 56 { … … 61 61 }); 62 62 } 63 63 64 64 // Create our "tiny" marker icon 65 65 var tinyIcon = new GIcon(); … … 84 84 class MapApiSeznam extends MapApi 85 85 { 86 86 87 87 } -
trunk/Modules/Meals/Meals.php
r586 r738 4 4 { 5 5 var $FullTitle = 'Jídleníček jídelny Na kopečku'; 6 var $ShortTitle = 'Jídelníček'; 6 var $ShortTitle = 'Jídelníček'; 7 7 var $ParentClass = 'PagePortal'; 8 8 var $DayNames = array('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota'); … … 14 14 { 15 15 if(count($this->System->PathItems) > 1) 16 { 16 { 17 17 if($this->System->PathItems[1] == 'tisk') return($this->ShowPrint()); 18 18 else if($this->System->PathItems[1] == 'menuedit.php') return($this->ShowEdit()); … … 42 42 return($Output); 43 43 } 44 44 45 45 function ShowPrint() 46 46 { 47 47 $this->ClearPage = true; 48 48 49 49 $Output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 50 50 <html> … … 79 79 { 80 80 $Output .= '<br>'.$this->Status[$Row['Status']].'<br> '; 81 } 81 } 82 82 $Output .= '</td></tr>'; 83 83 } … … 91 91 92 92 $Output .= '</body></html>'; 93 return($Output); 93 return($Output); 94 94 } 95 95 … … 109 109 '">Tisk</a></td>'; 110 110 else $WeekRowSpan = ''; 111 if($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = ''; 111 if($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = ''; 112 112 $Output = '<tr><td'.$Color.'>'.$this->DayNames[$Week].'</td><td>'.HumanDate($Row['Date']).'</td>'.$WeekRowSpan.' 113 113 <td><input name="soup_'.$Row['Date'].'" size="30" value="'.$Row['Soup'].'"></td> … … 190 190 $this->SupportedModels = array('Meals', 'MealsInfo'); 191 191 } 192 192 193 193 function DoInstall() 194 194 { 195 195 } 196 196 197 197 function DoUnInstall() 198 198 { -
trunk/Modules/Meteostation/Meteostation.php
r586 r738 9 9 var $ShortTitle = 'Meteostanice'; 10 10 var $ParentClass = 'PagePortal'; 11 11 12 12 function Show() 13 13 { … … 24 24 var $Period; 25 25 var $URL; 26 26 27 27 function DownloadData() 28 28 { 29 29 $XmlData = simplexml_load_file($this->URL); 30 30 31 $Data = array('MeteoStation' => $this->Id, 31 $Data = array('MeteoStation' => $this->Id, 32 32 'WindSpeed' => trim($XmlData->windspeed), 33 33 'WindDir' => trim($XmlData->winddir), … … 43 43 ); 44 44 $this->Database->insert('MeteoStationMeasure', array( 45 'Time' => TimeToMysqlDateTime(time()), 'MeteoStation' => $Data['MeteoStation'], 46 'WindSpeed' => $Data['WindSpeed'], 'WindDir' => $Data['WindDir'], 47 'WindGust' => $Data['WindGust'], 'Pressure' => $Data['Pressure'], 45 'Time' => TimeToMysqlDateTime(time()), 'MeteoStation' => $Data['MeteoStation'], 46 'WindSpeed' => $Data['WindSpeed'], 'WindDir' => $Data['WindDir'], 47 'WindGust' => $Data['WindGust'], 'Pressure' => $Data['Pressure'], 48 48 'SysTemp' => $Data['SysTemp'], 'Temperature' => $Data['Temperature'], 49 49 'BarAltitude' => $Data['BarAltitude'], 'WindChill' => $Data['WindChill'], … … 52 52 $this->Data = $Data; 53 53 } 54 54 55 55 function CreateImage($FileName) 56 56 { … … 65 65 $Image->SaveToFile($FileName); 66 66 } 67 67 68 68 function LoadFromDb() 69 69 { … … 79 79 { 80 80 var $Data; 81 81 82 82 function __construct($System) 83 83 { … … 90 90 $this->Dependencies = array(); 91 91 } 92 92 93 93 function DownloadAll() 94 94 { … … 98 98 $MeteoStation = new MeteoStation(); 99 99 $MeteoStation->Id = $DbRow['Id']; 100 $MeteoStation->LoadFromDb(); 100 $MeteoStation->LoadFromDb(); 101 101 $MeteoStation->DownloadData(); 102 102 $MeteoStation->CreateImage('cache/'.$DbRow['Id'].'.png'); 103 103 } 104 104 } 105 106 105 106 107 107 function DoInstall() 108 108 { 109 109 } 110 110 111 111 function DoUninstall() 112 { 112 { 113 113 } 114 114 115 115 function DoStart() 116 116 { 117 117 $this->System->RegisterPage('meteo', 'PageMeteo'); 118 } 119 118 } 119 120 120 function DoStop() 121 { 121 { 122 122 } 123 123 } -
trunk/Modules/Network/HostList.php
r717 r738 8 8 var $ShortTitle = 'Seznam počítačů'; 9 9 var $ParentClass = 'PageNetwork'; 10 10 11 11 function Show() 12 12 { … … 45 45 if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 46 46 $Output .= '<tr><td style="text-align: left; '.$Style.'"> '.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td> </td><td> </td><td> </td><td> </td></tr>'; 47 } 47 } 48 48 } 49 } 49 } 50 50 $Output .= '</table></div>'; 51 51 return($Output); -
trunk/Modules/Network/Network.php
r736 r738 65 65 $Output .= '<td style="background-color: '.$Color.';"> </td>'; 66 66 } 67 68 $Output .= '</tr>'; 67 68 $Output .= '</tr>'; 69 69 } 70 70 } … … 186 186 'Online' => array('Type' => 'TOnlineState', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true), 187 187 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true), 188 188 'Links' => array('Type' => 'TNetworkLinkListInterface', 'Caption' => 'Propojení', 'Default' => ''), 189 189 'UpDown' => array('Type' => 'TNetworkInterfaceUpDown', 'Caption' => 'Změny stavu', 'Default' => ''), 190 190 'Signal' => array('Type' => 'TNetworkSignalListInterface', 'Caption' => 'Signál', 'Default' => ''), … … 192 192 193 193 ), 194 )); 194 )); 195 195 $this->System->FormManager->RegisterClass('NetworkInterfaceType', array( 196 196 'Title' => 'Typ síťového rozhraní', … … 235 235 $this->System->FormManager->RegisterClass('NetworkLinkUnion', array( 236 236 'Title' => 'Síťové propojení', 237 237 'BaseTable' => 'NetworkLink', 238 238 'SQL' => '(SELECT `Id`, `Type`, `Interface1` AS `Interface`, `Interface2` AS `InterfaceOther` FROM `NetworkLink`) '. 239 239 'UNION (SELECT `Id`, `Type`, `Interface2` AS `Interface`, `Interface1` AS `InterfaceOther` FROM `NetworkLink`)', 240 240 'Items' => array( 241 241 'Type' => array('Type' => 'TNetworkLinkType', 'Caption' => 'Typ', 'Default' => '1', 'ReadOnly' => true), 242 242 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 1', 'Default' => '', 'ReadOnly' => true), 243 244 ), 245 )); 246 243 'InterfaceOther' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní 2', 'Default' => '', 'ReadOnly' => true), 244 ), 245 )); 246 247 247 $this->System->FormManager->RegisterClass('NetworkLinkType', array( 248 248 'Title' => 'Typ síťového propojení', … … 371 371 )); 372 372 $this->System->FormManager->RegisterFormType('TNetworkDevice', array( 373 374 375 376 377 373 'Type' => 'Reference', 374 'Table' => 'NetworkDevice', 375 'Id' => 'Id', 376 'Name' => 'Name', 377 'Filter' => '1', 378 378 )); 379 379 $this->System->FormManager->RegisterFormType('TNetworkDeviceType', array( 380 381 382 383 384 380 'Type' => 'Reference', 381 'Table' => 'NetworkDeviceType', 382 'Id' => 'Id', 383 'Name' => 'Name', 384 'Filter' => '1', 385 385 )); 386 386 $this->System->FormManager->RegisterFormType('TNetworkInterface', array( 387 388 389 390 391 392 393 387 'Type' => 'Reference', 388 'Table' => 'NetworkInterface', 389 'View' => '(SELECT NetworkInterface.*, CONCAT_WS("-", NetworkDevice.Name, NULLIF(NetworkInterface.Name, "")) AS DeviceName FROM NetworkInterface '. 390 'LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device) AS T', 391 'Id' => 'Id', 392 'Name' => 'DeviceName', 393 'Filter' => '1', 394 394 )); 395 395 $this->System->FormManager->RegisterFormType('TNetworkInterfaceType', array( 396 397 398 399 400 396 'Type' => 'Reference', 397 'Table' => 'NetworkInterfaceType', 398 'Id' => 'Id', 399 'Name' => 'Name', 400 'Filter' => '1', 401 401 )); 402 402 $this->System->FormManager->RegisterFormType('TDeviceList', array( … … 416 416 $this->System->FormManager->RegisterFormType('TNetworkLinkType', array( 417 417 'Type' => 'Reference', 418 419 420 421 422 )); 418 'Table' => 'NetworkLinkType', 419 'Id' => 'Id', 420 'Name' => 'Name', 421 'Filter' => '1', 422 )); 423 423 $this->System->FormManager->RegisterFormType('TDeviceAPIType', array( 424 424 'Type' => 'Reference', 425 426 427 428 429 )); 425 'Table' => 'DeviceAPIType', 426 'Id' => 'Id', 427 'Name' => 'Name', 428 'Filter' => '1', 429 )); 430 430 $this->System->FormManager->RegisterFormType('TNetworkInterfaceWirelessListInterface', array( 431 431 'Type' => 'ManyToOne', … … 445 445 'Type' => 'ManyToOne', 446 446 'Table' => 'NetworkLinkUnion', 447 448 449 447 'Id' => 'Id', 448 'Ref' => 'Interface', 449 'Filter' => '1', 450 450 )); 451 451 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface1', array( 452 453 454 455 456 452 'Type' => 'ManyToOne', 453 'Table' => 'NetworkLink', 454 'Id' => 'Id', 455 'Ref' => 'Interface1', 456 'Filter' => '1', 457 457 )); 458 458 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface2', array( 459 460 461 462 463 459 'Type' => 'ManyToOne', 460 'Table' => 'NetworkLink', 461 'Id' => 'Id', 462 'Ref' => 'Interface2', 463 'Filter' => '1', 464 464 )); 465 465 $this->System->FormManager->RegisterFormType('TNetworkInterfaceUpDown', array( 466 467 468 469 470 471 )); 472 466 'Type' => 'ManyToOne', 467 'Table' => 'NetworkInterfaceUpDown', 468 'Id' => 'Id', 469 'Ref' => 'Interface', 470 'Filter' => '1', 471 )); 472 473 473 } 474 474 -
trunk/Modules/Network/Subnet.php
r548 r738 15 15 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `NetworkSubnet`'); 16 16 $DbRow = $DbResult->fetch_row(); 17 $PageList = GetPageList($DbRow[0]); 17 $PageList = GetPageList($DbRow[0]); 18 18 19 19 $Output = $PageList['Output']; 20 20 $Output .= '<table class="WideTable" style="font-size: small;">'; 21 21 22 22 $TableColumns = array( 23 array('Name' => 'Name', 'Title' => 'Název'), 24 array('Name' => 'AddressRange', 'Title' => 'IP rozsah'), 25 array('Name' => 'DHCP', 'Title' => 'Adresa DHCP'), 26 array('Name' => 'Gateway', 'Title' => 'Výchozí brána'), 27 array('Name' => '', 'Title' => 'Max. adres'), 28 array('Name' => '', 'Title' => 'Registrovaných adres'), 29 array('Name' => '', 'Title' => 'Využití'), 30 array('Name' => 'SubjectName', 'Title' => 'Účastník'), 23 array('Name' => 'Name', 'Title' => 'Název'), 24 array('Name' => 'AddressRange', 'Title' => 'IP rozsah'), 25 array('Name' => 'DHCP', 'Title' => 'Adresa DHCP'), 26 array('Name' => 'Gateway', 'Title' => 'Výchozí brána'), 27 array('Name' => '', 'Title' => 'Max. adres'), 28 array('Name' => '', 'Title' => 'Registrovaných adres'), 29 array('Name' => '', 'Title' => 'Využití'), 30 array('Name' => 'SubjectName', 'Title' => 'Účastník'), 31 31 ); 32 32 $Order = GetOrderTableHeader($TableColumns, 'AddressRange', 0); … … 34 34 35 35 $Query = 'SELECT NetworkSubnet.*, Subject.Name AS SubjectName FROM NetworkSubnet LEFT JOIN Member ON Member.Id = NetworkSubnet.Member LEFT JOIN Subject ON Subject.Id = Member.Subject '.$Order['SQL'].$PageList['SQLLimit']; 36 36 37 37 $DbResult = $this->Database->query($Query); 38 while($Subnet = $DbResult->fetch_assoc()) 39 { 38 while($Subnet = $DbResult->fetch_assoc()) 39 { 40 40 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE CompareNetworkPrefix(INET_ATON("'.$Subnet['AddressRange'].'"), INET_ATON(LocalIP), '.$Subnet['Mask'].')'); 41 41 $DbRow = $DbResult2->fetch_row(); -
trunk/Modules/Network/UserHosts.php
r558 r738 14 14 { 15 15 global $Config; 16 16 17 17 if($this->System->User->User['Id'] == '') return($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci')); 18 18 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">'; … … 36 36 NotBlank($Interface['ExternalIP']).'</td><td>'. 37 37 NotBlank($Interface['MAC']).'</td><td> </td><td> </td></tr>'; 38 } 38 } 39 39 } 40 40 $Output .= '</table></div>'; -
trunk/Modules/NetworkConfig/Generate.php
r621 r738 19 19 $Output = array(); 20 20 foreach($ExecuteParts as $Command) 21 if($Command != '') 21 if($Command != '') 22 22 { 23 exec($Command, $Output); 23 exec($Command, $Output); 24 24 //echo($Command."\n"); 25 25 //sleep(5); -
trunk/Modules/NetworkConfig/NetworkConfig.php
r721 r738 13 13 $this->Dependencies = array('Network'); 14 14 } 15 15 16 16 function DoInstall() 17 17 { 18 18 } 19 19 20 20 function DoUnInstall() 21 21 { … … 48 48 ), 49 49 )); 50 50 51 51 } 52 52 } -
trunk/Modules/NetworkConfigLinux/Generators/DHCP.php
r548 r738 36 36 fputs($File, " host ".$Data."\t{ fixed-address ".$Row['IP'].";\thardware ethernet ".$Row['MAC']."; }\n"); 37 37 } 38 38 39 39 fputs($File, "}\n\n"); 40 40 } -
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r699 r738 137 137 if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != '')) 138 138 { 139 140 141 142 143 139 $Addr = new NetworkAddressIPv6(); 140 $Addr->AddressFromString($Host['IPv6']); 141 $Octets = $Addr->GetOctets(); 142 $Octets = array_slice($Octets, 0, (128 - $Prefix) / 4); 143 $Octets = implode('.', $Octets); 144 144 145 145 $Host['Name'] = strtolower($Host['Name']); … … 175 175 'Alias' => array(), 176 176 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68', 177 178 177 '10.145.69', '10.145.70', '10.145.71', '77.92.221', '172.16.0', '172.16.1'), 178 'IPv6Network' => array('2a00:e580:244::/48'), 179 179 ); 180 180 … … 237 237 'Alias' => array(), 238 238 'Network' => array('81.2.194', '193.86.238', '212.111.4', '77.92.221'), 239 239 'IPv6Network' => array('2a00:e580:244::/48'), 240 240 ); 241 241 … … 278 278 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', 279 279 '10.145.68', '10.145.69', '10.145.70', '10.145.71'), 280 280 'IPv6Network' => array(), 281 281 ); 282 282 … … 317 317 'Alias' => array(), 318 318 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', 319 320 319 '10.145.68', '10.145.69', '10.145.70', '10.145.71'), 320 'IPv6Network' => array(), 321 321 ); 322 322 -
trunk/Modules/NetworkConfigLinux/Generators/IPTables.php
r548 r738 13 13 /* 14 14 // Blocking according IP address 15 $DbResult = $Database->select('users', '*', 'inet = 0'); 15 $DbResult = $Database->select('users', '*', 'inet = 0'); 16 16 while($User = $DbResult->fetch_array()) 17 17 { … … 48 48 // else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 49 49 } else { 50 if($Row['vpn'] == 0) 50 if($Row['vpn'] == 0) 51 51 { 52 52 $CZFreeLocalIP = $Row['IP']; 53 53 //echo($Row['external_ip']."\n"); 54 55 54 //if($Row['name'] == 'TBC') 55 //{ 56 56 // exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725'); 57 57 // exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip'].':3724'); 58 58 //} 59 59 if(strtolower($Row['name']) != 'gate') 60 61 60 { 61 if($Row['external_ip'] != '') 62 62 { 63 63 echo($Row['name'].'='.$Row['external_ip']."\n"); 64 64 65 65 exec('/sbin/iptables -t nat -A PreroutingDNAT -i '.$InetInterface.' -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']); 66 66 exec('/sbin/iptables -t nat -A PreroutingDNAT -i '.$InetInterface.' -d '.$Row['external_ip'].' -j ACCEPT'); 67 67 exec('/sbin/iptables -t nat -A POSTROUTING -s '.$Row['IP'].' -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip']); 68 68 } 69 69 //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 70 70 } 71 71 } 72 72 else 73 73 { 74 74 $CZFreeLocalIP = $Row['external_ip']; 75 75 //echo('vpn'); 76 76 //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP'); … … 79 79 80 80 //if($Row['vpn'] == 1) 81 82 81 //{ 82 //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 83 83 //} else if($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 84 84 } -
trunk/Modules/NetworkConfigLinux/Generators/NAT.php
r548 r738 13 13 /* 14 14 // Blocking according IP address 15 $DbResult = $Database->select('users', '*', 'inet = 0'); 15 $DbResult = $Database->select('users', '*', 'inet = 0'); 16 16 while($User = $DbResult->fetch_array()) 17 17 { … … 48 48 // else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 49 49 } else { 50 if($Row['vpn'] == 0) 50 if($Row['vpn'] == 0) 51 51 { 52 52 $CZFreeLocalIP = $Row['IP']; 53 53 //echo($Row['external_ip']."\n"); 54 55 54 //if($Row['name'] == 'TBC') 55 //{ 56 56 // exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725'); 57 57 // exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o eth1 -j SNAT --to-source '.$Row['external_ip'].':3724'); 58 58 //} 59 59 if(strtolower($Row['name']) != 'centrala') 60 61 60 { 61 if($Row['external_ip'] != '') 62 62 { 63 63 echo($Row['name'].'='.$Row['external_ip']."\n"); 64 64 65 65 exec('/sbin/iptables -t nat -A PreroutingDNAT -i eth1 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP']); 66 66 exec('/sbin/iptables -t nat -A PreroutingDNAT -i eth1 -d '.$Row['external_ip'].' -j ACCEPT'); 67 67 exec('/sbin/iptables -t nat -A POSTROUTING -s '.$Row['IP'].' -o eth1 -j SNAT --to-source '.$Row['external_ip']); 68 68 } 69 69 //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 70 70 } 71 71 } 72 72 else 73 73 { 74 74 $CZFreeLocalIP = $Row['external_ip']; 75 75 //echo('vpn'); 76 76 //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP'); … … 79 79 80 80 //if($Row['vpn'] == 1) 81 82 81 //{ 82 //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 83 83 //} else if($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 84 84 } -
trunk/Modules/NetworkConfigLinux/Generators/TrafficShaping.php
r548 r738 10 10 // Generate traffic shaping rules 11 11 //$TotalMaxSpeedIn = 4048; //$RealMaxSpeed; //1536; 12 //TotalMaxSpeedOut = 3048; //$RealMaxSpeed; //1536; 12 //TotalMaxSpeedOut = 3048; //$RealMaxSpeed; //1536; 13 13 //$UsersMaxSpeedIn = 1900; //$MaxSpeed; 14 14 //$UsersMaxSpeedOut = 1900; //$MaxSpeed; … … 45 45 46 46 $FreeInetClass = 2; 47 47 48 48 // In going traffic 49 49 fputs($File, "/sbin/tc qdisc del dev ".$InInterface." root\n"); 50 50 if($Enabled) 51 { 51 { 52 52 fputs($File, "/sbin/tc qdisc add dev ".$InInterface." root handle 1:0 htb default 2\n"); 53 53 fputs($FileClassInfo, "1:1 Základní\n"); … … 68 68 fputs($File, "/sbin/tc qdisc add dev ".$OutInterface." parent 1:".$FreeInetClass." handle ".$FreeInetClass.": sfq perturb 10\n"); 69 69 } 70 70 71 71 if(!$Enabled) die("Traffic shaping disabled\n"); 72 72 73 if($ClassesEnabled) 73 if($ClassesEnabled) 74 74 { 75 75 $ClassId = 3; … … 98 98 //$SpeedOut = round($UsersMaxSpeedOut / $InetUserCount); 99 99 $Prio = 1; 100 101 100 101 102 102 $AllUsersClassId = $ClassId; 103 103 $ClassId = $ClassId + 1; … … 123 123 fputs($FileClassInfo, '1:'.$TorrentClassId." Torrent\n"); 124 124 125 $DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)'); 125 $DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)'); 126 126 while($User = $DbResult->fetch_array()) 127 127 { … … 144 144 145 145 //echo('User class id: '.$UserClassId."\n"); 146 146 147 147 $DbResult2 = $Database->select('hosts', 'COUNT(*)', "block=0 AND MAC!='' AND user=".$User['id']); 148 148 $Row = $DbResult2->fetch_array(); … … 150 150 $HostSpeedIn = round($SpeedIn / $HostCount); 151 151 $HostSpeedOut = round($SpeedOut / $HostCount); 152 152 153 153 $DbResult2 = $Database->select('hosts','*',"block=0 AND MAC!='' AND user=".$User['id']); 154 154 while($Host = $DbResult2->fetch_array()) … … 164 164 $Prio = 1; 165 165 if($Host['vpn'] == 1) 166 167 168 169 170 171 172 //else 166 { 167 if($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip']; 168 else $Host['IP'] = ToVpnIp($Host); 169 } 170 171 //if($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5; 172 //else 173 173 $SpeedDivider = 1; 174 174 175 176 177 178 179 180 175 if($Host['name'] == 'centrala') 176 { 177 $Host['IP'] = $Host['external_ip']; 178 $TableOut = 'OUTPUT'; 179 $TableIn = 'INPUT'; 180 } else 181 181 { 182 183 184 185 //if($Row['name'] == 'TERMINAL2') $Prio = 0; 186 // 187 if($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp'; 188 189 // 182 $TableOut = 'FORWARD'; 183 $TableIn = 'FORWARD'; 184 } 185 //if($Row['name'] == 'TERMINAL2') $Prio = 0; 186 // if($Row['name'] = 'TERMINAL2') $Prio = 0; 187 if($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp'; 188 else $Protocol = ''; 189 // if($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000; 190 190 /* 191 if($Host['name'] == 'GAME') 192 193 exec('/sbin/iptables -t mangle -F game-server'); 194 195 196 191 if($Host['name'] == 'GAME') 192 { 193 exec('/sbin/iptables -t mangle -F game-server'); 194 $TableOut = 'game-server'; 195 $TableIn = 'game-server'; 196 }*/ 197 197 //if($Host['name'] == 'TBC') continue; 198 198 199 199 // In going traffic 200 //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$HostClassId); 201 202 203 204 205 200 //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$HostClassId); 201 fputs($File, "/sbin/tc class add dev ".$InInterface." parent 1:".$UserClassId." classid 1:".$HostClassId." htb rate ".$HostSpeedIn."bit ceil ".$UserMaxSpeedIn."bit prio ".$Prio." quantum ".$Quantum."\n"); 202 fputs($File, "/sbin/tc qdisc add dev ".$InInterface." parent 1:".$HostClassId." handle ".$HostClassId.":0 sfq perturb 10\n"); 203 //fputs($File, "/sbin/tc filter add dev ".$InInterface." parent 1:0 protocol ip handle ".$HostClassId." fw flowid 1:".$UserClassId."\n"); 204 fputs($File, "/sbin/tc filter add dev ".$InInterface." parent 1:0 protocol ip prio 1 u32 match ip dst ".$Host['external_ip']."/32 flowid 1:".$HostClassId."\n"); 205 206 206 // Out going traffic 207 207 //exec('/sbin/iptables -t mangle -A '.$TableOut.' -o eth1 -s '.$Host['IP'].$Protocol." -j MARK --set-mark ".$HostClassId); 208 209 210 211 212 208 fputs($File, "/sbin/tc class add dev ".$OutInterface." parent 1:".$UserClassId." classid 1:".$HostClassId." htb rate ".$HostSpeedOut."bit ceil ".$UserMaxSpeedOut."bit prio ".$Prio." quantum ".$Quantum."\n"); 209 fputs($File, "/sbin/tc qdisc add dev ".$OutInterface." parent 1:".$HostClassId." handle ".$HostClassId.":0 sfq perturb 10\n"); 210 //fputs($File, "/sbin/tc filter add dev ".$OutInterface." parent 1:0 protocol ip handle ".$HostClassId." fw flowid 1:".$UserClassId."\n"); 211 fputs($File, "/sbin/tc filter add dev ".$OutInterface." parent 1:0 protocol ip prio 1 u32 match ip src ".$Host['external_ip']."/32 flowid 1:".$HostClassId."\n"); 212 //echo($Row['id'].','); 213 213 } 214 214 // Free inet 215 215 if($Tarify[$User['inet_tarif_now']]['group_id'] == 3) 216 216 { 217 //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$FreeInetClass); 217 //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$FreeInetClass); 218 218 //exec('/sbin/iptables -t mangle -A '.$TableOut.' -o eth1 -s '.$Host['IP'].$Protocol." -j MARK --set-mark ".$FreeInetClass); 219 219 } 220 220 // VoIP devices 221 221 /* 222 if(($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP')) 222 if(($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP')) 223 223 { 224 224 exec('/sbin/iptables -t mangle -A '.$TableIn." -i eth1 -d ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId); 225 225 exec('/sbin/iptables -t mangle -A '.$TableOut." -o eth1 -s ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId); 226 } else 226 } else 227 227 if($Host['name'] == 'GAME') 228 228 { 229 exec('/sbin/iptables -t mangle -A FORWARD -o eth1 -s '.$Host['IP']." -j game-server"); 230 exec('/sbin/iptables -t mangle -A FORWARD -i eth1 -d '.$Host['IP']." -j game-server"); 231 229 exec('/sbin/iptables -t mangle -A FORWARD -o eth1 -s '.$Host['IP']." -j game-server"); 230 exec('/sbin/iptables -t mangle -A FORWARD -i eth1 -d '.$Host['IP']." -j game-server"); 231 232 232 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -j MARK --set-mark ".$TorrentClassId); 233 233 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -j MARK --set-mark ".$TorrentClassId); … … 237 237 238 238 // Local services 239 239 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p icmp -j MARK --set-mark ".$HostClassId); // ICMP 240 240 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p icmp -j MARK --set-mark ".$HostClassId); 241 241 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p tcp --sport 6969 -j MARK --set-mark ".$HostClassId); // web torrent 242 242 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --dport 6969 -j MARK --set-mark ".$HostClassId); 243 243 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p tcp --sport 80 -j MARK --set-mark ".$HostClassId); // web 244 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --dport 80 -j MARK --set-mark ".$HostClassId); 244 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --dport 80 -j MARK --set-mark ".$HostClassId); 245 245 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p tcp --sport 21 -j MARK --set-mark ".$HostClassId); // FTP 246 246 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --dport 21 -j MARK --set-mark ".$HostClassId); … … 252 252 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --dport 22 -j MARK --set-mark ".$HostClassId); 253 253 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p tcp --sport 443 -j MARK --set-mark ".$HostClassId); // https 254 254 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --dport 443 -j MARK --set-mark ".$HostClassId); 255 255 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p tcp --sport 27015 -j MARK --set-mark ".$HostClassId); // Counter Strike 256 256 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --dport 27015 -j MARK --set-mark ".$HostClassId); … … 259 259 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p tcp --sport 5906 -j MARK --set-mark ".$HostClassId); // VNC 260 260 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --dport 5906 -j MARK --set-mark ".$HostClassId); 261 262 261 262 // Remote services 263 263 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p tcp --dport 443 -j MARK --set-mark ".$HostClassId); // https 264 264 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --sport 443 -j MARK --set-mark ".$HostClassId); 265 265 exec('/sbin/iptables -t mangle -A game-server -o eth1 -s '.$Host['IP']." -p tcp --dport 80 -j MARK --set-mark ".$HostClassId); // http 266 267 266 exec('/sbin/iptables -t mangle -A game-server -i eth1 -d '.$Host['IP']." -p tcp --sport 80 -j MARK --set-mark ".$HostClassId); 267 268 268 } 269 269 */ -
trunk/Modules/NetworkConfigLinux/NetworkConfigLinux.php
r586 r738 13 13 $this->Dependencies = array('NetworkConfig'); 14 14 } 15 15 16 16 function DoInstall() 17 17 { 18 18 } 19 19 20 20 function DoUnInstall() 21 21 { -
trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php
r548 r738 6 6 $Path = array('ip', 'dhcp-server', 'lease'); 7 7 8 $Host = array(); 8 $Host = array(); 9 9 10 10 function ConvertExpireTime2($Time) -
trunk/Modules/NetworkConfigRouterOS/Generators/Common.php
r548 r738 6 6 { 7 7 global $Database; 8 8 9 9 $DbResult = $Database->query('SELECT `Id` FROM `NetworkMark` WHERE `Comment`="'.$Comment.'"'); 10 10 if($DbResult->num_rows > 0) … … 16 16 $DbResult = $Database->query('INSERT INTO `NetworkMark` (`Comment`) VALUES ("'.$Comment.'")'); 17 17 return($Database->insert_id); 18 } 18 } 19 19 } 20 20 … … 22 22 { 23 23 global $Database; 24 24 25 25 $DbResult = $Database->query('SELECT `Id` FROM `NetworkMangleSubgroup` WHERE `AddressRange`="'.$AddressRange.'"'); 26 26 if($DbResult->num_rows > 0) … … 32 32 $DbResult = $Database->query('INSERT INTO `NetworkMangleSubgroup` (`AddressRange`) VALUES ("'.$AddressRange.'")'); 33 33 return($Database->insert_id); 34 } 34 } 35 35 } 36 36 … … 38 38 { 39 39 global $Config; 40 40 41 41 $Found = false; 42 42 foreach($Tree['Items'] as $Index => $Node) … … 50 50 if($Found == false) 51 51 { 52 if($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and 52 if($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and 53 53 ($Address->Prefix > ($Tree['Address']->Prefix + 1))) 54 54 { … … 61 61 } else 62 62 { 63 63 64 64 $NewNode = array('Address' => $Address, 'Name' => $Name, 'Items' => array(), 'ForceMark' => $ForceMark); 65 65 66 66 // Should be existed items placed under new node? 67 67 $Found = false; 68 68 foreach($Tree['Items'] as $Index => $Node) 69 69 { 70 if(($Node['Address']->Address == $NewNode['Address']->Address) and 71 ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true; 72 70 if(($Node['Address']->Address == $NewNode['Address']->Address) and 71 ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true; 72 73 73 //echo($Index.','); 74 74 if($Address->Contain($Node['Address'])) … … 78 78 } 79 79 } 80 if($Found == false) $Tree['Items'][] = $NewNode; 80 if($Found == false) $Tree['Items'][] = $NewNode; 81 81 } 82 82 } … … 89 89 { 90 90 ShowSubnetNode($Item, $Indent + 1); 91 } 91 } 92 92 } 93 93 -
trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
r617 r738 29 29 $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => $Server, 'comment' => $Name); 30 30 } 31 32 print_r($Routerboard->ListUpdate($Path, array('mac-address', 'address', 'server', 'comment'), $Items, array('server' => $Server, 'dynamic' => 'no'))); 31 32 print_r($Routerboard->ListUpdate($Path, array('mac-address', 'address', 'server', 'comment'), $Items, array('server' => $Server, 'dynamic' => 'no'))); 33 33 echo("\n"); 34 34 } -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php
r617 r738 24 24 25 25 // Inet traffic groups 26 //$Items[] = array('chain' => 'forward', 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-out', 'comment' => 'inet-out'); 26 //$Items[] = array('chain' => 'forward', 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-out', 'comment' => 'inet-out'); 27 27 //$Items[] = array('chain' => 'forward', 'in-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-in', 'comment' => 'inet-in'); 28 28 … … 63 63 $DbResult2 = $System->Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']); 64 64 while($Subnet = $DbResult2->fetch_assoc()) 65 { 65 { 66 66 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); 67 67 echo($Subnet['Name'].'('.$Subnet['AddressRange'].'/'.$Subnet['Mask'].'), '); … … 75 75 else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask']; 76 76 $Items[] = array('chain' => 'forward', 'out-interface' => $InetInterface, 'src-address' => $Src, 'action' => 'drop','comment' => $Subnet['Name'].'-out-drop'); 77 77 78 78 $NewAddress = new NetworkAddressIPv4(); 79 79 $NewAddress->AddressFromString($Subnet['AddressRange']); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php
r735 r738 30 30 $NewAddress->AddressFromString($Subnet['AddressRange']); 31 31 $NewAddress->Prefix = $Subnet['Mask']; 32 InsertToAddressTree($AddressTree, $NewAddress, 'subnet-'.RouterOSIdent($Subnet['Name'])); 32 InsertToAddressTree($AddressTree, $NewAddress, 'subnet-'.RouterOSIdent($Subnet['Name'])); 33 33 } 34 34 … … 58 58 } 59 59 } 60 60 61 61 $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']); 62 62 while($Subnet = $DbResult2->fetch_assoc()) … … 80 80 { 81 81 global $InetInterface, $ItemsFirewall; 82 82 83 83 foreach($Node['Items'] as $Index => $Item) 84 84 { … … 89 89 $Address = $Item['Address']->AddressToString(); 90 90 if($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix; 91 91 92 92 $PacketMark = GetMarkByComment($Item['Name'].'-out'); 93 93 $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-out', 'src-address' => $Address, 'out-interface' => $InetInterface, 'action' => 'mark-packet', 'new-packet-mark' => $PacketMark, 'passthrough' => 'no', 'comment' => $Item['Name'].'-out'); … … 100 100 $SubnetId = GetSubgroupByRange($Item['Address']->AddressToString().'/'.$Item['Address']->Prefix); 101 101 $PacketMark = GetMarkByComment($Item['Name'].'-out'); 102 102 103 103 $Address = $Item['Address']->AddressToString(); 104 104 if($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix; 105 106 $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-out', 'src-address' => $Address, 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-out', 'comment' => $Item['Name'].'-out'); 107 $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-in', 'dst-address' => $Address, 'in-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-in', 'comment' => $Item['Name'].'-in'); 108 109 ProcessNode($Item); 110 } 105 106 $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-out', 'src-address' => $Address, 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-out', 'comment' => $Item['Name'].'-out'); 107 $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-in', 'dst-address' => $Address, 'in-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-in', 'comment' => $Item['Name'].'-in'); 108 109 ProcessNode($Item); 110 } 111 111 } 112 112 if($Node['ForceMark'] == true) … … 133 133 // Slow free internet 134 134 $PacketMark = GetMarkByComment('free-out'); 135 $ItemsFirewall[] = array('chain' => 'inet-1-out', 'out-interface' => $InetInterface, 135 $ItemsFirewall[] = array('chain' => 'inet-1-out', 'out-interface' => $InetInterface, 136 136 'action' => 'mark-packet', 'new-packet-mark' => $PacketMark, 'comment' => 'free-out', 'passthrough' => 'yes'); 137 137 $PacketMark = GetMarkByComment('free-in'); 138 $ItemsFirewall[] = array('chain' => 'inet-1-in', 'in-interface' => $InetInterface, 139 138 $ItemsFirewall[] = array('chain' => 'inet-1-in', 'in-interface' => $InetInterface, 139 'action' => 'mark-packet', 'new-packet-mark' => $PacketMark, 'comment' => 'free-in', 'passthrough' => 'no'); 140 140 // Unregistred clients add to address list 141 $ItemsFirewall[] = array('chain' => 'inet-1-out', 'out-interface' => $InetInterface, 'src-address' => '10.145.0.0/16', 142 'action' => 'add-src-to-address-list', 'address-list' => 'unregistred', 'timeout' => '1d', 143 141 $ItemsFirewall[] = array('chain' => 'inet-1-out', 'out-interface' => $InetInterface, 'src-address' => '10.145.0.0/16', 142 'action' => 'add-src-to-address-list', 'address-list' => 'unregistred', 'timeout' => '1d', 143 'comment' => 'unregistred-clients'); 144 144 145 145 //print_r($ItemsFirewall); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php
r735 r738 34 34 35 35 // Skip local subnet 36 //$Items[] = array('chain' => 'inet-out', 'dst-address' => '172.16.1.1/30', 'action' => 'accept', 'comment' => 'Local_subnet'); 36 //$Items[] = array('chain' => 'inet-out', 'dst-address' => '172.16.1.1/30', 'action' => 'accept', 'comment' => 'Local_subnet'); 37 37 //$Items[] = array('chain' => 'inet-in', 'dst-address' => '172.16.1.1/30', 'action' => 'accept', 'comment' => 'Local_subnet'); 38 38 … … 46 46 $DbResult2 = $System->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName`, `NetworkDevice`.`InboundNATPriority` FROM `NetworkInterface`'. 47 47 ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE (`NetworkInterface`.`ExternalIP` <> "")'. 48 ' AND (`NetworkInterface`.`LocalIP` <> "")'. 48 ' AND (`NetworkInterface`.`LocalIP` <> "")'. 49 49 ' AND (`NetworkDevice`.`Member` = '.$Member['Id'].') AND (`NetworkInterface`.`LocalIP` != `NetworkInterface`.`ExternalIP`) ORDER BY `id` DESC'); 50 50 while($Interface = $DbResult2->fetch_assoc()) … … 57 57 { 58 58 $Items[] = array('chain' => 'inet-out', 'src-address' => $Interface['LocalIP'], 'action' => 'src-nat', 'to-addresses' => $Interface['ExternalIP'], 'comment' => $Name.'-out'); 59 if($Interface['InboundNATPriority'] > 0) 59 if($Interface['InboundNATPriority'] > 0) 60 60 $Items[] = array('chain' => 'inet-in', 'dst-address' => $Interface['ExternalIP'], 'action' => 'dst-nat', 'to-addresses' => $Interface['LocalIP'], 'comment' => $Name.'-in'); 61 } else 61 } else 62 62 { 63 63 $Items[] = array('chain' => 'dstnat', 'src-address' => $Interface['LocalIP'], 'protocol' => 'tcp', 'dst-port' => 80, 'action' => 'dst-nat', 'to-addresses' => $IPCentrala, 'to-ports' => 81, 'comment' => $Name.'-out'); … … 68 68 $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']); 69 69 while($Subnet = $DbResult2->fetch_assoc()) 70 { 70 { 71 71 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); 72 72 echo($Subnet['Name'].'('.$Subnet['AddressRange'].'/'.$Subnet['Mask'].'), '); … … 82 82 else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask']; 83 83 $Items[] = array('chain' => 'inet-out', 'src-address' => $Src, 'action' => 'src-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-out'); 84 84 85 85 $NewAddress = new NetworkAddressIPv4(); 86 86 $NewAddress->AddressFromString($Subnet['AddressRange']); … … 114 114 115 115 // Accept free-access clients 116 $Items[] = array('chain' => 'dstnat', 'dst-address' => '!10.145.0.0/16', 117 'src-address-list' => 'free-access', 'in-interface' => $LocalInterface, 118 116 $Items[] = array('chain' => 'dstnat', 'dst-address' => '!10.145.0.0/16', 117 'src-address-list' => 'free-access', 'in-interface' => $LocalInterface, 118 'action' => 'accept', 'comment' => 'Free_access'); 119 119 // Redirect unregistred clients to free access activation page 120 $Items[] = array('chain' => 'dstnat', 'dst-address' => '!10.145.0.0/16', 121 'src-address-list' => 'unregistred', 'in-interface' => $LocalInterface, 122 120 $Items[] = array('chain' => 'dstnat', 'dst-address' => '!10.145.0.0/16', 121 'src-address-list' => 'unregistred', 'in-interface' => $LocalInterface, 122 'action' => 'dst-nat', 'to-addresses' => '10.145.64.8', 'to-ports' => 82, 'comment' => 'Redirect_unregistred'); 123 123 124 124 /* -
trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php
r617 r738 35 35 } 36 36 } 37 $Routerboard->ListUpdate($Path, array('host', 'interval', 'comment'), $Items); 37 $Routerboard->ListUpdate($Path, array('host', 'interval', 'comment'), $Items); 38 38 echo("\n"); 39 39 } -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r697 r738 21 21 // Load netwatch status from all DHCP routers 22 22 $DbResult3 = $System->Database->query('SELECT `DHCP`, `AddressRange`, `Mask` FROM `NetworkSubnet` '. 23 23 'WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP'); 24 24 while($Subnet = $DbResult3->fetch_assoc()) 25 25 { … … 54 54 array('LastOnline' => TimeToMysqlDateTime($StartTime))); 55 55 56 56 if($Interface['Online'] != $Interface['NewOnline']) 57 57 { 58 58 // Online state changed 59 59 $DbResult = $System->Database->query('INSERT INTO `NetworkInterfaceUpDown` (`Interface`, 60 60 `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'. 61 61 TimeToMysqlDateTime($StartTime).'", NULL)'); 62 62 // Update previous record duration in UpDown table … … 64 64 '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '. 65 65 'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '. 66 66 'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Interface['Id'].')'); 67 67 $System->Database->update('NetworkInterface', '`Id` = "'.$Interface['Id'].'"', 68 68 array('Online' => $Interface['NewOnline'])); … … 75 75 while($DbRow = $DbResult->fetch_assoc()) 76 76 { 77 77 echo('IP '.$DbRow['LocalIP'].' online but time not updated.'."\n"); 78 78 } 79 79 $DbResult = $System->Database->select('NetworkInterface', '*', '(`Online` = 0) AND '. -
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r726 r738 22 22 { 23 23 global $UsedNames; 24 24 25 25 if(in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name); 26 26 else $UsedNames[] = $Name; … … 53 53 if($DbResult->num_rows == 1) 54 54 { 55 55 $Service = $DbResult->fetch_array(); 56 56 $FreeInetSpeed = $Service['InternetSpeedMax'] * 1000; 57 57 } else $FreeInetSpeed = 0; … … 128 128 } 129 129 } 130 130 131 131 $DbResult2 = $System->Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']); 132 132 while($Subnet = $DbResult2->fetch_assoc()) -
trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php
r682 r738 35 35 if($DbResult->num_rows > 0) 36 36 { 37 37 $DbRow = $DbResult->fetch_assoc(); 38 38 $Interface = $DbRow['Id']; 39 39 } else $Interface = null; -
trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php
r735 r738 28 28 function DoStart() 29 29 { 30 30 $this->System->Pages['zdarma'] = 'PageFreeAccess'; 31 31 $this->System->FormManager->RegisterClass('NetworkInterfaceUpDown', array( 32 32 'Title' => 'Změny stavu rozhraní', … … 44 44 } 45 45 46 class PageFreeAccess extends Page 46 class PageFreeAccess extends Page 47 47 { 48 48 var $FullTitle = 'Přístup zdarma k Internetu'; … … 51 51 var $AddressList = 'free-access'; 52 52 var $Timeout; 53 53 54 54 function __construct($System) 55 55 { 56 57 56 parent::__construct($System); 57 $this->Timeout = 24 * 60 * 60; 58 58 } 59 60 61 62 63 if(IsInternetAddr($IPAddress)) 64 return('<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>'); 65 66 67 68 69 if($DbResult->num_rows > 0) 70 71 72 $ActivationTime = MysqlDateTimeToTime($DbRow['Time']); 73 if(($ActivationTime + $this->Timeout) < $Time) 59 60 function Show() 61 { 62 $IPAddress = GetRemoteAddress(); 63 if(IsInternetAddr($IPAddress)) 64 return('<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>'); 65 $Time = time(); 66 67 $DbResult = $this->Database->select('NetworkFreeAccess', '*', '(IPAddress="'.$IPAddress. 68 '") ORDER BY Time DESC LIMIT 1'); 69 if($DbResult->num_rows > 0) 70 { 71 $DbRow = $DbResult->fetch_assoc(); 72 $ActivationTime = MysqlDateTimeToTime($DbRow['Time']); 73 if(($ActivationTime + $this->Timeout) < $Time) 74 74 { 75 76 } else $Activated = true; 77 78 79 if(array_key_exists('a', $_GET)) 80 81 if($_GET['a'] == 'activate') 82 83 if($Activated == false) 84 85 $DbResult = $this->Database->insert('NetworkFreeAccess', 86 array('IPAddress' => $IPAddress, 'Time' => TimeToMysqlDateTime(time()), 87 88 89 90 91 } 92 93 94 //$Output .= 'Vaše adresa IP je: '.GetRemoteAddress().'<br/>'; 95 $Output .= '<p>Pro přístup k Internetu zdarma sdílenou rychlostí 128/128 kbit/s klikněte na odkaz níže. 96 97 98 99 100 101 102 103 75 $Activated = false; 76 } else $Activated = true; 77 } else $Activated = false; 78 79 if(array_key_exists('a', $_GET)) 80 { 81 if($_GET['a'] == 'activate') 82 { 83 if($Activated == false) 84 { 85 $DbResult = $this->Database->insert('NetworkFreeAccess', 86 array('IPAddress' => $IPAddress, 'Time' => TimeToMysqlDateTime(time()), 87 'Configured' => 0)); 88 $ActivationTime = $Time; 89 $Activated = true; 90 } 91 } 92 } 93 $Output = '<div style="text-align:center;"><h3>Vítejte v síti ZděchovNET</h3></div>'; 94 //$Output .= 'Vaše adresa IP je: '.GetRemoteAddress().'<br/>'; 95 $Output .= '<p>Pro přístup k Internetu zdarma sdílenou rychlostí 128/128 kbit/s klikněte na odkaz níže. 96 Internet bude zpřístupněn po dobu 24 hodin. Po uplynutí této doby je potřeba provést novou aktivaci.</p>'; 97 $Output .= '<p>Pokud jste platícím zákazníkem a přesto se vám zobrazuje tato stránka, tak pravděpodobně nemáte registrovano v síti vaše klientské zařízení.</p>'; 98 99 $PrefixMultiplier = new PrefixMultiplier(); 100 if($Activated) $Output .= 'Aktivováno. Vyprší za '.$PrefixMultiplier->Add($ActivationTime + $this->Timeout - $Time, '', 4, 'Time'); 101 else $Output .= '<a href="?a=activate">Aktivovat</a>'; 102 103 return($Output); 104 104 } 105 105 } … … 107 107 class ScheduleConfigureFreeAccess extends SchedulerTask 108 108 { 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 109 function Execute() 110 { 111 $Output = ''; 112 $Commands = array(); 113 $DbResult = $this->Database->select('NetworkFreeAccess', '`Id`, `IPAddress`', '(`Configured`=0)'); 114 while($DbRow = $DbResult->fetch_assoc()) 115 { 116 $Commands[] = '/ip firewall address-list add address='.$DbRow['IPAddress']. 117 ' list=free-access timeout=1d'; 118 } 119 $DbResult = $this->Database->update('NetworkFreeAccess', '`Configured`=0', array('Configured' => 1)); 120 121 $Routerboard = new Routerboard($this->System->Config['MainRouter']['HostName']); 122 $Routerboard->UserName = $this->System->Config['MainRouter']['UserName']; 123 $Routerboard->Timeout = $this->System->Config['MainRouter']['ConnectTimeout']; 124 $Routerboard->Debug = true; 125 $Routerboard->ExecuteBatch(implode(';', $Commands)); 126 127 return($Output); 128 } 129 129 } -
trunk/Modules/NetworkConfigRouterOS/Routerboard2.php
r548 r738 67 67 function GetDHCPServerLeasesList() 68 68 { 69 return($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name'))); 69 return($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name'))); 70 70 } 71 71 } -
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r704 r738 48 48 if($this->SSL) 49 49 { 50 50 $IP = 'ssl://'.$IP; 51 51 } 52 52 $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout); -
trunk/Modules/NetworkConfigRouterOS/SSH.php
r548 r738 37 37 /* 38 38 //echo(') '.strlen($Buffer).' '.ord($Buffer{0}).'('); 39 for($I = 0; $I < strlen($Buffer); $I++) 39 for($I = 0; $I < strlen($Buffer); $I++) 40 40 { 41 41 if(((ord($Buffer{$I}) >= 32) and (ord($Buffer{$I}) <= 128)) or ($Buffer{$I} = "\n") or ($Buffer{$I} = "\r")) echo($Buffer{$I}); … … 55 55 echo($Response); 56 56 return(explode("\n", substr($Response, 0, -1))); 57 } 57 } 58 58 } -
trunk/Modules/NetworkShare/NetworkShare.php
r586 r738 17 17 $this->Dependencies = array('Network'); 18 18 } 19 19 20 20 function DoInstall() 21 21 { 22 22 } 23 23 24 24 function DoUnInstall() 25 25 { -
trunk/Modules/NetworkShare/SharePage.php
r584 r738 74 74 75 75 // Default host list view 76 if((count($_POST) == 0) and (count($_GET) == 0)) 76 if((count($_POST) == 0) and (count($_GET) == 0)) 77 77 { 78 78 $_POST['view'] = 1; 79 $_POST['page'] = 0; 79 $_POST['page'] = 0; 80 80 } 81 81 … … 101 101 102 102 // Log search 103 if(array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET)) 103 if(array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET)) 104 104 $this->System->ModuleManager->Modules['Log']->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']); 105 105 … … 218 218 $Pocet = $Row[0]; 219 219 220 if($Pocet > 0) 220 if($Pocet > 0) 221 221 { 222 222 $Output .= 'Nalezeno celkem: '.$Pocet.' položek<br />'; 223 } else 223 } else 224 224 $Output .= 'Podle zadaných podmínek nic nenalezeno'; 225 225 if(($Pocet > 0) || ($upstr)) … … 228 228 <tr><th bgcolor="#E0E0FF"><a href="index.php?order=name">Soubor</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=ext">Přípona</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=size">Velikost</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=date">Datum</a></th><th bgcolor="#E0E0FF">Umístění</th></tr>'; 229 229 $Output .= $upstr; 230 if($Pocet > 0) 230 if($Pocet > 0) 231 231 { 232 232 // Zobrazení tabulky s výsledky … … 260 260 } 261 261 } 262 if($Pocet > 0) 262 if($Pocet > 0) 263 263 { 264 264 // Celkový přehled -
trunk/Modules/NetworkShare/browse.php
r548 r738 4 4 $SambaSbinDir = '/usr/sbin/'; 5 5 $Database->select_db('share'); 6 $ZanoreniMax = 8; 7 $MaxProgress = 70; 6 $ZanoreniMax = 8; // Maximální úroven zanoreni 7 $MaxProgress = 70; // Pocet casti stavu prubehu operace 8 8 $StartTime = time(); 9 $MountDir = '/tmp/browse/host'; 10 $TempDir = '/tmp/browse/'; 9 $MountDir = '/tmp/browse/host'; // Složka, kde se dočasně připojují síťové disky 10 $TempDir = '/tmp/browse/'; // Složka, kde se dočasně připojují síťové disky 11 11 if(!is_dir($TempDir)) mkdir($TempDir, 0777); 12 12 if(!is_dir($MountDir)) mkdir($MountDir, 0777); … … 44 44 { 45 45 global $Citac, $Soubor, $Host, $HostID, $Share, $ZanoreniMax, $Pocet, $Hotovo, $MountDir, $TempDir, $FileSize, $MaxProgress, $Database; 46 46 47 47 $VelikostSlozky = 0; 48 48 //$Vlozit = ''; … … 93 93 $Nazev = ltrim(substr($Radek,strlen($Time)+1)); 94 94 //echo($Date.','.$Time.','.$Radek.' '); 95 95 96 96 if((strpos($Nazev,'.') > 0) && ($Type != 2)) 97 97 { … … 101 101 //$Vlozit .= "INSERT INTO NetworkShareItem (name,size,date,ext,parent,type,host) ". 102 102 //"VALUES ('$Nazev','$Velikost',NOW(),'$Ext','$Parent','$Type','$HostID'); "; 103 103 104 104 $Database->insert('NetworkShareItem', array( 105 105 'name' => $Nazev, … … 114 114 $Citac = $Citac + 1; 115 115 // Pokud jde o sloľku, tak projdi jeji obsah a aktualizuj velikost 116 if($Type == 2) 116 if($Type == 2) 117 117 { 118 118 //echo($Vlozit); … … 120 120 // $Vlozit = ''; 121 121 $VelikostSlozky += Vetev($Cesta.$Nazev.'/',$Zanoreni+1); 122 } 122 } 123 123 } 124 124 //echo($Vlozit); 125 125 //if($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky 126 126 127 127 // Aktualizuj velikost 128 128 //DB_Query("SELECT SUM(size) FROM NetworkShareItem WHERE (parent=".$Parent.")"); … … 134 134 135 135 // Proskenuj jednotlive sdileni 136 $Database->query('DELETE FROM NetworkShareItem WHERE host='.$HostID); 136 $Database->query('DELETE FROM NetworkShareItem WHERE host='.$HostID); // Smaz predchozi polozky 137 137 138 138 // Zapis nazev pocitace … … 185 185 $Soubor = fopen($TempDir.$Host.'.list','r'); 186 186 $Citac = 0; 187 Vetev('/', 0); 188 fclose($Soubor); 189 unlink($TempDir.$Host.'.list'); 187 Vetev('/', 0); // Skenuj sdileni 188 fclose($Soubor); // Uzavřít soubor 189 unlink($TempDir.$Host.'.list'); // Smazat soubor stromu adresářové struktury 190 190 //echo(str_repeat('#',40-$Pocet)); 191 191 echo("] $Citac\n"); 192 192 //} else echo("CHYBA\n"); 193 193 } else echo('Soubor sdílení nenalezen!'); 194 passthru('umount '.$MountDir); 194 passthru('umount '.$MountDir); // Odpojit sitovy disk 195 195 } 196 196 … … 215 215 $DbResult = $Database->query('SELECT id FROM hosts'); 216 216 $Vyber = ''; 217 while($Row = $DbResult->fetch_array()) 217 while($Row = $DbResult->fetch_array()) 218 218 $Vyber .= $Row['id'].','; 219 219 220 220 $Database->select_db('share'); 221 221 $DbResult = $Database->query("SELECT SUM(size) FROM NetworkShareItem WHERE ((parent=1) AND (host IN (".substr($Vyber,0,-1).')))'); … … 226 226 echo("Chyby sdílení...\n"); 227 227 $Database->delete('NetworkShareError', 'host="'.$Host.'"'); 228 if(is_dir($TempDir.'errors')) 228 if(is_dir($TempDir.'errors')) 229 229 { 230 230 $Dir = scandir($TempDir.'errors'); 231 231 foreach($Dir as $File) 232 { 232 { 233 233 if(substr($File, 0, strpos($File, '_')) == $Host) 234 234 { … … 241 241 { 242 242 $Row = fgets($ErrorFile); 243 if($Row != '') 243 if($Row != '') 244 244 { 245 245 $Row = substr($ShareFull.'/'.substr($Row, 39), 0, -1); … … 249 249 } 250 250 fclose($ErrorFile); 251 } 251 } 252 252 } 253 253 } -
trunk/Modules/NetworkShare/firefox.php
r548 r738 8 8 <!-- 9 9 function addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory){ 10 10 var msg="Přidání vyhledávacího modulu selhalo - "; 11 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 } 12 if((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){ 13 if(engineURL == null || engineURL == ""){ 14 alert(msg + "nebyla zadána jeho URL."); 15 return false; 16 } 17 if(iconURL == null || iconURL == ""){ 18 alert(msg + "nebyla zadána URL ikony."); 19 return false; 20 } 21 if(engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1){ 22 alert(msg + "nebyla zadána platná URL."); 23 return false; 24 } 25 if(iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1){ 26 alert(msg + " nebyla platná URL ikony."); 27 return false; 28 } 29 if(suggestedTitle == null) suggestedTitle = ""; 30 if(suggestedCategory == null) suggestedCategory = ""; 31 window.sidebar.addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory); 32 }else{ 33 alert("Váš prohlížeč nepodporuje tuto funkci. Zkuste Mozillu."); 34 } 35 return false; 36 } 37 37 //--> 38 38 </script>'); 39 echo(' 39 echo(' 40 40 Pomocí <a href="http://centrala/share/prohledavac_sdileni8.src" onclick="return addSearchEngine(\'http://centrala/share/prohledavac_sdileni8.src\', \'http://centrala/share/prohledavac_sdileni8.gif\', \'Prohledávač sdílení sítě ZděchovNET\', \'Web\')">tohoto odkazu</a> přidáte tento prohledávač sdílení do políčka Hledat ve vašem internetovém prohlížeči Mozilla Firefox. Pak můžete vyhledávat zjednodušeně zadáím hesel do tohoto políčka.<br><br> 41 41 <div align="center"><img src="firefox.png" alt="Firefox"></div>'); -
trunk/Modules/NetworkShare/online.php
r548 r738 12 12 echo("OK\n\nSeznam online pocitacu:\n"); 13 13 array_shift($Output); 14 $Online = array(); 14 $Online = array(); // Seznam online pocitacu 15 15 foreach($Output as $Radek) 16 16 { … … 35 35 { 36 36 $Output = array(); 37 37 38 38 //echo('arping -c 1 '.$Host); 39 39 exec('arping -c 1 '.$Host,$Output); 40 40 if(count($Output)!=4) 41 { 41 { 42 42 $Output = array(); 43 43 exec('arping -I wlan0 -c 1 '.$Host,$Output); 44 44 if(count($Output)!=4) 45 { 45 { 46 46 $Output = array(); 47 47 exec('arping -I wlan1 -c 1 '.$Host,$Output); 48 48 if(count($Output)!=4) 49 { 49 { 50 50 $Output = array(); 51 51 exec('arping -I wlan2 -c 1 '.$Host,$Output); 52 if(count($Output)!=4) 52 if(count($Output)!=4) 53 53 { 54 54 $Output = array(); … … 71 71 // Deaktivuj predchozi online pocitace 72 72 $Database->update('hosts', 1, array('online' => 0)); 73 73 74 74 //print_r($Online); 75 75 // Aktivuj online pocitace … … 82 82 } else $Database->insert('hosts',array('name' => $Item['host'], 'IP' => $Item['IP'], 'MAC' => $Item['MAC'], 'online' => 1,'date' => 'NOW()','lastdate' => 'NOW()', 'section' => $Section)); 83 83 } 84 84 85 85 echo("\nSeznam offline pocitacu:\n"); 86 86 $DbResult = $Database->query("SELECT * FROM hosts WHERE online=0"); -
trunk/Modules/NetworkShare/playlist.php
r548 r738 6 6 $Vyber = ''; 7 7 $Podminka = ''; 8 while($Row = $DbResult->fetch_array()) 8 while($Row = $DbResult->fetch_array()) 9 9 $Vyber .= $Row['id'].','; 10 10 $Podminka .= ' AND (host IN ('.substr($Vyber,0,-1).'))'; … … 20 20 { 21 21 global $MaxNesting, $Database; 22 22 23 23 // Vyhled�n� cesty 24 24 $Otec = $Row['parent']; -
trunk/Modules/NetworkShare/update.php
r548 r738 1 1 <?php 2 2 3 //$Perioda = 3600*3; 3 //$Perioda = 3600*3; // prochazet po tech hodinach 4 4 5 5 $Dnes = date('Y-m-d'); … … 12 12 { 13 13 //echo('Host: '.$Host."...\n"); 14 14 15 15 //echo(.','.$Row['date']."\n"); 16 16 $HostID = 100; 17 17 $StartTime2 = GetMicrotime(); 18 if($Dnes != $Row['last_share_check']) 18 if($Dnes != $Row['last_share_check']) 19 19 { 20 20 echo("Kontroluji ".$Row['Name']."...\n"); … … 22 22 } 23 23 else echo("Vynechavam ".$Row['Name']."...\n"); 24 // Aktualizuj datum prochazeni 24 // Aktualizuj datum prochazeni 25 25 $Database->update('Hosts', "name='".$Row['name']."'",array('last_share_check' => $Dnes)); 26 26 } 27 27 $Rozdil = GetMicrotime()-$StartTime+10; 28 28 29 29 // Oprav a zoptimalizuj tabulku 30 30 //$Database->select_db('share'); … … 33 33 echo("\nOptimalizuji tabulku..."); 34 34 $Database->query('OPTIMIZE TABLE NetworkShareItem'); 35 35 36 36 echo("\nDoba procháení ".date("H:i:s",$Rozdil-3600)."\n\n"); 37 37 //$Cekat = $Perioda-$Rozdil; -
trunk/Modules/NetworkTopology/NetworkTopology.php
r586 r738 7 7 var $ParentClass = 'PagePortal'; 8 8 var $TopHostName = 'NIX-ROUTER'; 9 9 10 10 function Show() 11 11 { 12 12 if(count($this->System->PathItems) > 1) 13 { 13 { 14 14 if($this->System->PathItems[1] == 'topologie.png') return($this->ShowImage()); 15 15 else return(PAGE_NOT_FOUND); 16 16 17 17 } else return($this->ShowOverview()); 18 18 } 19 19 20 20 function ShowImage() 21 21 { … … 31 31 $width = $item[0]; 32 32 $height = $item[1]; 33 33 34 34 $spacex = 32; 35 35 $spacey = 68; 36 36 $halfx = $spacex / 2; 37 37 $halfy = $spacey / 2; 38 // Načtení pomocných obrázků 38 // Načtení pomocných obrázků 39 39 $im_comp = imagecreatefrompng(dirname(__FILE__).'/images/comp.png'); 40 40 $im_dev = imagecreatefrompng(dirname(__FILE__).'/images/device.png'); … … 47 47 $blue = imagecolorallocate($im, 100, 100, 255); 48 48 $gray = imagecolorallocate($im, 160, 160, 160); 49 49 50 50 //$DbResult = $Database->query("SELECT * FROM hosts, NetworkTopology WHERE host = id AND used=1"); 51 51 $DbResult = $this->Database->query('SELECT NetworkTopology.*, NetworkTopology.Host AS Id, '. … … 98 98 } 99 99 } 100 100 101 101 // === Sestavení výsledného souboru ============================================ 102 102 if($debug == 0) 103 103 { 104 104 Header("Content-type: image/png"); 105 Header("Cache-Control: no-cache"); 105 Header("Cache-Control: no-cache"); // Dynamický graf, nekešovat 106 106 imagepng($im); 107 107 imagedestroy($im); … … 111 111 return(''); 112 112 } 113 113 114 114 function ShowOverview() 115 115 { … … 142 142 $this->Dependencies = array('Network'); 143 143 } 144 144 145 145 function DoInstall() 146 146 { 147 147 } 148 148 149 149 function DoUnInstall() 150 150 { -
trunk/Modules/NetworkTopology/topologie-img.php
r548 r738 9 9 10 10 // === Zpětné vyvážení stromu do hloubky ======================================= 11 function balance($id, $level, &$vlast, &$vleft, &$vpred, &$vfirst, &$vnext, &$tbound, &$width, $limit) 11 function balance($id, $level, &$vlast, &$vleft, &$vpred, &$vfirst, &$vnext, &$tbound, &$width, $limit) 12 12 { 13 13 global $debug, $bbound; 14 14 15 15 if(!array_key_exists($id, $vfirst)) $vfirst[$id] = 0; 16 if($i = $vfirst[$id]) 16 if($i = $vfirst[$id]) 17 17 { 18 18 //if ($debug==2) echo $id.':'.@$i.','.@$vpred[$i].'-'.@$vleft[@$vpred[$i]]."\n"; 19 if (($vlast[$id] > 0) && ($vleft[$id] > $vleft[$vlast[$id]])) 19 if (($vlast[$id] > 0) && ($vleft[$id] > $vleft[$vlast[$id]])) 20 20 { 21 21 $diff=$vleft[$id]-$vleft[$vlast[$id]]; 22 22 $i=$vfirst[$id]; 23 if ($vleft[$id] >= $tbound[$level]) 23 if ($vleft[$id] >= $tbound[$level]) 24 24 { 25 25 $tbound[$level] = $vleft[$id] + 2; … … 28 28 } else { 29 29 $diff=0; 30 if ($vpred[$i]&&($vleft[$i]<=$vleft[$vpred[$i]])) 30 if ($vpred[$i]&&($vleft[$i]<=$vleft[$vpred[$i]])) 31 31 { 32 32 $diff=$vleft[$i]-$vleft[$vpred[$i]]+2; 33 33 } else $i = 0; 34 34 } 35 while ($i>0) 35 while ($i>0) 36 36 { 37 37 $vleft[$i]+=$diff; … … 45 45 // === Generování rovinné stromové struktury =================================== 46 46 function gentree($mode) // depth-first algorithm 47 { 47 { 48 48 global $debug, $TopHostName, $Database; 49 49 50 50 // --- Inicializace ---------------------------------------------------------- 51 51 $tbound = array(); // Hranice pozic jednotlivých úrovní … … 58 58 $vtop = array(); // Pozice prvku shora 59 59 $vpred = array(); // Vedlejsi prvek na řádku 60 60 61 61 $index = 0; // Index aktuálního prvku 62 62 $curr = 0; // Aktuální prvek … … 68 68 $position[$level] = 0; // Aktuální pozice prvku na dané úrovni 69 69 $count[$level] = 0; // Počet prvků na dané úrovni 70 70 71 71 $maxindex = 0; 72 72 $tbound[$level] = 0; 73 73 $tranger[$level] = 0; 74 74 75 75 // --- Hlavní cyklus --------------------------------------------------------- 76 do 76 do 77 77 { 78 78 // --- Proveď databázový dotaz ----------------------------------------------- 79 79 $query = 'SELECT * FROM hosts WHERE used=1 AND '; 80 if ($level == 0) 81 { 82 $query .= 'name = "'.$TopHostName.'" ORDER BY id'; 83 } else 80 if ($level == 0) 81 { 82 $query .= 'name = "'.$TopHostName.'" ORDER BY id'; 83 } else 84 84 { 85 85 $query .= ' parent = '.$parent[$level].' ORDER BY id'; … … 91 91 $item = $DbResult->fetch_array(); 92 92 //print_r($item); 93 if($item) 93 if($item) 94 94 { 95 95 // --- Zpracování položky z DB ----------------------------------------------- 96 if($position[$level] > 0) 96 if($position[$level] > 0) 97 97 { 98 98 $vnext[$curr] = $item['id']; // Neprvní položka, nastav předchozí … … 114 114 $DbResult = $Database->query('SELECT COUNT(*) FROM hosts WHERE used=1 AND parent = '.$curr); 115 115 $childcnt = $DbResult->fetch_array(); 116 if ($childcnt[0] > 0) 117 { 116 if ($childcnt[0] > 0) 117 { 118 118 // Uzelový vrchol 119 if(array_key_exists($level + 1, $tbound)) 119 if(array_key_exists($level + 1, $tbound)) 120 120 if($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1]; 121 121 } 122 122 $tbound[$level] = $vleft[$curr] + 2; 123 123 if ($vleft[$curr] > $width) $width = $vleft[$curr]; 124 if ($childcnt[0] > 0) 124 if ($childcnt[0] > 0) 125 125 { 126 126 $level++; … … 130 130 $count[$level] = 0; 131 131 } else $index++; // Listový vrchol 132 } else 132 } else 133 133 { 134 134 // --- Zarovnávání prvků kvůli vzhledu 135 135 if(!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0; 136 136 if(!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0; 137 if ($vleft[$vfirst[$parent[$level]]] > $vleft[$parent[$level]]) 137 if ($vleft[$vfirst[$parent[$level]]] > $vleft[$parent[$level]]) 138 138 { 139 139 $vleft[$parent[$level]] = $vleft[$vfirst[$parent[$level]]]; … … 141 141 } 142 142 balance($parent[$level],$level, $vlast,$vleft,$vpred,$vfirst,$vnext,$tbound, $width, 0); 143 if ($position[$level]==1) 143 if ($position[$level]==1) 144 144 { 145 145 $vleft[$vfirst[$parent[$level]]] = $vleft[$parent[$level]]; … … 149 149 if(!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0; 150 150 $curr = $vlast[$parent[$level]]; 151 151 152 152 if(!array_key_exists($level, $tbound)) $tbound[$level] = 0; 153 153 if(!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0; … … 165 165 $datawidth = $data['width']; 166 166 for($i = 0; $i <= $maxindex; $i++) 167 { 167 { 168 168 if(!array_key_exists($i, $vleft)) $vleft[$i] = 0; 169 169 if(!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0; … … 179 179 $IconList = array(); 180 180 $DbResult = $Database->query('SELECT * FROM HostType'); 181 while($HostType = $DbResult->fetch_assoc()) 181 while($HostType = $DbResult->fetch_assoc()) 182 182 $IconList[$HostType['Id']] = imagecreatefrompng('images/'.$HostType['IconName'].'.png'); 183 183 … … 191 191 $gray = imagecolorallocate($im, 160, 160, 160); 192 192 193 function xpos($id) 193 function xpos($id) 194 194 { 195 195 global $vleft, $spacex; … … 198 198 199 199 $DbResult = $Database->query('SELECT * FROM hosts JOIN HostType ON HostType.Id = hosts.type WHERE hosts.used=1'); 200 while($item = $DbResult->fetch_array()) 200 while($item = $DbResult->fetch_array()) 201 201 { 202 202 $id = $item['id']; 203 203 if(!array_key_exists($id, $vtop)) $vtop[$id] = 0; 204 if(($vtop[$id] > 0) || ($item['name'] == $TopHostName)) 204 if(($vtop[$id] > 0) || ($item['name'] == $TopHostName)) 205 205 { 206 206 if($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black); 207 207 if(!array_key_exists($id, $vfirst)) $vfirst[$id] = 0; 208 if($vfirst[$id] > 0) 208 if($vfirst[$id] > 0) 209 209 { 210 210 imageline($im, xpos($vfirst[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, xpos($vlast[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, $black); 211 211 imageline($im, xpos($id) + $halfx, ($vtop[$id] + 1) * $spacey - 10, xpos($id) + $halfx, ($vtop[$id] + 1) * $spacey, $black); 212 212 } 213 213 214 214 $image = $IconList[$item['type']]; 215 215 if($item['IP'] == '') … … 228 228 imagecopy($im, $image, xpos($id) + $halfx - 15, $vtop[$id] * $spacey + 12, 0, 0, 30, 30); 229 229 // imagerectangle($im,xpos($id)+$halfx-6,$vtop[$id]*$spacey+16,xpos($id)+$halfx+6,$vtop[$id]*$spacey+28,$color); 230 if($debug) 230 if($debug) 231 231 { 232 232 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['id']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), $item['id'], $color); 233 } else 233 } else 234 234 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['name']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), strtoupper($item['name']), $color); 235 235 } -
trunk/Modules/NetworkTopology/topologie2.php
r577 r738 38 38 } 39 39 40 $this->Tree = $Hosts[$this->TopHostId]; 40 $this->Tree = $Hosts[$this->TopHostId]; 41 41 } 42 42 43 43 function CalculateDimension(&$Host) 44 44 { … … 66 66 67 67 function MoveNode(&$Host, $Displacement) 68 { 68 { 69 69 $Host['displacement'] = $Host['displacement'] + $Displacement; 70 70 foreach($Host['subitems'] as $Index => $SubHost) … … 92 92 $II = 0; 93 93 while($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++; 94 while($II < count($RightHost['parent_node']['subitems'])) 94 while($II < count($RightHost['parent_node']['subitems'])) 95 95 { 96 96 $this->MoveNode($RightHost['parent_node']['subitems'][$II], $Level[$I]['displacement'] - $Level[$I + 1]['displacement']); … … 100 100 } 101 101 } 102 102 103 103 function BuildLevels(&$Host) 104 104 { … … 116 116 { 117 117 $HostPos = array('x' => -$this->RelPos['min'] + $SubHost['displacement'], 'y' => $SubHost['level'] * $this->HostHeight); 118 imageline($this->Image, $ParentHostPos['x'], $ParentHostPos['y'], $ParentHostPos['x'], $ParentHostPos['y'] + $this->HostHeight * 0.5, $this->LineColor); 119 imageline($this->Image, $ParentHostPos['x'], $ParentHostPos['y'] + $this->HostHeight * 0.5, $HostPos['x'], $ParentHostPos['y'] + $this->HostHeight * 0.5, $this->LineColor); 120 imageline($this->Image, $HostPos['x'], $ParentHostPos['y'] + $this->HostHeight * 0.5, $HostPos['x'], $HostPos['y'], $this->LineColor); 118 imageline($this->Image, $ParentHostPos['x'], $ParentHostPos['y'], $ParentHostPos['x'], $ParentHostPos['y'] + $this->HostHeight * 0.5, $this->LineColor); 119 imageline($this->Image, $ParentHostPos['x'], $ParentHostPos['y'] + $this->HostHeight * 0.5, $HostPos['x'], $ParentHostPos['y'] + $this->HostHeight * 0.5, $this->LineColor); 120 imageline($this->Image, $HostPos['x'], $ParentHostPos['y'] + $this->HostHeight * 0.5, $HostPos['x'], $HostPos['y'], $this->LineColor); 121 121 $this->DrawNode(&$Host['subitems'][$Index]); 122 122 imagecopy($this->Image, $this->ImageComputer, $HostPos['x'] - imagesx($this->ImageComputer) * 0.5, $HostPos['y'] - imagesy($this->ImageComputer) * 0.5, 0, 0, 30, 30); -
trunk/Modules/News/ImportKinoVatra.php
r622 r738 16 16 $doc = new DOMDocument(); 17 17 $doc->load($SourceURL); 18 foreach($doc->getElementsByTagName('item') as $node) 18 foreach($doc->getElementsByTagName('item') as $node) 19 19 { 20 20 $Title = $node->getElementsByTagName('title')->item(0)->nodeValue; 21 21 $Description = $node->getElementsByTagName('description')->item(0)->nodeValue; 22 $Link = $node->getElementsByTagName('link')->item(0)->nodeValue; 22 $Link = $node->getElementsByTagName('link')->item(0)->nodeValue; 23 23 $Date = $node->getElementsByTagName('pubDate')->item(0)->nodeValue; 24 24 25 25 $Description = strip_tags($Description); 26 26 $Description = str_replace("\r", '', $Description); … … 29 29 // $Date = substr($Date, $CommaPos + 1); 30 30 $Date = TimeToMysqlDateTime(strtotime($Date)); 31 31 32 32 $Query = 'SELECT Id FROM News WHERE (`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")'; 33 33 $DbResult = $System->Database->query($Query); -
trunk/Modules/News/News.php
r711 r738 67 67 )); 68 68 $this->System->FormManager->RegisterFormType('TNewsCategory', array( 69 70 71 72 73 69 'Type' => 'Reference', 70 'Table' => 'NewsCategory', 71 'Id' => 'Id', 72 'Name' => 'Caption', 73 'Filter' => '1', 74 74 )); 75 75 $this->System->FormManager->RegisterFormType('TNewsList', array( 76 77 78 79 80 81 )); 82 76 'Type' => 'ManyToOne', 77 'Table' => 'News', 78 'Id' => 'Id', 79 'Ref' => 'Category', 80 'Filter' => '1', 81 )); 82 83 83 if($this->System->ModuleManager->ModulePresent('Search')) 84 84 { -
trunk/Modules/OpeningHours/OpeningHours.php
r586 r738 10 10 var $EventType = array('Žádný', 'Otevřeno', 'Zavřeno'); 11 11 var $ParentClass = 'PagePortal'; 12 12 13 13 function ToHumanTime($Time) 14 14 { 15 15 $Hours = floor($Time / 60); 16 16 $Minutes = $Time - $Hours * 60; 17 if($Minutes < 10) $Minutes = '0'.$Minutes; 17 if($Minutes < 10) $Minutes = '0'.$Minutes; 18 18 $Hours = $Hours % 24; 19 19 return($Hours.':'.$Minutes); 20 } 20 } 21 21 22 22 function ToHumanTime2($Time) … … 33 33 return($Output); 34 34 } 35 35 36 36 function EditSubject($Id) 37 37 { … … 72 72 return($Output); 73 73 } 74 74 75 75 function SaveSubject($Id) 76 76 { 77 77 global $Config; 78 78 79 79 $Output = ''; 80 80 if($this->System->User->CheckPermission('OpeningHours', 'Edit')) … … 97 97 $Day['Close2'] = $_POST['day'.$Index.'_close2_m'] + $_POST['day'.$Index.'_close2_h'] * 60; 98 98 $this->Database->insert('SubjectOpenTimeDay', $Day); 99 } 100 $Output .= 'Uloženo'; 101 99 } 100 $Output .= 'Uloženo'; 101 102 102 $File = new File($this->Database); 103 103 … … 112 112 } else $Output = 'Nemáte oprávnění'; 113 113 return($Output); 114 } 115 114 } 115 116 116 function ShowAll() 117 117 { … … 121 121 { 122 122 $Output .= '<strong>'.$Subject['Name'].':</strong><br />'; 123 123 124 124 // Load time event list 125 125 $Events = array(); … … 139 139 } 140 140 //print_r($Events); 141 141 142 142 // Calculate time to next event 143 143 if(count($Events) > 0) 144 144 { 145 145 $CurrentTime = ((date('w') + 6) % 7) * 24 * 60 + date('G') * 60 + date('i'); 146 146 147 147 $I = 0; 148 while(($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime)) 148 while(($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime)) 149 149 $I++; 150 150 if($I < count($Events)) … … 152 152 $NextTime = $Events[$I]['Time']; 153 153 $NextEventType = $Events[$I]['Type']; 154 } else 154 } else 155 155 { 156 156 $NextTime = $Events[0]['Time'] + 7 * 24 * 60; 157 157 $NextEventType = $Events[0]['Type']; 158 158 } 159 159 160 160 $TimeDelta = $NextTime - $CurrentTime; 161 161 //$Output .= $CurrentTime.' '.$NextTime; … … 163 163 else $Output .= 'Otevírá za '.$this->ToHumanTime2($TimeDelta); 164 164 } 165 166 // Show time inteval table 165 166 // Show time inteval table 167 167 $Output .= '<table class="WideTable"><tr><th>Den</th><th>Čas</th></tr>'; 168 168 foreach($this->DaysOfWeek as $DayIndex => $DayOfWeek) … … 187 187 $Output .= '</table>Aktualizováno: '.$Subject['UpdateTime'].'<br />'; 188 188 if($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />'; 189 189 190 190 if($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> '; 191 191 192 192 if($this->System->User->CheckPermission('SubjectOpenTime', 'Edit')) 193 193 $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />'; … … 197 197 return($Output); 198 198 } 199 199 200 200 function Show() 201 201 { 202 202 if(count($this->System->PathItems) > 1) 203 { 203 { 204 204 if($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']); 205 else if($this->System->PathItems[1] == 'save') 205 else if($this->System->PathItems[1] == 'save') 206 206 { 207 207 $Output = $this->SaveSubject($_GET['Subject']); 208 208 $Output .= $this->ShowAll(); 209 } else $Output = PAGE_NOT_FOUND; 210 } else $Output = $this->ShowAll(); 209 } else $Output = PAGE_NOT_FOUND; 210 } else $Output = $this->ShowAll(); 211 211 return($Output); 212 212 } … … 225 225 $this->Dependencies = array(); 226 226 } 227 227 228 228 function DoStart() 229 229 { 230 230 $this->System->Pages['otviraci-doby'] = 'PageSubjectOpenTime'; 231 231 } 232 232 233 233 function DoInstall() 234 234 { -
trunk/Modules/Portal/Portal.php
r737 r738 63 63 while($Action = $DbResult->fetch_assoc()) 64 64 { 65 65 $Output .= $this->System->ShowAction($Action['Id']).'<br/>'; 66 66 } 67 67 return($this->Panel($ActionGroup['Name'], $Output)); -
trunk/Modules/RSS/RSS.php
r670 r738 19 19 function Start() 20 20 { 21 21 $this->System->RegisterPage('rss', 'PageRSS'); 22 22 } 23 23 … … 42 42 $Output = ''; 43 43 foreach($this->RSSChannels as $Channel) 44 45 46 47 48 44 { 45 if($this->System->User->Licence($Channel['Permission'])) 46 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 47 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; 48 } 49 49 return($Output); 50 50 } … … 53 53 class PageRSS extends Page 54 54 { 55 56 57 55 function Show() 56 { 57 $this->ClearPage = true; 58 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 59 if(array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel']; 60 else $ChannelName = ''; 61 if(array_key_exists('token', $_GET)) $Token = $_GET['token']; 62 else $Token = ''; 63 if(array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels)) 64 { 65 $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName]; 66 if($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or 67 $this->System->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token)) 68 { 69 if(is_string($Channel['Callback'][0])) 70 { 71 $Class = new $Channel['Callback'][0]($this->System); 72 $Output = $Class->$Channel['Callback'][1](); 73 } else $Output = call_user_func($Channel['Callback']); 74 } else $Output = 'Nemáte oprávnění'; 75 } else $Output = 'Kanál nenalezen'; 76 76 return($Output); 77 77 } 78 78 } -
trunk/Modules/Scheduler/Scheduler.php
r735 r738 13 13 $this->Dependencies = array(); 14 14 } 15 15 16 16 function DoStart() 17 17 { … … 34 34 'Table' => 'SchedulerAction', 35 35 'DefaultSortColumn' => 'Name', 36 36 'ReadOnly' => true, 37 37 'Items' => array( 38 38 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => '', 'ReadOnly' => true), … … 41 41 )); 42 42 $this->System->FormManager->RegisterFormType('TSchedulerAction', array( 43 44 45 46 47 43 'Type' => 'Reference', 44 'Table' => 'SchedulerAction', 45 'Id' => 'Id', 46 'Name' => 'Name', 47 'Filter' => '1', 48 48 )); 49 49 $this->System->RegisterCommandLine('run-scheduler', array('ModuleScheduler', 'Run')); 50 50 } 51 51 52 52 function DoInstall() 53 53 { … … 55 55 56 56 function DoUnInstall() 57 { 57 { 58 58 } 59 59 60 60 function Run() 61 { 62 while(true)63 64 65 66 67 ' (`Scheduler`.`LastExecutedTime` < `Scheduler`.`ScheduledTime`)) OR '.68 69 70 71 72 73 if(class_exists($DbRow['Class']))74 75 76 77 78 $this->Database->update('Scheduler', 'Id='.$DbRow['Id'], 79 80 81 else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period']; 82 83 array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime)));84 }85 86 87 61 { 62 while(true) 63 { 64 $DbResult = $this->Database->query('SELECT `Scheduler`.*, `SchedulerAction`.`Class` AS `Class` FROM `Scheduler` '. 65 'LEFT JOIN `SchedulerAction` ON `SchedulerAction`.`Id` = `Scheduler`.`Action` '. 66 'WHERE (`Scheduler`.`Enabled`=1) AND (((`Scheduler`.`ScheduledTime` < "'.TimeToMysqlDateTime(time()).'") AND '. 67 ' (`Scheduler`.`LastExecutedTime` < `Scheduler`.`ScheduledTime`)) OR '. 68 '(`Scheduler`.`ScheduledTime` IS NULL))'); 69 while($DbRow = $DbResult->fetch_assoc()) 70 { 71 echo('Executing '.$DbRow['Name']."\n"); 72 $Output = ''; 73 if(class_exists($DbRow['Class'])) 74 { 75 $Class = new $DbRow['Class']($this->System); 76 $Output = $Class->Execute(); 77 } else echo('Class '.$DbRow['Class'].' not found'."\n"); 78 $this->Database->update('Scheduler', 'Id='.$DbRow['Id'], 79 array('Log' => $Output, 'LastExecutedTime' => 'NOW()')); 80 if($DbRow['ScheduledTime'] == '') $NewScheduledTime = time() + $DbRow['Period']; 81 else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period']; 82 if($DbRow['Period'] != '') $this->Database->update('Scheduler', 'Id='.$DbRow['Id'], 83 array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime))); 84 } 85 echo('.'); 86 sleep(1); 87 } 88 88 } 89 89 } … … 91 91 class SchedulerTask extends Model 92 92 { 93 94 95 93 function Execute() 94 { 95 } 96 96 } -
trunk/Modules/Search/Search.php
r586 r738 10 10 $this->ParentClass = 'PagePortal'; 11 11 } 12 12 13 13 function Show() 14 14 { … … 29 29 $Columns .= ', `'.$Column.'`'; 30 30 $Condition .= ' OR (`'.$Column.'` LIKE "%'.$Text.'%")'; 31 } 31 } 32 32 $Columns = substr($Columns, 2); 33 33 $Condition = substr($Condition, 3); … … 51 51 var $Items; 52 52 var $MaxItemCount; 53 53 54 54 function __construct($System) 55 55 { … … 64 64 $this->Items = array(); 65 65 } 66 66 67 67 function DoStart() 68 68 { 69 69 $this->System->Pages['search'] = 'PageSearch'; 70 70 } 71 71 72 72 function DoInstall() 73 73 { … … 75 75 76 76 function DoUnInstall() 77 { 77 { 78 78 } 79 79 80 80 function RegisterSearch($Title, $TableName, $Columns) 81 81 { -
trunk/Modules/SpeedTest/SpeedTest.php
r615 r738 24 24 $this->Dependencies = array(); 25 25 } 26 26 27 27 function DoStart() 28 28 { 29 29 $this->System->Pages['speedtest'] = 'PageSpeedTest'; 30 } 30 } 31 31 } 32 32 … … 36 36 var $ShortTitle = 'Test rychlosti'; 37 37 var $ParentClass = 'PagePortal'; 38 38 39 39 function Show() 40 40 { … … 46 46 } else return($this->ShowMain()); 47 47 } 48 48 49 49 function ShowDownload() 50 50 { 51 51 global $config; 52 52 require_once(dirname(__FILE__)."/download.php"); 53 53 54 54 } 55 55 56 56 function ShowMain() 57 { 57 { 58 58 global $config; 59 59 60 60 require_once(dirname(__FILE__)."/common.php"); 61 61 ReadConfig(dirname(__FILE__)."/speedtest.cfg"); 62 62 63 63 ## Redirect immediately to download.php if auto_start = 1 64 64 if($config->{'general'}->{'auto_start'}) { … … 70 70 <head> 71 71 <title>'.$config->{'general'}->{'page_title'}.' - Fancy Speed Test</title> 72 <meta http-equiv="Expires" CONTENT="Fri, Jan 1 1980 00:00:00 GMT" /> 73 <meta http-equiv="Pragma" CONTENT="no-cache" /> 74 <meta http-equiv="Cache-Control" CONTENT="no-cache" /> 72 <meta http-equiv="Expires" CONTENT="Fri, Jan 1 1980 00:00:00 GMT" /> 73 <meta http-equiv="Pragma" CONTENT="no-cache" /> 74 <meta http-equiv="Cache-Control" CONTENT="no-cache" /> 75 75 <link rel="stylesheet" href="style.css" /> 76 76 </head> … … 89 89 ## Include "welcome.html" for a custom welcome page, if the file exists 90 90 include("welcome.html"); 91 } else { 91 } else { 92 92 ## Else print a standard welcome message 93 93 -
trunk/Modules/SpeedTest/download.php
r560 r738 38 38 ## Intial test is done. Set down/upload sizes to the same as 39 39 ## our initial measured speeds. That way the test should take 40 ## about 8 seconds for each test (up/down) making it about a 40 ## about 8 seconds for each test (up/down) making it about a 41 41 ## 16 second test 42 42 $down_kbytes = $_GET['downspeed']; … … 46 46 $down_kbytes = $config->{'download'}->{'initial_kbytes'}; 47 47 $up_kbytes = $config->{'upload'}->{'initial_kbytes'}; 48 } 48 } 49 49 } else { 50 50 ## auto_size is off. Just to the default sizes … … 84 84 <head> 85 85 <title><?php print $config->{'general'}->{'page_title'}; ?> - Fancy Speed Test</title> 86 <meta http-equiv="Expires" CONTENT="Fri, Jan 1 1980 00:00:00 GMT" /> 87 <meta http-equiv="Pragma" CONTENT="no-cache" /> 88 <meta http-equiv="Cache-Control" CONTENT="no-cache" /> 86 <meta http-equiv="Expires" CONTENT="Fri, Jan 1 1980 00:00:00 GMT" /> 87 <meta http-equiv="Pragma" CONTENT="no-cache" /> 88 <meta http-equiv="Cache-Control" CONTENT="no-cache" /> 89 89 <link rel="stylesheet" href="style.css" /> 90 90 </head> 91 91 <body> 92 92 93 <?php 93 <?php 94 94 if(file_exists("header.html")) { 95 95 ## Include "header.html" for a custom header, if the file exists 96 96 include("header.html"); 97 } else { 97 } else { 98 98 ## Else just print a plain header 99 99 print "<br /><br /><br /><br />\n"; … … 102 102 <div id="speedtest_contents"> 103 103 104 <?php 105 if( ($config_auto_size) && (! isset($_GET['auto_size'])) ) { 104 <?php 105 if( ($config_auto_size) && (! isset($_GET['auto_size'])) ) { 106 106 ## auto_size is performing the initial, small test 107 107 print "<div>Calculating appropriate file sizes for testing</div>\n"; 108 ob_flush(); 108 ob_flush(); 109 109 } else { 110 110 ?> … … 190 190 } 191 191 } 192 192 193 193 194 194 // --> … … 218 218 219 219 ## Read some stuff from our payload file 220 221 220 $data_file = "payload.js"; 221 $fd = fopen ($data_file, "r"); 222 222 $data = fread ($fd, $each_chunk * 1024); 223 223 … … 281 281 CompleteDownloadBar(); 282 282 283 284 285 286 287 288 289 283 time = new Date(); 284 endtime = time.getTime(); 285 if (endtime == starttime) 286 {downloadtime = 0 287 } else { 288 downloadtime = (endtime - starttime)/1000; 289 } 290 290 <?php if(! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?> 291 291 292 293 294 292 down_size = <?php echo $total_kbytes; ?>; 293 downspeed = down_size/downloadtime; 294 downspeed = (Math.round((downspeed*8)*10*1.024))/10; 295 295 296 296 formElement = document.getElementById('upload_test_form'); 297 297 298 <?php 298 <?php 299 299 if($config_auto_size && (! isset($_GET['auto_size'])) ) { 300 300 $params_auto_size = "&auto_size=1"; -
trunk/Modules/SpeedTest/results.php
r331 r738 49 49 <head> 50 50 <title><?php print $config->{'general'}->{'page_title'}; ?> - Fancy Speed Test</title> 51 <meta http-equiv="Expires" CONTENT="Fri, Jan 1 1980 00:00:00 GMT" /> 52 <meta http-equiv="Pragma" CONTENT="no-cache" /> 53 <meta http-equiv="Cache-Control" CONTENT="no-cache" /> 51 <meta http-equiv="Expires" CONTENT="Fri, Jan 1 1980 00:00:00 GMT" /> 52 <meta http-equiv="Pragma" CONTENT="no-cache" /> 53 <meta http-equiv="Cache-Control" CONTENT="no-cache" /> 54 54 <link rel="stylesheet" href="style.css" /> 55 55 </head> 56 56 <body> 57 57 58 <?php 58 <?php 59 59 if(file_exists("header.html")) { 60 60 ## Include "header.html" for a custom header, if the file exists 61 61 include("header.html"); 62 } else { 62 } else { 63 63 ## Else just print a plain header 64 64 print "<center>\n"; … … 118 118 print "</table>\n"; 119 119 } 120 120 121 121 ?> 122 122 -
trunk/Modules/Stock/Stock.php
r736 r738 68 68 'ReadOnly' => true, 'SQL' => '(SELECT SUM(`SellPrice`) FROM `StockSerialNumber` WHERE '. 69 69 '(`StockSerialNumber`.`Stock`=#Id) AND (`StockSerialNumber`.`TimeElimination` IS NULL))', 'Suffix' => 'Kč'), 70 70 'Moves' => array('Type' => 'TStockMoveStock', 'Caption' => 'Pohyby', 'Default' => ''), 71 71 ), 72 72 )); … … 78 78 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 79 79 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 80 81 82 80 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''), 81 'StockFrom' => array('Type' => 'TStock', 'Caption' => 'Zdrojový sklad', 'Default' => '', 'Null' => true), 82 'StockTo' => array('Type' => 'TStock', 'Caption' => 'Cílový sklad', 'Default' => '', 'Null' => true), 83 83 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), 84 84 'Price' => array('Type' => 'Float', 'Caption' => 'Cena', 'Default' => '', 85 85 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT SUM(`StockMoveItem`.`UnitPrice` * `StockMoveItem`.`Amount`) FROM `StockMoveItem` '. 86 86 'WHERE `StockMoveItem`.`StockMove`=#Id)'), 87 88 ), 87 'Items' => array('Type' => 'TStockMoveItemListStockMove', 'Caption' => 'Položky', 'Default' => ''), 88 ), 89 89 'BeforeInsert' => array($this, 'BeforeInsertStockMove'), 90 90 )); … … 93 93 'BaseTable' => 'StockMove', 94 94 'DefaultSortColumn' => 'Time', 95 96 95 'SQL' => '(SELECT *, -1 AS `Direction`, `StockFrom` AS `Stock`, `StockTo` AS `StockOther` FROM `StockMove`) '. 96 'UNION (SELECT *, 1 AS `Direction`, `StockTo` AS `Stock`, `StockFrom` AS `StockOther` FROM `StockMove`)', 97 97 'Items' => array( 98 98 'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''), 99 99 'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''), 100 101 102 100 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''), 101 'Stock' => array('Type' => 'TStock', 'Caption' => 'První sklad', 'Default' => '', 'Null' => true), 102 'StockOther' => array('Type' => 'TStock', 'Caption' => 'Druhý sklad', 'Default' => '', 'Null' => true), 103 103 'File' => array('Type' => 'TFile', 'Caption' => 'Doklad', 'Default' => '', 'Null' => true), 104 104 'Price' => array('Type' => 'Float', 'Caption' => 'Cena', 'Default' => '', 105 105 'ReadOnly' => true, 'Suffix' => 'Kč', 'SQL' => '(SELECT `TX`.`Direction` * SUM(`StockMoveItem`.`UnitPrice` * `StockMoveItem`.`Amount`) FROM `StockMoveItem` '. 106 106 'WHERE `StockMoveItem`.`StockMove`=#Id)'), 107 108 ), 107 'Items' => array('Type' => 'TStockMoveItemListStockMove', 'Caption' => 'Položky', 'Default' => ''), 108 ), 109 109 'BeforeInsert' => array($this, 'BeforeInsertStockMove'), 110 110 )); … … 116 116 'StockMove' => array('Type' => 'TStockMove', 'Caption' => 'Skladový pohyb', 'Default' => ''), 117 117 'Product' => array('Type' => 'TProduct', 'Caption' => 'Produkt', 'Default' => ''), 118 119 118 'Amount' => array('Type' => 'Integer', 'Caption' => 'Množství', 'Default' => '1'), 119 'Text' => array('Type' => 'String', 'Caption' => 'Text', 'Default' => ''), 120 120 'UnitPrice' => array('Type' => 'Integer', 'Caption' => 'Jednotková cena', 'Default' => '0', 'Suffix' => 'Kč'), 121 ), 121 ), 122 122 )); 123 123 $this->System->FormManager->RegisterFormType('TStockMoveItemListStockMove', array( … … 127 127 'Ref' => 'StockMove', 128 128 'Filter' => '1', 129 )); 129 )); 130 130 $this->System->FormManager->RegisterFormType('TStockMoveStock', array( 131 131 'Type' => 'ManyToOne', … … 134 134 'Ref' => 'Stock', 135 135 'Filter' => '1', 136 )); 136 )); 137 137 $this->System->FormManager->RegisterFormType('TStockMove', array( 138 138 'Type' => 'Reference', … … 167 167 function BeforeInsertStockMove($Form) 168 168 { 169 170 169 if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 170 else $Year = date("Y", $Form->Values['ValidFrom']); 171 171 $DocumentLine = $Form->Values['DocumentLine']; 172 172 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year); -
trunk/Modules/Subject/Subject.php
r727 r738 28 28 'AddressCountry' => array('Type' => 'TCountry', 'Caption' => 'Země', 'Default' => ''), 29 29 'IC' => array('Type' => 'String', 'Caption' => 'IČ', 'Default' => ''), 30 'DIC' => array('Type' => 'String', 'Caption' => 'DIČ', 'Default' => ''), 30 'DIC' => array('Type' => 'String', 'Caption' => 'DIČ', 'Default' => ''), 31 31 'MapPosition' => array('Type' => 'TMapPosition', 'Caption' => 'Pozice na mapě', 'Default' => '', 'Null' => true), 32 32 'WWW' => array('Type' => 'Hyperlink', 'Caption' => 'WWW', 'Default' => ''), … … 39 39 'WHERE `FinanceOperation`.`Subject`=#Id), 0) - IFNULL((SELECT SUM(`FinanceInvoice`.`Value` * `FinanceInvoice`.`Direction`) FROM `FinanceInvoice` '. 40 40 'WHERE `FinanceInvoice`.`Subject`=#Id), 0)'), 41 41 'BankAccounts' => array('Type' => 'TFinanceBankAccountListSubject', 'Caption' => 'Bankovní účety', 'Default' => ''), 42 42 ), 43 43 )); -
trunk/Modules/System/System.php
r731 r738 2 2 3 3 class PageModules extends Page 4 { 4 { 5 5 function __construct($System) 6 6 { … … 10 10 $this->ParentClass = 'PagePortal'; 11 11 } 12 12 13 13 function ShowList() 14 14 { … … 17 17 $DbRow = $DbResult->fetch_row(); 18 18 $PageList = GetPageList($DbRow[0]); 19 19 20 20 $Output .= $PageList['Output']; 21 21 $Output .= '<table class="WideTable" style="font-size: small;">'; 22 22 23 23 $TableColumns = array( 24 24 array('Name' => 'Name', 'Title' => 'Jméno'), … … 37 37 'WHERE `ModuleLink`.`Module` = `Module`.`Id`) AS `Dependencies` '. 38 38 'FROM `Module` '.$Order['SQL'].$PageList['SQLLimit']; 39 39 40 40 $DbResult = $this->Database->query($Query); 41 41 while($Module = $DbResult->fetch_assoc()) … … 59 59 $Output .= $PageList['Output']; 60 60 $Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>'; 61 return($Output); 62 } 63 61 return($Output); 62 } 63 64 64 function Show() 65 { 65 { 66 66 $Output = ''; 67 67 if(array_key_exists('A', $_GET)) 68 68 { 69 if($_GET['A'] == 'SaveToDb') 69 if($_GET['A'] == 'SaveToDb') 70 70 { 71 71 $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase(); 72 $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován'); 72 $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován'); 73 73 } else 74 if($_GET['A'] == 'Install') 74 if($_GET['A'] == 'Install') 75 75 { 76 76 $this->System->ModuleManager->LoadModules(false); 77 77 $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']); 78 if($ModuleName != '') 78 if($ModuleName != '') 79 79 { 80 80 $this->System->Modules[$ModuleName]->Install(); 81 81 $this->System->ModuleManager->Init(); 82 82 } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen'; 83 83 84 84 } else 85 if($_GET['A'] == 'Uninstall') 85 if($_GET['A'] == 'Uninstall') 86 86 { 87 87 $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']); 88 if($ModuleName != '') 88 if($ModuleName != '') 89 89 { 90 90 $this->System->ModuleManager->Modules[$ModuleName]->UnInstall(); 91 91 $this->System->ModuleManager->Init(); 92 92 } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen'; 93 } else $Output .= 'Neplatná akce'; 93 } else $Output .= 'Neplatná akce'; 94 94 } 95 95 $Output .= $this->ShowList(); 96 return($Output); 97 } 98 } 96 return($Output); 97 } 98 } 99 99 100 100 class ModuleSystem extends AppModule 101 101 { 102 102 var $InstalledChecked; 103 103 104 104 function __construct($System) 105 105 { … … 112 112 $this->Dependencies = array(); 113 113 } 114 114 115 115 function DoInstall() 116 116 { … … 131 131 PRIMARY KEY (`Id`) 132 132 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 133 133 134 134 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModuleDependency` ( 135 135 `Id` int(11) NOT NULL AUTO_INCREMENT, … … 143 143 $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD CONSTRAINT `SystemModuleDependency_ibfk_1` FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)'); 144 144 $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD CONSTRAINT `SystemModuleDependency_ibfk_2` FOREIGN KEY ( `DependencyModule` ) REFERENCES `SystemModule` (`Id`)'); 145 145 146 146 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModel` ( 147 147 `Id` int(11) NOT NULL AUTO_INCREMENT, … … 152 152 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 153 153 $this->Database->query('ALTER TABLE `SystemModel` ADD CONSTRAINT `SystemModel_ibfk_1` FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)'); 154 154 155 155 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModelProperty` ( 156 156 `Id` int(11) NOT NULL AUTO_INCREMENT, … … 163 163 $this->Database->query('ALTER TABLE `SystemModelProperty` ADD CONSTRAINT `SystemModelProperty_ibfk_1` FOREIGN KEY ( `Model` ) REFERENCES `SystemModel` (`Id`)'); 164 164 } 165 165 166 166 function DoUnInstall() 167 167 { … … 220 220 )); 221 221 $this->System->FormManager->RegisterClass('Module', array( 222 223 224 225 226 227 228 229 230 231 'HomePage' => array('Type' => 'Hyperlink', 'Caption' => 'Domovské stránky', 'Default' => ''), 232 233 234 235 236 237 238 222 'Title' => 'Moduly', 223 'Table' => 'Module', 224 'Items' => array( 225 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''), 226 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 227 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''), 228 'Version' => array('Type' => 'String', 'Caption' => 'Verze', 'Default' => ''), 229 'License' => array('Type' => 'String', 'Caption' => 'Licence', 'Default' => ''), 230 'Creator' => array('Type' => 'String', 'Caption' => 'Tvůrce', 'Default' => ''), 231 'HomePage' => array('Type' => 'Hyperlink', 'Caption' => 'Domovské stránky', 'Default' => ''), 232 'Installed' => array('Type' => 'Boolean', 'Caption' => 'Instalováno', 'Default' => '', 'ReadOnly' => true), 233 'Models' => array('Type' => 'TModelListModule', 'Caption' => 'Modely', 'Default' => ''), 234 'Links' => array('Type' => 'TModuleLinkListModule', 'Caption' => 'Vazby', 'Default' => ''), 235 ), 236 'Actions' => array( 237 array('Caption' => 'Aktualizovat z disku', 'URL' => '/module/?A=SaveToDb'), 238 ), 239 239 )); 240 240 $this->System->FormManager->RegisterFormType('TModule', array( 241 242 243 244 245 241 'Type' => 'Reference', 242 'Table' => 'Module', 243 'Id' => 'Id', 244 'Name' => 'Title', 245 'Filter' => '1', 246 246 )); 247 247 $this->System->FormManager->RegisterFormType('TModelListModule', array( … … 253 253 )); 254 254 $this->System->FormManager->RegisterClass('Model', array( 255 256 257 258 259 260 261 262 263 264 265 255 'Title' => 'Modely', 256 'Table' => 'Model', 257 'Items' => array( 258 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''), 259 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 260 'Module' => array('Type' => 'TModule', 'Caption' => 'Module', 'Default' => ''), 261 'Query' => array('Type' => 'String', 'Caption' => 'SQL dotaz', 'Default' => ''), 262 'DefaultSortColumn' => array('Type' => 'String', 'Caption' => 'Výchozí sloupce řazení', 'Default' => ''), 263 'DefaultSortOrder' => array('Type' => 'Text', 'Caption' => 'Výchozí směr řazení', 'Default' => ''), 264 'Fields' => array('Type' => 'TModelFieldListModel', 'Caption' => 'Pole', 'Default' => ''), 265 ), 266 266 )); 267 267 $this->System->FormManager->RegisterFormType('TModel', array( 268 269 270 271 272 268 'Type' => 'Reference', 269 'Table' => 'Model', 270 'Id' => 'Id', 271 'Name' => 'Title', 272 'Filter' => '1', 273 273 )); 274 274 $this->System->FormManager->RegisterFormType('TModelFieldListModel', array( … … 280 280 )); 281 281 $this->System->FormManager->RegisterClass('ModelField', array( 282 283 284 285 286 287 288 289 290 291 292 293 282 'Title' => 'Pole modelu', 283 'Table' => 'ModelField', 284 'Items' => array( 285 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''), 286 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 287 'Model' => array('Type' => 'TModel', 'Caption' => 'Model', 'Default' => ''), 288 'Query' => array('Type' => 'String', 'Caption' => 'SQL dotaz', 'Default' => ''), 289 'Type' => array('Type' => 'String', 'Caption' => 'Typ', 'Default' => ''), 290 'DefaultValue' => array('Type' => 'String', 'Caption' => 'Výchozí hodnota', 'Default' => ''), 291 'IsNull' => array('Type' => 'Boolean', 'Caption' => 'Také nulová hodnota', 'Default' => ''), 292 'Suffix' => array('Type' => 'String', 'Caption' => 'Text za', 'Default' => ''), 293 ), 294 294 )); 295 295 $this->System->FormManager->RegisterFormType('TModuleLink', array( 296 297 298 299 300 296 'Type' => 'Reference', 297 'Table' => 'ModuleLink', 298 'Id' => 'Id', 299 'Name' => 'Module', 300 'Filter' => '1', 301 301 )); 302 302 $this->System->FormManager->RegisterFormType('TModuleLinkListModule', array( … … 308 308 )); 309 309 $this->System->FormManager->RegisterClass('ModuleLink', array( 310 311 312 313 314 315 316 310 'Title' => 'Vazby modulu', 311 'Table' => 'ModuleLink', 312 'Items' => array( 313 'Module' => array('Type' => 'TModule', 'Caption' => 'Modul', 'Default' => ''), 314 'LinkedModule' => array('Type' => 'TModule', 'Caption' => 'Vázaný modul', 'Default' => ''), 315 'Type' => array('Type' => 'String', 'Caption' => 'Typ vazby', 'Default' => ''), 316 ), 317 317 )); 318 318 $this->System->FormManager->RegisterClass('Language', array( 319 320 321 322 323 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),324 319 'Title' => 'Jazyky', 320 'Table' => 'Language', 321 'DefaultSortColumn' => 'Name', 322 'Items' => array( 323 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 324 ), 325 325 )); 326 326 $this->System->FormManager->RegisterClass('UnitOfMeasure', array( 327 328 329 330 331 332 333 327 'Title' => 'Měrné jednotky', 328 'Table' => 'UnitOfMeasure', 329 'DefaultSortColumn' => 'Name', 330 'Items' => array( 331 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 332 'Unit' => array('Type' => 'String', 'Caption' => 'Jednotka', 'Default' => ''), 333 ), 334 334 )); 335 335 $this->System->FormManager->RegisterClass('Country', array( 336 337 338 339 340 341 336 'Title' => 'Země', 337 'Table' => 'Country', 338 'DefaultSortColumn' => 'Name', 339 'Items' => array( 340 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 341 ), 342 342 )); 343 343 $this->System->FormManager->RegisterFormType('TCountry', array( 344 345 346 347 348 344 'Type' => 'Reference', 345 'Table' => 'Country', 346 'Id' => 'Id', 347 'Name' => 'Name', 348 'Filter' => '1', 349 349 )); 350 350 $this->System->FormManager->RegisterFormType('TUnitOfMeasure', array( 351 352 353 354 355 351 'Type' => 'Reference', 352 'Table' => 'UnitOfMeasure', 353 'Id' => 'Id', 354 'Name' => 'Name', 355 'Filter' => '1', 356 356 )); 357 357 $this->System->FormManager->RegisterFormType('TLanguage', array( 358 359 360 361 362 358 'Type' => 'Reference', 359 'Table' => 'Language', 360 'Id' => 'Id', 361 'Name' => 'Name', 362 'Filter' => '1', 363 363 )); 364 364 $this->System->FormManager->RegisterFormType('TAction', array( 365 366 367 368 369 365 'Type' => 'Reference', 366 'Table' => 'Action', 367 'Id' => 'Id', 368 'Name' => 'Title', 369 'Filter' => '1', 370 370 )); 371 371 $this->System->FormManager->RegisterFormType('TActionIcon', array( 372 373 374 375 376 372 'Type' => 'Reference', 373 'Table' => 'ActionIcon', 374 'Id' => 'Id', 375 'Name' => 'Name', 376 'Filter' => '1', 377 377 )); 378 378 $this->System->FormManager->RegisterFormType('TActionType', array( 379 380 381 382 383 379 'Type' => 'Reference', 380 'Table' => 'ActionType', 381 'Id' => 'Id', 382 'Name' => 'Name', 383 'Filter' => '1', 384 384 )); 385 385 $this->System->FormManager->RegisterFormType('TActionGroup', array( 386 387 388 389 390 391 )); 386 'Type' => 'Reference', 387 'Table' => 'ActionGroup', 388 'Id' => 'Id', 389 'Name' => 'Name', 390 'Filter' => '1', 391 )); 392 392 $this->System->FormManager->RegisterFormType('TModule', array( 393 394 395 396 397 398 )); 399 393 'Type' => 'Reference', 394 'Table' => 'Module', 395 'Id' => 'Id', 396 'Name' => 'Name', 397 'Filter' => '1', 398 )); 399 400 400 //$this->Manager->OnModuleChange = array($this, 'ModuleChange'); 401 401 //$this->LoadFromDatabase(); 402 402 } 403 403 404 404 function DoStop() 405 405 { 406 406 } 407 407 408 408 function IsInstalled() 409 409 { … … 411 411 { 412 412 $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables 413 WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";'); 413 WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";'); 414 414 if($DbResult->num_rows > 0) $this->Installed = true; 415 415 else $this->Installed = false; 416 416 $this->InstalledChecked = true; 417 417 } 418 return($this->Installed); 419 } 420 418 return($this->Installed); 419 } 420 421 421 function ModuleChange($Module) 422 422 { 423 423 //if($this->IsInstalled()) 424 424 { 425 425 426 426 if($Module->IsInstalled()) $Installed = 1; 427 else $Installed = 0; 427 else $Installed = 0; 428 428 $this->Database->query('UPDATE `Module` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"'); 429 429 } 430 430 } 431 431 432 432 function LoadFromDatabase() 433 433 { … … 441 441 include_once('Modules/'.$Module['Name'].'/'.$Module['Name'].'.php'); 442 442 $ModuleClassName = 'Module'.$Module['Name']; 443 $NewModule = new $ModuleClassName($this->Database, $this->Manager); 443 $NewModule = new $ModuleClassName($this->Database, $this->Manager); 444 444 $NewModule->Id = $Module['Id']; 445 $NewModule->Installed = $Module['Installed']; 445 $NewModule->Installed = $Module['Installed']; 446 446 $this->Manager->RegisterModule($NewModule); 447 } 448 } 449 447 } 448 } 449 450 450 function SaveToDatabase() 451 451 { 452 452 $Output = ''; 453 453 $Modules = array(); 454 454 $DbResult = $this->Database->query('SELECT * FROM `Module`'); … … 461 461 462 462 // Add missing 463 foreach($this->System->ModuleManager->Modules as $Module) 464 { 463 foreach($this->System->ModuleManager->Modules as $Module) 464 { 465 465 if(!array_key_exists($Module->Name, $Modules)) 466 466 { 467 $this->Database->insert('Module', array('Name' => $Module->Name, 467 $this->Database->insert('Module', array('Name' => $Module->Name, 468 468 'Version' => $Module->Version, 'Creator' => $Module->Creator, 469 469 'HomePage' => $Module->HomePage, 'Title' => $Module->Title, 470 470 'Description' => $Module->Description, 'License' => $Module->License, 471 471 'Installed' => $Module->Installed)); … … 474 474 else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array( 475 475 'Version' => $Module->Version, 'Creator' => $Module->Creator, 476 476 'HomePage' => $Module->HomePage, 'Title' => $Module->Title, 477 477 'Description' => $Module->Description, 'License' => $Module->License, 478 478 'Installed' => $Module->Installed)); 479 479 } 480 480 481 481 // Remove exceeding 482 foreach($Modules as $Module) 482 foreach($Modules as $Module) 483 483 if(!$this->System->ModuleManager->ModulePresent($Module['Name'])) 484 484 { … … 487 487 $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']); 488 488 $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']); 489 while($DbRow = $DbResult->fetch_assoc()) 489 while($DbRow = $DbResult->fetch_assoc()) 490 490 { 491 491 $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']); … … 498 498 $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']); 499 499 $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']); 500 } 501 500 } 501 502 502 // Reload dependencies 503 503 $DbDependency = array(); … … 505 505 while($DbRow = $DbResult->fetch_assoc()) 506 506 $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule']; 507 507 508 508 foreach($this->System->ModuleManager->Modules as $Module) 509 509 { … … 517 517 $DependencyId = $this->System->ModuleManager->Modules[$Dependency]->Id; 518 518 else throw new Exception('Dependent module '.$Dependency.' not found'); 519 $this->Database->insert('ModuleLink', array('Module' => $Module->Id, 519 $this->Database->insert('ModuleLink', array('Module' => $Module->Id, 520 520 'LinkedModule' => $DependencyId, 'Type' => 'DependOn')); 521 } 521 } 522 522 } 523 523 524 524 // Remove exceeding 525 525 if(array_key_exists($Module->Id, $DbDependency)) … … 530 530 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '. 531 531 $Module->Id.' AND LinkedModule='.$Dep); 532 } 532 } 533 533 } 534 534 return($Output); 535 } 535 } 536 536 } -
trunk/Modules/TV/TV.php
r712 r738 8 8 var $ShortTitle = 'IPTV'; 9 9 var $ParentClass = 'PagePortal'; 10 10 11 11 function Show() 12 { 12 { 13 13 if(count($this->System->PathItems) > 1) 14 { 14 { 15 15 if($this->System->PathItems[1] == 'playlist.m3u') return($this->ShowPlayList()); 16 16 else return(PAGE_NOT_FOUND); 17 17 } else return($this->ShowChannelList()); 18 18 } 19 19 20 20 function ShowChannelList() 21 21 { 22 22 global $Channels; 23 23 24 24 $Output = 'Stažení přehrávače: <a href="http://www.videolan.org/vlc/">VLC Media Player</a><br/>'. 25 25 'Seznam všech kanálů do přehrávače: <a href="playlist.m3u">Playlist</a><br/>'. … … 28 28 '<div align="center"><strong>Výpis kanálů:</strong><br>'; 29 29 30 $Where = 30 $Where = 31 31 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '. 32 32 ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "")'); 33 33 $DbRow = $DbResult->fetch_row(); 34 $PageList = GetPageList($DbRow[0]); 34 $PageList = GetPageList($DbRow[0]); 35 35 36 36 $Output .= $PageList['Output']; 37 37 $Output .= '<table class="WideTable">'; 38 38 39 39 $TableColumns = array( 40 array('Name' => 'Name', 'Title' => 'Jméno stanice'), 41 array('Name' => 'Language', 'Title' => 'Jazyk'), 42 array('Name' => 'Category', 'Title' => 'Zaměření'), 43 array('Name' => 'SourceType', 'Title' => 'Zdroj'), 44 array('Name' => '', 'Title' => 'Ladění'), 40 array('Name' => 'Name', 'Title' => 'Jméno stanice'), 41 array('Name' => 'Language', 'Title' => 'Jazyk'), 42 array('Name' => 'Category', 'Title' => 'Zaměření'), 43 array('Name' => 'SourceType', 'Title' => 'Zdroj'), 44 array('Name' => '', 'Title' => 'Ladění'), 45 45 ); 46 46 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); … … 51 51 52 52 $DbResult = $this->Database->query($Query); 53 while($Line = $DbResult->fetch_assoc()) 54 { 53 while($Line = $DbResult->fetch_assoc()) 54 { 55 55 if($Line['Stream'] <> '') $Line['Show'] = '<a href="playlist.m3u?id='.$Line['ShortName'].'">Naladit</a>'; 56 56 else 57 57 if($Line['StreamWeb'] <> '') $Line['Show'] = '<a href="'.$Line['StreamWeb'].'">Naladit</a>'; 58 58 else $Line['Show'] = ' '; 59 59 60 60 $Output .= '<tr><td><a href="'.$Line['Homepage'].'">'.$Line['Name'].'</a></td>'. 61 61 '<td>'.$Line['Language'].'</td>'. … … 66 66 $Output .= '</table>'; 67 67 $Output .= $PageList['Output']; 68 68 69 69 $Output .= '</div><br/>'; 70 70 71 71 $Output .= 'Další online TV na webu: <a href="http://spustit.cz">Spustit.cz</a><br/>'; 72 72 $Output .= 'Další online TV na webu: <a href="http://www.tvinfo.cz/live/televize/evropa/cz">TV info</a><br/>'; 73 73 74 74 return($Output); 75 75 } … … 78 78 { 79 79 $this->ClearPage = true; 80 80 81 81 Header("Content-Type: audio/mpegurl"); 82 82 Header("Content-Disposition: attachment; filename=playlist.m3u"); … … 101 101 } 102 102 } 103 } 103 } 104 104 } 105 105 … … 115 115 $this->Description = 'Television channels management'; 116 116 $this->Dependencies = array(); 117 } 117 } 118 118 119 119 function DoInstall() 120 120 { 121 121 } 122 122 123 123 function DoUninstall() 124 { 124 { 125 125 } 126 126 127 127 function DoStart() 128 128 { … … 155 155 )); 156 156 $this->System->FormManager->RegisterFormType('TTVGroup', array( 157 158 159 160 161 157 'Type' => 'Reference', 158 'Table' => 'TVGroup', 159 'Id' => 'Id', 160 'Name' => 'Name', 161 'Filter' => '1', 162 162 )); 163 163 $this->System->FormManager->RegisterFormType('TTVListCategory', array( 164 165 166 167 168 169 )); 170 } 171 164 'Type' => 'ManyToOne', 165 'Table' => 'TV', 166 'Id' => 'Id', 167 'Ref' => 'Category', 168 'Filter' => '1', 169 )); 170 } 171 172 172 function DoStop() 173 { 174 } 173 { 174 } 175 175 } -
trunk/Modules/Task/Task.php
r712 r738 68 68 )); 69 69 $this->System->FormManager->RegisterFormType('TWorkListTask', array( 70 71 72 73 74 70 'Type' => 'ManyToOne', 71 'Table' => 'Work', 72 'Id' => 'Id', 73 'Ref' => 'Task', 74 'Filter' => '1', 75 75 )); 76 76 $this->System->FormManager->RegisterFormType('TTaskList', array( 77 78 79 80 81 77 'Type' => 'ManyToOne', 78 'Table' => 'Task', 79 'Id' => 'Id', 80 'Ref' => 'Group', 81 'Filter' => '1', 82 82 )); 83 83 $this->System->FormManager->RegisterFormType('TTaskGroup', array( 84 85 86 87 88 84 'Type' => 'Reference', 85 'Table' => 'TaskGroup', 86 'Id' => 'Id', 87 'Name' => 'Name', 88 'Filter' => '1', 89 89 )); 90 90 91 91 } 92 92 } -
trunk/Modules/TimeMeasure/Graph.php
r656 r738 20 20 { 21 21 $this->ClearPage = true; 22 22 return($this->Render()); 23 23 } 24 24 -
trunk/Modules/TimeMeasure/Main.php
r656 r738 16 16 $this->ImageHeight = 200; 17 17 $this->ParentClass = 'PagePortal'; 18 18 $this->DefaultVariables = array( 19 19 'TimeSpecify' => 0, 20 20 'Period' => 'day', -
trunk/Modules/TimeMeasure/Measurement/MeasureClient.php
r548 r738 26 26 } else echo('Třída '.$MeasureMethod['MeasureClass'].' neexistuje.'); 27 27 } 28 } 28 } 29 29 } -
trunk/Modules/TimeMeasure/Measurement/WoW.php
r536 r738 28 28 $DbResult = $Database->query('SELECT COUNT(*) FROM account'); 29 29 $Row = $DbResult->fetch_array(); 30 return($Row[0]); 30 return($Row[0]); 31 31 } 32 32 … … 57 57 function WoWEmulatorAvailability() 58 58 { 59 if(CheckPortStatus('localhost', 8085)) return(100); else return(0); 59 if(CheckPortStatus('localhost', 8085)) return(100); else return(0); 60 60 } 61 61 -
trunk/Modules/User/User.php
r729 r738 434 434 class ModuleUser extends AppModule 435 435 { 436 436 var $UserPanel; 437 437 438 438 function __construct($System) … … 659 659 )); 660 660 $this->System->FormManager->RegisterFormType('TUser', array( 661 662 663 664 665 661 'Type' => 'Reference', 662 'Table' => 'User', 663 'Id' => 'Id', 664 'Name' => 'Name', 665 'Filter' => '1', 666 666 )); 667 667 $this->System->FormManager->RegisterFormType('TPermissionGroup', array( 668 669 670 671 672 668 'Type' => 'Reference', 669 'Table' => 'PermissionGroup', 670 'Id' => 'Id', 671 'Name' => 'Description', 672 'Filter' => '1', 673 673 )); 674 674 $this->System->FormManager->RegisterFormType('TPermissionGroupAssignment', array( 675 676 677 678 679 675 'Type' => 'Reference', 676 'Table' => 'PermissionGroupAssignment', 677 'Id' => 'Id', 678 'Name' => 'Id', 679 'Filter' => '1', 680 680 )); 681 681 $this->System->FormManager->RegisterFormType('TPermissionOperation', array( 682 683 684 685 686 687 )); 688 682 'Type' => 'Reference', 683 'Table' => 'PermissionOperation', 684 'Id' => 'Id', 685 'Name' => 'Id', 686 'Filter' => '1', 687 )); 688 689 689 } 690 690 … … 695 695 function TopBarCallback() 696 696 { 697 if($this->System->User->User['Id'] == null) 697 if($this->System->User->User['Id'] == null) 698 698 { 699 699 $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '. 700 700 '<a href="'.$this->System->Link('/user/?Action=UserRegister').'">Registrace</a>'; 701 } else 702 { 703 701 } else 702 { 703 $Output = $this->System->User->User['Name']. 704 704 ' <a href="'.$this->System->Link('/user/?Action=UserMenu').'">Nabídka</a>'. 705 705 ' <a href="'.$this->System->Link('/user/?Action=Logout').'">Odhlásit</a>'; 706 706 // <a href="'.$this->System->Link('/?Action=UserOptions').'">Nastavení</a>'; 707 707 } 708 708 return($Output); -
trunk/Modules/User/UserPage.php
r694 r738 54 54 if($this->System->User->User['Id'] != null) 55 55 { 56 57 58 59 60 61 62 63 64 56 $Actions = ''; 57 foreach($this->System->ModuleManager->Modules['User']->UserPanel as $Action) 58 { 59 if(is_string($Action[0])) 60 { 61 $Class = new $Action[0]($this->System); 62 $Actions .= $Class->$Action[1](); 63 } else $Actions .= call_user_func($Action).'<br/>'; 64 } 65 65 $Output .= '<div class="Centred"><table id="MainTable"><tr><td style="vertical-align:top;">'; 66 66 $Output .= $this->Panel('Nabídka uživatele', $Actions); … … 83 83 } 84 84 85 86 87 85 function Show() 86 { 87 $Output = ''; 88 88 if(array_key_exists('Action', $_GET)) 89 89 { … … 209 209 } else $Output = $this->ShowMain(); 210 210 return($Output); 211 212 213 214 215 216 217 211 } 212 213 function ShowMain() 214 { 215 $Output = 'Nebyla vybrána akce'; 216 return($Output); 217 } 218 218 } -
trunk/Modules/VPS/VPS.php
r731 r738 15 15 $this->Modules = array(); 16 16 } 17 17 18 18 function DoStart() 19 19 { 20 21 } 20 21 } 22 22 } -
trunk/Modules/WebCam/WebCam.php
r586 r738 6 6 var $ShortTitle = 'Kamera'; 7 7 var $ParentClass = 'PagePortal'; 8 8 9 9 function Show() 10 10 { … … 17 17 var theTimer = setTimeout("reloadImage()", 1); 18 18 19 function reloadImage() 19 function reloadImage() 20 20 { 21 21 theDate = new Date(); … … 57 57 $this->SupportedModels = array(); 58 58 } 59 59 60 60 function DoStart() 61 61 { 62 62 $this->System->Pages['webcam'] = 'PageWebcam'; 63 } 63 } 64 64 65 65 function ShowImage() … … 71 71 $Output .= '<a href="http://www.zdechov.net/kamery/?id=3"><img alt="Skiareál, motokrosová grapa" width="140" height="79" src="http://www.zdechov.net/images/webcam/webcam3.jpg" /></a>'; 72 72 $Output .= '<a href="http://www.zdechov.net/kamery/?id=4"><img alt="Fotbalové hřiště" width="140" height="79" src="http://www.zdechov.net/images/webcam/webcam4.jpg" /></a>'; 73 return($Output);74 } 73 return($Output); 74 } 75 75 } -
trunk/Modules/WebCam/webcam_refresh.php
r579 r738 10 10 // $Output = shell_exec('wget "http://kamera-stred/Webcam.jpg?MobilePass='.$Config['Web']['WebcamPassword'].'&V=2&Q=2&B=2&U=0" -O webcam_cache.jpg -T '.($Config['Web']['WebcamRefresh']).' --limit-rate=200k'); 11 11 $Output = shell_exec('wget "http://kamera-knihovna/cgi-bin/viewer/video.jpg" -O webcam_cache.jpg -T '.($Config['Web']['WebcamRefresh']).' --limit-rate=200k'); 12 13 if((strpos($Output, 'failed') === false) and (strpos($Output, 'error') === false)) 12 13 if((strpos($Output, 'failed') === false) and (strpos($Output, 'error') === false)) 14 14 shell_exec('mv -f webcam_cache.jpg webcam.jpg'); 15 15 } -
trunk/Modules/Wiki/Wiki.php
r586 r738 14 14 $this->Revision = 1; 15 15 } 16 16 17 17 function DoInstall() 18 18 { 19 19 parent::Install(); 20 20 $this->Database->Query("'CREATE TABLE IF NOT EXISTS `WikiPage` ( 21 22 23 24 25 26 27 21 `Id` int(11) NOT NULL AUTO_INCREMENT, 22 `Name` varchar(255) NOT NULL, 23 `NormalizedName` varchar(255) NOT NULL, 24 `VisibleInMenu` int(11) NOT NULL, 25 PRIMARY KEY (`Id`), 26 UNIQUE KEY `Name` (`Name`), 27 KEY `VisibleInMenu` (`VisibleInMenu`) 28 28 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 29 29 CREATE TABLE IF NOT EXISTS `WikiPageContent` ( 30 31 32 33 34 35 36 37 30 `Id` int(11) NOT NULL AUTO_INCREMENT, 31 `Page` int(11) NOT NULL, 32 `Time` datetime NOT NULL, 33 `Content` text NOT NULL, 34 `User` int(11) NOT NULL, 35 PRIMARY KEY (`Id`), 36 KEY `User` (`User`), 37 KEY `Page` (`Page`) 38 38 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 39 39 ALTER TABLE `WikiPageContent` … … 47 47 'DELETE TABLE `WikiPage`;"); 48 48 parent::UnInstall(); 49 } 50 49 } 50 51 51 function DoStart() 52 52 { 53 53 $this->LoadPages(); 54 54 } 55 55 56 56 function DoStop() 57 57 { 58 58 } 59 59 60 60 function LoadPages() 61 61 { 62 63 64 65 66 67 68 69 70 71 72 73 62 $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1'); 63 while($DbRow = $DbResult->fetch_assoc()) 64 { 65 $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki'); 66 $this->System->RegisterMenuItem(array( 67 'Title' => $DbRow['Name'], 68 'Hint' => '', 69 'Link' => $this->System->Link('/'.$DbRow['NormalizedName'].'/'), 70 'Permission' => LICENCE_ANONYMOUS, 71 'Icon' => '', 72 ), 2); 73 } 74 74 } 75 75 } … … 80 80 var $ShortTitle = 'Wiki'; 81 81 var $ParentClass = 'PagePortal'; 82 82 83 83 function Show() 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 } else 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 168 169 170 171 172 173 174 175 176 { 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 '<td><a href="'.$this->System->Link('/user.php?user='.$PageContent['User']).'">'.$PageContent['UserName'].'</a></td>'.210 211 212 } 213 214 215 216 217 218 219 } 220 84 { 85 if(array_key_exists('Action', $_GET)) 86 { 87 if($_GET['Action'] == 'Edit') $Output = $this->EditContent(); 88 else if($_GET['Action'] == 'EditSave') $Output = $this->SaveContent(); 89 else if($_GET['Action'] == 'History') $Output = $this->ShowHistory(); 90 else $Output = $this->ShowContent(); 91 } else $Output = $this->ShowContent(); 92 return($Output); 93 } 94 95 function ShowContent() 96 { 97 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 98 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 99 if($DbResult->num_rows > 0) 100 { 101 $DbRow = $DbResult->fetch_assoc(); 102 if(array_key_exists('ver', $_GET)) 103 { 104 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1); 105 if($DbResult2->num_rows > 0) 106 { 107 $DbRow2 = $DbResult2->fetch_assoc(); 108 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 109 $Output .= $DbRow2['Content']; 110 if($this->System->User->Licence(LICENCE_MODERATOR)) 111 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 112 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 113 } else 114 { 115 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 116 if($DbResult2->num_rows > 0) 117 { 118 $DbRow2 = $DbResult2->fetch_assoc(); 119 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 120 $Output .= $DbRow2['Content']; 121 if($this->System->User->Licence(LICENCE_MODERATOR)) 122 $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 123 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 124 } 125 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 126 return($Output); 127 } 128 129 function EditContent() 130 { 131 if($this->System->User->Licence(LICENCE_MODERATOR)) 132 { 133 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 134 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 135 if($DbResult->num_rows > 0) 136 { 137 $DbRow = $DbResult->fetch_assoc(); 138 $Output = '<h3>Úprava '.$DbRow['Name'].'</h3>'; 139 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 140 if($DbResult2->num_rows > 0) 141 { 142 $DbRow2 = $DbResult2->fetch_assoc(); 143 $Output .= '<form action="?Action=EditSave" method="post">'. 144 '<textarea name="content" rows="8" cols="80" onkeydown="ResizeTextArea(this)" class="textedit">'.$DbRow2['Content'].'</textarea><br/>'. 145 '<input type="submit" name="save" value="Uložit"/> '. 146 '<input type="button" name="cancel" value="Zrušit" onclick="location.href=\'?\'"/>'. 147 '</form>'; 148 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 149 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 150 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 151 return($Output); 152 } 153 154 function SaveContent() 155 { 156 if($this->System->User->Licence(LICENCE_MODERATOR)) 157 { 158 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 159 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 160 if($DbResult->num_rows > 0) 161 { 162 $DbRow = $DbResult->fetch_assoc(); 163 if(array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 164 { 165 $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), 166 'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id'])); 167 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 168 } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL); 169 $Output .= $this->ShowContent(); 170 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 171 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 172 return($Output); 173 } 174 175 function ShowHistory() 176 { 177 if($this->System->User->Licence(LICENCE_MODERATOR)) 178 { 179 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 180 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 181 if($DbResult->num_rows > 0) 182 { 183 $DbRow = $DbResult->fetch_assoc(); 184 185 $Output = '<h3>Historie stránky '.$DbRow['Name'].'</h3>'; 186 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM `WikiPageContent` WHERE Page='.$DbRow['Id']); 187 $DbRow2 = $DbResult2->fetch_row(); 188 $PageList = GetPageList($DbRow2[0]); 189 190 $Output .= $PageList['Output']; 191 $Output .= '<table class="BaseTable">'; 192 193 $TableColumns = array( 194 array('Name' => 'Time', 'Title' => 'Čas'), 195 array('Name' => 'User', 'Title' => 'Uživatel'), 196 array('Name' => 'Action', 'Title' => 'Akce'), 197 ); 198 199 $Order = GetOrderTableHeader($TableColumns, 'Time', 1); 200 $Output .= $Order['Output']; 201 202 $DbResult2 = $this->Database->query('SELECT *, (SELECT `Name` FROM `User` WHERE `User`.`ID`=`WikiPageContent`.`User`) AS `UserName` '. 203 ' FROM `WikiPageContent` WHERE Page='. 204 $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']); 205 while($PageContent = $DbResult2->fetch_assoc()) 206 { 207 $Output .= '<tr>'. 208 '<td>'.HumanDateTime($PageContent['Time']).'</td>'. 209 '<td><a href="'.$this->System->Link('/user.php?user='.$PageContent['User']).'">'.$PageContent['UserName'].'</a></td>'. 210 '<td><a href="?id='.$PageContent['Id'].'&ver='.$PageContent['Id'].'">Zobrazit</a></td>'; 211 $Output .= '</tr>'; 212 } 213 214 $Output .= '</table>'. 215 $PageList['Output']; 216 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 217 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 218 return($Output); 219 } 220 221 221 function ToHtml($text) 222 222 {
Note:
See TracChangeset
for help on using the changeset viewer.