- Timestamp:
- Mar 24, 2009, 11:44:03 AM (16 years ago)
- Location:
- www
- Files:
-
- 2 added
- 3 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/clenove.php
r164 r167 10 10 { 11 11 $Finance = $this->System->Modules['Finance']; 12 $this->System->Modules['Finance']->RecalculateTariffs(1);13 if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');12 $this->System->Modules['Finance']->RecalculateTariffs(1); 13 if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění'); 14 14 15 15 // Seznam členů 16 16 $Output = 'Seznam účastníků:<br>'. 17 '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">'.18 '<tr><th> JZástupce</th><th>Subjekt</th>';17 '<table class="WideTable">'. 18 '<tr><th>Zástupce</th><th>Subjekt</th>'; 19 19 //<th>Cena za zařízení [Kč]</th> 20 $Output .= '<th>Měsíční poplatek [Kč]</th><th>Stav účtu [Kč]</th><th>Běžící tarif</th><th>Příští tarif</th>< th>Poznámky</th></tr>';20 $Output .= '<th>Měsíční poplatek [Kč]</th><th>Stav účtu [Kč]</th><th>Běžící tarif</th><th>Příští tarif</th></tr>'; 21 21 $TotalDevice = 0; 22 22 $TotalMonth = 0; 23 23 $TotalCash = 0; 24 $DbResult = $this->Database->query('SELECT MonthlyTotal, Cash, Subject.Id, Subject.Name, NetworkDevice, InternetTariffCurrentMonth, InternetTariffNextMonth, CONCAT(User.SecondName, " ", User.FirstName) AS FullName FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.MemberJOIN Subject ON Subject.Id=Member.Subject JOIN User ON User.Id=Member.ResponsibleUser ORDER BY FullName');24 $DbResult = $this->Database->query('SELECT MonthlyTotal, Cash, Subject.Id, Subject.Name, NetworkDevice, InternetTariffCurrentMonth, InternetTariffNextMonth, CONCAT(User.SecondName, " ", User.FirstName) AS FullName FROM MemberPayment LEFT JOIN Member ON Member.Id=MemberPayment.Member LEFT JOIN Subject ON Subject.Id=Member.Subject JOIN User ON User.Id=Member.ResponsibleUser ORDER BY FullName'); 25 25 while($Row = $DbResult->fetch_assoc()) 26 26 { … … 38 38 $Output .= '<tr><td><strong>Celkem</strong></td><td> </td>'; 39 39 //<td align="right"><strong>'.$TotalDevice.'</strong></td> 40 $Output .= '<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right"> </td><td align="right"> </td>< td align="right"> </td></tr>';40 $Output .= '<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right"> </td><td align="right"> </td></tr>'; 41 41 $Output .= '</table>'; 42 42 return($Output); -
www/finance/index.php
r163 r167 10 10 { 11 11 $Finance = $this->System->Modules['Finance']; 12 $Output = '<table><tr><td valign="top">'; 13 14 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php?old">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />'; 12 $Output = '<table><tr><td valign="top">'; 13 if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state.php?old">Vaše finanční operace</a> (Tato volba je také přístupná po přihlášení do systému v uživatelském menu).<br /><br /><br />'; 15 14 16 15 $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />'; … … 63 62 64 63 $Output .= 'Měsíční vyúčtování:<br /> 65 <table border="1" cellspacing="0" cellpadding="3">64 <table class="WideTable"> 66 65 <tr><th>Položka</th><th>Cena [Kč]</th></tr> 67 66 <tr><th colspan="2">Příjmy</th></tr>'; -
www/finance/manage.php
r165 r167 381 381 function ConvertData() 382 382 { 383 $Output = ''; 384 $this->Database->query('TRUNCATE TABLE FinanceOperation'); 383 $Finance = $this->System->Modules['Finance']; 384 $Output = ''; 385 $this->Database->query('TRUNCATE TABLE FinanceOperation'); 386 $this->Database->query('TRUNCATE TABLE FinanceClaimsLiabilities'); 385 387 386 388 // Move time of device price transformation … … 388 390 389 391 // Transform old operations 390 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01"'); 391 while($DbRow = $DbResult->fetch_assoc()) 392 { 393 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'SourceSubject' => $DbRow['Source'], 'DestinationSubject' => $DbRow['Destination'], 'Value' => abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 394 $Output .= '.'; 395 } 392 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Source = '.$Finance->ExternalSubject.')'); 393 while($DbRow = $DbResult->fetch_assoc()) 394 { 395 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Destination'], 'Cash' => $DbRow['cash'], 'Value' => abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 396 $Output .= '.'; 397 } 398 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Destination = '.$Finance->ExternalSubject.')'); 399 while($DbRow = $DbResult->fetch_assoc()) 400 { 401 $this->Database->insert('FinanceOperation', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Source'], 'Cash' => $DbRow['cash'], 'Value' => -abs($DbRow['money']), 'Time' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Taxable' => $DbRow['Taxable'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 402 $Output .= '.'; 403 } 404 405 // Transform old invoices 406 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Source = '.$Finance->MainSubject.')'); 407 while($DbRow = $DbResult->fetch_assoc()) 408 { 409 $this->Database->insert('FinanceClaimsLiabilities', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Destination'], 'Value' => -abs($DbRow['money']), 'TimeCreation' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 410 $Output .= 'FV '.$DbRow['comment'].'<br />'; 411 } 412 $DbResult = $this->Database->query('SELECT * FROM finance_operations WHERE finance_operations.date >= "2007-12-01" AND (Destination = '.$Finance->MainSubject.')'); 413 while($DbRow = $DbResult->fetch_assoc()) 414 { 415 $this->Database->insert('FinanceClaimsLiabilities', array('Id' => $DbRow['id'], 'Subject' => $DbRow['Source'], 'Value' => abs($DbRow['money']), 'TimeCreation' => $DbRow['date'], 'BillCode' => $DbRow['BillCode'], 'Text' => $DbRow['comment'], 'Bill' => $DbRow['bill_id'])); 416 $Output .= 'FP '.$DbRow['comment'].'<br />'; 417 } 396 418 397 419 // Transfer finance before era … … 402 424 $DbRow2 = $DbResult2->fetch_assoc(); 403 425 404 if($DbRow2['money'] > 0) 405 { 406 $DestinationSubject = $Subject['Id']; 407 $SourceSubject = 96; 408 $Comment = 'Přijatá záloha (z období před daňovou evidencí)'; 409 } else 410 { 411 $DestinationSubject = 71; 412 $SourceSubject = $Subject['Id']; 413 $Comment = 'Připojení k síti (z období před daňovou evidencí)'; 414 } 415 $DbRow2['date'] = TimeToMysqlDateTime(mktime(0, 0, 0, 12, 1, 2007)); 416 $this->Database->insert('FinanceOperation', array('SourceSubject' => $SourceSubject, 'DestinationSubject' => $DestinationSubject, 'Value' => abs($DbRow2['money']), 'Time' => $DbRow2['date'], 'Taxable' => 1, 'Text' => $Comment)); 417 $Output .= '#'; 426 $DbRow2['date'] = TimeToMysqlDateTime(mktime(0, 0, 0, 12, 1, 2007)); 427 if($DbRow2['money'] > 0) 428 { 429 $Comment = 'Přijatá záloha (z období před daňovou evidencí)'; 430 $this->Database->insert('FinanceOperation', array('Subject' => $Subject['Id'], 'Cash' => 0, 'Value' => abs($DbRow2['money']), 'Time' => $DbRow2['date'], 'Taxable' => 1, 'Text' => $Comment)); 431 } else 432 { 433 $Comment = 'Připojení k síti (z období před daňovou evidencí)'; 434 $this->Database->insert('FinanceClaimsLiabilities', array('Subject' => $Subject['Id'], 'Value' => abs($DbRow2['money']), 'TimeCreation' => $DbRow2['date'], 'Text' => $Comment)); 435 } 436 $Output .= '#'; 418 437 } 419 438 -
www/finance/prepocet.php
r164 r167 11 11 $Finance = &$this->System->Modules['Finance']; 12 12 $Output = 'Aktualizuju finance uživatelů...<br />'; 13 $this->Database->query('TRUNCATE TABLE MemberPayment');13 $this->Database->query('TRUNCATE TABLE MemberPayment'); 14 14 $DbResult = $this->Database->query('SELECT * FROM Member'); 15 15 while($Member = $DbResult->fetch_assoc()) 16 16 { 17 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM Finance CashFlowWHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Member['Subject'].')) as Cash');17 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE Subject='.$Member['Subject'].') + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject='.$Member['Subject'].')) as Cash'); 18 18 $Cash = $DbResult2->fetch_row(); 19 $Cash = $Cash[0];19 $Cash = $Cash[0]; 20 20 21 21 $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE user='.$Member['Id'].' AND used=1'); 22 22 $ConsumptionPlus = $DbResult2->fetch_row(); 23 $ConsumptionPlus = $ConsumptionPlus[0];23 $ConsumptionPlus = $ConsumptionPlus[0]; 24 24 25 25 $NetworkDevice = 0; … … 39 39 $MonthlyInet = $Finance->Tarify[$Member['InternetTariffNextMonth']]['price']; 40 40 //if($Row['inet'] == 1) 41 $Monthly += $MonthlyInet;41 $Monthly += $MonthlyInet; 42 42 $Monthly -= $Finance->W2Kc($ConsumptionPlus); 43 43 //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption); … … 196 196 $BillCode = $Finance->GetNextDocumentLineNumber(6); // Faktury vydané 197 197 $BillId = $this->System->Modules['Bill']->CreateBill($User['Id'], array(array('Description' => 'Připojení k síti', 'Price' => $PayPerPeriod, 'Quantity' => 1)), $PeriodFrom, $PeriodTo, $BillCode); 198 $this->Database->insert(' finance_operations', array('money' => -$PayPerPeriod, 'user' => $User['Id'], 'type' => 2, 'date' => 'NOW()', 'comment' => 'Připojení k síti za období '.$TimePeriodText, 'group' => 1, 'bill_id' => $BillId, 'BillCode' => $BillCode));198 $this->Database->insert('FinanceClaimsLiabilities', array('Value' => $PayPerPeriod, 'Subject' => $User['Id'], 'TimeCreation' => 'NOW()', 'Text' => 'Připojení k síti za období '.$TimePeriodText, 'Bill' => $BillId, 'BillCode' => $BillCode)); 199 199 } else $Output .= ("<br />"); 200 200 } -
www/finance/spotreba.php
r157 r167 9 9 function Show() 10 10 { 11 global $kWh;11 $Finance = $this->System->Modules['Finance']; 12 12 13 13 // Seznam segmentů a zařízení 14 $Output = 'Spotřeba zařízení jednotlivých segmentů:< br /><table border="1" cellspacing="0" cellpadding="3"><tr><th>Jméno segmentu</th><th>Spotřeba [W]</th><th>Cena [Kč/měsíc]</th></tr>';14 $Output = 'Spotřeba zařízení jednotlivých segmentů:<div align="center"><table class="WideTable"><tr><th>Jméno segmentu</th><th>Spotřeba [W]</th><th>Cena [Kč/měsíc]</th></tr>'; 15 15 $CelkovaSpotreba = 0; 16 16 $DbResult = $this->Database->query("SELECT * FROM network_segments"); … … 23 23 } 24 24 $Output .= '<tr style="font-weight: Bold;"><td><strong>Celkem</strong></td><td align="right">'.$CelkovaSpotreba.'</td><td align="right">'.$this->System->Modules['Finance']->W2Kc($CelkovaSpotreba).'</td></tr>'; 25 $Output .= '</table>< br />';26 $Output .= 'Dohodnutá cena za jednu kWh: <strong>'.$ kWh.' Kč</strong><br />';25 $Output .= '</table></div>'; 26 $Output .= 'Dohodnutá cena za jednu kWh: <strong>'.$Finance->kWh.' Kč</strong><br />'; 27 27 return($Output); 28 28 } -
www/finance/user_state.php
r165 r167 29 29 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))'); 30 30 $Subject = $DbResult->fetch_assoc(); 31 $DbResult = $this->Database->query('SELECT * FROM Member JOIN MemberPayment ON MemberPayment.Member=Member.Id WHERE Member.Id=(SELECT Member FROM User WHERE User.Id='.$UserId.')');31 $DbResult = $this->Database->query('SELECT * FROM Member LEFT JOIN MemberPayment ON MemberPayment.Member=Member.Id WHERE Member.Id=(SELECT Member FROM User WHERE User.Id='.$UserId.')'); 32 32 $Member = $DbResult->fetch_assoc(); 33 33 $TarifName = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]['name']; … … 41 41 $Output .= '<table style="font-size: smaller;" class="WideTable"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>'; 42 42 $Operations = array(); 43 $DbResult = $this->Database->query('(SELECT Time, Value, Text, Bill FROM FinanceOperation WHERE (DestinationSubject='.$Subject['Id'].') AND (SourceSubject = '.$Finance->ExternalSubject.')) UNION ALL '. 44 '(SELECT Time, -Value as Value, Text, Bill FROM FinanceOperation WHERE (SourceSubject='.$Subject['Id'].') AND (DestinationSubject='.$Finance->MainSubject.')) UNION ALL '. 45 '(SELECT Time, -Value as Value, Text, Bill FROM FinanceOperation WHERE (SourceSubject='.$Subject['Id'].') AND (DestinationSubject='.$Finance->ExternalSubject.')) UNION ALL '. 46 '(SELECT Time, Value, Text, Bill FROM FinanceOperation WHERE (DestinationSubject='.$Subject['Id'].') AND (SourceSubject = '.$Finance->MainSubject.')) '. 47 'ORDER BY Time DESC'); 43 $UserOperationTableQuery = '((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '. 44 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceClaimsLiabilities WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1'; 45 $DbResult = $this->Database->query('SELECT T1.* FROM '.$UserOperationTableQuery); 48 46 while($DbRow = $DbResult->fetch_array()) 49 47 $Operations[] = $DbRow; … … 57 55 //echo('<tr><td> </td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr> 58 56 $Output .= '</table>'; 59 $DbResult = $this->Database->query('SELECT ('. 60 '(SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE (DestinationSubject='.$Subject['Id'].') AND (SourceSubject = '.$Finance->ExternalSubject.')) - '. 61 '(SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE (SourceSubject='.$Subject['Id'].') AND (DestinationSubject='.$Finance->MainSubject.')) - '. 62 '(SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE (SourceSubject='.$Subject['Id'].') AND (DestinationSubject = '.$Finance->ExternalSubject.')) + '. 63 '(SELECT COALESCE(SUM(Value), 0) FROM FinanceOperation WHERE (DestinationSubject='.$Subject['Id'].') AND (SourceSubject='.$Finance->MainSubject.'))) as Total'); 57 $DbResult = $this->Database->query('SELECT SUM(T1.Value) AS Total FROM '.$UserOperationTableQuery); 64 58 $DbRow = $DbResult->fetch_array(); 65 59 $Total = $DbRow['Total']; -
www/finance/zarizeni.php
r157 r167 10 10 { 11 11 // Seznam segmentů a zařízení 12 $Output = 'Seznam segmentů a zařízení:<br><table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3"><tr><th>Název</th><th>Spotřeba<br>[W]</th><th>Datum<br>zakoupení</th><th>Cena [Kč]</th></tr>';12 $Output = 'Seznam segmentů a zařízení:<br><table style="font-size: smaller;" class="WideTable"><tr><th>Název</th><th>Spotřeba<br>[W]</th><th>Datum<br>zakoupení</th><th>Cena [Kč]</th></tr>'; 13 13 $DbResult = $this->Database->query("SELECT * FROM network_segments"); 14 14 while($Row = $DbResult->fetch_array()) 15 15 { 16 $Output .= '<tr><td colspan="3"><strong>Segment: '.$Row['name'].' ('.$Row['users'].')</strong></td><td style="font-weight: Bold;" align="right">'.$Row['price'].'</td></tr>';16 $Output .= '<tr><td style="text-align: left" colspan="3"><strong>Segment: '.$Row['name'].' ('.$Row['users'].')</strong></td><td style="font-weight: Bold;" align="right">'.$Row['price'].'</td></tr>'; 17 17 $DbResult2 = $this->Database->query("SELECT * FROM network_devices WHERE segment=".$Row['id']." AND used=1"); 18 18 while($Row = $DbResult2->fetch_array()) 19 19 { 20 $Output .= '<tr><td >'.$Row['name'].'</td><td align="right">'.$Row['consumption'].'</td><td align="right">'.HumanDate($Row['date']).'</td><td align="right">'.$Row['price'].'</td></tr>';20 $Output .= '<tr><td style="text-align: left; padding-left: 20px;">'.$Row['name'].'</td><td align="right">'.$Row['consumption'].'</td><td align="right">'.HumanDate($Row['date']).'</td><td align="right">'.$Row['price'].'</td></tr>'; 21 21 } 22 22 } -
www/finance/zivnost.php
r165 r167 33 33 { 34 34 $Balance = array(); 35 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND ( SourceSubject = '.$this->ExternalSubject.')');35 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value > 0)'); 36 36 $Row = $DbResult->fetch_array(); 37 37 $Balance['Income']['Start'] = $Row[0] + 0; 38 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND ( SourceSubject = '.$this->ExternalSubject.')');38 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value > 0)'); 39 39 //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />'); 40 40 $Row = $DbResult->fetch_array(); 41 41 $Balance['Income']['End'] = $Row[0] + 0; 42 42 43 $DbResult = $this->Database->query('SELECT SUM( Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (DestinationSubject = '.$this->ExternalSubject.')');43 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value < 0)'); 44 44 $Row = $DbResult->fetch_array(); 45 45 $Balance['Spend']['Start'] = $Row[0] + 0; 46 $DbResult = $this->Database->query('SELECT SUM( Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (DestinationSubject = '.$this->ExternalSubject.')');46 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Taxable = 1) AND (Value < 0)'); 47 47 //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />'); 48 48 $Row = $DbResult->fetch_array(); 49 49 $Balance['Spend']['End'] = $Row[0] + 0; 50 50 51 $DbResult = $this->Database->query('SELECT SUM(Value) FROM Finance Operation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (DestinationSubject = '.$this->MainSubject.')');51 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)'); 52 52 $Row = $DbResult->fetch_array(); 53 53 $Balance['Claims']['Start'] = $Row[0] + 0; 54 $DbResult = $this->Database->query('SELECT SUM(Value) FROM Finance Operation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (DestinationSubject = '.$this->MainSubject.')');54 $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)'); 55 55 $Row = $DbResult->fetch_array(); 56 56 $Balance['Claims']['End'] = $Row[0] + 0; 57 57 58 $DbResult = $this->Database->query('SELECT SUM( Value) FROM FinanceOperation WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (SourceSubject = '.$this->MainSubject.')');58 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)'); 59 59 $Row = $DbResult->fetch_array(); 60 60 $Balance['Liabilities']['Start'] = $Row[0] + 0; 61 $DbResult = $this->Database->query('SELECT SUM( Value) FROM FinanceOperation WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (SourceSubject = '.$this->MainSubject.')');61 $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceClaimsLiabilities WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)'); 62 62 $Row = $DbResult->fetch_array(); 63 63 $Balance['Liabilities']['End'] = $Row[0] + 0; … … 71 71 $Row = $DbResult->fetch_array(); 72 72 $Balance['SmallAssets']['End'] = $Row[0] + 0; 73 return($Balance);73 return($Balance); 74 74 } 75 75 76 76 function Show() 77 77 { 78 if(!$this->System->Modules['User']->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění'); 78 79 $this->System->Modules['Finance']->RecalculateTariffs(1); 79 80 //TransformFinance(); … … 157 158 case 'CashFlow': 158 159 $Table = array('Ne', 'Ano'); 159 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';160 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 160 161 $Output .= '<tr><th>Čas</th><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Daňový</th><th>Hotovost</th></tr>'; 161 $DbResult = $this->Database->query('SELECT * FROM FinanceCashFlow JOIN Subject ON Subject.Id = FinanceCashFlow.Subject ORDER BY Time'); 162 while($Row = $DbResult->fetch_array()) 163 { 162 $DbResult = $this->Database->query('SELECT * FROM FinanceOperation LEFT JOIN Subject ON Subject.Id = FinanceOperation.Subject ORDER BY Time'); 163 while($Row = $DbResult->fetch_array()) 164 { 165 $Row['Time'] = explode(' ', $Row['Time']); 166 $Row['Time'] = $Row['Time'][0]; 164 167 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td><td>'.$Table[$Row['Taxable']].'</td><td>'.$Table[$Row['Cash']].'</td></tr>'; 165 168 } … … 169 172 $Output .= '<table width="100%"><tr><td valign="top">'; 170 173 $Output .= '<strong>Pohledávky</strong>'; 171 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';174 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 172 175 $Output .= '<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>'; 173 176 $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject WHERE Value > 0 ORDER BY TimeCreation'); … … 180 183 181 184 $Output .= '<strong>Závazky</strong>'; 182 $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';185 $Output .= '<table style="font-size: smaller;" class="WideTable">'; 183 186 $Output .= '<tr><th>Subjekt</th><th>Text</th><th>Hodnota [Kč]</th><th>Čas vystavení</th><th>Čas splatnosti</th><th>Čas uhrazení</th></tr>'; 184 187 $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject WHERE Value < 0 ORDER BY TimeCreation'); -
www/global.php
r163 r167 7 7 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 8 8 9 session_start();9 if(!isset($SessionDisable)) session_start(); 10 10 include('config.php'); 11 11 include('database.php'); -
www/index.php
r163 r167 20 20 array('WebMail', '/webmail/', 'openwebmail.gif'), 21 21 array('Jídelníček', '/jidelna/', 'apple.gif'), 22 array('Televize', 'http://tv.zdechov.net/', ' clear.gif'),23 array('Herní server', 'http://game -server.zdechov.net/', 'cube.gif'),22 array('Televize', 'http://tv.zdechov.net/', ''), 23 array('Herní server', 'http://game.zdechov.net/', 'cube.gif'), 24 24 array('Telefonní seznam', '/telseznam.php', 'tel.gif'), 25 25 array('Mapa Zděchova', 'http://www.mapy.cz/#x=141560832@y=133134848@z=13@mm=FP@sa=s@st=s@ssq=zd%C4%9Bchov@sss=1@ssp=120738725_123701121_150360997_149800833', 'clear.gif'), … … 29 29 array('Technické informace', '/network.php', 'tech.gif'), 30 30 array('Webkamera', '/webcam/', 'clear.gif'), 31 array('Stránky naší sítě', 'http://www.zdechov.net/', ' clear.gif'),31 array('Stránky naší sítě', 'http://www.zdechov.net/', ''), 32 32 array('Kanály kabelovky', '/tkr.php', 'tv.gif'), 33 array('Historie sítě', '/history.php', ' clear.gif'),33 array('Historie sítě', '/history.php', ''), 34 34 array('Měřič spotřeby', '/merak.php', 'electric.gif'), 35 array('Plány do budoucna', '/ukoly.php', ' clear.gif'),36 ),37 'local' => array('Místní subjekty',38 array('Obecní stránky', 'http://www.zdechov.cz/', 'clear.gif'),39 array(' Zděchovská grapa', 'http://zdechovskagrapa.sweb.cz/', 'clear.gif'),40 array('Snowpark', 'http://www.snbzdechov.com/', ' clear.gif'),41 array('Sbor dobrovolných hasičů', 'http://www.sdhzdechov.wz.cz/', ' clear.gif'),42 array('TJ Sokol Zděchov', 'http://fotbal.zdechov.net/', 'socer.gif'),43 array('Farnost Zděchov', 'http://farnost.zdechov.net/', 'cfix.gif'),35 array('Plány do budoucna', '/ukoly.php', ''), 36 ), 37 'local' => array('Místní subjekty', 38 array('Obecní úřad', 'http://www.zdechov.cz/', ''), 39 array('Motokrosová grapa', 'http://zdechovskagrapa.sweb.cz/', ''), 40 array('Snowpark', 'http://www.snbzdechov.com/', ''), 41 array('Sbor dobrovolných hasičů', 'http://www.sdhzdechov.wz.cz/', ''), 42 array('TJ Sokol', 'http://fotbal.zdechov.net/', 'socer.gif'), 43 array('Farnost', 'http://farnost.zdechov.net/', 'cfix.gif'), 44 44 ), 45 45 'search' => array('Vyhledávání', … … 52 52 ), 53 53 'usefull' => array('Užitečné', 54 array('Mapa ČR', 'http://www.mapy.cz/', ' clear.gif'),55 array('Online TV', 'http://www.tvinfo.cz/live/televize/ cz/', 'www_tvinfo_cz.gif'),54 array('Mapa ČR', 'http://www.mapy.cz/', ''), 55 array('Online TV', 'http://www.tvinfo.cz/live/televize/evropa/cz/', 'www_tvinfo_cz.gif'), 56 56 array('Jízdní řády', 'http://jizdnirady.idnes.cz/', 'www_idos_cz.gif'), 57 57 array('TV programy', 'http://tv.atlas.cz/', 'www_atlas_cz.gif'), 58 58 array('ICQ', 'javascript:openClient(\'flash\')', 'www_icq_com.gif'), 59 array('Slovníky', 'http:// slovniky.centrum.cz/', 'www_centrum_cz.gif'),59 array('Slovníky', 'http://www.slovnik.cz/', ''), 60 60 array('Počasí', 'http://www.meteopress.cz/', 'pocasi.gif'), 61 61 array('T-Mobile SMS', 'http://www.tzones.cz/', 'www_tzones_cz.gif'), … … 63 63 ), 64 64 'fun' => array('Zábava', 65 array('Youtube', 'http://www.youtube.com/', 'clear.gif'),66 array('Last.fm', 'http://www.last.fm/', ' clear.gif'),65 array('Youtube', 'http://www.youtube.com/', ''), 66 array('Last.fm', 'http://www.last.fm/', ''), 67 67 ), 68 68 /*'computers' => array('Prodej počítačů', … … 86 86 if(substr($Link[1], 0, 4) != 'http') $Link[1] = $this->System->Config['Web']['RootFolder'].$Link[1]; 87 87 if(!isset($Link[3]) or (isset($Link[3]) and $this->System->Modules['User']->CheckPermission($Link[3][0], $Link[3][1]))) 88 $Result .= '<img alt="'.$Link[0].'" src="images/favicons/'.$Link[2].'" width="16" height="16" /> <a href="'.$Link[1].'">'.$Link[0].'</a><br />'; 88 if($Link[2] == '') $Link[2] = 'clear.gif'; 89 $Result .= '<img alt="'.$Link[0].'" src="images/favicons/'.$Link[2].'" width="16" height="16" /> <a href="'.$Link[1].'">'.$Link[0].'</a><br />'; 89 90 } 90 91 //} … … 145 146 if($this->System->Modules['User']->CheckPermission('Network', 'RegistredHostList')) 146 147 $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/network/user_hosts.php">Registrované počítače</a><br />'; 147 //if($this->System->Modules['User']->CheckPermission('EatingPlace', 'Edit'))148 if($this->System->Modules['User']->CheckPermission('News', 'Insert')) 148 149 $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/aktuality/?action=add">Vložení aktuality</a><br />'; 149 150 if($this->System->Modules['User']->CheckPermission('EatingPlace', 'Edit')) $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/jidelna/menuedit.php">Editace jídelníčků</a><br />'; … … 225 226 <tr align="left"><td colspan="2"><input type="password" name="Password" size="40" maxlength="16" /></td></tr> 226 227 <tr><td colspan="2"> </td></tr> 227 <tr align="left"> 228 <td><input type="checkbox" name="remember" value="1" checked="checked" /> Trvalé přihlášení</td>229 <td align="right"><input type="submit" value="Přihlásit" /></td>228 <tr align="left">'. 229 //<td><input type="checkbox" name="remember" value="1" checked="checked" /> Trvalé přihlášení</td> 230 '<td align="center" colspan="2"><input type="submit" value="Přihlásit" /></td> 230 231 </tr> 231 232 <tr align="left"> … … 298 299 $Database->select_db('is'); 299 300 300 $Output .= $this->InfoBar();301 //$Output .= $this->InfoBar(); 301 302 $Output .= '<table id="MainTable"><tr><td valign="top">'; 302 303 $Output .= '<div class="Panel">'.$this->ShowLinks($this->Links['main']).'</div>'; -
www/network/dostupnost.php
r148 r167 14 14 15 15 // Zařízení 16 $Output .= '<br /><table style="font-size: small;" cellspacing="0" cellpadding="3" border="1">';17 $Output .= '<tr><th>Jméno</th><th>Hodina [%]</th><th>Den [%]</th><th>Týden [%]</th><th>Měsíc [%]</th><th> Year[%]</th></tr>';16 $Output .= '<br /><table class="WideTable" style="font-size: small;">'; 17 $Output .= '<tr><th>Jméno</th><th>Hodina [%]</th><th>Den [%]</th><th>Týden [%]</th><th>Měsíc [%]</th><th>Rok [%]</th></tr>'; 18 18 $DbResult = $this->Database->query('SELECT hosts.name, PeriodHour.Percent as Hour, PeriodDay.Percent as Day, PeriodWeek.Percent as Week, PeriodMonth.Percent as Month, PeriodYear.Percent as Year FROM hosts LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 1 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 1 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodHour ON PeriodHour.host_id=hosts.id LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodDay ON PeriodDay.host_id=hosts.id LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 7 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 7 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodWeek ON PeriodWeek.host_id=hosts.id LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 30 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 30 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodMonth ON PeriodMonth.host_id=hosts.id LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 365 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 365 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodYear ON PeriodYear.host_id=hosts.id WHERE hosts.used=1 AND hosts.show_online=0 GROUP BY hosts.IP ORDER BY name'); 19 19 echo($this->Database->error); -
www/page.php
r163 r167 142 142 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'. 143 143 '<head><link rel="stylesheet" href="'.$this->System->Config['Web']['RootFolder'].'/style.css" type="text/css" media="all" />'. 144 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->System->Config['Web']['Charset'].'" />'.144 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->System->Config['Web']['Charset'].'" />'. 145 145 '<script type="text/javascript" src="'.$this->System->Config['Web']['RootFolder'].'/global.js"></script>'. 146 146 '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title> 147 147 </head><body'.$BodyParam.'> 148 148 <div id="Title">'.$Title.'</div> 149 <div class="Navigation"><span class="MenuItem"><strong>Navigace >></strong> '.$Navigation.'</span><div class="MenuItem2">';149 <div class="Navigation"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">'; 150 150 if($this->System->Config['Web']['UserSupport'] == 1) 151 151 { -
www/sql/updates/165.sql
r166 r167 2 2 ADD `Destination` INT NOT NULL ; 3 3 4 UPDATE `finance_operations` SET `Source` = 0, `Destination` = 0; 4 5 UPDATE `finance_operations` SET `Source` = 96, `Destination` = `user` WHERE `Comment` = "Vklad"; 5 6 UPDATE `finance_operations` SET `Source` = 96, `Destination` = `user` WHERE `Comment` = "Úhrada faktury"; 6 7 7 8 UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Comment` LIKE "Připojení k síti za období%"; 8 UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Comment` LIKE "Poplatek za měsíc%"; 9 UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Comment` LIKE "Poplatek za měsíc%" AND money < 0; 10 UPDATE `finance_operations` SET `Source` = 71, `Destination` = `user` WHERE `Comment` LIKE "Poplatek za měsíc%" AND money > 0; 9 11 UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Comment` LIKE "Poplatek za internet za měsíc%"; 10 12 UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Comment` = "Zřízení přípojky"; … … 27 29 UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 96 WHERE `Comment` LIKE "Výběr%"; 28 30 29 UPDATE `finance_operations` SET `Source` = 96, `Destination` = `user` WHERE `Source` = 0 AND `Destination` = 0 ;30 UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Source` = 0 AND `Destination` = 0 ;31 UPDATE `finance_operations` SET `Source` = 96, `Destination` = `user` WHERE `Source` = 0 AND `Destination` = 0 AND `money` > 0; 32 UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Source` = 0 AND `Destination` = 0 AND `money` < 0; 31 33 32 34 -
www/system/generators
-
Property svn:ignore
set to
id_dsa
id_dsa.pub
-
Property svn:ignore
set to
-
www/system/generators/dhcp_routerboard.php
r161 r167 1 1 <?php 2 3 $SessionDisable = true; 2 4 include_once('../../global.php'); 3 5 4 // Generate DHCP server configuration 5 /* 6 $File = fopen('/etc/dhcpd.conf', 'w'); 7 fputs($File, "# DHCP Configuration file\n". 8 "authoritative;\n". 9 'option domain-name "zdechov.net";'."\n". 10 "server-name centrala;\n". 11 "ddns-update-style ad-hoc;\n". 12 "default-lease-time 86400;\n". 13 "max-lease-time 86400;\n". 14 "ddns-hostname centrala;\n". 15 "option domain-name-servers 192.168.0.1;\n". 16 "#option subnet-mask 255.255.0.0;\n\n". 17 "# nastaveni WINS serveru\n". 18 "option netbios-name-servers 192.168.0.1;\n". 19 "option netbios-dd-server 192.168.0.1;\n". 20 "option netbios-node-type 8;\n". 21 'option netbios-scope "";'."\n". 22 "server-identifier 192.168.0.1;\n\n"); 23 */ 24 $Commands = array(); 25 //$MaxSubnet = 1; 26 $Commands[] = '/ip dhcp-server lease { remove [find]}'; 27 for($i = 0; $i <= 5; $i++) 6 $UserName = 'admin-ssh'; 7 8 $DbResult = $Database->query('SELECT * FROM NetworkSubnet'); 9 while($Subnet = $DbResult->fetch_assoc()) 28 10 { 29 /* 30 fputs($File, "subnet 192.168.".$i.".0 netmask 255.255.255.0 {\n". 31 " range 192.168.".$i.".128 192.168.".$i.".254;\n". 32 " option broadcast-address 192.168.".$i.".255;\n". 33 " option routers 192.168.".$i.".1;\n"); 34 */ 35 $DbResult = $Database->select('hosts', '*', "IP LIKE '192.168.".$i."%' ORDER BY IP"); 36 while($Row = $DbResult->fetch_array()) 11 //print_r($Subnet); 12 $I = explode('.', $Subnet['AddressRange']); 13 $I = $I[2]; 14 $Commands = array(); 15 $Commands[] = '/ip dhcp-server lease { remove [find server=dhcp'.$I.']}'; 16 $DbResult2 = $Database->query('SELECT * FROM hosts WHERE (IP LIKE "192.168.'.$I.'.%") AND (MAC != "00:00:00:00:00:00") ORDER BY IP'); 17 while($Host = $DbResult2->fetch_assoc()) 37 18 { 38 // $Data = $Row['name']; 39 // if(strlen($Data) < 9) $Data .= "\t"; 40 // fputs($File, " host ".$Data."\t{ fixed-address ".$Row['IP'].";\thardware ethernet ".$Row['MAC']."; }\n"); 41 $Commands[] = '/ip dhcp-server lease add mac-address='.$Row['MAC'].' address='.$Row['IP'].' server=dhcp'.$i.' comment='.$Row['name']; 19 $Commands[] = '/ip dhcp-server lease add mac-address='.$Host['MAC'].' address='.$Host['IP'].' server=dhcp'.$I.' comment='.$Host['name']; 42 20 } 43 44 // fputs($File, "}\n\n"); 21 $Commands = implode(';', $Commands); 22 $Command = '/usr/bin/ssh -l '.$UserName.' -i id_dsa '.$Subnet['DHCP'].' "'.$Commands.'"'; 23 echo($Command."\n"); 24 $Output = ''; 25 exec($Command, $Output); 26 print_r($Output); 27 echo("\n"); 45 28 } 46 //fclose($File);47 $Commands = implode(';', $Commands);48 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa rt-hajda-0 "'.$Commands.'"';49 echo($Command);50 exec($Command, $Output);51 print_r($Output);52 29 53 30 ?> -
www/system/generators/netwatch.php
r161 r167 1 1 <?php 2 3 $SessionDisable = true; 2 4 include_once('../../global.php'); 3 5 4 $Commands = array(); 5 //$MaxSubnet = 1; 6 $Commands[] = '/tool netwatch remove [/tool netwatch find]'; 7 //for($i = 0; $i <= 4; $i++) 8 //{ 9 $DbResult = $Database->select('hosts', '*', 'IP != "" ORDER BY IP'); 10 while($Row = $DbResult->fetch_array()) 6 $UserName = 'admin-ssh'; 7 8 $DbResult3 = $Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet`'); 9 while($Router = $DbResult3->fetch_assoc()) 10 { 11 $Commands = array(); 12 $Commands[] = '/tool netwatch remove [find]'; 13 $DbResult = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `DHCP`="'.$Router['DHCP'].'"'); 14 while($Subnet = $DbResult->fetch_assoc()) 11 15 { 12 $Commands[] = '/tool netwatch add host='.$Row['IP'].' interval=1m comment='.$Row['name']; 16 //print_r($Subnet); 17 $I = explode('.', $Subnet['AddressRange']); 18 $I = $I[2]; 19 $DbResult2 = $Database->query('SELECT * FROM hosts WHERE (IP LIKE "192.168.'.$I.'.%") AND (MAC != "00:00:00:00:00:00") ORDER BY IP'); 20 while($Host = $DbResult2->fetch_assoc()) 21 { 22 $Commands[] = '/tool netwatch add host='.$Host['IP'].' interval=1m comment='.$Host['name']; 23 } 13 24 } 14 //} 15 $Commands = implode(';', $Commands); 16 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa rt-hajda-0 "'.$Commands.'"'; 17 echo($Command); 18 exec($Command, $Output); 19 print_r($Output); 25 $Commands = implode(';', $Commands); 26 $Command = '/usr/bin/ssh -l '.$UserName.' -i id_dsa '.$Router['DHCP'].' "'.$Commands.'"'; 27 echo($Command."\n"); 28 $Output = ''; 29 exec($Command, $Output); 30 print_r($Output); 31 echo("\n"); 32 } 20 33 21 34 ?> -
www/system/generators/traffic_shaping_routerboard.php
r163 r167 3 3 $Enabled = 1; 4 4 $ClassesEnabled = 1; 5 $SessionDisable = true; 5 6 include_once('../../global.php'); 6 7 $Finance = &$System->Modules['Finance']; … … 28 29 29 30 $InetInterface = 'ether3'; 30 $Router = '192.168.0. 11';31 $Router = '192.168.0.99'; 31 32 32 33 $Commands = array(); -
www/system/netwatch_import.php
r161 r167 1 1 <?php 2 include_once('/a/www/centrala/global.php'); 2 $SessionDisable = true; 3 include_once('../global.php'); 3 4 5 $UserName = 'admin-ssh'; 4 6 $Config['Web']['ShowErrors'] = 1; 5 7 6 $Commands = array(); 7 //$MaxSubnet = 1; 8 $Commands[] = '/tool netwatch print terse'; 9 $Commands = implode(';', $Commands); 10 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa rt-hajda-0 "'.$Commands.'"'; 11 //echo($Command."\n"); 12 exec($Command, $Output); 13 array_pop($Output); 14 //print_r($Output); 8 $DbResult3 = $Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet`'); 9 while($Router = $DbResult3->fetch_assoc()) 10 { 11 $Commands = array(); 12 $Commands[] = '/tool netwatch print terse'; 13 $Commands = implode(';', $Commands); 14 $Command = '/usr/bin/ssh -l '.$UserName.' -i generators/id_dsa '.$Router['DHCP'].' "'.$Commands.'"'; 15 //echo($Command."\n"); 16 $Output = ''; 17 exec($Command, $Output); 18 array_pop($Output); 19 //print_r($Output); 20 foreach($Output as $Row) 21 { 22 $Row = substr($Row, 6); 23 $RowParts = explode(' ', $Row); 24 $Properties = array(); 25 foreach($RowParts as $Index => $Item) 26 { 27 if(strpos($Item, '=') !== false) 28 { 29 $ItemParts = explode('=', $Item); 30 $Properties[$ItemParts[0]] = $ItemParts[1]; 31 } 32 } 33 if($Properties['status'] == 'up') 34 { 35 $Online = 1; 36 $Values = array('online' => $Online, 'last_online' => 'NOW()'); 37 } else 38 { 39 $Online = 0; 40 $Values = array('online' => $Online); 41 } 15 42 16 foreach($Output as $Row) 17 { 18 $Row = substr($Row, 6); 19 $RowParts = explode(' ', $Row); 20 $Properties = array(); 21 foreach($RowParts as $Index => $Item) 22 { 23 if(strpos($Item, '=') !== false) 43 $DbResult = $Database->update('hosts', 'IP="'.$Properties['host'].'"', $Values); 44 if($Online == 1) 24 45 { 25 $ItemParts = explode('=', $Item); 26 $Properties[$ItemParts[0]] = $ItemParts[1]; 46 $DbResult = $Database->select('hosts', 'id', 'IP="'.$Properties['host'].'"'); 47 $DbRow = $DbResult->fetch_array(); 48 $HostId = $DbRow['id']; 49 $DbResult2 = $Database->select('stat_hosts', '*', '(host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 50 if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO stat_hosts (host_id, time) VALUES ("'.$HostId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 51 $Database->query('UPDATE stat_hosts SET count = count + 1 WHERE (host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 27 52 } 28 }29 if($Properties['status'] == 'up')30 {31 $Online = 1;32 $Values = array('online' => $Online, 'last_online' => 'NOW()');33 } else34 {35 $Online = 0;36 $Values = array('online' => $Online);37 }38 39 $DbResult = $Database->update('hosts', 'IP="'.$Properties['host'].'"', $Values);40 if($Online == 1)41 {42 $DbResult = $Database->select('hosts', 'id', 'IP="'.$Properties['host'].'"');43 $DbRow = $DbResult->fetch_array();44 $HostId = $DbRow['id'];45 $DbResult2 = $Database->select('stat_hosts', '*', '(host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');46 if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO stat_hosts (host_id, time) VALUES ("'.$HostId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');47 $Database->query('UPDATE stat_hosts SET count = count + 1 WHERE (host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');48 53 } 49 54 } -
www/temp/transform.php
r164 r167 1 1 <?php 2 2 3 //$SessionDisable = true; 3 4 include('../global.php'); 4 5 … … 140 141 $this->Database->insert('PermissionGroup', array('Description' => 'Ostatní')); 141 142 $PermissionGroupOthers = $this->Database->insert_id; 142 $this->Database->insert('PermissionGroup', array('Description' => ' Členové sítě'));143 $PermissionGroup Members= $this->Database->insert_id;144 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroup Members, 'GroupOrOperation' => $PermissionGroupOthers, 'Type' => 'Group'));143 $this->Database->insert('PermissionGroup', array('Description' => 'Registrovaní uživatelé')); 144 $PermissionGroupRegistred = $this->Database->insert_id; 145 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $PermissionGroupOthers, 'Type' => 'Group')); 145 146 //echo($this->Database->LastQuery); 146 147 $this->Database->insert('PermissionGroup', array('Description' => 'Zástupci za domácnost')); 147 148 $PermissionGroupSubjects = $this->Database->insert_id; 148 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $PermissionGroup Members, 'Type' => 'Group'));149 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $PermissionGroupRegistred, 'Type' => 'Group')); 149 150 $this->Database->insert('PermissionGroup', array('Description' => 'Správci sítě')); 150 151 $PermissionGroupNetworkAdmins = $this->Database->insert_id; … … 158 159 $OperationId = $this->Database->insert_id; 159 160 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 161 162 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Insert', 'Item' => '')); 163 $OperationId = $this->Database->insert_id; 164 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 160 165 161 166 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Display', 'Item' => 'Item')); … … 176 181 } else 177 182 { 178 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroup Others, 'GroupOrOperation' => $OperationIdInsert, 'Type' => 'Operation'));183 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $OperationIdInsert, 'Type' => 'Operation')); 179 184 } 180 185 } … … 186 191 $this->Database->insert('PermissionOperation', array('Module' => 'Share', 'Operation' => 'Display')); 187 192 $OperationId = $this->Database->insert_id; 188 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroup Members, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));193 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 189 194 190 195 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'DisplaySubjectState')); … … 219 224 $OperationId = $this->Database->insert_id; 220 225 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 226 227 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'TradingStatus')); 228 $OperationId = $this->Database->insert_id; 229 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupAdmin, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 221 230 222 231 // Init User table from users … … 230 239 if($DbRow['role'] == 1) 231 240 { 232 $this->Database->insert('User', array('Id' => $DbRow['id'], 'Name' => $DbRow['nick'], 'FirstName' => $DbRow['first_name'], 'SecondName' => $DbRow['second_name'], 'PhoneNumber' => $DbRow['phone'], 'Password' => substr(sha1(strtoupper($DbRow['nick'])), 0, 70), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0)); 241 //$Password = sha1(strtoupper($DbRow['nick'])); 242 $Password = substr(sha1(mt_rand(0, 1000000)), 0, 10); 243 $this->Database->insert('User', array('Id' => $DbRow['id'], 'Name' => $DbRow['nick'], 'FirstName' => $DbRow['first_name'], 'SecondName' => $DbRow['second_name'], 'PhoneNumber' => $DbRow['phone'], 'Password' => sha1($Password), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0, 'InitPassword' => $Password, 'Nick' => $DbRow['nick'])); 233 244 $UserId = $this->Database->insert_id; 234 $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroup Members, 'Type' => 'Group'));245 $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupRegistred, 'Type' => 'Group')); 235 246 } else 236 247 if($DbRow['role'] == 2) 237 248 { 238 249 $this->Database->insert('Subject', array('Id' => $DbRow['id'], 'Name' => $DbRow['subject_name'], 'AddressStreet' => $DbRow['street'], 'AddressTown' => $DbRow['town'], 'AddressPSC' => $DbRow['psc'], 'IC' => $DbRow['ico'], 'DIC' => $DbRow['dic'], 'MapPositionX' => $DbRow['PositionX'], 'MapPositionY' => $DbRow['PositionY'])); 239 $SubjectId = $this->Database->insert_id;240 $this->Database->insert('Member', array('Id' => $DbRow['id'], 'Subject' => $SubjectId, 'FamilyMemberCount' => $DbRow['family'], 'NetworkSegment' => $DbRow['network_segment'], 'InternetTariffCurrentMonth' => $DbRow['inet_tarif_now'], 'InternetTariffNextMonth' => $DbRow['inet_tarif_next'], 'MembershipDate' => $DbRow['membership_date'], 'MemberState' => 0, 'BillingPeriod' => $DbRow['BillingPeriod']));250 $SubjectId = $this->Database->insert_id; 251 $this->Database->insert('Member', array('Id' => $DbRow['id'], 'Subject' => $SubjectId, 'FamilyMemberCount' => $DbRow['family'], 'NetworkSegment' => $DbRow['network_segment'], 'InternetTariffCurrentMonth' => $DbRow['inet_tarif_now'], 'InternetTariffNextMonth' => $DbRow['inet_tarif_next'], 'MembershipDate' => $DbRow['membership_date'], 'MemberState' => 0, 'BillingPeriod' => $DbRow['BillingPeriod'])); 241 252 $MemberId = $this->Database->insert_id; 242 $this->Database->insert('User', array('Id' => $DbRow['id'], 'Name' => $DbRow['nick'], 'FirstName' => $DbRow['first_name'], 'SecondName' => $DbRow['second_name'], 'PhoneNumber' => $DbRow['phone'], 'Password' => substr(sha1(strtoupper($DbRow['nick'])), 0, 70), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0, 'Member' => $MemberId)); 253 $Password = substr(sha1(mt_rand(0, 1000000)), 0, 10); 254 $this->Database->insert('User', array('Id' => $DbRow['id'], 'Name' => $DbRow['nick'], 'FirstName' => $DbRow['first_name'], 'SecondName' => $DbRow['second_name'], 'PhoneNumber' => $DbRow['phone'], 'Password' => sha1($Password), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0, 'Member' => $MemberId, 'InitPassword' => $Password, 'Nick' => $DbRow['nick'])); 243 255 $UserId = $this->Database->insert_id; 244 $this->Database->update('Member', 'Id='.$MemberId, array('ResponsibleUser' => $UserId));245 if($DbRow['id'] == 1) $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupAdmin, 'Type' => 'Group'));256 $this->Database->update('Member', 'Id='.$MemberId, array('ResponsibleUser' => $UserId)); 257 if($DbRow['id'] == 1) $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupAdmin, 'Type' => 'Group')); 246 258 else $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupSubjects, 'Type' => 'Group')); 247 259 } -
www/user.php
r164 r167 46 46 //echo($this->Database->LastQuery); 47 47 48 // Zkontroluj přihlášení48 // Check login 49 49 $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"'); 50 50 $Row = $Query->fetch_assoc(); … … 61 61 } 62 62 63 // Odeber neaktivní uživatele63 // Remove nonactive users 64 64 $DbResult = $this->Database->select('UserOnline', 'Id, User', 'ActivityTime < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)'); 65 65 while($DbRow = $DbResult->fetch_array()) … … 126 126 { 127 127 $SID = session_id(); 128 // Je uživatel registrován?129 128 $Query = $this->Database->select('User', '*', 'Name="'.$Nick.'"'); 130 129 if($Query->num_rows > 0) … … 135 134 else 136 135 { 137 $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()')); 138 136 $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()')); 139 137 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id'])); 140 138 // načtení stavu stromu
Note:
See TracChangeset
for help on using the changeset viewer.