Changeset 163


Ignore:
Timestamp:
Feb 20, 2009, 9:53:27 AM (16 years ago)
Author:
george
Message:
  • Opraveno: Další vlna odstraňování odkazů na starou tabulku users.
  • Upraveno: Posílání konfigurace traffic shapingu do rotueru mikrotik po menších blocích.
  • Přidáno: Nová tabulka MemberPayment fungující jako bilance skutečných měsíčních plateb a jako cache některých výpočtů k placení.
  • Přidáno: Zobrazení běhových ladících informací na spodku stránky.
  • Opraveno: V XHTML hlavičce opravena volba kódování.
Location:
www
Files:
1 added
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • www/block/index.php

    r154 r163  
    66</head><body>
    77
    8 <?php
    9 /*
    10 <div style="font-size: 20 pt;">Nemáte povoleno přistupovat k internetu!</div>
    11 <br>
    12 <strong>Důvod:</strong>
    13 $Duvody = array('Internet máte povolen, avšak došlo k chybě při kontrole přístupů k internetu.',
    14 'Váš počítač má blokován přístup k internetu.',
    15 'Váš účet je v mínusu. Zaplaťte prosím chybějící peníze.',
    16 'Přistupovat k internetu můžete pouze pomocí VPN(Virtuální Privátní Sítě). Aktivujte toto připojení.',
    17 'Váš počítač není registrován. Zaregistrujte jej prosím.');
    18 
    19 include_once('../centrala/global.php');
    20 $DbResult = $Database->query("SELECT * FROM hosts WHERE IP='".$_SERVER['REMOTE_ADDR']."'");
    21 if($DbResult->num_rows > 0)
    22 {
    23   $Row = $DbResult->fetch_array();
    24   $DbResult = $Database->select('users', '*', 'id='.$Row['user']);
    25   $User = $DbResult->fetch_array();
    26  
    27   if(($Row['vpn'] == 1) and ($User['inet'] == 1)) echo($Duvody[3]);
    28   else {
    29     if($User['inet'] == 1) echo($Duvody[0]);
    30     else echo($Duvody[1]);
    31   }
    32 //  else echo('K tomuto důvodu není popis');
    33 
    34 } else echo($Duvody[4]);
    35 echo('<br><br>V případě problémů kontaktujte správce na emailové adrese robie@centrum.cz<br>');
    36 */
    37 ?>
    388Pokračujte na hlavní stránku serveru Centrála <a href="http://centrala.zdechov.net/">zde</a>
    399</body></html>
  • www/config.sample.php

    r161 r163  
    2424    'ShowSQLError' => false,
    2525    'ShowSQLQuery' => false,
     26    'ShowRuntimeInfo' => false,
    2627    'ErrorLogFile' => '/var/www/html/dev/centrala/www/php_script_error.log',   
    2728    'WebcamPassword' => '',
  • www/finance/clenove.php

    r157 r163  
    2222      $TotalMonth = 0;
    2323      $TotalCash = 0;
    24       $DbResult = $this->Database->query('SELECT *, CONCAT(users.second_name, " ", users.first_name) as Fullname, ((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject=users.id) + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject=users.id)) as Cash FROM users WHERE role=2 ORDER BY fullname');
    25 
    26       //$DbResult = $Database->query("SELECT *,CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE role=2 ORDER BY fullname");
     24      $DbResult = $this->Database->query('SELECT * FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.Member JOIN Subject ON Subject.Id=Member.Subject ORDER BY Name');
    2725      while($Row = $DbResult->fetch_array())
    2826      {
    29         $Monthly = $Row['monthly'] - $Row['plus'];
    30         if($Row['hw'] == 0) $Monthly = '(trvale nepřipojen) '.(-$Row['plus']);
    31         else
    32         {
    33           if($Row['overheads'] == 0) $Monthly = '(dočasně nepřipojen) '.$Monthly;
    34           else
    35           {
    36             if($Row['inet'] == 0) $Monthly = '(bez internetu) '.$Monthly;
    37             else $Monthly = $Monthly;
    38           }
    39         }
    40         //$Row['cash'] = $Row['AdvancesIn'] - $Row['AdvancesOut'] + $Row['Liabilities'] - $Row['Claims'];
     27       //$Row['cash'] = $Row['AdvancesIn'] - $Row['AdvancesOut'] + $Row['Liabilities'] - $Row['Claims'];
    4128        $TotalCash += $Row['Cash'];
    4229        if($Row['Cash'] < 0) $Row['Cash'] = '<span style="color: red;">'.$Row['Cash'].'</span>';
    43         $Tarif = $Finance->Tarify[$Row['inet_tarif_now']]['name'];
    44         $PristiTarif = $Finance->Tarify[$Row['inet_tarif_next']]['name'];
    45         $Output .= '<tr><td><a href="user_state.php?id='.$Row['id'].'">'.$Row['Fullname'].'</a></td>';
     30        $Tarif = $Finance->Tarify[$Row['InternetTariffCurrentMonth']]['name'];
     31        $PristiTarif = $Finance->Tarify[$Row['InternetTariffNextMonth']]['name'];
     32        $Output .= '<tr><td><a href="user_state.php?id='.$Row['Id'].'">'.$Row['Name'].'</a></td>';
    4633        //<td align="right">'.$Row['network_device'].'</td>
    47         $Output .= '<td align="right">'.$Monthly.'</td><td align="right">'.$Row['Cash'].'</td><td align="center">'.$Tarif.'</td><td align="center">'.$PristiTarif.'</td><td>'.$Row['notice'].'&nbsp;</td></tr>';
    48         $TotalDevice += $Row['network_device'];
    49         $TotalMonth += ($Row['monthly'] - $Row['plus']);
     34        $Output .= '<td align="right">'.$Row['MonthlyTotal'].'</td><td align="right">'.$Row['Cash'].'</td><td align="center">'.$Tarif.'</td><td align="center">'.$PristiTarif.'</td></tr>';
     35        $TotalDevice += $Row['NetworkDevice'];
     36        $TotalMonth += ($Row['MonthlyTotal']);
    5037      }
    5138      $Output .= '<tr><td><strong>Celkem</strong></td>';
  • www/finance/finance.php

    r157 r163  
    3434    } 
    3535
    36     if($Period == 0) $Column = 'now'; else $Column = 'next';
     36    if($Period == 0) $Column = 'Current'; else $Column = 'Next';
    3737    $TotalUserCount = 0;
    3838    $TotalUnits = 0;
     
    4141    foreach($Tarify as $Index => $Tarif)
    4242    {
    43       $DbResult = $this->Database->select('users', 'COUNT(*)', 'inet_tarif_'.$Column.'='.$Index.' AND inet=1 AND role=2');
    44       $Row = $DbResult->fetch_array();
     43      $DbResult = $this->Database->select('Member', 'COUNT(*)', 'InternetTariff'.$Column.'Month='.$Index);
     44      $Row = $DbResult->fetch_row();
    4545      $Tarify[$Index]['user_count'] = $Row[0];   
    4646      switch($Tarif['group_id'])
     
    108108    $this->BaseTariffPrice = $Row['BaseTariffPrice'];
    109109
    110     $DbResult = $this->Database->query("SELECT COUNT(*) FROM users WHERE inet=1 AND role=2");
    111     $Row = $DbResult->fetch_array();
     110    $DbResult = $this->Database->query('SELECT COUNT(*) FROM Member');
     111    $Row = $DbResult->fetch_row();
    112112    $this->InternetUsers = $Row[0];
    113  
    114     $DbResult = $this->Database->query("SELECT COUNT(*) FROM users WHERE overheads=1 AND role=2");
    115     $SpravaUsers = $DbResult->fetch_array();
    116     $this->SpravaUsers = $SpravaUsers[0];
     113   
     114    $this->SpravaUsers = $this->InternetUsers;
    117115    $DbResult = $this->Database->query("SELECT SUM(consumption) FROM network_segments");
    118116    $TotalConsumption = $DbResult->fetch_array();
    119117    $this->TotalConsumption = $TotalConsumption[0];
    120118
    121     $DbResult = $this->Database->query("SELECT SUM(`monthly`) as `internet`, SUM(`monthly` - `plus`) as `real` FROM users WHERE role=2");
    122     $Row = $DbResult->fetch_array();
    123     $this->TotalInternetPaid = $Row['internet'];
    124     $this->TotalPaid = $Row['real'];
     119    $DbResult = $this->Database->query('SELECT SUM(`MonthlyInternet`) AS `MonthlyInternet`, SUM(`MonthlyTotal`) AS `MonthlyTotal` FROM MemberPayment');
     120    $Row = $DbResult->fetch_assoc();
     121    $this->TotalInternetPaid = $Row['MonthlyInternet'];
     122    $this->TotalPaid = $Row['MonthlyTotal'];
    125123 
    126124    $this->RecalculateTariffs($Period);
  • www/finance/index.php

    r157 r163  
    1212        $Output = '<table><tr><td valign="top">';
    1313
    14     if(GetMemberByIP(GetRemoteAddress()) > 0) $Output .= '<a href="user_state_ip.php">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 />';
     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 />';
    1515       
    1616    $Output .= '<a href="monthly_overall.php">Měsíční přehledy</a><br />';
     
    2929    $Output .= 'Platba za internetovou linku ('.$Finance->RealMaxSpeed.'/'.$Finance->RealMaxSpeed.' kbit/s): <strong>'.$Finance->Internet.' Kč</strong><br />';
    3030
    31     $DbResult = $this->Database->query("SELECT COUNT(*) FROM users WHERE role=2");
     31    $DbResult = $this->Database->query('SELECT COUNT(*) FROM Member');
    3232    $Row2 = $DbResult->fetch_array();
    3333    $Output .= 'Počet účastníků: <strong>'.$Row2[0].'</strong><br />';
    3434
    35     $DbResult = $this->Database->query("SELECT SUM(price) FROM network_devices WHERE used=1");
     35    $DbResult = $this->Database->query('SELECT SUM(price) FROM network_devices WHERE used=1');
    3636    $Row4 = $DbResult->fetch_array();
    3737    $Output .= 'Celková cena zařízení sítě: <strong>'.$Row4[0].' Kč</strong><br />';
    3838
    39     $DbResult = $this->Database->query('SELECT SUM((SELECT COALESCE(SUM(Value), 0) FROM FinanceCashFlow WHERE Subject=users.id) + (SELECT COALESCE(SUM(-Value), 0) FROM FinanceClaimsLiabilities WHERE Subject=users.id)) as Cash FROM users WHERE role=2');
     39    $DbResult = $this->Database->query('SELECT SUM(Cash) as Cash FROM MemberPayment');
    4040    $Row4 = $DbResult->fetch_array();
    4141    $Output .= 'Celkem peněz na účtech: <strong>'.$Row4[0].' Kč</strong><br />';
    4242    $Output .= 'Stanovená cena jedné kWh: <strong>'.$Finance->kWh.' Kč</strong><br />';
    4343    //echo('Komunitou stanovený poplatek za správu sítě pro jednoho uživatele: <strong>'.$Sprava.' Kč</strong><br />');
    44     $DbResult = $this->Database->query("SELECT SUM(family) FROM users WHERE role=2");
    45     $Row5 = $DbResult->fetch_array();
     44    $DbResult = $this->Database->query('SELECT SUM(FamilyMemberCount) AS Family FROM Member');
     45    $Family = $DbResult->fetch_assoc();
     46        $Family = $Family['Family'];
    4647    $TotalFamily = 600;
    47     $Output .= 'V připojených domácnostech celkem <strong>'.$Row5[0].'</strong> občanů ze všech <strong>'.$TotalFamily.'</strong> ('.round($Row5[0] / $TotalFamily * 100).' %)<br />';
     48    $Output .= 'V připojených domácnostech celkem <strong>'.$Family.'</strong> občanů ze všech <strong>'.$TotalFamily.'</strong> ('.round($Family / $TotalFamily * 100).' %)<br />';
    4849    $Output .= 'IČ: <strong>75904535</strong><br />'.
    4950    'DIČ: <strong>CZ8303255884</strong><br />'.
     
    7980    $Output .= '<tr><td>Převod do dalšího měsíce</td><td align="right">'.($TotalGain - $TotalExpense).'</td></tr>';
    8081    $Output .= '</table><br />';
    81     $DbResult = $this->Database->select('users', 'cash', 'id='.$Finance->UserIdNetwork);
     82    /* $DbResult = $this->Database->select('', 'cash', 'id='.$Finance->UserIdNetwork);
    8283    $Row = $DbResult->fetch_array();
    8384    $NetworkCash = $Row['cash'];
    84     $Output .= 'Stav účtu sítě: '.$NetworkCash.' Kč<br /><a href="clenove.php?show=user&amp;id='.$Finance->UserIdNetwork.'">Výpis účtu</a><br />';
     85    $Output .= 'Stav účtu sítě: '.$NetworkCash.' Kč<br /><a href="clenove.php?show=user&amp;id='.$Finance->UserIdNetwork.'">Výpis účtu</a><br />';*/
    8586
    8687    $Output .= '</td></tr></table>';
  • www/finance/prepocet.php

    r157 r163  
    1111    $Finance = &$this->System->Modules['Finance'];
    1212    $Output = 'Aktualizuju finance uživatelů...<br />';
    13     $DbResult = $this->Database->query('SELECT * FROM users WHERE role=2 OR id='.$Finance->UserIdNetwork);  // Select network members only
    14     while($Row = $DbResult->fetch_array())
    15     {
    16       $DbResult2 = $this->Database->query('SELECT SUM(money) FROM finance_operations WHERE user='.$Row['id']);  // Account state
    17       $Row3 = $DbResult2->fetch_array();
    18       $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE user='.$Row['id'].' AND used=1');
    19       $Row4 = $DbResult2->fetch_array();
    20 
    21       $Price = 0;
     13        $this->Database->query('TRUNCATE TABLE MemberPayment');
     14    $DbResult = $this->Database->query('SELECT * FROM Member');
     15    while($Member = $DbResult->fetch_assoc())
     16    {
     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');
     18      $Cash = $DbResult2->fetch_row();
     19          $Cash = $Cash[0];
     20         
     21      $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE user='.$Member['Id'].' AND used=1');
     22      $ConsumptionPlus = $DbResult2->fetch_row();
     23          $ConsumptionPlus = $ConsumptionPlus[0];
     24
     25      $NetworkDevice = 0;
    2226      $Consumption = 0;
    23       $ID = $Row['network_segment'];
     27      $ID = $Member['NetworkSegment'];
    2428      while($ID != 0)
    2529      {
    2630        $DbResult2 = $this->Database->query('SELECT * FROM network_segments WHERE id='.$ID);
    27         $Row2 = $DbResult2->fetch_array();
    28         if(!(($Row['inet_hw'] == 0) and ($ID == $Finance->InternetSegmentId)))
    29         {
    30           $Price += $Row2['price'] / $Row2['users'];
    31           $Consumption += $Row2['consumption'] / $Row2['users_overheads'];
    32         }
     31        $Device = $DbResult2->fetch_assoc();
     32        $NetworkDevice += $Device['price'] / $Device['users'];
     33        $Consumption += $Device['consumption'] / $Device['users_overheads'];
    3334        //echo($ID.' '.$InternetSegment.' '.$InternetSegmentId.' '.$Row['inet_hw'].' '.$Price.'<br>');
    34         $ID = $Row2['parent'];
    35       }
     35        $ID = $Device['parent'];
     36      }
     37         
    3638      $Monthly = 0;
    37       $MonthlyInet = $Finance->Tarify[$Row['inet_tarif_next']]['price'];
    38       if($Row['inet'] == 1) $Monthly += $MonthlyInet;
     39      $MonthlyInet = $Finance->Tarify[$Member['InternetTariffNextMonth']]['price'];
     40      //if($Row['inet'] == 1)
     41          $Monthly += $MonthlyInet;
     42      $Monthly -= $ConsumptionPlus;
    3943      //if($Row['overheads'] == 1) $Monthly += $Sprava; // + W2Kc($Consumption);
    4044      //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>');
    4145      $Monthly = round($Monthly);
    4246      //echo($Row['fullname'].' '.$Row['inet'].' '.$Monthly.'<br>');
    43       $this->Database->update('users', 'id='.$Row['id'], array('network_device' => $Price, 'monthly_inet' => $MonthlyInet, 'monthly' => $Monthly, 'consumption' => $this->System->Modules['Finance']->W2Kc($Consumption), 'cash' => $Row3[0], 'plus' => $Finance->W2Kc($Row4[0])));
     47               
     48      $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 'NetworkDevice' => $NetworkDevice, 'MonthlyInternet' => $MonthlyInet, 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->System->Modules['Finance']->W2Kc($Consumption), 'Cash' => $Cash, 'MonthlyPlus' => $Finance->W2Kc($ConsumptionPlus)));
    4449    }
    4550        return($Output);
     
    5257    $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0');               // Vynulovat počty uživatelů
    5358    $DbResult = $this->Database->query('SELECT * FROM network_segments');
    54     while($Row = $DbResult->fetch_array())
     59    while($NetworkSegment = $DbResult->fetch_array())
    5560    {
    5661      //echo('Segment '.$Row['name'].'<br>');
    57       $DbResult2 = $this->Database->query('SELECT users FROM network_segments WHERE id='.$Row['id']);
     62      $DbResult2 = $this->Database->query('SELECT users FROM network_segments WHERE id='.$NetworkSegment['id']);
    5863      $RowP = $DbResult2->fetch_array();
    59       $DbResult2 = $this->Database->query("SELECT users_overheads FROM network_segments WHERE id=".$Row['id']);
     64      $DbResult2 = $this->Database->query('SELECT users_overheads FROM network_segments WHERE id='.$NetworkSegment['id']);
    6065      $RowP2 = $DbResult2->fetch_array();
    6166
    62       $DbResult2 = $this->Database->query("SELECT SUM(price) as Price, SUM(consumption) as Consumption FROM network_devices WHERE segment=".$Row['id']." AND used=1");
     67      $DbResult2 = $this->Database->query('SELECT SUM(price) as Price, SUM(consumption) as Consumption FROM network_devices WHERE segment='.$NetworkSegment['id'].' AND used=1');
    6368      $Row2 = $DbResult2->fetch_array();
    64       $DbResult2 = $this->Database->query("SELECT COUNT(*) FROM users WHERE network_segment=".$Row['id'].' AND hw=1');
     69      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['id']);
    6570      $Row3 = $DbResult2->fetch_array();
    66       $DbResult2 = $this->Database->query("SELECT COUNT(*) FROM users WHERE network_segment=".$Row['id'].' AND overheads=1');
     71      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['id']);
    6772      $Row5 = $DbResult2->fetch_array();
    68       $ID = $Row['parent'];
     73      $ID = $NetworkSegment['parent'];
    6974      while($ID != 0)
    7075      {
    7176        //echo($ID.', ');
    72         $DbResult2 = $this->Database->query("SELECT * FROM network_segments WHERE id=".$ID);
     77        $DbResult2 = $this->Database->query('SELECT * FROM network_segments WHERE id='.$ID);
    7378        $Row4 = $DbResult2->fetch_array();
    7479        $this->Database->update('network_segments', 'id='.$Row4['id'], array('users' => ($Row4['users'] + $Row3[0]), 'users_overheads' => ($Row4['users_overheads'] + $Row5[0])));
     
    7681      }
    7782      //echo('Pocet '.$Row3[0].','.$Row['hosts'].'<br>');
    78       $this->Database->update('network_segments', 'id='.$Row['id'], array('price' => $Row2['Price'], 'users' => ($Row3[0] + $RowP['users']), 'consumption' => $Row2['Consumption'], 'users_overheads' => ($Row5[0] + $RowP2['users_overheads'])));
     83      $this->Database->update('network_segments', 'id='.$NetworkSegment['id'], array('price' => $Row2['Price'], 'users' => ($Row3[0] + $RowP['users']), 'consumption' => $Row2['Consumption'], 'users_overheads' => ($Row5[0] + $RowP2['users_overheads'])));
    7984    }
    8085
    8186    // Zkorigovat segment Internet
    82     $DbResult = $this->Database->select('users', 'COUNT(*)', 'inet_hw=1');
     87    $DbResult = $this->Database->select('Member', 'COUNT(*)');
    8388    $Row = $DbResult->fetch_array();
    84     $DbResult = $this->Database->select('users', 'COUNT(*)', 'inet=1');
    85     $Row2 = $DbResult->fetch_array();
    86     $DbResult = $this->Database->update('network_segments','id='.$Finance->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row2[0]));
     89    $DbResult = $this->Database->update('network_segments','id='.$Finance->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row[0]));
    8790    return($Output);
    8891  }
    8992
    90   function CreateMonthlyOverallBill()
     93  /*function CreateMonthlyOverallBill()
    9194  {
    9295    global $Sprava, $SpravaUsers, $TotalConsumption, $UserIdNetwork, $Internet, $TotalInternetPaid;
     
    117120    }
    118121        return($Output);
    119   }
    120 
     122  }*/
    121123
    122124  function Show()
     
    149151    $Row = $DbResult->fetch_array();
    150152    $Output .= "), Segmenty(".$Row[0];
    151     $DbResult = $this->Database->query("SELECT SUM(network_device) FROM users");
     153    $DbResult = $this->Database->query('SELECT SUM(NetworkDevice) FROM MemberPayment');
    152154    $Row5 = $DbResult->fetch_array();
    153155    $Output .= "), Uživatelé(".$Row5[0].")<br>\n";
    154     $DbResult = $this->Database->query("SELECT SUM(cash) FROM users WHERE role=2");
     156    $DbResult = $this->Database->query("SELECT SUM(Cash) FROM MemberPayment");
    155157    $Row6 = $DbResult->fetch_array();
    156158    $Output .= "Stav pokladny: Uživatelé(".$Row6[0].")";
     
    178180
    179181      // Generuj účetní položky
    180       $DbResult = $this->Database->query("SELECT *, CONCAT(second_name, ' ', first_name) as fullname FROM users WHERE (role = 2)");
     182      $DbResult = $this->Database->query('SELECT * FROM MemberPayment JOIN Member ON Member.Id=MemberPayment.Member JOIN Subject ON Subject.Id=Member.Subject');
    181183      while($User = $DbResult->fetch_array())
    182184      {
    183         $Output .= $User['fullname'].': ';
     185        $Output .= $User['Name'].': ';
    184186        $MonthCount = $BillingPeriodMonthCount[$User['BillingPeriod']];
    185         if(($MonthCount > 0) and (((($Mesic - 1) % 12) % $MonthCount) == 0) and ($User['inet_tarif_now'] != 6))
     187        if(($MonthCount > 0) and (((($Mesic - 1) % 12) % $MonthCount) == 0) and ($User['InternetTariffCurrentMonth'] != 6))
    186188        {
    187189          //echo($Mesic.'%'.$MonthCount.'='.($Mesic % $MonthCount).' ');
    188           $PayPerMonth = -($User['plus'] - $User['monthly']);
     190          $PayPerMonth = $User['MonthlyTotal'];
    189191          $PayPerPeriod = $PayPerMonth * $MonthCount;
    190192          $PeriodFrom = mktime(0, 0, 0, date('n'), 1, date('Y'));
     
    193195          $Output .= $TimePeriodText.': '.$PayPerMonth." * ".$MonthCount." = ".$PayPerPeriod."<br />\n";
    194196          $BillCode = $Finance->GetNextDocumentLineNumber(6); // Faktury vydané
    195           $BillId = $this->System->Modules['Bill']->CreateBill($User['id'], array(array('Description' => 'Připojení k síti', 'Price' => $PayPerPeriod, 'Quantity' => 1)), $PeriodFrom, $PeriodTo, $BillCode);
    196           $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));
     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));
    197199        } else $Output .= ("<br />");
    198200      }
     
    220222      }
    221223
    222       $Output .= "Měním aktuální tarify uživatelů...<br>\n";
    223 
    224224      // Update tariff user selection
    225       $DbResult = $this->Database->query("SELECT id,inet_tarif_next FROM users WHERE role=2");
     225      $Output .= "Měním aktuální tarify uživatelů...<br />\n";
     226      $DbResult = $this->Database->query('SELECT Id, InternetTariffNextMonth FROM Member');
    226227      while($User = $DbResult->fetch_array())
    227228      {
    228         $this->Database->update('users', 'id='.$User['id'], array('inet_tarif_now' => $User['inet_tarif_next']));
     229        $this->Database->update('Member', 'Id='.$User['Id'], array('InternetTariffCurrentMonth' => $User['InternetTariffNextMonth']));
    229230      }
    230231
  • www/finance/user_state.php

    r157 r163  
    1010  function Show()
    1111  {
    12     global $Tarify, $Sprava;
     12    if(array_key_exists('old', $_GET))
     13        {
     14          $UserId = GetMemberByIP(GetRemoteAddress());
     15        } else
     16    if(array_key_exists('userid', $_GET))
     17        {
     18          if(!$this->System->Modules['User']->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     19          $UserId = $_GET['userid'];
     20        } else
     21        {
     22          if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
     23      $UserId = $this->System->Modules['User']->User['Id'];
     24        }
    1325
    14     if(!$this->System->Modules['User']->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
    15 
     26        $Finance = &$this->System->Modules['Finance'];
    1627        $this->System->Modules['Finance']->RecalculateTariffs(1);
    17     $UserId = $this->System->Modules['User']->User['Id'];
    1828    if(!array_key_exists('show', $_GET)) $_GET['show'] = '';
    1929    $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id=(SELECT Subject FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.'))');
    2030    $Subject = $DbResult->fetch_assoc();
    21     $DbResult = $this->Database->query('SELECT InternetTariffCurrentMonth FROM Member WHERE Id=(SELECT Member FROM User WHERE Id='.$UserId.')');
     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.')');
    2232    $Member = $DbResult->fetch_assoc();
    23     $TarifName = $Tarify[$Member['InternetTariffCurrentMonth']]['name'];
    24         $TarifPrice = $Tarify[$Member['InternetTariffCurrentMonth']]['price'];
     33    $TarifName = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]['name'];
     34        $TarifPrice = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]['price'];
    2535    $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">';
    2636
     
    5363    $Output .= 'Variabilní symbol pro platby: <strong>'.$Subject['Id'].'</strong><br><br>';
    5464
    55     $DbResult = $this->Database->query('SELECT SUM(consumption) AS Total FROM network_devices WHERE user='.$UserId.' AND used=1');
    56         $ConsumptionBonus = $DbResult->fetch_assoc();
    57         $ConsumptionBonus = $this->System->Modules['Finance']->W2Kc($ConsumptionBonus['Total']);
    58 
    5965        $Total = 0;
    6066    $Output .= 'Rozpis měsíčního poplatku:<br><table border="1" cellspacing="0" cellpadding="3">'.
     
    6268      '<tr><td>Internet - tarif '.$TarifName.'</td><td>'.$TarifPrice.'</td></tr>';
    6369        $Total += $TarifPrice;
    64         if($ConsumptionBonus != 0)
    65       $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$ConsumptionBonus)  .'</td></tr>';
    66         $Total += -$ConsumptionBonus;
     70        if($Member['MonthlyPlus'] != 0)
     71      $Output .= '<tr><td>Příjem za spotřebu</td><td>'.(-$Member['MonthlyPlus'])  .'</td></tr>';
     72        $Total += -$Member['MonthlyPlus'];
    6773    $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr></table>';
    6874    //echo('Tarif pro příští měsíc: '.$Tarify[$Row2['inet_tarif_next']]['name'].'<br><br>');
    6975    $Output .= '<br />';
    7076   
    71     if($ConsumptionBonus != 0)
     77    if($Member['MonthlyPlus'] != 0)
    7278    {
    7379          $Output .= 'Měsíční příjem za spotřebu zařízení umístěných u uživatele:<br>';
  • www/global.php

    r157 r163  
    11<?php
     2
     3$ScriptTimeStart = GetMicrotime();
    24
    35// SQL injection hack protection
  • www/index.php

    r154 r163  
    99  var $ShortTitle = 'Rozcestník';
    1010  var $Links = array(
    11     'main' => array('Důležité odkazy',
     11    'main' => array('Síť',
    1212      array('Finance', '/finance/', 'money.gif'),
    1313      array('Statistika', 'http://stat.zdechov.net/centrala/', 'chart.gif'),
     
    2222      array('Televize', 'http://tv.zdechov.net/', 'clear.gif'),
    2323      array('Herní server', 'http://game-server.zdechov.net/', 'cube.gif'),
    24       array('Rozpis mší', 'http://farnost.zdechov.net/', 'cfix.gif'),
    2524      array('Telefonní seznam', '/telseznam.php', 'tel.gif'),
    2625      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'),
     
    2928      array('Dostupnost sítě', '/network/dostupnost.php', 'satellite.gif'),
    3029      array('Technické informace', '/network.php', 'tech.gif'),
    31       array('Fotbal Sokol Zděchov', 'http://fotbal.zdechov.net/', 'socer.gif'),
    3230      array('Webkamera', '/webcam/', 'clear.gif'),
    3331      array('Stránky naší sítě', 'http://www.zdechov.net/', 'clear.gif'),
    34     ),
    35     'other' => array('Další odkazy',
    3632      array('Kanály kabelovky', '/tkr.php', 'tv.gif'),
    3733      array('Historie sítě', '/history.php', 'clear.gif'),
    3834      array('Měřič spotřeby', '/merak.php', 'electric.gif'),
    3935      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'),
    4044    ),
    4145    'search' => array('Vyhledávání',
     
    297301    $Output .= '<table id="MainTable"><tr><td valign="top">';
    298302    $Output .= '<div class="Panel">'.$this->ShowLinks($this->Links['main']).'</div>';
    299     $Output .= '<div class="Panel">'.$this->ShowLinks($this->Links['other']).'</div>';
    300303    $Output .= '</td><td valign="top">';
    301304    $Output .= '<div class="Panel">'.$this->ShowLinks($this->Links['search']).'</div>';
    302305    $Output .= '<div class="Panel">'.$this->ShowLinks($this->Links['usefull']).'</div>';
    303306    $Output .= '<div class="Panel">'.$this->ShowLinks($this->Links['fun']).'</div>';
     307    $Output .= '<div class="Panel">'.$this->ShowLinks($this->Links['local']).'</div>';
    304308    $Output .= '</td><td id="NewsColumn" valign="top">';
    305309    $Output .= '<div class="Panel">'.$this->System->Modules['News']->Show().'</div>';
  • www/is/administration_page.php

    r154 r163  
    2121<a href="'.$this->System->Config['Web']['RootFolder'].'/is/wlan.php">Bezdrátové sítě v okolí</a><br>
    2222<a href="'.$this->System->Config['Web']['RootFolder'].'/is/restart.php">Správa restartů služeb</a><br>
    23 <a href="'.$this->System->Config['Web']['RootFolder'].'/finance/prepocet.php">Přepočet financí</a><br>
    2423<a href="'.$this->System->Config['Web']['RootFolder'].'/backup/index.php">Nastavení zálohování</a><br>
    2524<a href="tc.php?dev=imq0">Traffic control IMQ0(Inet down)</a><br>
  • www/network/user_hosts.php

    r154 r163  
    1717    while($Host = $DbResult->fetch_array())
    1818    {
    19 /*
    20       $DbResult2 = $this->Database->select('users','*, CONCAT(second_name," ",first_name) as fullname','id='.$Host['user']);
    21       $User = $DbResult2->fetch_array();
    22 */
    23      //'<img src="http://wwp.icq.com/scripts/online.dll?icq='.$Row['icq'].'&img=5">'.
    2419      if($Host['online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    2520      if($Host['IP'] == '') $Host['IP'] = '&nbsp;';
  • www/page.php

    r148 r163  
    109109  function ShowHeader($Title, $Path, $BodyParam = '')
    110110  {
    111     $this->Time_Start = GetMicrotime();         // Zjisti počáteční čas
    112111    $ScriptName = $_SERVER['SCRIPT_NAME'];
    113112    while(strpos($ScriptName, '//') !== false)
     
    141140    $Output = '<?xml version="1.0" encoding="'.$this->System->Config['Web']['Charset'].'"?>'."\n".
    142141    '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
    143     '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'.
     142    '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.
    144143    '<head><link rel="stylesheet" href="'.$this->System->Config['Web']['RootFolder'].'/style.css" type="text/css" media="all" />'.
    145         '<meta http-equiv="content-type" content="text/html; charset='.$this->System->Config['Web']['Charset'].'" />'.
     144        '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->System->Config['Web']['Charset'].'" />'.
    146145    '<script type="text/javascript" src="'.$this->System->Config['Web']['RootFolder'].'/global.js"></script>'.
    147146    '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title>
     
    162161  function ShowFooter()
    163162  {
    164     $Time = floor((GetMicrotime() - $this->Time_Start) * 100) / 100;
     163        global $ScriptTimeStart;
     164    $Time = round(GetMicrotime() - $ScriptTimeStart, 2);
    165165    $Output = '<div id="Footer">
    166    <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' | Vygenerováno za '.$Time.' s |  Použitá paměť:  '.HumanSize(memory_get_peak_usage(FALSE)).' |</i></div></body></html>';
     166   <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' |';
     167    if($this->System->Config['Web']['ShowRuntimeInfo'] == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |';
     168        $Output .= '</i></div></body></html>';
    167169    return($Output);
    168170  }
  • www/system/generators/traffic_shaping_routerboard.php

    r161 r163  
    5757
    5858// Process users
     59$Index = 0;
    5960$DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)');
    6061while($User = $DbResult->fetch_array())
     
    9394    $Commands[] = ' /queue tree add name='.$Host['name'].'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$User['fullname'].'-in packet-mark='.$PacketMark.' queue=wireless-default';
    9495    $PacketMark++;
    95     /*
    96         // In going traffic
    97         //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$HostClassId);
    98               fputs($File, "/sbin/tc class add dev ".$InInterface." parent 1:".$UserClassId." classid 1:".$HostClassId." htb rate ".$HostSpeedIn."bit ceil ".$UserMaxSpeedIn."bit prio ".$Prio." quantum ".$Quantum."\n");
    99               fputs($File, "/sbin/tc qdisc add dev ".$InInterface." parent 1:".$HostClassId." handle ".$HostClassId.":0 sfq perturb 10\n");
    100             //fputs($File, "/sbin/tc filter add dev ".$InInterface." parent 1:0 protocol ip handle ".$HostClassId." fw flowid 1:".$UserClassId."\n");
    101             fputs($File, "/sbin/tc filter add dev ".$InInterface." parent 1:0 protocol ip prio 1 u32 match ip dst ".$Host['external_ip']."/32 flowid 1:".$HostClassId."\n");
    102        
    103         // Out going traffic
    104         //exec('/sbin/iptables -t mangle -A '.$TableOut.' -o eth1 -s '.$Host['IP'].$Protocol." -j MARK --set-mark ".$HostClassId);
    105         fputs($File, "/sbin/tc class add dev ".$OutInterface." parent 1:".$UserClassId." classid 1:".$HostClassId." htb rate ".$HostSpeedOut."bit ceil ".$UserMaxSpeedOut."bit prio ".$Prio." quantum ".$Quantum."\n");
    106               fputs($File, "/sbin/tc qdisc add dev ".$OutInterface." parent 1:".$HostClassId." handle ".$HostClassId.":0 sfq perturb 10\n");
    107               //fputs($File, "/sbin/tc filter add dev ".$OutInterface." parent 1:0 protocol ip handle ".$HostClassId." fw flowid 1:".$UserClassId."\n");
    108               fputs($File, "/sbin/tc filter add dev ".$OutInterface." parent 1:0 protocol ip prio 1 u32 match ip src ".$Host['external_ip']."/32 flowid 1:".$HostClassId."\n");
    109                //echo($Row['id'].',');
    110 */
     96
     97    // Posílej po menších částech
     98    if($Index > 50)
     99        {
     100      $Commands = addslashes(implode(';', $Commands));
     101      $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa '.$Router.' "'.$Commands.'"';
     102      exec($Command, $Output);
     103      print_r($Output);
     104          $Commands = array();
     105          $Index = 0;
     106        }
     107    $Index++;
    111108  }
    112109  echo("\n");
     
    115112$Commands = addslashes(implode(';', $Commands));
    116113$Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa '.$Router.' "'.$Commands.'"';
    117 echo($Command."\n");
     114//echo($Command."\n");
    118115exec($Command, $Output);
    119116//array_pop($Output);
  • www/temp/transform.php

    r154 r163  
    2626    ),
    2727    'Pošta' => array(
    28       'Notice' => 'Schránka se vybírá v pracovní dny v 7:45 a 9:30',
    29       'LastUpdateTime' => '2007-07-20',
    30       'Intervals' => array(
    31         array('DayOfWeek' => 0, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     28      'Notice' => 'Schránka se vybírá v pracovní dny v 7:45 a 15:30',
     29      'LastUpdateTime' => '2009-02-18',
     30      'Intervals' => array(
     31        array('DayOfWeek' => 0, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
    3232        array('DayOfWeek' => 0, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
    33         array('DayOfWeek' => 1, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     33        array('DayOfWeek' => 1, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
    3434        array('DayOfWeek' => 1, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
    35         array('DayOfWeek' => 2, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     35        array('DayOfWeek' => 2, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
    3636        array('DayOfWeek' => 2, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
    37         array('DayOfWeek' => 3, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     37        array('DayOfWeek' => 3, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
    3838        array('DayOfWeek' => 3, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
    39         array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '10:00:00'),
     39        array('DayOfWeek' => 4, 'Index' => 0,  'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
    4040        array('DayOfWeek' => 4, 'Index' => 1,  'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
    41         array('DayOfWeek' => 5, 'Index' => 0,  'OpenTime' => '6:00:00', 'CloseTime' => '10:30:00'),
     41        array('DayOfWeek' => 5, 'Index' => 0,  'OpenTime' => '6:00:00', 'CloseTime' => '9:30:00'),
    4242      ),
    4343    ),
Note: See TracChangeset for help on using the changeset viewer.