Changeset 167 for www


Ignore:
Timestamp:
Mar 24, 2009, 11:44:03 AM (16 years ago)
Author:
george
Message:
  • Přidáno: Stránka pro rozeslání emailů s počátečními hesly.
  • Upraveno: Konfigurační skripty pro nastavení síťových zařízení se systémem RouterOS doplněny o podporu zápisu konfigurace do více samostatných zařízení. Změna se týká konfigurace DHCP serveru a sledování net_watch.
  • Opraveno: Některé nefunkční odkazy na hlavní stránce.
  • Upraveno: Tabulka finance_operations nově převedena na tabulky FinanceOperation a FinanceClaimsLiabilities. Upraveny související stránky.
Location:
www
Files:
2 added
3 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • www/finance/clenove.php

    r164 r167  
    1010  {
    1111    $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í');
    1414
    1515        // Seznam členů
    1616    $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>';
    1919    //<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>';
    2121    $TotalDevice = 0;
    2222    $TotalMonth = 0;
    2323    $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.Member JOIN 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');
    2525    while($Row = $DbResult->fetch_assoc())
    2626    {
     
    3838    $Output .= '<tr><td><strong>Celkem</strong></td><td>&nbsp;</td>';
    3939    //<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">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td></tr>';
     40    $Output .= '<td align="right"><strong>'.$TotalMonth.'</strong></td><td align="right"><strong>'.$TotalCash.'</strong></td><td align="right">&nbsp;</td><td align="right">&nbsp;</td></tr>';
    4141    $Output .= '</table>';
    4242    return($Output);
  • www/finance/index.php

    r163 r167  
    1010  {
    1111    $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 />';
    1514       
    1615    $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />';
     
    6362
    6463    $Output .= 'Měsíční vyúčtování:<br />
    65     <table border="1" cellspacing="0" cellpadding="3">
     64    <table class="WideTable">
    6665    <tr><th>Položka</th><th>Cena [Kč]</th></tr>
    6766    <tr><th colspan="2">Příjmy</th></tr>';
  • www/finance/manage.php

    r165 r167  
    381381  function ConvertData()
    382382  {
    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');
    385387
    386388    // Move time of device price transformation
     
    388390
    389391    // 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          }
    396418
    397419    // Transfer finance before era
     
    402424      $DbRow2 = $DbResult2->fetch_assoc();
    403425
    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 .= '#';
    418437    }
    419438
  • www/finance/prepocet.php

    r164 r167  
    1111    $Finance = &$this->System->Modules['Finance'];
    1212    $Output = 'Aktualizuju finance uživatelů...<br />';
    13         $this->Database->query('TRUNCATE TABLE MemberPayment');
     13          $this->Database->query('TRUNCATE TABLE MemberPayment');
    1414    $DbResult = $this->Database->query('SELECT * FROM Member');
    1515    while($Member = $DbResult->fetch_assoc())
    1616    {
    17       $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE 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');
    1818      $Cash = $DbResult2->fetch_row();
    19           $Cash = $Cash[0];
     19            $Cash = $Cash[0];
    2020         
    2121      $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE user='.$Member['Id'].' AND used=1');
    2222      $ConsumptionPlus = $DbResult2->fetch_row();
    23           $ConsumptionPlus = $ConsumptionPlus[0];
     23            $ConsumptionPlus = $ConsumptionPlus[0];
    2424
    2525      $NetworkDevice = 0;
     
    3939      $MonthlyInet = $Finance->Tarify[$Member['InternetTariffNextMonth']]['price'];
    4040      //if($Row['inet'] == 1)
    41           $Monthly += $MonthlyInet;
     41            $Monthly += $MonthlyInet;
    4242      $Monthly -= $Finance->W2Kc($ConsumptionPlus);
    4343      //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption);
     
    196196          $BillCode = $Finance->GetNextDocumentLineNumber(6); // Faktury vydané
    197197          $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));
    199199        } else $Output .= ("<br />");
    200200      }
  • www/finance/spotreba.php

    r157 r167  
    99  function Show()
    1010  {
    11     global $kWh;
     11    $Finance = $this->System->Modules['Finance'];
    1212
    1313    // 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>';
    1515    $CelkovaSpotreba = 0;
    1616    $DbResult = $this->Database->query("SELECT * FROM network_segments");
     
    2323    }
    2424    $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 />';
    2727    return($Output);
    2828  }
  • www/finance/user_state.php

    r165 r167  
    2929    $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))');
    3030    $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.')');
    3232    $Member = $DbResult->fetch_assoc();
    3333    $TarifName = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]['name'];
     
    4141    $Output .= '<table style="font-size: smaller;" class="WideTable"><tr><th>Datum</th><th>Popis</th><th>Částka</th><th>Doklad</th></tr>';
    4242    $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);
    4846    while($DbRow = $DbResult->fetch_array())
    4947      $Operations[] = $DbRow;
     
    5755    //echo('<tr><td>&nbsp;</td><td>-'.$Row2['network_device'].'</td><td>Proměnná cena za zařízení</td></tr>
    5856    $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);
    6458    $DbRow = $DbResult->fetch_array();
    6559    $Total = $DbRow['Total'];
  • www/finance/zarizeni.php

    r157 r167  
    1010  {
    1111    // 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>';
    1313    $DbResult = $this->Database->query("SELECT * FROM network_segments");   
    1414    while($Row = $DbResult->fetch_array())
    1515    {
    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>';
    1717      $DbResult2 = $this->Database->query("SELECT * FROM network_devices WHERE segment=".$Row['id']." AND used=1");
    1818      while($Row = $DbResult2->fetch_array())
    1919      {
    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>';
    2121      }
    2222    }
  • www/finance/zivnost.php

    r165 r167  
    3333  {
    3434    $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)');
    3636    $Row = $DbResult->fetch_array();
    3737    $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)');
    3939    //echo('SELECT SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value > 0 AND Taxable = 1'.'<br />');
    4040    $Row = $DbResult->fetch_array();
    4141    $Balance['Income']['End'] = $Row[0] + 0;
    4242
    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)');
    4444    $Row = $DbResult->fetch_array();
    4545    $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)');
    4747          //echo('SELECT -SUM(Value) FROM FinanceCashFlow WHERE Time <= "'.TimeToMysqlDateTime($EndTime).'" AND Value < 0 AND Taxable = 1'.'<br />');
    4848    $Row = $DbResult->fetch_array();
    4949    $Balance['Spend']['End'] = $Row[0] + 0;
    5050
    51     $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation 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)');
    5252    $Row = $DbResult->fetch_array();
    5353    $Balance['Claims']['Start'] = $Row[0] + 0;
    54     $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceOperation 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)');
    5555    $Row = $DbResult->fetch_array();
    5656    $Balance['Claims']['End'] = $Row[0] + 0;
    5757
    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)');
    5959    $Row = $DbResult->fetch_array();
    6060    $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)');
    6262    $Row = $DbResult->fetch_array();
    6363    $Balance['Liabilities']['End'] = $Row[0] + 0;
     
    7171    $Row = $DbResult->fetch_array();
    7272    $Balance['SmallAssets']['End'] = $Row[0] + 0;
    73         return($Balance);
     73          return($Balance);
    7474  }
    7575
    7676  function Show()
    7777  {
     78          if(!$this->System->Modules['User']->CheckPermission('Finance', 'TradingStatus')) return('Nemáte oprávnění');
    7879    $this->System->Modules['Finance']->RecalculateTariffs(1);
    7980    //TransformFinance();
     
    157158      case 'CashFlow':
    158159        $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">';
    160161        $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];
    164167          $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>';
    165168        }
     
    169172        $Output .= '<table width="100%"><tr><td valign="top">';
    170173        $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">';
    172175        $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>';
    173176        $DbResult = $this->Database->query('SELECT * FROM FinanceClaimsLiabilities JOIN Subject ON Subject.Id = FinanceClaimsLiabilities.Subject WHERE Value > 0 ORDER BY TimeCreation');
     
    180183
    181184        $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">';
    183186        $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>';
    184187        $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  
    77foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
    88
    9 session_start();
     9if(!isset($SessionDisable)) session_start();
    1010include('config.php');
    1111include('database.php');
  • www/index.php

    r163 r167  
    2020      array('WebMail', '/webmail/', 'openwebmail.gif'),
    2121      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'),
    2424      array('Telefonní seznam', '/telseznam.php', 'tel.gif'),
    2525      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'),
     
    2929      array('Technické informace', '/network.php', 'tech.gif'),
    3030      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/', ''),
    3232      array('Kanály kabelovky', '/tkr.php', 'tv.gif'),
    33       array('Historie sítě', '/history.php', 'clear.gif'),
     33      array('Historie sítě', '/history.php', ''),
    3434      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'),
    4444    ),
    4545    'search' => array('Vyhledávání',
     
    5252    ),
    5353    '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'),
    5656      array('Jízdní řády', 'http://jizdnirady.idnes.cz/', 'www_idos_cz.gif'),
    5757      array('TV programy', 'http://tv.atlas.cz/', 'www_atlas_cz.gif'),
    5858      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/', ''),
    6060      array('Počasí', 'http://www.meteopress.cz/', 'pocasi.gif'),
    6161      array('T-Mobile SMS', 'http://www.tzones.cz/', 'www_tzones_cz.gif'),
     
    6363    ),
    6464    '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/', ''),   
    6767    ),
    6868    /*'computers' => array('Prodej počítačů',
     
    8686        if(substr($Link[1], 0, 4) != 'http') $Link[1] = $this->System->Config['Web']['RootFolder'].$Link[1];
    8787        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 />';
    8990      }
    9091    //}
     
    145146    if($this->System->Modules['User']->CheckPermission('Network', 'RegistredHostList'))
    146147          $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'))
    148149          $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/aktuality/?action=add">Vložení aktuality</a><br />';
    149150    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 />';
     
    225226            <tr align="left"><td colspan="2"><input type="password" name="Password" size="40" maxlength="16" /></td></tr>
    226227            <tr><td colspan="2">&nbsp;</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>
    230231        </tr>
    231232        <tr align="left">
     
    298299    $Database->select_db('is');
    299300
    300     $Output .= $this->InfoBar();
     301    //$Output .= $this->InfoBar();
    301302    $Output .= '<table id="MainTable"><tr><td valign="top">';
    302303    $Output .= '<div class="Panel">'.$this->ShowLinks($this->Links['main']).'</div>';
  • www/network/dostupnost.php

    r148 r167  
    1414
    1515    // 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>';
    1818    $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');
    1919    echo($this->Database->error);
  • www/page.php

    r163 r167  
    142142    '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.
    143143    '<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'].'" />'.
    145145    '<script type="text/javascript" src="'.$this->System->Config['Web']['RootFolder'].'/global.js"></script>'.
    146146    '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title>
    147147    </head><body'.$BodyParam.'>
    148148    <div id="Title">'.$Title.'</div>
    149     <div class="Navigation"><span class="MenuItem"><strong>Navigace &gt;&gt;</strong> '.$Navigation.'</span><div class="MenuItem2">';
     149    <div class="Navigation"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">';
    150150    if($this->System->Config['Web']['UserSupport'] == 1)
    151151    {
  • www/sql/updates/165.sql

    r166 r167  
    22ADD `Destination` INT NOT NULL ;
    33
     4UPDATE `finance_operations` SET `Source` = 0, `Destination` = 0;
    45UPDATE `finance_operations` SET `Source` = 96, `Destination` = `user` WHERE `Comment` = "Vklad";
    56UPDATE `finance_operations` SET `Source` = 96, `Destination` = `user` WHERE `Comment` = "Úhrada faktury";
    67
    78UPDATE `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%";
     9UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Comment` LIKE "Poplatek za měsíc%" AND money < 0;
     10UPDATE `finance_operations` SET `Source` = 71, `Destination` = `user` WHERE `Comment` LIKE "Poplatek za měsíc%" AND money > 0;
    911UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Comment` LIKE "Poplatek za internet za měsíc%";
    1012UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Comment` = "Zřízení přípojky";
     
    2729UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 96 WHERE `Comment` LIKE "Výběr%";
    2830
    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;
     31UPDATE `finance_operations` SET `Source` = 96, `Destination` = `user` WHERE `Source` = 0 AND `Destination` = 0 AND `money` > 0;
     32UPDATE `finance_operations` SET `Source` = `user`, `Destination` = 71 WHERE `Source` = 0 AND `Destination` = 0 AND `money` < 0;
    3133
    3234
  • www/system/generators

    • Property svn:ignore set to
      id_dsa
      id_dsa.pub
  • www/system/generators/dhcp_routerboard.php

    r161 r167  
    11<?php
     2
     3$SessionDisable = true;
    24include_once('../../global.php');
    35
    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');
     9while($Subnet = $DbResult->fetch_assoc())
    2810{
    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())
    3718  {
    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'];
    4220  }
    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");
    4528}
    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);
    5229
    5330?>
  • www/system/generators/netwatch.php

    r161 r167  
    11<?php
     2
     3$SessionDisable = true;
    24include_once('../../global.php');
    35
    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`');
     9while($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())
    1115  {
    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    }
    1324  }
    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}
    2033
    2134?>
  • www/system/generators/traffic_shaping_routerboard.php

    r163 r167  
    33$Enabled = 1;
    44$ClassesEnabled = 1;
     5$SessionDisable = true;
    56include_once('../../global.php');
    67$Finance = &$System->Modules['Finance'];
     
    2829
    2930$InetInterface = 'ether3';
    30 $Router = '192.168.0.11';
     31$Router = '192.168.0.99';
    3132
    3233$Commands = array();
  • www/system/netwatch_import.php

    r161 r167  
    11<?php
    2 include_once('/a/www/centrala/global.php');
     2$SessionDisable = true;
     3include_once('../global.php');
    34
     5$UserName = 'admin-ssh';
    46$Config['Web']['ShowErrors'] = 1;
    57
    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`');
     9while($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    }
    1542
    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)
    2445    {
    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"))');
    2752    }
    28   }
    29   if($Properties['status'] == 'up')
    30   {
    31     $Online = 1;
    32     $Values = array('online' => $Online,  'last_online' => 'NOW()');
    33   } else
    34   {
    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"))');
    4853  }
    4954}
  • www/temp/transform.php

    r164 r167  
    11<?php
    22
     3//$SessionDisable = true;
    34include('../global.php');
    45
     
    140141    $this->Database->insert('PermissionGroup', array('Description' => 'Ostatní'));
    141142    $PermissionGroupOthers = $this->Database->insert_id;
    142     $this->Database->insert('PermissionGroup', array('Description' => 'Členové sítě'));
    143     $PermissionGroupMembers = $this->Database->insert_id;
    144     $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupMembers, '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'));
    145146//echo($this->Database->LastQuery);
    146147    $this->Database->insert('PermissionGroup', array('Description' => 'Zástupci za domácnost'));
    147148    $PermissionGroupSubjects = $this->Database->insert_id;
    148     $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $PermissionGroupMembers, 'Type' => 'Group'));
     149    $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $PermissionGroupRegistred, 'Type' => 'Group'));
    149150$this->Database->insert('PermissionGroup', array('Description' => 'Správci sítě'));
    150151    $PermissionGroupNetworkAdmins = $this->Database->insert_id;
     
    158159    $OperationId = $this->Database->insert_id;
    159160    $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'));
    160165
    161166    $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Display', 'Item' => 'Item'));
     
    176181      } else
    177182      {
    178         $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationIdInsert, 'Type' => 'Operation'));
     183        $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $OperationIdInsert, 'Type' => 'Operation'));
    179184      }
    180185    }
     
    186191    $this->Database->insert('PermissionOperation', array('Module' => 'Share', 'Operation' => 'Display'));
    187192    $OperationId = $this->Database->insert_id;
    188     $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupMembers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
     193    $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
    189194
    190195    $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'DisplaySubjectState'));
     
    219224    $OperationId = $this->Database->insert_id;
    220225    $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'));
    221230
    222231    // Init User table from users
     
    230239      if($DbRow['role'] == 1)
    231240      {
    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']));
    233244        $UserId = $this->Database->insert_id;
    234         $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupMembers, 'Type' => 'Group'));
     245        $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupRegistred, 'Type' => 'Group'));
    235246      } else
    236247      if($DbRow['role'] == 2)
    237248      {
    238249        $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']));
    241252        $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']));
    243255        $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'));
    246258          else $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupSubjects, 'Type' => 'Group'));
    247259      }
  • www/user.php

    r164 r167  
    4646    //echo($this->Database->LastQuery);
    4747
    48     // Zkontroluj přihlášení
     48    // Check login
    4949    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    5050    $Row = $Query->fetch_assoc();
     
    6161    }
    6262
    63     // Odeber neaktivní uživatele
     63    // Remove nonactive users
    6464    $DbResult = $this->Database->select('UserOnline', 'Id, User', 'ActivityTime < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)');
    6565    while($DbRow = $DbResult->fetch_array())
     
    126126  {
    127127    $SID = session_id();
    128     // Je uživatel registrován?
    129128    $Query = $this->Database->select('User', '*', 'Name="'.$Nick.'"');
    130129    if($Query->num_rows > 0)
     
    135134      else
    136135      {
    137         $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()'));
    138        
     136        $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()'));           
    139137        $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id']));
    140138        // načtení stavu stromu
Note: See TracChangeset for help on using the changeset viewer.