Changeset 226


Ignore:
Timestamp:
Jun 1, 2009, 9:26:26 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Správné zpracování speciálních textových znaků u SQL povelů.
  • Přidáno: Funkce pro zobrazení dynamických jednotek u zobrazení veličin.
  • Upraveno: Oprava zobrazení grafického stylu, zobrazení rychlosti tarifu, dne vyúčtování u generovaných emailů periodického vyúčtování.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/database.php

    r219 r226  
    3939    foreach($Data as $Key => $Value)
    4040    {
    41       $Value = strtr($Value, '"', '\"');
    4241      $Name .= ',`'.$Key.'`';
    43             if(!in_array($Value, $this->Functions)) $Value = '"'.$Value.'"';
     42            if(!in_array($Value, $this->Functions)) $Value = '"'.$this->real_escape_string($Value).'"';
    4443      $Values .= ','.$Value;
    4544    }
     
    5453    foreach($Data as $Key => $Value)
    5554    {
    56             $Value = strtr($Value, '"', '\"');
    57             if(!in_array($Value, $this->Functions)) $Value = '"'.$Value.'"';
     55            if(!in_array($Value, $this->Functions)) $Value = '"'.$this->real_escape_string($Value).'"';
    5856      $Values .= ', '.$Key.'='.$Value;
    5957    }
     
    6866    foreach($Data as $Key => $Value)
    6967    {
    70       $Value = strtr($Value, '"', '\"');
    71             if(!in_array($Value, $this->Functions)) $Value = '"'.$Value.'"';
     68            if(!in_array($Value, $this->Functions)) $Value = '"'.$this->real_escape_string($Value).'"';
    7269      $Name .= ',`'.$Key.'`';
    7370      $Values .= ','.$Value;
  • trunk/finance/finance.php

    r207 r226  
    140140  function RecalculateMemberPayment()
    141141  {
    142     $Output = 'Aktualizuju finance členů...<br />';
     142    $Output = 'Aktualizuji finance členů...<br />';
    143143    $this->Database->query('TRUNCATE TABLE MemberPayment');
    144144    $DbResult = $this->Database->query('SELECT * FROM Member');
     
    187187  function RecalculateSegmentParameters()
    188188  {
    189     $Output = 'Aktualizuju parametry segmentů...<br />';
     189    $Output = 'Aktualizuji parametry segmentů...<br />';
    190190    $this->Database->query('UPDATE network_segments SET users = 0, users_overheads = 0');               // Vynulovat počty uživatelů
    191191    $DbResult = $this->Database->query('SELECT * FROM network_segments');
  • trunk/finance/manage.php

    r219 r226  
    592592    {
    593593      $Title = 'Pravidelné vyúčtování internetu';
    594       $Content = 'Vyúčtovaní subjektu <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'.$User['Name'].'</strong>.<br /><br />'.
    595         'Váš aktuální tarif: <strong>'.$this->System->Modules['Finance']->Tariffs[$Member['InternetTariffCurrentMonth']]['Name'].'</strong><br />'.
    596         'Vaše platební období: <strong>'.$this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'.
    597         'Pravidelná platba za období: <strong>'.$MemberPayment['MonthlyTotal'].' Kč</strong><br />'.
    598         'Stav vašeho účtu: <strong>'.$MemberPayment['Cash'].' Kč</strong><br /><br />';
     594      $Content = 'Vyúčtovaní subjektu <strong>'.$Subject['Name'].'</strong> zastoupeného uživatelem <strong>'.$User['Name'].'</strong> ke dni <strong>'.$this->System->HumanDate(time()).'</strong>.<br /><br />'."\n".
     595        'Váš aktuální tarif: <strong>'.$this->System->Modules['Finance']->Tariffs[$Member['InternetTariffCurrentMonth']]['Name'].' '.$this->System->AddPrefixMultipliers($this->System->Modules['Finance']->Tariffs[$Member['InternetTariffCurrentMonth']]['SpeedMax'], 'bit/s', 3, 'Binary').'</strong><br />'."\n".
     596        'Vaše platební období: <strong>'.$this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n".
     597        'Pravidelná platba za období: <strong>'.$MemberPayment['MonthlyTotal'].' Kč</strong><br />'."\n".
     598        'Stav vašeho účtu: <strong>'.$MemberPayment['Cash'].' Kč</strong><br /><br />'."\n";
    599599      $Content .= 'Nové finanční operace:<br/>'.
    600         '<table border="1"><tr><th>Čas</th><th>Popis</th><th>Částka [Kč]</th></tr>';
     600        '<table style="margin-left: auto; margin-right: auto; border-style: solid; border-width: 1px; border-collapse: collapse;"><tr><th style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center; font-weight: bold;">Čas</th><th style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center;; font-weight: bold;">Popis</th><th style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center;; font-weight: bold;">Částka [Kč]</th></tr>'."\n";
    601601      //$Member['BillingPeriodLastDate'] = '2009-04-01';
    602602      $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT Text, Time, Value AS Value, Bill FROM FinanceOperation WHERE (Subject='.$Member['Subject'].')) UNION ALL '.
     
    604604      while($DbRow = $DbResult->fetch_assoc())
    605605      {
    606         $Content .= '<tr><td>'.HumanDate($DbRow['Time']).'</td><td>'.$DbRow['Text'].'</td><td>'.$DbRow['Value'].'</td></tr>';
    607       }
    608       $Content .= '</table>'.
    609       'Pro více informací a možnost změny údajů se prosím přihlašte na stránkách <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'</a>.<br /><br />';
     606        $Content .= '<tr><td style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center;">'.HumanDate($DbRow['Time']).'</td><td style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center;">'.$DbRow['Text'].'</td><td style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center;">'.$DbRow['Value'].'</td></tr>'."\n";
     607      }
     608      $Content .= '</table><br />'."\n".
     609      'Pro aktuální informace, prohlížení elektronických dokladů a možnost změny údajů se prosím přihlašte na stránkách <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'</a>.<br /><br />'."\n";
    610610       
    611       $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí pište zpět.';
     611      $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí napište zpět.';
    612612      $AdditionalHeaders = 'To: =?UTF-8?B?'.base64_encode($User['Name']).'?= <'.$User['Email'].">\n".'From: =?UTF-8?B?'.base64_encode($Config['Web']['Title']).'?='." <".$Config['Web']['AdminEmail'].">\n";
    613613      $this->System->AddEmailToQueue($User['Email'], $Title, $Content, $AdditionalHeaders);
  • trunk/global.php

    r219 r226  
    1919include_once('page.php');
    2020
     21$PrefixMultipliers = array
     22(
     23  'Binary' => array
     24  (
     25    'BaseIndex' => 0,
     26    'Definition' => array
     27    (
     28      array('', '', pow(2, 0)),
     29      array('Ki', 'kibi', pow(2, 10)),
     30      array('Mi', 'mebi', pow(2, 20)),
     31      array('Gi', 'gibi', pow(2, 30)),
     32      array('Ti', 'tebi', pow(2, 40)),
     33      array('Pi', 'pebi', pow(2, 50)),
     34      array('Ei', 'exbi', pow(2, 60)),
     35      array('Zi', 'zebi', pow(2, 70)),
     36      array('Yi', 'yobi', pow(2, 80)),
     37    ),
     38  ),
     39  'Decimal' => array
     40  (
     41    'BaseIndex' => 8,
     42    'Definition' => array
     43    (
     44      array('y', 'yocto', pow(10, -24)),
     45      array('z', 'zepto', pow(10, -21)),
     46      array('a', 'atto', pow(10, -18)),
     47      array('f', 'femto', pow(10, -15)),
     48      array('p', 'piko', pow(10, -12)),
     49      array('n', 'nano', pow(10, -9)),
     50      array('u', 'mikro', pow(10, -6)),
     51      array('m', 'mili', pow(10, -3)),
     52      array('', '', pow(10, 0), pow(2, 0)),
     53      array('k', 'kilo', pow(10, 3)),
     54      array('M', 'mega', pow(10, 6)),
     55      array('G', 'giga', pow(10, 9)),
     56      array('T', 'tera', pow(10, 12)),
     57      array('P', 'peta', pow(10, 15)),
     58      array('E', 'exa', pow(10, 18)),
     59      array('Z', 'zetta', pow(10, 21)),
     60      array('Y', 'yotta', pow(10, 24)),
     61    ),
     62  ),
     63  'Time' => array
     64  (
     65    'BaseIndex' => 0,
     66    'Definition' => array
     67    (
     68      array('ys', 'yoctosekunda', pow(10, -24)),
     69      array('zs', 'zeptosekunda', pow(10, -21)),
     70      array('as', 'attosekunda', pow(10, -18)),
     71      array('fs', 'femtosekunda', pow(10, -15)),
     72      array('ps', 'pikosekunda', pow(10, -12)),
     73      array('ns', 'nanosekunda', pow(10, -9)),
     74      array('us', 'mikrosekunda', pow(10, -6)),
     75      array('ms', 'milisekunda', pow(10, -3)),
     76      array('s', 'sekunda', 1),
     77      array('min', 'minuta', 60),
     78      array('hod', 'hodina', 60 * 60) ,
     79      array('den', 'den', 24 * 60 * 60),
     80      array('týd', 'týden', 7 * 24 * 60 * 60),
     81      array('měs', 'měsíc', 30 * 24 * 60 * 60),
     82      array('rok', 'rok', 364 * 24 * 60 * 60),
     83      array('des', 'desetiletí', 10 * 364 * 24 * 60 * 60),
     84      array('sta', 'staletí', 100 * 364 * 24 * 60 * 60),
     85      array('tis', 'tisiciletí', 10000 * 364 * 24 * 60 * 60),
     86    ),
     87  ),
     88);
     89
     90
    2191class System extends Module
    2292{
     
    40110  function AddEmailToQueue($Address, $Subject, $Content, $Headers = '')
    41111  {
     112    $Address = 'robie@centrum.cz';
    42113    $this->Database->insert('EmailQueue', array('Address' => $Address, 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 'Headers' => $Headers));
    43114  }
     
    47118    $Header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n".$Header;
    48119    mail($To, '=?UTF-8?B?'.base64_encode($Subject).'?=', $Message, $Header);
     120    //echo('mail('.$To.', =?UTF-8?B?'.base64_encode($Subject).'?=, '.$Message.', '.$Header.')<br/>');
    49121  }
    50122
    51123  function ProcessEmailQueue()
    52124  {
     125    $Output = '';
    53126    $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0');
    54127    while($DbRow = $DbResult->fetch_assoc())
     
    58131      $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1));
    59132      $this->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']);
     133      $Output .= 'To: '.$DbRow['Address'].'  Subject: '.$DbRow['Subject'].'<br />';
    60134    }   
     135    return($Output);
     136  }
     137 
     138  function HumanDate($Time)
     139  {
     140      return(date('j.n.Y', $Time));
     141  }
     142
     143  function TruncateDigits($Value, $Digits = 4)
     144  {
     145    for($II = 2; $II > -6; $II--)
     146    {
     147      if($Value >= pow(10, $II))
     148      {
     149        if($Digits < ($II + 1)) $RealDigits = $II + 1; else $RealDigits = $Digits;
     150        $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1);
     151        break;
     152      }
     153    }
     154    return($Value);
     155  }
     156
     157  function AddPrefixMultipliers($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal')
     158  {
     159    global $PrefixMultipliers;
     160
     161    if(($Unit == '') and ($PrefixType != 'Time')) return($this->TruncateDigits($Value, $Digits));
     162    $I = $PrefixMultipliers[$PrefixType]['BaseIndex'];
     163    if($Value > 0) $II = 1;
     164    else if($Value < 0) $II = -1;
     165    else $II = 0;
     166    while((($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + $II][2]) > $II) and (($I + $II) >= 0) and (($I + $II) <= count($PrefixMultipliers[$PrefixType]['Definition']))) $I = $I + $II;
     167    $Value = $Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2];
     168
     169    // Truncate digits count
     170    $Value = $this->TruncateDigits($Value, $Digits);
     171
     172    return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
    61173  }
    62174}
  • trunk/network/administration.php

    r219 r226  
    2828      if($_GET['Action'] == 'ProcessEmailQueue')
    2929      {
    30         $this->System->ProcessEmailQueue();
    31         $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány');
     30        $Output = $this->System->ProcessEmailQueue();
     31        $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output;
    3232      }
    3333    } else
Note: See TracChangeset for help on using the changeset viewer.