- Timestamp:
- May 27, 2009, 1:17:11 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/database.php
r187 r219 4 4 // Date: 2009-02-16 5 5 6 6 7 class Database extends mysqli 7 8 { 8 9 var $Prefix = ''; 10 var $Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()'); 9 11 10 12 function query($Query) 11 13 { 12 global $Config;14 global $Config; 13 15 14 if($Config['Web']['ShowSQLQuery'] == true)15 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>');16 $Result = parent::query($Query);16 if($Config['Web']['ShowSQLQuery'] == true) 17 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'); 18 $Result = parent::query($Query); 17 19 if(($this->error != '') and ($Config['Web']['ShowSQLError'] == true)) 18 20 echo('<div><strong>SQL Error: </strong>'.$this->error.'<br />'.$Query.'</div>'); … … 39 41 $Value = strtr($Value, '"', '\"'); 40 42 $Name .= ',`'.$Key.'`'; 41 if($Value == 'NOW()') $Values .= ",".$Value; 42 else if($Value == 'UUID()') $Values .= ",".$Value; 43 else $Values .= ",'".$Value."'"; 43 if(!in_array($Value, $this->Functions)) $Value = '"'.$Value.'"'; 44 $Values .= ','.$Value; 44 45 } 45 46 $Name = substr($Name, 1); … … 54 55 { 55 56 $Value = strtr($Value, '"', '\"'); 56 if($Value != 'NOW()') $Value = "'".$Value."'";57 if(!in_array($Value, $this->Functions)) $Value = '"'.$Value.'"'; 57 58 $Values .= ', '.$Key.'='.$Value; 58 59 } … … 68 69 { 69 70 $Value = strtr($Value, '"', '\"'); 71 if(!in_array($Value, $this->Functions)) $Value = '"'.$Value.'"'; 70 72 $Name .= ',`'.$Key.'`'; 71 if($Value == 'NOW()') $Values .= ','.$Value; 72 else $Values .= ',"'.$Value.'"'; 73 $Values .= ','.$Value; 73 74 } 74 75 $Name = substr($Name, 1); -
trunk/error.php
r212 r219 5 5 global $Config; 6 6 7 $Date = date( "Y-m-d H:i:s"); // časové razítko položky7 $Date = date('Y-m-d H:i:s'); // časové razítko položky 8 8 $ErrorType = array 9 9 ( … … 29 29 $Backtrace[0]['args'] = ''; 30 30 //$First = array_shift($Backtrace); 31 print_r($First);31 //print_r($First); 32 32 33 33 //array_unshift($Backtrace, $First); -
trunk/finance/manage.php
r207 r219 517 517 // Generuj účetní položky 518 518 $DbResult = $this->Database->query('SELECT Member.*, MemberPayment.MonthlyTotal, UNIX_TIMESTAMP(Member.BillingPeriodLastDate), Subject.Name AS SubjectName FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.Member JOIN Subject ON Subject.Id=Member.Subject'); 519 while($Member = $DbResult->fetch_a rray())519 while($Member = $DbResult->fetch_assoc()) 520 520 { 521 521 $Output .= $Member['SubjectName'].': '; 522 $Period = $this->GetBillingPeriod($Member['BillingPeriodNext']); 522 //$Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)'] = MysqlDateTimeToTime('2009-04-01 1:1:1'); 523 $Period = $this->GetBillingPeriod($Member['BillingPeriodNext']); 523 524 if($Period['From'] > $Member['UNIX_TIMESTAMP(Member.BillingPeriodLastDate)']) 524 525 { 525 526 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriod' => $Member['BillingPeriodNext'], 'InternetTariffCurrentMonth' => $Member['InternetTariffNextMonth'])); 526 527 $Member['BillingPeriod'] = $Member['BillingPeriodNext']; 528 $Member['InternetTariffCurrentMonth'] = $Member['InternetTariffNextMonth']; 527 529 } 528 530 $Period = $this->GetBillingPeriod($Member['BillingPeriod']); … … 536 538 $BillId = $this->System->Modules['Bill']->CreateBill($Member['Subject'], array(array('Description' => 'Připojení k síti', 'Price' => $PayPerPeriod, 'Quantity' => 1)), $Period['From'], $Period['To'], $BillCode); 537 539 $this->Database->insert('FinanceClaimsLiabilities', array('Value' => $PayPerPeriod, 'Subject' => $Member['Subject'], 'TimeCreation' => 'NOW()', 'Text' => 'Připojení k síti za období '.$TimePeriodText, 'Bill' => $BillId, 'BillCode' => $BillCode)); 540 $Output .= $this->SendPaymentEmail($Member['Id']); 538 541 $this->Database->update('Member', 'Id='.$Member['Id'], array('BillingPeriodLastDate' => TimeToMysqlDateTime($Period['To']))); 539 542 } else $Output .= '<br />'; … … 565 568 566 569 // Restart traffic shaping 567 //$this->Database->update('NetworkConfiguration', 'Id = 3', array('Changed' => 1)); 568 } 569 return($Output); 570 //$this->Database->update('NetworkConfiguration', 'Id = 3', array('Changed' => 1)); 571 } 572 return($Output); 573 } 574 575 function SendPaymentEmail($MemberId) 576 { 577 global $Config; 578 579 $DbResult = $this->Database->select('Member', '*', 'Id='.$MemberId); 580 $Member = $DbResult->fetch_assoc(); 581 582 $DbResult = $this->Database->select('MemberPayment', '*', 'Member='.$MemberId); 583 $MemberPayment = $DbResult->fetch_assoc(); 584 585 $DbResult = $this->Database->select('Subject', 'Name', 'Id='.$Member['Subject']); 586 $Subject = $DbResult->fetch_assoc(); 587 588 $DbResult = $this->Database->select('User', '*', 'Id='.$Member['ResponsibleUser']); 589 $User = $DbResult->fetch_assoc(); 590 591 if($User['Email'] != '') 592 { 593 $Title = 'Pravidelné vyúčtování internetu'; 594 $Content = 'Vyúčtovaní subjektu <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'.$User['Name'].'</strong>.<br /><br />'. 595 'Váš aktuální tarif: <strong>'.$this->System->Modules['Finance']->Tariffs[$Member['InternetTariffCurrentMonth']]['Name'].'</strong><br />'. 596 'Vaše platební období: <strong>'.$this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'. 597 'Pravidelná platba za období: <strong>'.$MemberPayment['MonthlyTotal'].' Kč</strong><br />'. 598 'Stav vašeho účtu: <strong>'.$MemberPayment['Cash'].' Kč</strong><br /><br />'; 599 $Content .= 'Nové finanční operace:<br/>'. 600 '<table border="1"><tr><th>Čas</th><th>Popis</th><th>Částka [Kč]</th></tr>'; 601 //$Member['BillingPeriodLastDate'] = '2009-04-01'; 602 $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Member['Subject'].')) UNION ALL '. 603 '(SELECT Text, TimeCreation as Time, -Value as Value, Bill FROM FinanceClaimsLiabilities WHERE (Subject='.$Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")'); 604 while($DbRow = $DbResult->fetch_assoc()) 605 { 606 $Content .= '<tr><td>'.HumanDate($DbRow['Time']).'</td><td>'.$DbRow['Text'].'</td><td>'.$DbRow['Value'].'</td></tr>'; 607 } 608 $Content .= '</table>'. 609 'Pro více informací a možnost změny údajů se prosím přihlašte na stránkách <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'</a>.<br /><br />'; 610 611 $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí pište zpět.'; 612 $AdditionalHeaders = 'To: =?UTF-8?B?'.base64_encode($User['Name']).'?= <'.$User['Email'].">\n".'From: =?UTF-8?B?'.base64_encode($Config['Web']['Title']).'?='." <".$Config['Web']['AdminEmail'].">\n"; 613 $this->System->AddEmailToQueue($User['Email'], $Title, $Content, $AdditionalHeaders); 614 $Output = ''; 615 } else $Output = 'Uživatel '.$User['Name'].' nemá email.'; 570 616 } 571 617 } -
trunk/form_classes.php
r204 r219 149 149 ), 150 150 ), 151 'Email' => array( 152 'Title' => 'Nový email', 153 'Table' => 'EmailQueue', 154 'SubmitText' => 'Odeslat', 155 'Items' => array( 156 'Address' => array('Type' => 'String', 'Caption' => 'Adresa', 'Default' => ''), 157 'Subject' => array('Type' => 'String', 'Caption' => 'Předmět', 'Default' => ''), 158 'Content' => array('Type' => 'Text', 'Caption' => 'Obsah', 'Default' => ''), 159 ), 160 ), 151 161 ); 152 162 -
trunk/forms.php
r202 r219 43 43 break; 44 44 case 'String': 45 $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 46 break; 47 case 'Password': 48 $Edit = '<input type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 45 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 46 break; 47 case 'Text': 48 $Edit = '<textarea style="width: 100%; height: 200px;" name="'.$Context.$Index.'">'.$this->Values[$Index].'</textarea>'; 49 break; 50 case 'Password': 51 $Edit = '<input style="width: 100%;" type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 49 52 break; 50 53 case 'Integer': 51 $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';54 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 52 55 break; 53 56 case 'Float': 54 $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';57 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 55 58 break; 56 59 case 'Time': 57 60 if($this->Values[$Index] == 'Now') $this->Values[$Index] = date('j.n.Y'); 58 $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';61 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 59 62 break; 60 63 case 'Array': … … 79 82 { 80 83 case 'Enumeration': 81 $Edit = '<select name="'.$Context.$Index.'">';84 $Edit = '<select style="width: 100%;" name="'.$Context.$Index.'">'; 82 85 foreach($FormTypes[$Item['Type']]['States'] as $StateIndex => $StateName) 83 86 { … … 89 92 break; 90 93 case 'Reference': 91 $Edit = '<select name="'.$Context.$Index.'">';94 $Edit = '<select style="width: 100%;" name="'.$Context.$Index.'">'; 92 95 $DbResult = $Database->select($FormTypes[$Item['Type']]['Table'], $FormTypes[$Item['Type']]['Id'].' as Id, '.$FormTypes[$Item['Type']]['Name'].' as Name', $FormTypes[$Item['Type']]['Filter'].' ORDER BY Name'); 93 96 while($Row = $DbResult->fetch_array()) … … 175 178 break; 176 179 case 'String': 180 $Values[$Index] = $_POST[$Context.$Index]; 181 break; 182 case 'Text': 177 183 $Values[$Index] = $_POST[$Context.$Index]; 178 184 break; -
trunk/global.php
r208 r219 37 37 $this->Modules[get_class($Module)] = $Module; 38 38 } 39 40 function AddEmailToQueue($Address, $Subject, $Content, $Headers = '') 41 { 42 $this->Database->insert('EmailQueue', array('Address' => $Address, 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 'Headers' => $Headers)); 43 } 44 45 function MailUTF8($To, $Subject = '(No subject)', $Message = '', $Header = '') 46 { 47 $Header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n".$Header; 48 mail($To, '=?UTF-8?B?'.base64_encode($Subject).'?=', $Message, $Header); 49 } 50 51 function ProcessEmailQueue() 52 { 53 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 54 while($DbRow = $DbResult->fetch_assoc()) 55 { 56 $this->MailUTF8($DbRow['Address'], $DbRow['Subject'], $DbRow['Content'], $DbRow['Headers']); 57 //echo('mail('.$DbRow['Address'].', '.$DbRow['Subject'].', '.$DbRow['Content'].', FromUTF8('.$DbRow['Headers'].', \'iso2\'));'); 58 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 59 $this->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']); 60 } 61 } 39 62 } 40 63 41 64 $System = new System(); 42 65 $System->Config = $Config; 66 $System->Database = &$Database; 43 67 include_once('log.php'); 44 68 $System->AddModule(new Log()); … … 119 143 function ToCzfreeIp($Host) 120 144 { 121 122 123 145 $Parts = explode('.', $Host['external_ip']); 146 if($Host['name'] == 'CENTRALA') return('10.144.1.1'); 147 else return('10.144.200.'.$Parts[3]); 124 148 } 125 149 -
trunk/network/administration.php
r197 r219 6 6 var $FullTitle = 'Administrace sítě'; 7 7 var $ShortTitle = 'Administrace sítě'; 8 var $State = array('Neplánováno', 'V plánu');9 var $Period = 60;10 8 11 9 function Show() 12 10 { 13 11 if(!$this->System->Modules['User']->CheckPermission('Network', 'Administration')) return('Nemáte oprávnění'); 14 15 $Output = ' 16 <a href="'.$this->System->Config['Web']['RootFolder'].'/statistic/known_mac.php">Zachycené MAC adresy</a><br> 17 <a href="'.$this->System->Config['Web']['RootFolder'].'/statistic/connections.php">Síťová připojení</a><br> 18 <a href="'.$this->System->Config['Web']['RootFolder'].'/statistic/bandwidth.php">Zatížení linky do internetu</a><br> 19 <a href="'.$this->System->Config['Web']['RootFolder'].'/statistic/bandwidth_full.php">Zatížení linky do internetu všechny počítače</a><br> 20 <a href="'.$this->System->Config['Web']['RootFolder'].'/network/dostupnost.php">Dostupnost sítě</a><br> 21 <a href="'.$this->System->Config['Web']['RootFolder'].'/is/wlan.php">Bezdrátové sítě v okolí</a><br> 22 <a href="'.$this->System->Config['Web']['RootFolder'].'/network/restart.php">Ruční restart konfigurace sítě</a><br> 23 <a href="'.$this->System->Config['Web']['RootFolder'].'/backup/index.php">Nastavení zálohování</a><br> 24 <a href="'.$this->System->Config['Web']['RootFolder'].'/LogShow.php">Záznamy operací</a><br> 25 <a href="tc.php?dev=imq0">Traffic control IMQ0(Inet down)</a><br> 26 <a href="tc.php?dev=imq1">Traffic control IMQ1(Inet up)</a><br> 27 <a href="wlan.php">WiFi signál</a><br>'; 12 $Output = ''; 13 if(array_key_exists('Action', $_GET)) 14 { 15 if($_GET['Action'] == 'SendEmail') 16 { 17 $Form = new Form('Email'); 18 $Form->OnSubmit = '?Action=SendEmail2'; 19 $Output = $Form->ShowEditForm(); 20 } else 21 if($_GET['Action'] == 'SendEmail2') 22 { 23 $Form = new Form('Email'); 24 $Form->LoadValuesFromForm(); 25 $Result = $this->System->AddEmailToQueue($Form->Values['Address'], $Form->Values['Subject'], $Form->Values['Content']); 26 $Output = $this->SystemMessage('Vložení emailu', 'Nový email byl vložen do fronty'); 27 } 28 if($_GET['Action'] == 'ProcessEmailQueue') 29 { 30 $this->System->ProcessEmailQueue(); 31 $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány'); 32 } 33 } else 34 $Output = 35 //'<a href="'.$this->System->Config['Web']['RootFolder'].'/statistic/known_mac.php">Zachycené MAC adresy</a><br />'. 36 //'<a href="'.$this->System->Config['Web']['RootFolder'].'/statistic/connections.php">Síťová připojení</a><br />'. 37 //'<a href="'.$this->System->Config['Web']['RootFolder'].'/statistic/bandwidth.php">Zatížení linky do internetu</a><br />'. 38 //'<a href="'.$this->System->Config['Web']['RootFolder'].'/statistic/bandwidth_full.php">Zatížení linky do internetu všechny počítače</a><br />'. 39 '<a href="'.$this->System->Config['Web']['RootFolder'].'/network/dostupnost.php">Dostupnost sítě</a><br />'. 40 //'<a href="'.$this->System->Config['Web']['RootFolder'].'/is/wlan.php">Bezdrátové sítě v okolí</a><br />'. 41 '<a href="'.$this->System->Config['Web']['RootFolder'].'/network/restart.php">Ruční restart konfigurace sítě</a><br />'. 42 //'<a href="'.$this->System->Config['Web']['RootFolder'].'/backup/index.php">Nastavení zálohování</a><br />'. 43 '<a href="'.$this->System->Config['Web']['RootFolder'].'/LogShow.php">Záznamy operací</a><br />'. 44 '<a href="?Action=SendEmail">Zaslat email</a><br />'. 45 '<a href="?Action=ProcessEmailQueue">Zpracovat frontu emailů</a><br />'; 46 //'<a href="tc.php?dev=imq0">Traffic control IMQ0(Inet down)</a><br />'. 47 //'<a href="tc.php?dev=imq1">Traffic control IMQ1(Inet up)</a><br />'. 48 //'<a href="wlan.php">WiFi signál</a><br />'; 28 49 return($Output); 29 50 }
Note:
See TracChangeset
for help on using the changeset viewer.