Changeset 507
- Timestamp:
- Apr 1, 2013, 7:14:59 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Types/File.php
r502 r507 68 68 { 69 69 parent::__construct($FormManager); 70 $this->FileDownloadURL = ' File.php';70 $this->FileDownloadURL = 'file'; 71 71 $this->DirectoryId = null; 72 72 } … … 75 75 { 76 76 $File = &$Item['Value']; 77 return('<a href="'.$this->FileDownloadURL.'? Id='.$File->Id.'">'.77 return('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'. 78 78 $File.'</a> ('.HumanSize($File->Size).')'); 79 79 } -
trunk/Common/Global.php
r506 r507 196 196 $System->AddModule(new Bill()); 197 197 $System->AddModule(new Finance()); 198 $System->Modules['Finance']->MainSubject = $Config['Finance']['MainSubjectId']; 199 $System->Modules['Finance']->DirectoryId = $Config['Finance']['DirectoryId']; 198 200 $System->Modules['Finance']->LoadMonthParameters(0); 199 201 RegisterFormClasses($System->FormManager); -
trunk/Common/Update.php
r505 r507 76 76 echo($Query.';<br/>'); 77 77 flush(); 78 $this->Database->query($Query);78 return($this->Database->query($Query)); 79 79 } 80 80 } -
trunk/Common/Version.php
r505 r507 1 1 <?php 2 2 3 $Revision = 50 5; // Subversion revision4 $DatabaseRevision = 50 5;5 $ReleaseTime = '2013-0 3-31';3 $Revision = 507; // Subversion revision 4 $DatabaseRevision = 507; 5 $ReleaseTime = '2013-04-01'; 6 6 7 7 ?> -
trunk/Modules/File/File.php
r506 r507 54 54 { 55 55 $DbRow = $DbResult->fetch_assoc(); 56 if(file_exists($this->FilesDir.'/'.$DbRow['Name'])) 56 if($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']); 57 else $FileName = $this->FilesDir; 58 $FileName .= $DbRow['Name']; 59 if(file_exists($FileName)) 57 60 { 58 Header('Content-Type: '.$this->DetectMimeType($ this->FilesDir.'/'.$DbRow['Name']));61 Header('Content-Type: '.$this->DetectMimeType($FileName)); 59 62 Header('Content-Disposition: attachment; filename="'.$DbRow['Name'].'"'); 60 echo(file_get_contents($ this->FilesDir.'/'.$DbRow['Name']));63 echo(file_get_contents($FileName)); 61 64 } else echo('Soubor nenalezen!'); 62 65 } else echo('Soubor nenalezen!'); 63 66 } 67 68 function GetDir($Id) 69 { 70 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id); 71 $DbRow = $DbResult->fetch_assoc(); 72 if($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']); 73 else $Result = $this->FilesDir; 74 $Result .= $DbRow['Name'].'/'; 75 return($Result); 76 } 64 77 } 78 65 79 66 80 class PageFile extends Page … … 73 87 } 74 88 } 75 76 89 77 90 class ModuleFile extends AppModule … … 105 118 $this->System->RegisterPage('file', 'PageFile'); 106 119 $File = new File($this->System->Database); 107 $File->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder'] .'/';120 $File->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder']; 108 121 $this->System->AddModule($File); 109 122 } -
trunk/Modules/OpeningHours/OpeningHours.php
r501 r507 187 187 if($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />'; 188 188 189 if($Subject['Photo'] != 0) $Output .= '<a href=" FileDownload.php?Id='.$Subject['Photo'].'">Fotka</a> ';189 if($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> '; 190 190 191 191 if($this->System->Modules['User']->CheckPermission('SubjectOpenTime', 'Edit')) -
trunk/Readme.txt
r469 r507 2 2 ======================================== 3 3 4 1) Konfigurační soubory4 1) Instalace a nastavení systému 5 5 6 Zkopírovat soubor config.sample.php na config.php a vyplnit údaje. 6 V prohlížeči otevřete podadresář admin v umístění, ze kterého je web dostupný. 7 Zde stiskem tlačítka nastavení nastavíte údaje pro připojení do databáze. 8 Následně stiskem tlačítka Instalovat se nainstalují tabulky do databáze. 7 9 8 10 … … 17 19 18 20 finance/doklady - účetní doklady 19 aktuality/uploads - přílohy aktualit21 files - úložiště souborů 20 22 galerie - fotogalerie obrázků 21 23 files - načtené soubory přes web … … 26 28 files - vlastníka nastavit na apache 27 29 finance/doklady - vlastníka nastavit na apache 28 aktuality/uploads - vlastníka nastavit na apache29 30 30 31 -
trunk/ToDo.txt
r499 r507 28 28 - Automatické zasílání SMS informací 29 29 - Vytvořit modul pro záznam a vykreslování časových grafů 30 30 - V modulu News předělat přílohy na odkazy do tabulky File 31 31 32 32 Hotové -
trunk/admin/DefaultConfig.php
r491 r507 26 26 array('Name' => 'Web/UserSupport', 'Type' => 'Boolean', 'Default' => '1', 'Title' => 'Podpora uživatelů'), 27 27 array('Name' => 'Web/UploadFileFolder', 'Type' => 'String', 'Default' => 'files', 'Title' => 'Složka načtených souborů'), 28 array('Name' => 'Web/FileRootPath', 'Type' => 'String', 'Default' => 'finance/doklady', 'Title' => 'Složka generovaných dokladů'),29 28 array('Name' => 'Web/News/DaysAgo', 'Type' => 'Integer', 'Default' => '30', 'Title' => 'Stáří zobrazovaných aktualit'), 30 29 array('Name' => 'Web/News/Count', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Počet zobrazovaných aktualit na skupinu'), 30 array('Name' => 'Web/News/DirectoryId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id adresáře souborů příloh aktualit'), 31 31 array('Name' => 'Web/GoogleMapsApiKey', 'Type' => 'String', 'Default' => '', 'Title' => 'API google map'), 32 32 array('Name' => 'Web/ItemsPerPage', 'Type' => 'Integer', 'Default' => '50', 'Title' => 'Položek na stránku'), … … 39 39 array('Name' => 'Finance/MainUserId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id hlavního uživatele'), 40 40 array('Name' => 'Finance/MainSubjectId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id hlavního subjektu'), 41 array('Name' => 'Finance/DirectoryId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id adresáře souborů dokladů'), 41 42 array('Name' => 'MainRouter/HostName', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Hlavní brána'), 42 43 array('Name' => 'MainRouter/UserName', 'Type' => 'String', 'Default' => 'admin', 'Title' => 'Uživatelské jméno'), -
trunk/admin/Updates.php
r505 r507 183 183 `Message` varchar(255) NOT NULL DEFAULT '', 184 184 PRIMARY KEY (`Id`) 185 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 186 185 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 186 } 187 188 function UpdateTo507($Manager) 189 { 190 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". 191 "VALUES (NULL , 'Aktuality', NULL, '', '');"); 192 $Id = $Manager->Database->insert_id; 193 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". 194 "VALUES (NULL , 'Aktuality', '".$Id."', 'News', '');"); 195 $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ". 196 "VALUES (NULL , 'Kategorie aktualit', '".$Id."', 'NewsCategory', '');"); 197 $Manager->Execute("INSERT INTO `FileDirectory` (`Id` ,`Name` ,`Parent`". 198 ") VALUES (NULL , 'news', NULL);"); 199 $Manager->Execute("ALTER TABLE `File` ADD `Time` DATETIME NOT NULL "); 200 // Convert Hire column to Service item 201 $Manager->Execute("INSERT INTO `ServiceCategory` ( 202 `Id` ,`Name`) VALUES (NULL , 'Pevný nájem');"); 203 $ServiceCategoryHire = $Manager->Database->insert_id; 204 $DbResult = $Manager->Execute("SELECT * FROM Member WHERE Hire>0"); 205 while($Member = $DbResult->fetch_assoc()) 206 { 207 $Manager->Execute("INSERT INTO `Service` ( 208 `Id` ,`Name` ,`Category` ,`Price` ,`VAT` ,`CustomerCount` ,`Action` ,`ReplaceId` , 209 `Public` ,`InternetSpeedMin` ,`InternetSpeedMax` ,`UploadAsymmetry` ,`Memory` ,`MemorySwap` ,`Storage` ,`CPUCount`) 210 VALUES ( 211 NULL , 'Nájem', '".$ServiceCategoryHire."', '-".$Member['Hire']."', '2', '', NULL , NULL , '', '', '', '', '', '', '', '' 212 );"); 213 $ServiceHire = $Manager->Database->insert_id; 214 $Manager->Execute("INSERT INTO `ServiceCustomerRel` (`Service`, `Customer`) VALUES ". 215 "(".$ServiceHire.",".$Member['Id'].")"); 216 } 217 $Manager->Execute("ALTER TABLE `Member` DROP `Hire`"); 218 // Each device and subnet have to be assigned to payed service to determine service parameters 219 $Manager->Execute("ALTER TABLE `NetworkDevice` ADD `Service` INT NULL AFTER `Location` , 220 ADD INDEX ( `Service` )"); 221 $Manager->Execute("ALTER TABLE `NetworkDevice` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` ( 222 `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); 223 $Manager->Execute("UPDATE `NetworkDevice` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkDevice`.`Member` LIMIT 1)"); 224 $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD `Service` INT NULL AFTER `Member` , 225 ADD INDEX ( `Service` ) "); 226 $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` ( 227 `Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;"); 228 $Manager->Execute("UPDATE `NetworkSubnet` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkSubnet`.`Member` LIMIT 1)"); 187 229 } 188 230 … … 197 239 500 => array('Revision' => 502, 'Function' => 'UpdateTo502'), 198 240 502 => array('Revision' => 505, 'Function' => 'UpdateTo505'), 241 505 => array('Revision' => 507, 'Function' => 'UpdateTo507'), 199 242 ); 200 243 -
trunk/finance/finance.php
r497 r507 26 26 var $Tariffs; 27 27 var $ExternalSubject = 96; 28 var $MainSubject = 71;28 var $MainSubject; 29 29 var $BillingPeriods; 30 var $DirectoryId; 30 31 31 32 function LoadTariffs() … … 35 36 while($Tariff = $DbResult->fetch_array()) 36 37 { 37 $Tariff['InternetSpeedMin'] = $Tariff['InternetSpeedMin'] * 10 24;38 $Tariff['InternetSpeedMax'] = $Tariff['InternetSpeedMax'] * 10 24;38 $Tariff['InternetSpeedMin'] = $Tariff['InternetSpeedMin'] * 1000; 39 $Tariff['InternetSpeedMax'] = $Tariff['InternetSpeedMax'] * 1000; 39 40 $this->Tariffs[$Tariff['Id']] = $Tariff; 40 41 } … … 43 44 function RecalculateTariffs() 44 45 { 45 $ResidualSpeed = $this->MaxSpeed * 10 24;46 $ResidualSpeed = $this->MaxSpeed * 1000; 46 47 47 48 $this->LoadTariffs(); … … 92 93 } 93 94 $this->Database->update('Service', 'Id='.$Tariff['Id'], 94 array('InternetSpeedMin' => ($Tariff['InternetSpeedMin'] / 10 24),95 array('InternetSpeedMin' => ($Tariff['InternetSpeedMin'] / 1000), 95 96 'CustomerCount' => $Tariff['CustomerCount'])); 96 97 } … … 211 212 else $MonthlyInet = 0; 212 213 213 //if($Row['inet'] == 1)214 214 $Monthly += $MonthlyInet; 215 215 $Monthly -= $this->W2Kc($ConsumptionPlus); 216 $Monthly -= $Member['Hire'];217 //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption);218 216 $Monthly = round($Monthly); 219 217 -
trunk/finance/manage.php
r505 r507 381 381 } 382 382 $Period = $this->GetBillingPeriod($Member['BillingPeriod']); 383 if(($Period[' From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)']) and384 ($Member['Blocked'] == 0))383 if(($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and 384 ($Period['From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)'])) 385 385 { 386 386 $InvoiceItems = array(); … … 398 398 $MonthlyTotal += $Service['Price']; 399 399 } 400 if($Member['Hire'] != 0)401 {402 $Output .= '<tr><td>Nájem</td><td>'.(-$Member['Hire']).'</td></tr>';403 $MonthlyTotal -= $Member['Hire'];404 }405 400 if($Member['MonthlyPlus'] != 0) 406 401 { 402 $InvoiceItems[] = array('Description' => 'Spotřeba energie', 'Price' => -$Member['MonthlyPlus'], 403 'Quantity' => $Period['MonthCount'], 'VAT' => 2); 407 404 $MonthlyTotal -= $Member['MonthlyPlus']; 408 405 } … … 610 607 while($Row = $DbResult->fetch_assoc()) 611 608 { 612 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0)); 609 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 610 'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()')); 613 611 $FileId = $this->Database->insert_id; 614 612 $FileName = 'doklad-'.$FileId.'.pdf'; … … 617 615 $Bill->System = &$this->System; 618 616 $Bill->InvoiceId = $Row['Id']; 619 $FullFileName = $this->System->Modules['File']-> FilesDir.$FileName;617 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName; 620 618 $Bill->SaveToFile($FullFileName); 621 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName))); 622 $this->Database->update('FinanceInvoice', 'Id='.$Row['Id'], array('File' => $FileId)); 623 $Output .= '.'; 619 if(file_exists($FullFileName)) 620 { 621 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName))); 622 $this->Database->update('FinanceInvoice', 'Id='.$Row['Id'], array('File' => $FileId)); 623 $Output .= '.'; 624 } else $Output .= 'Soubor "'.$FullFileName.'" se nepodařilo uložit.'; 624 625 } 625 626 -
trunk/finance/tarify.php
r479 r507 25 25 { 26 26 $Tariff['Aggregation'] = '1:'.round($Tariff['InternetSpeedMax'] / $Tariff['InternetSpeedMin']); 27 $Output .= '<tr><td style="color: blue;">'.$Tariff['Name'].'</td><td align="center">'.round($Tariff['InternetSpeedMin'] / 10 24).'</td><td align="center" style="color: blue;">'.round($Tariff['InternetSpeedMax'] / 1024).'</td><td align="center">'.$Tariff['Aggregation'].'</td><td align="center">'.$Tariff['CustomerCount'].'</td><td align="center" style="color: blue;">'.$Tariff['Price'].'</td><td align="center">'.$Tariff['CustomerCount'] * $Tariff['Price'].'</td></tr>';27 $Output .= '<tr><td style="color: blue;">'.$Tariff['Name'].'</td><td align="center">'.round($Tariff['InternetSpeedMin'] / 1000).'</td><td align="center" style="color: blue;">'.round($Tariff['InternetSpeedMax'] / 1000).'</td><td align="center">'.$Tariff['Aggregation'].'</td><td align="center">'.$Tariff['CustomerCount'].'</td><td align="center" style="color: blue;">'.$Tariff['Price'].'</td><td align="center">'.$Tariff['CustomerCount'] * $Tariff['Price'].'</td></tr>'; 28 28 $TotalPrice = $TotalPrice + $Tariff['Price'] * $Tariff['CustomerCount']; 29 29 $TotalMemberCount = $TotalMemberCount + $Tariff['CustomerCount']; -
trunk/finance/user_state.php
r499 r507 85 85 if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 86 86 if($Row['BillCode'] == '') $Row['BillCode'] = 'PDF'; 87 if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/ FileDownload.php?id='.$Row['File']).'">'.$Row['BillCode'].'</a>';87 if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillCode'].'</a>'; 88 88 else $Invoice = ' '; 89 89 if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); … … 118 118 } 119 119 120 if($Member['Hire'] != 0)121 {122 $Output .= '<tr><td>Nájem</td><td>'.(-$Member['Hire']).'</td></tr>';123 $Total -= $Member['Hire'];124 }125 120 if($Member['MonthlyPlus'] != 0) 126 121 { -
trunk/finance/zivnost.php
r486 r507 8 8 var $ShortTitle = 'Daňová evidence'; 9 9 var $ExternalSubject = 96; 10 var $MainSubject = 71;11 10 var $StartEvidence = 0; 12 11 -
trunk/form_classes.php
r502 r507 150 150 ), 151 151 'ItemActions' => array( 152 array('Caption' => 'Stáhnout', 'URL' => '/ FileDownload.php?download'),152 array('Caption' => 'Stáhnout', 'URL' => '/file?download'), 153 153 ), 154 154 ), … … 456 456 'BillingPeriodLastDate' => array('Type' => 'Date', 'Caption' => 'Datum poslední fakturace', 'Default' => ''), 457 457 'NetworkSegment' => array('Type' => 'TNetworkSegment', 'Caption' => 'Úsek sítě', 'Default' => '', 'Null' => true), 458 'Hire' => array('Type' => 'Integer', 'Caption' => 'Nájem', 'Default' => '0', 'Suffix' => 'Kč'),459 458 'Blocked' => array('Type' => 'Boolean', 'Caption' => 'Blokování', 'Default' => '0'), 460 459 'PayDay' => array('Type' => 'Integer', 'Caption' => 'Den placení', 'Default' => '0', 'Suffix' => 'den'), … … 557 556 'Member' => array('Type' => 'TMember', 'Caption' => 'Zákazník', 'Default' => '0'), 558 557 'Location' => array('Type' => 'TMember', 'Caption' => 'Umístění', 'Default' => '0'), 558 'Service' => array('Type' => 'TServiceCustomerRel', 'Caption' => 'Služba', 'Default' => '', 'Null' => true), 559 559 'Used' => array('Type' => 'Boolean', 'Caption' => 'Použito', 'Default' => '1'), 560 560 'Online' => array('Type' => 'Boolean', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true), … … 810 810 'News' => array( 811 811 'Title' => 'Nová aktualita', 812 'Table' => '', 813 'SubmitText' => 'Vložit', 812 'Table' => 'News', 814 813 'Items' => array( 815 814 'Category' => array('Type' => 'TNewsCategory', 'Caption' => 'Kategorie', 'Default' => 0), 816 815 'Title' => array('Type' => 'String', 'Caption' => 'Nadpis', 'Default' => ''), 817 816 'Content' => array('Type' => 'Text', 'Caption' => 'Obsah', 'Default' => ''), 818 'Enclosure1' => array('Type' => 'File', 'Caption' => 'Přílohy (Max. velikost souboru 1 MB)', 'Default' => ''), 819 'Enclosure2' => array('Type' => 'File', 'Caption' => '', 'Default' => ''), 820 'Enclosure3' => array('Type' => 'File', 'Caption' => '', 'Default' => ''), 817 'Date' => array('Type' => 'Date', 'Caption' => 'Datum', 'Default' => ''), 818 'Author' => array('Type' => 'String', 'Caption' => 'Autor', 'Default' => ''), 819 'Enclosure' => array('Type' => 'String', 'Caption' => 'Přílohy', 'Default' => ''), 820 'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => ''), 821 'IP' => array('Type' => 'String', 'Caption' => 'IP adresa', 'Default' => '', 'ReadOnly' => true), 822 'Link' => array('Type' => 'Hyperlink', 'Caption' => 'Odkaz', 'Default' => ''), 823 ), 824 ), 825 'NewsCategory' => array( 826 'Title' => 'Kategorie aktualit', 827 'Table' => 'NewsCategory', 828 'Items' => array( 829 'Caption' => array('Type' => 'String', 'Caption' => 'Titulek', 'Default' => ''), 830 'RSS' => array('Type' => 'Hyperlink', 'Caption' => 'Zdroj RSS', 'Default' => ''), 831 'Permission' => array('Type' => 'Boolean', 'Caption' => 'Veřejné upravitelné', 'Default' => ''), 832 'Sequence' => array('Type' => 'Integer', 'Caption' => 'Pořadí', 'Default' => ''), 833 'Group' => array('Type' => 'Integer', 'Caption' => 'Skupina', 'Default' => ''), 821 834 ), 822 835 ), -
trunk/sql/updates/479.sql
r486 r507 46 46 -- Transform data from FinanceTariff 47 47 INSERT INTO Service (SELECT Id AS Id, Name, `Group` AS Category, Price, MemberCount AS CustomerCount, 48 ReplaceId, Public, SpeedM ax AS InternetSpeedMax, SpeedMin AS InternetSpeedMin,48 ReplaceId, Public, SpeedMin AS InternetSpeedMin, SpeedMax AS InternetSpeedMax, 49 49 UploadAsymmetry, 0 AS Memory, 0 AS MemorySwap, 0 AS Storage, 0 AS CPUCount FROM FinanceTariff); 50 50 51 INSERT INTO ServiceCustomerRel (SELECT NULL AS Id, InternetTariffCurrentMonth AS Ser ice, Id AS Customer, 0 AS Period FROM `Member`);52 INSERT INTO ServiceCustomerRel (SELECT NULL AS Id, InternetTariffNextMonth AS Ser ice, Id AS Customer, 1 AS Period FROM `Member`);51 INSERT INTO ServiceCustomerRel (SELECT NULL AS Id, InternetTariffCurrentMonth AS Service, Id AS Customer, 0 AS Period FROM `Member`); 52 INSERT INTO ServiceCustomerRel (SELECT NULL AS Id, InternetTariffNextMonth AS Service, Id AS Customer, 1 AS Period FROM `Member`); 53 53 54 54 ALTER TABLE `Member` DROP FOREIGN KEY `Member_ibfk_25` ; -
trunk/system/generators/dhcp.php
r440 r507 5 5 include('../routerboard.php'); 6 6 $Path = array('ip', 'dhcp-server', 'lease'); 7 $Database = &$System->Database; 7 8 8 9 $Routerboard = new Routerboard(); … … 20 21 $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE '. 21 22 ' CompareNetworkPrefix(INET_ATON(LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`'); 22 //echo($Database->error);23 23 while($Interface = $DbResult2->fetch_assoc()) 24 24 { -
trunk/system/generators/firewall_filter.php
r440 r507 6 6 include('common.php'); 7 7 $Path = array('ip', 'firewall', 'filter'); 8 $Database = &$System->Database; 8 9 9 10 $Routerboard = new Routerboard($Config['MainRouter']['HostName']); -
trunk/system/generators/firewall_mangle.php
r440 r507 9 9 include('common.php'); 10 10 $PathFirewall = array('ip', 'firewall', 'mangle'); 11 $Database = &$System->Database; 11 12 12 13 $Routerboard = new Routerboard(); … … 33 34 34 35 // Process users 35 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject`'); 36 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '. 37 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 38 'WHERE `Member`.`Blocked` = 0'); 36 39 while($Member = $DbResult->fetch_assoc()) 37 40 { -
trunk/system/generators/firewall_nat.php
r440 r507 6 6 include('common.php'); 7 7 $Path = array('ip', 'firewall', 'nat'); 8 $Database = &$System->Database; 8 9 9 10 $Routerboard = new Routerboard($Config['MainRouter']['HostName']); … … 36 37 //$Items[] = array('chain' => 'inet-in', 'dst-address' => '172.16.1.1/30', 'action' => 'accept', 'comment' => 'Local_subnet'); 37 38 38 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` JOIN `Subject` ON `Member`.`Subject` = `Subject`.`Id`'); 39 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '. 40 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 41 'WHERE `Member`.`Blocked` = 0'); 39 42 while($Member = $DbResult->fetch_assoc()) 40 43 { -
trunk/system/generators/generate.php
r440 r507 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 include('../../Common/Global.php'); 5 $Database = &$System->Database; 5 6 6 7 $Now = time(); -
trunk/system/generators/netwatch.php
r440 r507 5 5 include('../routerboard.php'); 6 6 $Path = array('tool', 'netwatch'); 7 $Database = &$System->Database; 7 8 8 9 $Routerboard = new Routerboard(); … … 20 21 while($Subnet = $DbResult->fetch_assoc()) 21 22 { 22 //print_r($Subnet);23 23 $I = explode('.', $Subnet['AddressRange']); 24 24 $I = $I[2]; -
trunk/system/generators/netwatch_import.php
r440 r507 7 7 $Path = array('tool', 'netwatch'); 8 8 $Period = 60; // every 60 seconds 9 $Database = &$System->Database; 9 10 10 11 while(1) -
trunk/system/generators/queue.php
r479 r507 9 9 include('common.php'); 10 10 $PathQueue = array('queue', 'tree'); 11 $Database = &$System->Database; 11 12 12 13 $Routerboard = new Routerboard(); … … 27 28 $InDivider = 1; 28 29 $OutDivider = 1; 29 $TotalMaxSpeedIn = round($Finance->RealMaxSpeed / $InDivider) * 10 24;30 $TotalMaxSpeedOut = round($Finance->RealMaxSpeed / $OutDivider) * 10 24;31 $UsersMaxSpeedIn = round($Finance->MaxSpeed / $InDivider) * 10 24;32 $UsersMaxSpeedOut = round($Finance->MaxSpeed / $OutDivider) * 10 24;30 $TotalMaxSpeedIn = round($Finance->RealMaxSpeed / $InDivider) * 1000; 31 $TotalMaxSpeedOut = round($Finance->RealMaxSpeed / $OutDivider) * 1000; 32 $UsersMaxSpeedIn = round($Finance->MaxSpeed / $InDivider) * 1000; 33 $UsersMaxSpeedOut = round($Finance->MaxSpeed / $OutDivider) * 1000; 33 34 $VoipMaxSpeedIn = $TotalMaxSpeedIn - 136; 34 35 $VoipMaxSpeedOut = $TotalMaxSpeedOut - 136; … … 55 56 56 57 // Process users 57 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` ');58 $DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Blocked`=0'); 58 59 while($Member = $DbResult->fetch_assoc()) 59 60 { 60 61 $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] ); 61 62 62 echo('Uživatel '.$Member['Name'].': '); 63 $Tariff = $Finance->Tariffs[$Member['InternetTariffCurrentMonth']]; 64 $SpeedIn = round($Tariff['InternetSpeedMin'] / $InDivider); 65 $SpeedOut = round($Tariff['InternetSpeedMin'] / $OutDivider); 66 $UserMaxSpeedIn = round($Tariff['InternetSpeedMax'] / $InDivider); 67 $UserMaxSpeedOut = round($Tariff['InternetSpeedMax'] / $OutDivider); 68 $ItemsQueue[] = array('name' => $Member['Name'].'-out', 'limit-at' => $SpeedIn, 'max-limit' => $UserMaxSpeedIn, 'parent' => 'main-out'); 69 $ItemsQueue[] = array('name' => $Member['Name'].'-in', 'limit-at' => $SpeedOut, 'max-limit' => $UserMaxSpeedOut, 'parent' => 'main-in'); 63 echo('Zákazník '.$Member['Name']."\n"); 64 $DbResult4 = $Database->query('SELECT `Service`.*, `ServiceCustomerRel`.`Id` AS `RelId` FROM `ServiceCustomerRel` JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` '. 65 'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`Action` IS NULL)'); 66 while($Service = $DbResult4->fetch_assoc()) 67 { 68 echo('Služba '.$Service['Name'].': '); 69 $SpeedIn = round($Service['InternetSpeedMin'] / $InDivider) * 1000; 70 $SpeedOut = round($Service['InternetSpeedMin'] / $OutDivider) * 1000; 71 $UserMaxSpeedIn = round($Service['InternetSpeedMax'] / $InDivider) * 1000; 72 $UserMaxSpeedOut = round($Service['InternetSpeedMax'] / $OutDivider) * 1000; 73 $ItemsQueue[] = array('name' => $Member['Name'].'-out', 'limit-at' => $SpeedIn, 'max-limit' => $UserMaxSpeedIn, 'parent' => 'main-out'); 74 $ItemsQueue[] = array('name' => $Member['Name'].'-in', 'limit-at' => $SpeedOut, 'max-limit' => $UserMaxSpeedOut, 'parent' => 'main-in'); 70 75 71 $DbResult2 = $Database->select('NetworkDevice', 'COUNT(*)', '(`Used` = 1) AND (`Member`='.$Member['Id'].')'); 72 $Row = $DbResult2->fetch_row(); 73 $HostCount = $Row[0]; 74 if($HostCount > 0) 75 { 76 $HostSpeedIn = round($SpeedIn / $HostCount); 77 $HostSpeedOut = round($SpeedOut / $HostCount); 78 } else 79 { 80 $HostSpeedIn = $SpeedIn; 81 $HostSpeedOut = $SpeedOut; 76 $Filter = '(`Used` = 1) AND (`Service` = '.$Service['RelId'].')'; 77 $DbResult2 = $Database->select('NetworkDevice', 'COUNT(*)', $Filter); 78 $Row = $DbResult2->fetch_row(); 79 $HostCount = $Row[0]; 80 if($HostCount > 0) 81 { 82 $HostSpeedIn = round($SpeedIn / $HostCount); 83 $HostSpeedOut = round($SpeedOut / $HostCount); 84 } else 85 { 86 $HostSpeedIn = $SpeedIn; 87 $HostSpeedOut = $SpeedOut; 88 } 89 90 $DbResult2 = $Database->select('NetworkDevice', '*', $Filter); 91 while($Device = $DbResult2->fetch_assoc()) 92 { 93 $DbResult3 = $Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 94 while($Interface = $DbResult3->fetch_assoc()) 95 { 96 $Name = $Device['Name']; 97 if($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 98 $Name = RouterOSIdent($Name); 99 echo($Name.', '); 100 $IPParts = explode('.', $Interface['LocalIP']); 101 $Subnet = $IPParts[2]; 102 $PacketMark = GetMarkByComment($Name.'-out'); 103 $ItemsQueue[] = array('name' => $Name.'-out', 'limit-at' => $HostSpeedIn, 'max-limit' => $UserMaxSpeedIn, 'parent' => $Member['Name'].'-out', 'packet-mark' => $PacketMark); 104 $PacketMark = GetMarkByComment($Name.'-in'); 105 $ItemsQueue[] = array('name' => $Name.'-in', 'limit-at' => $HostSpeedOut, 'max-limit' => $UserMaxSpeedOut, 'parent' => $Member['Name'].'-in', 'packet-mark' => $PacketMark); 106 } 107 } 108 109 $DbResult2 = $Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']); 110 while($Subnet = $DbResult2->fetch_assoc()) 111 { 112 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); 113 echo($Subnet['Name'].', '); 114 $IPParts = explode('.', $Subnet['AddressRange']); 115 $SubnetNumber = $IPParts[2]; 116 $PacketMark = GetMarkByComment($Subnet['Name'].'-out'); 117 $ItemsQueue[] = array('name' => $Subnet['Name'].'-out', 'limit-at' => $HostSpeedIn, 'max-limit' => $UserMaxSpeedIn, 'parent' => $Member['Name'].'-out', 'packet-mark' => $PacketMark); 118 $PacketMark = GetMarkByComment($Subnet['Name'].'-in'); 119 $ItemsQueue[] = array('name' => $Subnet['Name'].'-in', 'limit-at' => $HostSpeedOut, 'max-limit' => $UserMaxSpeedOut, 'parent' => $Member['Name'].'-in', 'packet-mark' => $PacketMark); 120 } 121 echo("\n"); 82 122 } 83 84 $DbResult2 = $Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']);85 while($Device = $DbResult2->fetch_assoc())86 {87 $DbResult3 = $Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');88 while($Interface = $DbResult3->fetch_assoc())89 {90 $Name = $Device['Name'];91 if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];92 $Name = RouterOSIdent($Name);93 echo($Name.', ');94 $IPParts = explode('.', $Interface['LocalIP']);95 $Subnet = $IPParts[2];96 $PacketMark = GetMarkByComment($Name.'-out');97 $ItemsQueue[] = array('name' => $Name.'-out', 'limit-at' => $HostSpeedIn, 'max-limit' => $UserMaxSpeedIn, 'parent' => $Member['Name'].'-out', 'packet-mark' => $PacketMark);98 $PacketMark = GetMarkByComment($Name.'-in');99 $ItemsQueue[] = array('name' => $Name.'-in', 'limit-at' => $HostSpeedOut, 'max-limit' => $UserMaxSpeedOut, 'parent' => $Member['Name'].'-in', 'packet-mark' => $PacketMark);100 }101 }102 103 $DbResult2 = $Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);104 while($Subnet = $DbResult2->fetch_assoc())105 {106 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);107 echo($Subnet['Name'].', ');108 $IPParts = explode('.', $Subnet['AddressRange']);109 $SubnetNumber = $IPParts[2];110 $PacketMark = GetMarkByComment($Subnet['Name'].'-out');111 $ItemsQueue[] = array('name' => $Subnet['Name'].'-out', 'limit-at' => $HostSpeedIn, 'max-limit' => $UserMaxSpeedIn, 'parent' => $Member['Name'].'-out', 'packet-mark' => $PacketMark);112 $PacketMark = GetMarkByComment($Subnet['Name'].'-in');113 $ItemsQueue[] = array('name' => $Subnet['Name'].'-in', 'limit-at' => $HostSpeedOut, 'max-limit' => $UserMaxSpeedOut, 'parent' => $Member['Name'].'-in', 'packet-mark' => $PacketMark);114 }115 echo("\n");116 123 } 117 124
Note:
See TracChangeset
for help on using the changeset viewer.