Changeset 873 for trunk/Modules


Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
Location:
trunk/Modules
Files:
105 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/API/API.php

    r804 r873  
    4747  {
    4848    // p - token
    49     if(array_key_exists('p', $_GET)) {
     49    if (array_key_exists('p', $_GET)) {
    5050      $Token = $_GET['p'];
    5151      $DbResult = $this->Database->query('SELECT `User` FROM `APIToken` WHERE `Token`="'.$Token.'"');
    52       if($DbResult->num_rows > 0)
     52      if ($DbResult->num_rows > 0)
    5353      {
    5454        $DbRow = $DbResult->fetch_assoc();
     
    5757    } else die('Missing access token');
    5858    // f - data format
    59     if(array_key_exists('f', $_GET)) $this->DataFormat = $_GET['f'];
     59    if (array_key_exists('f', $_GET)) $this->DataFormat = $_GET['f'];
    6060      else $this->DataFormat = 'php';
    6161    // a - action
    62     if(array_key_exists('a', $_GET)) $Action = $_GET['a'];
     62    if (array_key_exists('a', $_GET)) $Action = $_GET['a'];
    6363      else $Action = '';
    6464    // t - table
    65     if(array_key_exists('t', $_GET)) $Table = $_GET['t'];
     65    if (array_key_exists('t', $_GET)) $Table = $_GET['t'];
    6666      else $Table = '';
    6767    // i - index of item
    68     if(array_key_exists('i', $_GET)) $ItemId = $_GET['i'];
     68    if (array_key_exists('i', $_GET)) $ItemId = $_GET['i'];
    6969      else $ItemId = 0;
    7070
    71     if($Action == 'list') $Output = $this->ShowList($Table, $ItemId);
     71    if ($Action == 'list') $Output = $this->ShowList($Table, $ItemId);
    7272      else $Output = 'Unsupported action';
    7373
    74     return($Output);
     74    return ($Output);
    7575  }
    7676
    7777  function ShowList($Table, $ItemId)
    7878  {
    79     if(($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
     79    if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
    8080      $FormClass = $this->System->FormManager->Classes[$Table];
    81       else return('Table not found');
     81      else return ('Table not found');
    8282
    83     if(array_key_exists('SQL', $FormClass))
     83    if (array_key_exists('SQL', $FormClass))
    8484      $SourceTable = '('.$FormClass['SQL'].') AS `TX`';
    8585      else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`';
    8686     
    8787    $Filter = '';
    88     if($ItemId != 0)
     88    if ($ItemId != 0)
    8989    {
    9090      $Filter .= '`Id`='.$ItemId;
    9191    }
    92     if($Filter != '') $Filter = ' WHERE '.$Filter;
     92    if ($Filter != '') $Filter = ' WHERE '.$Filter;
    9393
    9494    $Result = array();
    9595    $DbResult = $this->Database->query('SELECT * FROM '.$SourceTable.$Filter);
    96     while($DbRow = $DbResult->fetch_assoc())
     96    while ($DbRow = $DbResult->fetch_assoc())
    9797    {
    9898      $Result[] = $DbRow;
    9999    }
    100     if($this->DataFormat == 'php') $Output = serialize($Result);
    101       else if($this->DataFormat == 'xml') $Output = $this->array2xml($Result);
    102       else if($this->DataFormat == 'json') $Output = json_encode($Result);
     100    if ($this->DataFormat == 'php') $Output = serialize($Result);
     101      else if ($this->DataFormat == 'xml') $Output = $this->array2xml($Result);
     102      else if ($this->DataFormat == 'json') $Output = json_encode($Result);
    103103      else die('Unknown data format '.$this->DataFormat);
    104     return($Output);
     104    return ($Output);
    105105  }
    106106
     
    114114    $array2xml = function ($node, $array) use ($dom, &$array2xml)
    115115    {
    116       foreach($array as $key => $value)
     116      foreach ($array as $key => $value)
    117117      {
    118118        if ( is_array($value) )
    119119        {
    120           if(is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric');
     120          if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric');
    121121          $n = $dom->createElement($key);
    122122          $node->appendChild($n);
    123123          $array2xml($n, $value);
    124124        } else {
    125           if(is_numeric($key)) $key = 'N'.$key; //die('XML attribute name "'.$key.'" can\'t be numeric');
     125          if (is_numeric($key)) $key = 'N'.$key; //die('XML attribute name "'.$key.'" can\'t be numeric');
    126126          $attr = $dom->createAttribute($key);
    127127          $attr->value = $value;
  • trunk/Modules/Chat/Chat.php

    r790 r873  
    1414  {
    1515    $Num = dechex($Num);
    16     return(substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2));
     16    return (substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2));
    1717  }
    1818
     
    2121    global $MonthNames;
    2222
    23     if(!$this->System->User->CheckPermission('Chat', 'Display')) return('Nemáte oprávnění');
     23    if (!$this->System->User->CheckPermission('Chat', 'Display')) return ('Nemáte oprávnění');
    2424
    25     if(array_key_exists('date', $_GET)) $Date = $_GET['date'];
     25    if (array_key_exists('date', $_GET)) $Date = $_GET['date'];
    2626      else $Date = date('Y-m-d');
    2727    $DateParts = explode('-', $Date);
     
    3535    $EndDateParts = explode('-', $EndDateTimeParts[0]);
    3636
    37     if(!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time());
    38     if(array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']);
     37    if (!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time());
     38    if (array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']);
    3939
    40     if(!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time());
    41     if(array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']);
     40    if (!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time());
     41    if (array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']);
    4242
    4343    $Output = '<div class="ChatHistory">';
    44     for($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--)
     44    for ($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--)
    4545    {
    46       if($_SESSION['year'] == $Year)
     46      if ($_SESSION['year'] == $Year)
    4747      {
    4848        $Output .= '<div class="Year">'.$Year.'<div class="YearContent">';
    49         if($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1;
    50         if($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12;
    51         for($Month = $EndMonth; $Month >= $StartMonth; $Month--)
     49        if ($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1;
     50        if ($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12;
     51        for ($Month = $EndMonth; $Month >= $StartMonth; $Month--)
    5252        {
    53           if($_SESSION['month'] == $Month)
     53          if ($_SESSION['month'] == $Month)
    5454          {
    5555            $Output .= '<div class="Months">'.$MonthNames[$Month].'<span>';
    56             if(($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1;
    57             if(($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year));
    58             for($Day = $StartDay; $Day <= $EndDay; $Day++)
     56            if (($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1;
     57            if (($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year));
     58            for ($Day = $StartDay; $Day <= $EndDay; $Day++)
    5959            {
    6060              $Text = '<a href="?date='.$Year.'-'.$Month.'-'.$Day.'">'.$Day.'</a> ';
    61               if(($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>';
     61              if (($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>';
    6262              $Output .= $Text;
    6363            }
     
    7272    $DbResult = $this->Database->select('ChatHistory', 'Nick, Color, Text, UNIX_TIMESTAMP(Time)', "RoomType = 0 AND Time > '".$Date." 00:00:00' AND Time < '".$Date." 23:59:59' ORDER BY Time DESC");
    7373    $Output .= '<div class="ChatHistoryText">';
    74     if($DbResult->num_rows > 0)
    75     while($Row = $DbResult->fetch_array())
     74    if ($DbResult->num_rows > 0)
     75    while ($Row = $DbResult->fetch_array())
    7676    {
    7777      $Text = $Row['Text'];;
     
    8181    else $Output .= 'V daném dni nebyly zaznamenány žádné zprávy.';
    8282    $Output .= '</div>';
    83     return($Output);
     83    return ($Output);
    8484  }
    8585}
  • trunk/Modules/Chat/irc_bot.php

    r738 r873  
    3030  function Say($Message, $Recipient = '')
    3131  {
    32     if($Recipient == '') $Recipient = $this->Channel;
     32    if ($Recipient == '') $Recipient = $this->Channel;
    3333    $this->Command(': PRIVMSG '.$Recipient.' :'.$Message);
    3434  }
     
    4343    global $Database;
    4444
    45     while(!fwrite($this->File, ''))
     45    while (!fwrite($this->File, ''))
    4646    {
    4747      $this->Command('JOIN '.$this->Channel);
     
    5151
    5252      $LineParts = explode(' ', $Line);
    53       if(count($LineParts) > 0)
     53      if (count($LineParts) > 0)
    5454      {
    55         if($LineParts[0] == 'PING')
     55        if ($LineParts[0] == 'PING')
    5656        {
    5757          $this->Command('PONG '.trim($LineParts[1])."\n");
     
    5959        }
    6060
    61         if(count($LineParts) > 1)
    62         {
    63           if((trim($LineParts[1]) == 'INVITE') && (substr(trim($LineParts[3]), 0, 2) == ':#'))
     61        if (count($LineParts) > 1)
     62        {
     63          if ((trim($LineParts[1]) == 'INVITE') && (substr(trim($LineParts[3]), 0, 2) == ':#'))
    6464          {
    6565            $CurrentChannel = substr(trim($LineParts[3]), 1);
     
    7878
    7979      // Log messages to database
    80       if(strpos($Line, 'PRIVMSG') !== false)
     80      if (strpos($Line, 'PRIVMSG') !== false)
    8181      {
    8282        $Text = addslashes($Commands[2]);
     
    9191
    9292      explode(':', $Line);
    93       foreach($Commands as $Index => $Item)
     93      foreach ($Commands as $Index => $Item)
    9494        $Commands[$Index] = trim($Item);
    9595
    96       if(count($Commands) >= 2)
     96      if (count($Commands) >= 2)
    9797      {
    9898        $Command = $Commands[2];
    9999
    100100        // Jméno - Pošle vizitku
    101         if($Command == $this->Nick)
     101        if ($Command == $this->Nick)
    102102        {
    103103          $this->Say('Ahoj lidi, ja jsem '.$this->OwnerName.' bot. Random#: '.rand(0, 10));
     
    106106
    107107        // hhelp - vypise tuto napovedu
    108         if($Command == 'hhelp')
     108        if ($Command == 'hhelp')
    109109        {
    110110          $this->Say('Ja jsem Harvester.');
     
    124124
    125125        // hsay:Message - Posle zpravu
    126         if($Command == 'hsay')
     126        if ($Command == 'hsay')
    127127        {
    128128          $this->Say($Commands[3]);
     
    131131
    132132        // hpsay:to:Message - Posle soukromou zpravu kanalu nebo osobe
    133         if($Command == 'hpsay')
     133        if ($Command == 'hpsay')
    134134        {
    135135          $this->Say($Commands[4], $Commands[3]);
     
    138138
    139139        // hcol:to:Message - Posle kolizni zpravu kanalu nebo osobe
    140         if($Command == 'hcol')
     140        if ($Command == 'hcol')
    141141        {
    142142          $this->Say($Commands[4], $Commands[3]);
     
    145145
    146146        // hdo:Command - Posle serveru prikaz
    147         if($Command == 'hdo')
     147        if ($Command == 'hdo')
    148148        {
    149149          $hdo = explode('hdo:', $Line);
     
    153153
    154154        // hpart:Channel - Odpoji se z kanalu
    155         if($Command == 'hpart')
     155        if ($Command == 'hpart')
    156156        {
    157157          $hdo = explode('hpart:', $Line);
    158           if(trim($hdo[1]) != trim($this->Channel))
     158          if (trim($hdo[1]) != trim($this->Channel))
    159159          {
    160160            $this->Command('PART :'.trim($hdo[1])."\n");
     
    164164
    165165        // hmove:Channel - Zmeni aktivni kanal
    166         if($Command == 'hmove')
     166        if ($Command == 'hmove')
    167167        {
    168168          $hdo = explode("hmove:", $Line);
    169           if(trim($hdo[1]) != trim($$this->Cannel))
     169          if (trim($hdo[1]) != trim($$this->Cannel))
    170170          {
    171171            $this->Channel = trim($hdo[1]);
     
    177177
    178178        // htime - udaje o casu
    179         if($Command == 'htime')
     179        if ($Command == 'htime')
    180180        {
    181181          $Date = implode("-", getdate(time()));
     
    185185
    186186        // hjoke - Posle nahodny vtip
    187         if($Command == 'hjoke')
     187        if ($Command == 'hjoke')
    188188        {
    189189          $Joke = ($this->Jokes[rand(0, (sizeof($this->Jokes) - 1))]);
  • trunk/Modules/Customer/Customer.php

    r871 r873  
    201201    $Output .= ' platících:'.$DbRow['0'].'<br/>';
    202202
    203     return($Output);
     203    return ($Output);
    204204  }
    205205
  • trunk/Modules/EmailQueue/EmailQueue.php

    r738 r873  
    1111    $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process();
    1212    $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output;
    13     return($Output);
     13    return ($Output);
    1414  }
    1515}
     
    7979      'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()',
    8080      'From' => $From);
    81     if($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId;
     81    if ($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId;
    8282    $this->Database->insert('EmailQueue', $Values);
    8383  }
     
    8787    $Output = '';
    8888    $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0');
    89     while($DbRow = $DbResult->fetch_assoc())
     89    while ($DbRow = $DbResult->fetch_assoc())
    9090    {
    9191      $Mail = new Mail();
     
    9595      $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain');
    9696      $Mail->AddBody($DbRow['Content'], 'text/html');
    97       if($DbRow['AttachmentFile'] != '')
     97      if ($DbRow['AttachmentFile'] != '')
    9898      {
    9999        $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']);
    100         while($File = $DbResult2->fetch_assoc())
     100        while ($File = $DbResult2->fetch_assoc())
    101101          $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']);
    102102      }
     
    106106      $Output .= 'To: '.$DbRow['To'].'  Subject: '.$DbRow['Subject'].'<br />';
    107107    }
    108     return($Output);
     108    return ($Output);
    109109  }
    110110}
  • trunk/Modules/Error/Error.php

    r784 r873  
    4545    $this->System->ModuleManager->Modules['Log']->NewRecord('Error', 'Log', $Error);
    4646
    47     //if($Config['Web']['ErrorLogFile'] != '')
     47    //if ($Config['Web']['ErrorLogFile'] != '')
    4848    // error_log($Error, 3, $Config['Web']['ErrorLogFile']);
    4949    // Pošli mi zprávu (pokud je to kritická chyba)
    5050    //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error);
    5151    // Show error message
    52     if($this->ErrorHandler->ShowError == true)
     52    if ($this->ErrorHandler->ShowError == true)
    5353    {
    54       if(array_key_exists('REMOTE_ADDR', $_SERVER))
     54      if (array_key_exists('REMOTE_ADDR', $_SERVER))
    5555      {
    5656        echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
  • trunk/Modules/File/File.php

    r738 r873  
    1616  {
    1717    $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id);
    18     if($DbResult->num_rows > 0)
     18    if ($DbResult->num_rows > 0)
    1919    {
    2020      $DbRow = $DbResult->fetch_assoc();
     
    2828    // Submited form with file input have to be enctype="multipart/form-data"
    2929    $Result = 0;
    30     if(array_key_exists($Name, $_FILES) and ($_FILES[$Name]['name'] != ''))
     30    if (array_key_exists($Name, $_FILES) and ($_FILES[$Name]['name'] != ''))
    3131    {
    32       if(file_exists($_FILES[$Name]['tmp_name']))
     32      if (file_exists($_FILES[$Name]['tmp_name']))
    3333      {
    3434        $FileName = substr($_FILES[$Name]['name'], strrpos($_FILES[$Name]['name'], '/'));
    3535        $this->Database->query('INSERT INTO File (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Name]['tmp_name']).')');
    3636        $InsertId = $this->Database->insert_id;
    37         if(move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId;
     37        if (move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId;
    3838      }
    3939    }
    40     return($Result);
     40    return ($Result);
    4141  }
    4242
     
    4646
    4747    $Result = $MimeTypes[pathinfo($FileName, PATHINFO_EXTENSION)][0];
    48     return($Result);
     48    return ($Result);
    4949  }
    5050
     
    5252  {
    5353    $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id));
    54     if($DbResult->num_rows > 0)
     54    if ($DbResult->num_rows > 0)
    5555    {
    5656      $DbRow = $DbResult->fetch_assoc();
    57       if($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']);
     57      if ($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']);
    5858        else $FileName = $this->FilesDir;
    5959      $FileName .= $DbRow['Name'];
    60       if(file_exists($FileName))
     60      if (file_exists($FileName))
    6161      {
    6262        Header('Content-Type: '.$this->DetectMimeType($FileName));
     
    7171    $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id);
    7272    $DbRow = $DbResult->fetch_assoc();
    73     if($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']);
     73    if ($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']);
    7474      else $Result = $this->FilesDir;
    7575    $Result .= $DbRow['Name'].'/';
    76     return($Result);
     76    return ($Result);
    7777  }
    7878}
     
    8383  function Show()
    8484  {
    85     if(array_key_exists('id', $_GET)) $Id = $_GET['id'];
    86     else if(array_key_exists('i', $_GET)) $Id = $_GET['i'];
    87     else return($this->SystemMessage('Chyba', 'Nezadáno id souboru'));
     85    if (array_key_exists('id', $_GET)) $Id = $_GET['id'];
     86    else if (array_key_exists('i', $_GET)) $Id = $_GET['i'];
     87    else return ($this->SystemMessage('Chyba', 'Nezadáno id souboru'));
    8888    $this->ClearPage = true;
    8989    $Output = $this->System->Modules['File']->Download($Id);
    90     return($Output);
     90    return ($Output);
    9191  }
    9292}
  • trunk/Modules/Finance/Bill.php

    r748 r873  
    88  function GenerateHTML()
    99  {
    10     return('');
     10    return ('');
    1111  }
    1212
     
    2222  {
    2323    $Encoding = new Encoding();
    24     if($this->Checked == false) {
    25       if(CommandExist('htmldoc')) {
     24    if ($this->Checked == false) {
     25      if (CommandExist('htmldoc')) {
    2626        $this->Checked = true;
    2727      } else throw new Exception('htmldoc is not installed.');
     
    2929    $Output = shell_exec('echo "'.addslashes($Encoding->FromUTF8($HtmlCode)).
    3030      '"|htmldoc --no-numbered --webpage --no-embedfonts --charset 8859-2 -t pdf -');
    31     return($Output);
     31    return ($Output);
    3232  }
    3333}
     
    4343      $Subject['AddressStreet'].'<br>'.
    4444      $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
    45     if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
    46     if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
    47     if($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';
    48     if($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>';
    49     return($Output);
     45    if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
     46    if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
     47    if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';
     48    if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>';
     49    return ($Output);
    5050  }
    5151
     
    7878    $InvoiceItems = array();
    7979    $DbResult = $this->Database->select('FinanceInvoiceItem', '*, ROUND(`Price` * `Quantity`, '.$Finance->Rounding.') AS `Total`', '`FinanceInvoice`='.$this->InvoiceId);
    80     while($Item = $DbResult->fetch_assoc())
     80    while ($Item = $DbResult->fetch_assoc())
    8181    {
    8282      $InvoiceItems[$Item['Id']] = $Item;
     
    8484
    8585    // If direction is in => switch sides
    86     if($Invoice['Direction'] == FINANCE_DIRECTION_OUT)
    87     {
    88     }
    89     else if($Invoice['Direction'] == FINANCE_DIRECTION_IN)
     86    if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT)
     87    {
     88    }
     89    else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN)
    9090    {
    9191      $Subject = $SubjectTo;
     
    121121      'Datum zdanitel. plnění: '.HumanDate($Invoice['Time']).'<br>'.
    122122      'Datum splatnosti: '.HumanDate($Invoice['TimeDue']).'<br>';
    123     if(($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != ''))
     123    if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != ''))
    124124      $Output .= 'Fakturované období: '.HumanDate($Invoice['PeriodFrom']).' - '.
    125125        HumanDate($Invoice['PeriodTo']).'<br>';
     
    133133
    134134    $Total = 0;
    135     foreach($InvoiceItems as $Item)
     135    foreach ($InvoiceItems as $Item)
    136136    {
    137137      $Output .= '<tr><td>'.$Item['Description'].'</td><td align="right">'.
     
    146146      '</table>';
    147147
    148     return($Output);
     148    return ($Output);
    149149  }
    150150}
     
    174174
    175175    $BooleanText = array('Ne', 'Ano');
    176     if($Operation['Direction'] == FINANCE_DIRECTION_OUT)
     176    if ($Operation['Direction'] == FINANCE_DIRECTION_OUT)
    177177    $Desc = array(
    178178      'Type' => 'VÝDAJOVÝ',
     
    180180      'Target' => 'Vydáno komu',
    181181    );
    182     else if($Operation['Direction'] == FINANCE_DIRECTION_IN)
     182    else if ($Operation['Direction'] == FINANCE_DIRECTION_IN)
    183183    $Desc = array(
    184184      'Type' => 'PŘÍJMOVÝ',
     
    206206      $Subject['AddressStreet'].'<br>'.
    207207      $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
    208     if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
    209     if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
     208    if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
     209    if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
    210210    $Description = $Operation['Text'];
    211211    $Output .= '</td></tr>'.
     
    215215      '<tr><td>&nbsp;</td><td><br><br>'.$Desc['Signature'].':</td></tr>';
    216216    $Output .= '</table>';
    217     return($Output);
     217    return ($Output);
    218218  }
    219219}
  • trunk/Modules/Finance/Finance.php

    r866 r873  
    4444  {
    4545    $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`');
    46     while($BillingPeriod = $DbResult->fetch_assoc())
     46    while ($BillingPeriod = $DbResult->fetch_assoc())
    4747      $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod;
    4848
     
    8080  function W2Kc($Spotreba)
    8181  {
    82     return(round($Spotreba * 0.72 * $this->kWh));
     82    return (round($Spotreba * 0.72 * $this->kWh));
    8383  }
    8484
     
    9393    // Create DocumentLineSequence from previous
    9494    $DbResult = $this->Database->select('DocumentLine', 'Id', '`Yearly` = 1');
    95     while($DbRow = $DbResult->fetch_assoc())
     95    while ($DbRow = $DbResult->fetch_assoc())
    9696    {
    9797          $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,
     
    102102  function GetFinanceYear($Year)
    103103  {
    104     if($Year == 0)
     104    if ($Year == 0)
    105105    {
    106106      // Get latest year
    107107      $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1');
    108108    } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year);
    109     if($DbResult->num_rows == 0) {
    110           if($Year == date('Y'))
     109    if ($DbResult->num_rows == 0) {
     110          if ($Year == date('Y'))
    111111          {
    112112                $this->CreateFinanceYear($Year);
     
    115115        }
    116116    $FinanceYear = $DbResult->fetch_assoc();
    117     if($FinanceYear['Closed'] == 1)
     117    if ($FinanceYear['Closed'] == 1)
    118118      throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.');
    119119    return $FinanceYear;
     
    131131    $Sequence = $DbResult->fetch_assoc();
    132132
    133     if($Sequence['YearPrefix'] == 1)
     133    if ($Sequence['YearPrefix'] == 1)
    134134    {
    135135      $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year'];
     
    138138    $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '.
    139139      'WHERE (`DocumentLine`='.$Id.') AND (`FinanceYear`='.$FinanceYear['Id'].')');
    140     return($Result);
     140    return ($Result);
    141141  }
    142142
     
    151151  {
    152152    $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id);
    153     if($DbResult->num_rows == 1) {
     153    if ($DbResult->num_rows == 1) {
    154154      $Group = $DbResult->fetch_assoc();
    155       return($Group);
     155      return ($Group);
    156156    } else die('Finance group id '.$Id.' not found in table '.$Table);
    157157  }
     
    162162    $this->Database->query('TRUNCATE TABLE `MemberPayment`');
    163163    $DbResult = $this->Database->query('SELECT * FROM `Member`');
    164     while($Member = $DbResult->fetch_assoc())
     164    while ($Member = $DbResult->fetch_assoc())
    165165    {
    166166      $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(`Value`), 0) FROM `FinanceOperation` '.
     
    182182      $DbRow = $DbResult2->fetch_assoc();
    183183      $Monthly = 0;
    184       if($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];
     184      if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];
    185185      else $MonthlyInet = 0;
    186186
     
    189189      $Monthly = round($Monthly);
    190190
    191       if($Member['BillingPeriod'] == 1)
     191      if ($Member['BillingPeriod'] == 1)
    192192      {
    193193        // Inactive payer
     
    204204    }
    205205    $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');
    206     return($Output);
     206    return ($Output);
    207207  }
    208208
     
    214214      TimeToMysqlDate($Time).'") OR (ValidTo IS NULL)) LIMIT 1');
    215215    $Row = $DbResult->fetch_array();
    216     return($Row[0]);
     216    return ($Row[0]);
    217217  }
    218218}
     
    665665  function BeforeInsertFinanceOperation($Form)
    666666  {
    667     if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
     667    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    668668      else $Year = date("Y", $Form->Values['ValidFrom']);
    669669    $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
    670670    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
    671     return($Form->Values);
     671    return ($Form->Values);
    672672  }
    673673
     
    677677    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    678678      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
    679     return($Form->Values);
     679    return ($Form->Values);
    680680  }
    681681
     
    685685    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    686686      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
    687     return($Form->Values);
     687    return ($Form->Values);
    688688  }
    689689
     
    691691  {
    692692    // Get new DocumentLineCode by selected invoice Group
    693     if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
     693    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    694694      else $Year = date("Y", $Form->Values['ValidFrom']);
    695695    $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
    696696    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    697     return($Form->Values);
     697    return ($Form->Values);
    698698  }
    699699
     
    707707    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    708708      ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
    709     return($Form->Values);
     709    return ($Form->Values);
    710710  }
    711711
     
    718718    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    719719      ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
    720     return($Form->Values);
     720    return ($Form->Values);
    721721  }
    722722
     
    727727    $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']);
    728728    $this->AfterInsertFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']);
    729     return($Form->Values);
     729    return ($Form->Values);
    730730  }
    731731
     
    736736    $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']);
    737737    $this->BeforeModifyFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']);
    738     return($Form->Values);
     738    return ($Form->Values);
    739739  }
    740740
    741741  function BeforeInsertContract($Form)
    742742  {
    743     if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
     743    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    744744      else $Year = date("Y", $Form->Values['ValidFrom']);
    745745    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year);
    746     return($Form->Values);
     746    return ($Form->Values);
    747747  }
    748748}
  • trunk/Modules/Finance/Import.php

    r812 r873  
    99  function Show()
    1010  {
    11     if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    12     if(array_key_exists('Operation', $_GET))
     11    if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return ('Nemáte oprávnění');
     12    if (array_key_exists('Operation', $_GET))
    1313    {
    14       if($_GET['Operation'] == 'prepare') return($this->Prepare());
    15       else if($_GET['Operation'] == 'insert') return($this->Insert());
     14      if ($_GET['Operation'] == 'prepare') return ($this->Prepare());
     15      else if ($_GET['Operation'] == 'insert') return ($this->Insert());
    1616      else echo('Neplatná akce');
    1717    } else
     
    2222      $Output .= '<input type="submit" value="Analyzovat"/>';
    2323      $Output .= '</form>';
    24       return($Output);
     24      return ($Output);
    2525    }
    2626  }
     
    3131    $Finance->LoadMonthParameters(0);
    3232    $Data = explode("\n", $_POST['Source']);
    33     foreach($Data as $Key => $Value)
     33    foreach ($Data as $Key => $Value)
    3434    {
    3535      $Value = str_replace('\"', '"', $Value);
    3636      $Data[$Key] = str_getcsv($Value, ',', '"', "\\");
    3737      //print_r($Data[$Key]);
    38       foreach($Data[$Key] as $Key2 => $Value2)
     38      foreach ($Data[$Key] as $Key2 => $Value2)
    3939      {
    40         if(substr($Data[$Key][$Key2], 0, 2) == '\"')
     40        if (substr($Data[$Key][$Key2], 0, 2) == '\"')
    4141          $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2);
    4242      }
     
    6161    //print_r($Data);
    6262
    63     if($Header != $Data[0]) {
     63    if ($Header != $Data[0]) {
    6464      $Output = 'Nekompatibilní struktura CSV';
    6565      print_r($Header);
     
    7373      $Output = '<form action="?Operation=insert" method="post">';
    7474      $I = 0;
    75       foreach($Data as $Key => $Value)
     75      foreach ($Data as $Key => $Value)
    7676      {
    77         if(count($Value) <= 1) continue;
    78         if($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna
     77        if (count($Value) <= 1) continue;
     78        if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna
    7979        $Time = explode('.', $Value[0]);
    8080        $Time = $Time[2].'-'.$Time[1].'-'.$Time[0];
    8181        $Money = $Value[1];
    82         if(is_numeric($Value[5]))
     82        if (is_numeric($Value[5]))
    8383        {
    8484          $Subject = $Value[5] * 1;
    8585          $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$this->Database->real_escape_string($Subject));
    86           if($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';
     86          if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';
    8787        } else
    8888        {
    8989          $Subject = '? ('.$Value[5].')';
    9090        }
    91         if(!is_numeric($Subject))
     91        if (!is_numeric($Subject))
    9292        {
    9393          $Mode = 'Ručně';
     
    9999        }
    100100
    101         if($Money < 0) $Text = 'Platba převodem';
     101        if ($Money < 0) $Text = 'Platba převodem';
    102102          else $Text = 'Přijatá platba';
    103103        $Automatic .= '<tr>'.
     
    121121      $Output .= '<input type="submit" value="Zpracovat"/></form>';
    122122    }
    123     return($Output);
     123    return ($Output);
    124124  }
    125125
     
    142142    $Output = '';
    143143
    144     for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
     144    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    145145    {
    146       if($_POST['Money'.$I] < 0) {
     146      if ($_POST['Money'.$I] < 0) {
    147147        $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
    148148      } else {
     
    156156      $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
    157157    }
    158     return($Output);
     158    return ($Output);
    159159  }
    160160}
  • trunk/Modules/Finance/Manage.php

    r866 r873  
    1010  {
    1111    $Output = '';
    12     if(!$this->System->User->CheckPermission('Finance', 'Manage'))
    13       return('Nemáte oprávnění');
    14 
    15     if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation'];
     12    if (!$this->System->User->CheckPermission('Finance', 'Manage'))
     13      return ('Nemáte oprávnění');
     14
     15    if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation'];
    1616      else $Operation = '';
    17     switch($Operation)
     17    switch ($Operation)
    1818    {
    1919      case 'Recalculate':
     
    4242        $Output .= '<a href="'.$this->System->Link('/finance/import/').'">Import plateb</a><br />';
    4343    }
    44     return($Output);
     44    return ($Output);
    4545  }
    4646
     
    5252
    5353    $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];
    54     if($MonthCount <= 0) return(array('From' => NULL, 'To' => NULL, 'MonthCount' => 0));
     54    if ($MonthCount <= 0) return (array('From' => NULL, 'To' => NULL, 'MonthCount' => 0));
    5555    $MonthCurrent = date('n', $Time);
    5656
     
    6767    $PeriodTo = mktime(0, 0, 0, $MonthTo, date('t', mktime(0, 0, 0, $MonthTo, 1, $Year)), $Year);
    6868
    69     return(array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));
     69    return (array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));
    7070  }
    7171
    7272  function ShowMonthlyPayment()
    7373  {
    74     if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     74    if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění');
    7575    $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '.
    7676      '`MemberPayment`.`Cash` AS `Cash`, '.
     
    106106
    107107    $DbResult = $this->Database->query($Query);
    108     while($Row = $DbResult->fetch_assoc())
     108    while ($Row = $DbResult->fetch_assoc())
    109109    {
    110110      $Output .= '<tr>'.
     
    120120    $Output .= $PageList['Output'];
    121121    $Output .= '<a href="?Operation=ProcessMonthlyPayment">Generovat faktury</a>';
    122     return($Output);
     122    return ($Output);
    123123  }
    124124
     
    131131    $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    132132    $SumValue = 0;
    133     foreach($Items as $Item) {
     133    foreach ($Items as $Item) {
    134134      $SumValue = $SumValue + $Item['Price'] * $Item['Quantity'];
    135135    }
     
    143143      'Generate' => 1, 'Group' => $Group['Id']));
    144144    $InvoiceId = $this->Database->insert_id;
    145     foreach($Items as $Item)
     145    foreach ($Items as $Item)
    146146      $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId,
    147147        'Description' => $Item['Description'], 'Price' => $Item['Price'],
     
    149149    //$LastInsertTime = $Time;
    150150    //$this->CheckAdvancesAndLiabilities($Subject);
    151     return($InvoiceId);
     151    return ($InvoiceId);
    152152  }
    153153
     
    162162      'FROM `MemberPayment` JOIN `Member` ON `Member`.`Id`=`MemberPayment`.`Member` '.
    163163      'JOIN `Subject` ON `Subject`.`Id`=`Member`.`Subject`');
    164     while($Member = $DbResult->fetch_assoc())
     164    while ($Member = $DbResult->fetch_assoc())
    165165    {
    166166      $Output .= $Member['SubjectName'].': ';
     
    168168
    169169      /* Check if need to produce new invoice for customer */
    170       if(($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and
     170      if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and
    171171        ($Period['From'] > $Member['BillingPeriodLastUnixTime']))
    172172      {
     
    178178          'WHERE (`ServiceCustomerRel`.`Customer`='.
    179179          $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) ');
    180         while($Service = $DbResult2->fetch_assoc())
     180        while ($Service = $DbResult2->fetch_assoc())
    181181        {
    182182          $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'],
     
    188188        // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction
    189189        // Other subject should invoice only positive items. Negative items should be somehow removed.
    190         if($MonthlyTotal >= 0)
     190        if ($MonthlyTotal >= 0)
    191191        {
    192192          $InvoiceGroupId = INVOICE_GROUP_OUT;
     
    197197        // Load invoice group
    198198        $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');
    199         foreach($InvoiceItems as $Index => $Item)
     199        foreach ($InvoiceItems as $Index => $Item)
    200200        {
    201201          $InvoiceItems[$Index]['Price'] = $Item['Price'] * $FinanceGroup['ValueSign'];
    202202        }
    203203
    204         if($PayPerPeriod != 0)
     204        if ($PayPerPeriod != 0)
    205205        {
    206206          $TimePeriodText = date('j.n.Y', $Period['From']).' - '.date('j.n.Y', $Period['To']);
     
    217217      $Output .= "\n";
    218218    }
    219     return($Output);
     219    return ($Output);
    220220  }
    221221
     
    225225    $DbResult = $this->Database->select($Table, '*', '(`ChangeAction` IS NOT NULL) AND '.
    226226      '(`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'") ORDER BY `ChangeTime` ASC');
    227     while($Service = $DbResult->fetch_assoc())
    228     {
    229       if($Service['ChangeAction'] == 'add')
     227    while ($Service = $DbResult->fetch_assoc())
     228    {
     229      if ($Service['ChangeAction'] == 'add')
    230230      {
    231231        unset($Service['Id']);
     
    235235        $this->Database->insert($Table, $Service);
    236236      } else
    237       if($Service['ChangeAction'] == 'modify')
     237      if ($Service['ChangeAction'] == 'modify')
    238238      {
    239239        unset($Service['Id']);
     
    244244        $this->Database->update($Table, '`Id`='.$ReplaceId, $Service);
    245245      } else
    246       if($Service['ChangeAction'] == 'delete')
     246      if ($Service['ChangeAction'] == 'delete')
    247247      {
    248248        $this->Database->delete($Table, '`Id`='.$Service['ReplaceId']);
     
    270270    $this->TableUpdateChanges('ServiceCustomerRel');
    271271
    272     return($Output);
     272    return ($Output);
    273273  }
    274274
    275275  function ProcessMonthlyPayment()
    276276  {
    277     if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     277    if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění');
    278278    $Output = '';
    279279
     
    311311    // Zkontrolovat odečtení měsíčního poplatku
    312312    $Output .= 'Kontrola odečtení poplatků: Poslední měsíc-'.$MonthLast.' Aktuální měsíc-'.$MonthCurrent."\n";
    313     if($MonthCurrent != $MonthLast)
     313    if ($MonthCurrent != $MonthLast)
    314314    {
    315315      $Output .= 'Odečítám pravidelný poplatek...'."\n";
     
    335335    }
    336336    $Output = str_replace("\n", '<br/>', $Output);
    337     return($Output);
     337    return ($Output);
    338338  }
    339339
     
    366366    $MainSubjectAccount = $DbResult->fetch_assoc();
    367367
    368     if($User['Email'] != '')
     368    if ($User['Email'] != '')
    369369    {
    370370      $Title = 'Pravidelné vyúčtování služeb';
     
    392392        '`Time`, -`Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='.
    393393        $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")');
    394       while($DbRow = $DbResult->fetch_assoc())
     394      while ($DbRow = $DbResult->fetch_assoc())
    395395      {
    396396        $Text = $DbRow['Text'];
     
    417417    $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '.
    418418      'AND (`Value` != 0) AND (`Generate` = 1)'.$Where);
    419     while($Row = $DbResult->fetch_assoc())
     419    while ($Row = $DbResult->fetch_assoc())
    420420    {
    421421      if ($Row['File'] == null)
     
    447447    $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '.
    448448        'AND (`Value` != 0) AND (`Generate` = 1)'.$Where);
    449     while($Row = $DbResult->fetch_assoc())
     449    while ($Row = $DbResult->fetch_assoc())
    450450    {
    451451      if ($Row['File'] == null)
     
    462462      $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;
    463463      $Bill->SaveToFile($FullFileName);
    464       if(file_exists($FullFileName))
     464      if (file_exists($FullFileName))
    465465      {
    466466        $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName)));
     
    478478    $Output .= $this->GenerateInvoice(' AND (`File` IS NULL)');
    479479    $Output .= $this->GenerateOperation(' AND (`File` IS NULL)');
    480     return($Output);
     480    return ($Output);
    481481  }
    482482}
  • trunk/Modules/Finance/Trade.php

    r847 r873  
    6565    $Row = $DbResult->fetch_array();
    6666    $Balance['SmallAssets']['End'] = $Row[0] + 0;
    67     return($Balance);
     67    return ($Balance);
    6868  }
    6969
     
    7777    $StartYear = date('Y', $this->StartEvidence);
    7878    $EndYear = date('Y', time());
    79     for($Year = $StartYear; $Year <= $EndYear; $Year++)
     79    for ($Year = $StartYear; $Year <= $EndYear; $Year++)
    8080    {
    8181      $EndTime = mktime(0, 0, 0, 12, 31, $Year);
    8282      //$Year = date('Y', $EndTime);
    8383      $StartTime = mktime(0, 0, 0, 1, 1, $Year);
    84       if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
     84      if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
    8585
    8686      $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);
     
    113113    $StartYear = date('Y', $this->StartEvidence);
    114114    $EndYear = date('Y', time());
    115     for($Year = $StartYear; $Year <= $EndYear; $Year++)
    116     {
    117       for($Month = 1; $Month <= 12; $Month++)
     115    for ($Year = $StartYear; $Year <= $EndYear; $Year++)
     116    {
     117      for ($Month = 1; $Month <= 12; $Month++)
    118118      {
    119119        $EndTime = mktime(0, 0, 0, $Month, 31, $Year);
    120120        //$Year = date('Y', $EndTime);
    121121        $StartTime = mktime(0, 0, 0, $Month, 1, $Year);
    122         if(($StartTime < time()) and ($EndTime > $this->StartEvidence))
     122        if (($StartTime < time()) and ($EndTime > $this->StartEvidence))
    123123        {
    124           if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
     124          if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
    125125
    126126          $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);
     
    164164      'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '.
    165165      'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`');
    166     while($Row = $DbResult->fetch_array())
     166    while ($Row = $DbResult->fetch_array())
    167167    {
    168168      $Row['Time'] = explode(' ', $Row['Time']);
     
    204204      'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '.
    205205      'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`');
    206     while($Row = $DbResult->fetch_array())
     206    while ($Row = $DbResult->fetch_array())
    207207    {
    208208      $Row['Time'] = explode(' ', $Row['Time']);
     
    245245      'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart'].
    246246      '") AND (`FinanceInvoice`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`');
    247     while($Row = $DbResult->fetch_array())
    248     {
    249       if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
     247    while ($Row = $DbResult->fetch_array())
     248    {
     249      if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
    250250      $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName'].
    251251      '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>';
     
    276276      'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart'].
    277277      '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');
    278     while($Row = $DbResult->fetch_array())
    279     {
    280       if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
     278    while ($Row = $DbResult->fetch_array())
     279    {
     280      if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
    281281      $Row['Value'] = $Row['Value'] * $Row['ValueSign'];
    282282      $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName'].
     
    314314      'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '.
    315315      'FROM Subject ORDER BY Name');
    316     while($Row = $DbResult->fetch_assoc())
     316    while ($Row = $DbResult->fetch_assoc())
    317317    {
    318318      $Output .= '<tr><td style="text-align: left;"><a href="?table=SubjectAccount&Id='.$Row['Id'].'">'.$Row['Name'].'</a></td><td>'.$Row['Liabilities'].' / '.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].' / '.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.($Row['Gains'] - $Row['Spends'] - $Row['Claims'] + $Row['Liabilities']).'</td><td>'.$Row['Cash'].'</td></tr>';
     
    330330      'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '.
    331331      'WHERE (TimeElimination IS NOT NULL)');
    332     while($Row = $DbResult->fetch_array())
     332    while ($Row = $DbResult->fetch_array())
    333333    {
    334334      $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>';
     
    349349      'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
    350350      'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`');
    351     while($Row = $DbResult->fetch_array())
     351    while ($Row = $DbResult->fetch_array())
    352352    {
    353353      $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text'].
     
    364364      'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '.
    365365      'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`');
    366     while($Row = $DbResult->fetch_array())
     366    while ($Row = $DbResult->fetch_array())
    367367    {
    368368      $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']).
     
    375375     $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>';
    376376     $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']);
    377      while($Row = $DbResult->fetch_array())
     377     while ($Row = $DbResult->fetch_array())
    378378     {
    379379     $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>';
     
    411411    $Output .= '<strong>Roční přehledy</strong><br/>';
    412412    $Output .= $this->ShowFinanceYears();
    413     if(array_key_exists('year', $_GET))
     413    if (array_key_exists('year', $_GET))
    414414    {
    415415      $Year = $_GET['year'] * 1;
     
    426426  function Show()
    427427  {
    428     if(!$this->System->User->CheckPermission('Finance', 'TradingStatus'))
    429       return('Nemáte oprávnění');
     428    if (!$this->System->User->CheckPermission('Finance', 'TradingStatus'))
     429      return ('Nemáte oprávnění');
    430430
    431431    $Finance = &$this->System->Modules['Finance'];
    432432
    433433    $Output = '';
    434     if(!array_key_exists('table', $_GET)) $_GET['table'] = '';
    435     switch($_GET['table'])
     434    if (!array_key_exists('table', $_GET)) $_GET['table'] = '';
     435    switch ($_GET['table'])
    436436    {
    437437      case 'AnnualBalance':
     
    478478        $Output = $this->ShowDefault();
    479479    }
    480     return($Output);
     480    return ($Output);
    481481  }
    482482
     
    485485    $Output = 'Roky: ';
    486486    $DbRows = $this->Database->select('FinanceYear', '*');
    487     while($DbRow = $DbRows->fetch_assoc())
     487    while ($DbRow = $DbRows->fetch_assoc())
    488488      $Output .= '<a href="?year='.$DbRow['Id'].'">'.$DbRow['Year'].'</a> ';
    489489    $Output .= '<br/>';
    490     return($Output);
     490    return ($Output);
    491491  }
    492492
  • trunk/Modules/Finance/UserState.php

    r825 r873  
    4444    $DbResult = $this->Database->query($Query);
    4545    $SumValue = 0;
    46     while($Row = $DbResult->fetch_assoc())
     46    while ($Row = $DbResult->fetch_assoc())
    4747    {
    4848      $Row['State'] = round($Row['State'], 2);
    49       if($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>';
    50       if($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>';
    51       if($Row['Value'] == -0) $Row['Value'] = 0;
    52       if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
    53       if($Row['BillName'] == '') $Row['BillName'] = 'PDF';
    54       if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';
     49      if ($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>';
     50      if ($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>';
     51      if ($Row['Value'] == -0) $Row['Value'] = 0;
     52      if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
     53      if ($Row['BillName'] == '') $Row['BillName'] = 'PDF';
     54      if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';
    5555        else $Invoice = NotBlank($Row['BillName']);
    56       if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);
     56      if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);
    5757        else $Period = '&nbsp;';
    5858      $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'.
     
    6666    $Output .= '</table>';
    6767    $Output .= $PageList['Output'];
    68     return($Output);
     68    return ($Output);
    6969  }
    7070
     
    7575
    7676    // Determine which customer should be displayed
    77     if(array_key_exists('i', $_GET))
     77    if (array_key_exists('i', $_GET))
    7878    {
    79       if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     79      if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění');
    8080      $CustomerId = $_GET['i'];
    8181    } else
    8282    {
    83       if(!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
     83      if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return ('Nemáte oprávnění');
    8484      $UserId = $this->System->User->User['Id'];
    8585      $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1');
    86       if($DbResult->num_rows > 0)
     86      if ($DbResult->num_rows > 0)
    8787      {
    8888        $CustomerUserRel = $DbResult->fetch_assoc();
    8989        $CustomerId = $CustomerUserRel['Customer'];
    90       } else return($this->SystemMessage('Chyba', 'Nejste zákazníkem'));
     90      } else return ($this->SystemMessage('Chyba', 'Nejste zákazníkem'));
    9191    }
    9292
    9393    // Load customer info
    9494    $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId);
    95     if($DbResult->num_rows == 1)
     95    if ($DbResult->num_rows == 1)
    9696    {
    9797      $Customer = $DbResult->fetch_assoc();
    98     } else return($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'));
     98    } else return ($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'));
    9999
    100100
    101101    // Load subject info
    102102    $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']);
    103     if($DbResult->num_rows == 1)
     103    if ($DbResult->num_rows == 1)
    104104    {
    105105      $Subject = $DbResult->fetch_assoc();
    106     } else return($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen'));
     106    } else return ($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen'));
    107107
    108108
     
    141141      'LEFT JOIN `Service` ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '.
    142142      'WHERE (`ServiceCustomerRel`.`Customer`='.$Customer['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)');
    143     while($DbRow = $DbResult->fetch_assoc())
     143    while ($DbRow = $DbResult->fetch_assoc())
    144144    {
    145145      $Output .= '<tr><td>'.$DbRow['Name'].'</td><td>'.$DbRow['Price'].'</td></tr>';
     
    152152
    153153    $Output .= '</td></tr></table>';
    154     return($Output);
     154    return ($Output);
    155155  }
    156156}
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r765 r873  
    2626  {
    2727    $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL');
    28     while($DbRow = $DbResult->fetch_assoc())
     28    while ($DbRow = $DbResult->fetch_assoc())
    2929    {
    30       if(is_numeric($DbRow['VariableSymbol']))
     30      if (is_numeric($DbRow['VariableSymbol']))
    3131      {
    3232        $DbResult2 = $this->Database->select('Subject', 'Id', 'Id='.$DbRow['VariableSymbol']);
    33         if($DbResult2->num_rows == 1)
     33        if ($DbResult2->num_rows == 1)
    3434        {
    3535          $DbRow2 = $DbResult2->fetch_assoc();
    36           if($DbRow['Value'] >= 0) {
     36          if ($DbRow['Value'] >= 0) {
    3737            $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup');
    3838          } else {
     
    5151          $Form->SetClass('FinanceOperation');
    5252          $Form->LoadValuesFromDatabase($Id);
    53           if(array_key_exists('AfterInsert', $Form->Definition))
     53          if (array_key_exists('AfterInsert', $Form->Definition))
    5454          {
    5555            $Class = $Form->Definition['AfterInsert'][0];
     
    8080    $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'."\n";
    8181
    82     if($Bank['Code'] == '2010') $Import = new ImportFio($this->System);
    83       else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System);
     82    if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System);
     83      else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System);
    8484      else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován');
    85     if(isset($Import))
     85    if (isset($Import))
    8686    {
    8787      $Import->BankAccount = $BankAccount;
     
    8989      $Import->PairOperations();
    9090    }
    91     return($Output);
     91    return ($Output);
    9292  }
    9393
    9494  function Show()
    9595  {
    96     if(!$this->System->User->CheckPermission('Finance', 'SubjectList'))
    97       return('Nemáte oprávnění');
     96    if (!$this->System->User->CheckPermission('Finance', 'SubjectList'))
     97      return ('Nemáte oprávnění');
    9898
    9999    $Output = $this->Import($_GET['i']);
    100     return($Output);
     100    return ($Output);
    101101  }
    102102}
     
    111111  {
    112112    $Output = '';
    113     if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    114     if(array_key_exists('Operation', $_GET))
     113    if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return ('Nemáte oprávnění');
     114    if (array_key_exists('Operation', $_GET))
    115115    {
    116       if($_GET['Operation'] == 'prepare') $Output .= $this->Prepare();
    117       else if($_GET['Operation'] == 'insert') $Output .= $this->Insert();
     116      if ($_GET['Operation'] == 'prepare') $Output .= $this->Prepare();
     117      else if ($_GET['Operation'] == 'insert') $Output .= $this->Insert();
    118118      else $Output .= 'Neplatná akce';
    119119    } else $Output .= $this->ShowForm();
    120     return($Output);
     120    return ($Output);
    121121  }
    122122
     
    128128    $Form->Values['BankAccount'] = $_GET['id'];
    129129    $Output = $Form->ShowEditForm();
    130     return($Output);
     130    return ($Output);
    131131  }
    132132
     
    147147    $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')';
    148148
    149     if($Bank['Code'] == '2010') $Import = new ImportFio($this->System);
    150       else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System);
     149    if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System);
     150      else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System);
    151151      else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován');
    152152    $Import->BankAccount = $BankAccount;
    153153    $Output .= $Import->ImportFile($File->GetContent(), $File->GetExt());
    154154
    155     return($Output);
     155    return ($Output);
    156156  }
    157157
     
    171171    $Output = '';
    172172
    173     for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
     173    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    174174    {
    175       if($_POST['Money'.$I] >= 0) {
     175      if ($_POST['Money'.$I] >= 0) {
    176176        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN,
    177177          'FinanceOperationGroup');
     
    187187      $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
    188188    }
    189     return($Output);
     189    return ($Output);
    190190  }
    191191}
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r799 r873  
    7676    $DbRow = $DbResult->fetch_row();
    7777    $Output = 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>';
    78     return($Output);
     78    return ($Output);
    7979  }
    8080
     
    8282  {
    8383    $Preset = array();
    84     if($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT;
     84    if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT;
    8585       else $OperationGroupId = OPERATION_GROUP_ACCOUNT_IN;
    8686    $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup');
     
    9494      'presetBankAccount' => $Item['BankAccount'],
    9595      'presetGroup' => $FinanceGroup['Id']);
    96     return($Preset);
     96    return ($Preset);
    9797  }
    9898}
     
    106106      '(`AutoImport`=1) AND (`TimeCreate` < NOW()) AND '.
    107107      '((`TimeEnd` IS NULL) OR (`TimeEnd` > NOW()))');
    108     while($DbRow = $DbResult->fetch_assoc())
     108    while ($DbRow = $DbResult->fetch_assoc())
    109109    {
    110110      echo($DbRow['Comment']."\n");
     
    112112      $Output .= $Page->Import($DbRow['Id']);
    113113    }
    114     return($Output);
     114    return ($Output);
    115115  }
    116116}
  • trunk/Modules/FinanceBankAPI/Fio.php

    r738 r873  
    1111  function Import($TimeFrom, $TimeTo)
    1212  {
    13     if($this->UserName == '') throw new Exception('Missing value for UserName property.');
    14     if($this->Password == '') throw new Exception('Missing value for Password property.');
    15     if(!is_numeric($this->Account)) throw new Exception('Missing or not numeric value for Account property.');
     13    if ($this->UserName == '') throw new Exception('Missing value for UserName property.');
     14    if ($this->Password == '') throw new Exception('Missing value for Password property.');
     15    if (!is_numeric($this->Account)) throw new Exception('Missing or not numeric value for Account property.');
    1616
    1717    $fp = fsockopen('ssl://www.fio.cz', 443, $errno, $errstr, 30);
    18     if(!$fp)
     18    if (!$fp)
    1919    {
    2020      throw new Exception('Connection error: '.$errstr);
     
    3535      // Read response
    3636      $Response = array();
    37       while(!feof($fp))
     37      while (!feof($fp))
    3838      {
    3939        $Response[] = trim(fgets($fp, 1024));
     
    4242
    4343      // Strip HTTP header
    44       while($Response[0] != '') array_shift($Response);
     44      while ($Response[0] != '') array_shift($Response);
    4545      array_shift($Response); // Remove empty line
    4646      //echo(implode("\n", $Response));
     
    4949      $GPC = new GPC();
    5050      $Result = array();
    51       foreach($Response as $Index => $Line)
     51      foreach ($Response as $Index => $Line)
    5252      {
    53         if(($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);
     53        if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);
    5454        $GPCLine = $GPC->ParseLine($Line);
    55         if($GPCLine != NULL) $Result[] = $GPCLine;
     55        if ($GPCLine != NULL) $Result[] = $GPCLine;
    5656      }
    57       return($Result);
     57      return ($Result);
    5858    }
    5959  }
     
    6565  $Response = implode('', $Response);
    6666    $ErrorMessageStart = '<div id="oldform_warning">';
    67     if(strpos($Response, $ErrorMessageStart) !== false)
     67    if (strpos($Response, $ErrorMessageStart) !== false)
    6868  {
    6969    $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));
  • trunk/Modules/FinanceBankAPI/FioAPI.php

    r836 r873  
    77function RemoveComma($Text)
    88{
    9   if((mb_strlen($Text) >= 2) and ($Text[0] == '"') and (mb_substr($Text, -1, 1) == '"')) return(mb_substr($Text, 1, -1));
    10     else return($Text);
     9  if ((mb_strlen($Text) >= 2) and ($Text[0] == '"') and (mb_substr($Text, -1, 1) == '"')) return (mb_substr($Text, 1, -1));
     10    else return ($Text);
    1111}
    1212
     
    2525  function Import($TimeFrom, $TimeTo)
    2626  {
    27     if($this->Token == '') throw new Exception('Missing value for Token property.');
     27    if ($this->Token == '') throw new Exception('Missing value for Token property.');
    2828
    2929    // URL format: https://www.fio.cz/ib_api/rest/periods/{token}/{datum od}/{datum do}/transactions.{format}
     
    3333    $Response = '';
    3434    $Response = @file_get_contents('https://www.fio.cz'.$RequestURL);
    35     if($Response == FALSE)
     35    if ($Response == FALSE)
    3636    {
    3737      throw new Exception('Connection error');
    3838    } else
    3939    {
    40       if($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response);
     40      if ($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response);
    4141      $Response = explode("\n", $Response);
    4242
    43       if($this->Format == 'gpc')
     43      if ($this->Format == 'gpc')
    4444      {
    4545        // Parse all GPC lines
    4646        $GPC = new GPC();
    4747        $Result = array();
    48         foreach($Response as $Index => $Line)
     48        foreach ($Response as $Index => $Line)
    4949        {
    50           if(($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);
     50          if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);
    5151          $GPCLine = $GPC->ParseLine($Line);
    52           if($GPCLine != NULL) $Result[] = $GPCLine;
     52          if ($GPCLine != NULL) $Result[] = $GPCLine;
    5353        }
    5454      } else
    55       if($this->Format == 'csv')
     55      if ($this->Format == 'csv')
    5656      {
    5757        $Result = array(
     
    6060
    6161        // CVS header
    62         while((count($Response) > 0) and ($Response[0] != ''))
     62        while ((count($Response) > 0) and ($Response[0] != ''))
    6363        {
    6464          $Line = explode(';', $Response[0]);
    65           if($Line[0] == 'accountId') $Result['AccountNumber'] = $Line[0];
    66           else if($Line[0] == 'bankId') $Result['BankId'] = $Line[0];
    67           else if($Line[0] == 'currency') $Result['Currency'] = $Line[0];
    68           else if($Line[0] == 'iban') $Result['IBAN'] = $Line[0];
    69           else if($Line[0] == 'bic') $Result['BIC'] = $Line[0];
    70           else if($Line[0] == 'openingBalance') $Result['OpeningBalance'] = $Line[0];
    71           else if($Line[0] == 'closingBalance') $Result['ClosingBalance'] = $Line[0];
    72           else if($Line[0] == 'dateStart') $Result['DateStart'] = $Line[0];
    73           else if($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0];
    74           else if($Line[0] == 'idFrom') $Result['IdFrom'] = $Line[0];
    75           else if($Line[0] == 'idTo') $Result['IdTo'] = $Line[0];
     65          if ($Line[0] == 'accountId') $Result['AccountNumber'] = $Line[0];
     66          else if ($Line[0] == 'bankId') $Result['BankId'] = $Line[0];
     67          else if ($Line[0] == 'currency') $Result['Currency'] = $Line[0];
     68          else if ($Line[0] == 'iban') $Result['IBAN'] = $Line[0];
     69          else if ($Line[0] == 'bic') $Result['BIC'] = $Line[0];
     70          else if ($Line[0] == 'openingBalance') $Result['OpeningBalance'] = $Line[0];
     71          else if ($Line[0] == 'closingBalance') $Result['ClosingBalance'] = $Line[0];
     72          else if ($Line[0] == 'dateStart') $Result['DateStart'] = $Line[0];
     73          else if ($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0];
     74          else if ($Line[0] == 'idFrom') $Result['IdFrom'] = $Line[0];
     75          else if ($Line[0] == 'idTo') $Result['IdTo'] = $Line[0];
    7676          array_shift($Response);
    7777        }
    7878        array_shift($Response); // Remove empty line
    7979
    80         if((count($Response) == 0) or
     80        if ((count($Response) == 0) or
    8181          ($Response[0] != 'ID pohybu;Datum;Objem;Měna;Protiúčet;Název protiúčtu;Kód banky;Název banky;KS;VS;SS;Uživatelská identifikace;Zpráva pro příjemce;Typ;Provedl;Upřesnění;Komentář;BIC;ID pokynu')
    8282          ) throw new Exception('Unsupported CSV header');
    8383        array_shift($Response);
    8484        array_pop($Response);
    85         foreach($Response as $Index => $Line)
     85        foreach ($Response as $Index => $Line)
    8686        {
    8787          $Line = explode(';', $Line);
     
    9797        }
    9898      }
    99       return($Result);
     99      return ($Result);
    100100    }
    101101  }
     
    107107    $Response = implode('', $Response);
    108108    $ErrorMessageStart = '<div id="oldform_warning">';
    109     if(strpos($Response, $ErrorMessageStart) !== false)
     109    if (strpos($Response, $ErrorMessageStart) !== false)
    110110    {
    111111      $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));
  • trunk/Modules/FinanceBankAPI/FioDemo.php

    r738 r873  
    1111echo('<html><head><meta charset="utf-8"></head><body>');
    1212echo('<table border="1">');
    13 foreach($Records as $Record)
     13foreach ($Records as $Record)
    1414{
    1515  echo('<tr>');
    16   if($Record['Type'] == GPC_TYPE_REPORT)
     16  if ($Record['Type'] == GPC_TYPE_REPORT)
    1717  {
    1818    echo('<td>Jméno účtu: '.$Record['AccountName'].'</td>');
     
    3535    echo('<th>Uživatelská identifikace</th>');
    3636  } else
    37   if($Record['Type'] == GPC_TYPE_ITEM)
     37  if ($Record['Type'] == GPC_TYPE_ITEM)
    3838  {
    3939    echo('<td>'.date('j.n.Y', $Record['DueDate']).'</td>');
  • trunk/Modules/FinanceBankAPI/GPC.php

    r738 r873  
    1111    $Type = mb_substr($Line, 1, 3);
    1212
    13     if($Type == GPC_TYPE_REPORT)
     13    if ($Type == GPC_TYPE_REPORT)
    1414    {
    1515      $GPCLine = array
     
    2929      );
    3030    } else
    31     if($Type == GPC_TYPE_ITEM)
     31    if ($Type == GPC_TYPE_ITEM)
    3232    {
    3333      $GPCLine = array
     
    5353    $GPCLine = NULL;
    5454
    55     return($GPCLine);
     55    return ($GPCLine);
    5656  }
    5757}
  • trunk/Modules/FinanceBankAPI/ImportFio.php

    r765 r873  
    99    $Fio = new FioAPI();
    1010    $Fio->Token = $this->BankAccount['LoginName'];
    11     if($this->BankAccount['LastImportDate'] == '') $PeriodStart = time();
     11    if ($this->BankAccount['LastImportDate'] == '') $PeriodStart = time();
    1212      else $PeriodStart = MysqlDateToTime($this->BankAccount['LastImportDate']);
    1313    $PeriodEnd = time();
     
    2222        //$Output .= '<td>Suma výdajů: '.$Records['DebitValue'].' Kč</td>';
    2323      //$Output .= '</tr>';
    24     foreach($Records['Items'] as $Record)
     24    foreach ($Records['Items'] as $Record)
    2525    {
    2626      $DbResult = $this->Database->select('FinanceBankImport', 'ID', 'Identification='.$Record['ID']);
    27       if($DbResult->num_rows == 0)
     27      if ($DbResult->num_rows == 0)
    2828      {
    2929        $Output .= '<tr>';
     
    4444    $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'],
    4545      array('LastImportDate' => TimeToMysqlDate($PeriodEnd)));
    46     return($Output);
     46    return ($Output);
    4747  }
    4848}
  • trunk/Modules/FinanceBankAPI/ImportPS.php

    r738 r873  
    55  function ImportFile($Content, $Ext)
    66  {
    7     if($Ext == 'txt') $this->ImportTxt($Content);
    8       else if($Ext == 'cvs') $this->ImportCVS($Content);
     7    if ($Ext == 'txt') $this->ImportTxt($Content);
     8      else if ($Ext == 'cvs') $this->ImportCVS($Content);
    99  }
    1010
     
    2020
    2121    $Data = explode("\n", $Content);
    22     foreach($Data as $Key => $Value)
     22    foreach ($Data as $Key => $Value)
    2323    {
    2424      $Value = str_replace('\"', '"', $Value);
    2525      $Data[$Key] = str_getcsv($Value, ',', '"', "\\");
    2626      //print_r($Data[$Key]);
    27       foreach($Data[$Key] as $Key2 => $Value2)
     27      foreach ($Data[$Key] as $Key2 => $Value2)
    2828      {
    29         if(substr($Data[$Key][$Key2], 0, 2) == '\"')
     29        if (substr($Data[$Key][$Key2], 0, 2) == '\"')
    3030          $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2);
    3131      }
     
    4646    );
    4747
    48     if($Header != $Data[0]) $Output = 'Nekompatibilní struktura CSV';
     48    if ($Header != $Data[0]) $Output = 'Nekompatibilní struktura CSV';
    4949    else
    5050    {
     
    5454      $Output = '<form action="?Operation=insert" method="post">';
    5555      $I = 0;
    56       foreach($Data as $Key => $Value)
     56      foreach ($Data as $Key => $Value)
    5757      {
    58         if(count($Value) <= 1) continue;
    59         if($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna
     58        if (count($Value) <= 1) continue;
     59        if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna
    6060        $Time = explode('.', $Value[0]);
    6161        $Time = $Time[2].'-'.$Time[1].'-'.$Time[0];
    6262        $Money = $Value[1];
    63         if(is_numeric($Value[5]))
     63        if (is_numeric($Value[5]))
    6464        {
    6565          $Subject = $Value[5] * 1;
    6666          $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$this->Database->real_escape_string($Subject));
    67           if($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';
     67          if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';
    6868        } else
    6969        {
    7070          $Subject = '? ('.$Value[5].')';
    7171        }
    72         if(!is_numeric($Subject))
     72        if (!is_numeric($Subject))
    7373        {
    7474          $Mode = 'Ručně';
     
    8080        }
    8181
    82         if($Money < 0) $Text = 'Platba převodem';
     82        if ($Money < 0) $Text = 'Platba převodem';
    8383        else $Text = 'Přijatá platba';
    8484        $Automatic .= '<tr>'.
  • trunk/Modules/IS/IS.php

    r871 r873  
    309309            $DbRow = $DbResult->fetch_assoc();
    310310            $Actions[] = '<a href="javascript:window.close();" onclick="add_select_item('.$Id.',&quot;'.$DbRow['Name'].'&quot;,&quot;'.
    311               $_GET['r'].'&quot;); set_return('.$Id.',&quot;'.
     311              $_GET['r'].'&quot;); set_return ('.$Id.',&quot;'.
    312312              $_GET['r'].'&quot;);"><img alt="Vybrat" title="Vybrat" src="'.
    313313              $this->System->Link('/images/select.png').'"/> Vybrat</a>';
     
    679679    $this->BasicHTML = true;
    680680    $this->HideMenu = true;
    681     $RowActions = '<a href="javascript:window.close();" onclick="set_return(#RowId,&quot;'.
     681    $RowActions = '<a href="javascript:window.close();" onclick="set_return (#RowId,&quot;'.
    682682      $_GET['r'].'&quot;);"><img alt="Vybrat" title="Vybrat" src="'.
    683683      $this->System->Link('/images/select.png').'"/></a>';
     
    706706    if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
    707707      return 'Nemáte oprávnění';
    708     if(!array_key_exists($Table, $this->System->FormManager->Classes))
     708    if (!array_key_exists($Table, $this->System->FormManager->Classes))
    709709      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    710710    $FormClass = $this->System->FormManager->Classes[$Table];
  • trunk/Modules/Log/Log.php

    r681 r873  
    4949  function NewRecord($Module, $Operation, $Value = '')
    5050  {
    51     if(array_key_exists('User', $this->System->ModuleManager->Modules) and
     51    if (array_key_exists('User', $this->System->ModuleManager->Modules) and
    5252      array_key_exists('Id', $this->System->User->User))
    5353      $UserId = $this->System->User->User['Id'];
    5454      else $UserId = NULL;
    55     if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR'];
     55    if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR'];
    5656      else $IPAddress = '';
    5757    $this->Database->insert('Log', array('Time' => 'NOW()',
     
    6969    $Output = '';
    7070    $Items = array();
    71     if(array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"';
     71    if (array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"';
    7272      else $Where = '';
    7373    $sql = 'SELECT *, UNIX_TIMESTAMP(`Time`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`Id` = `Log`.`User`) AS `UserName`, `Time` FROM `Log`'.
    7474      $Where.' ORDER BY `Time` DESC LIMIT '.$Count;
    7575    $DbResult = $this->System->Database->query($sql);
    76     while($Line = $DbResult->fetch_assoc())
     76    while ($Line = $DbResult->fetch_assoc())
    7777    {
    7878      $Line['Value'] = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $Line['Value']);
     
    9696    $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail'];
    9797    $RSS->Items = $Items;
    98     return($RSS->Generate());
     98    return ($RSS->Generate());
    9999  }
    100100}
  • trunk/Modules/Map/Map.php

    r865 r873  
    1313  function Show()
    1414  {
    15     if(!$this->System->User->CheckPermission('Map', 'Show'))
    16       return('Nemáte oprávnění');
    17 
    18     if(count($this->System->PathItems) > 1)
    19     {
    20       if($this->System->PathItems[1] == 'show-position') return($this->ShowPosition());
    21       else return(PAGE_NOT_FOUND);
    22     } else return($this->ShowMain());
     15    if (!$this->System->User->CheckPermission('Map', 'Show'))
     16      return ('Nemáte oprávnění');
     17
     18    if (count($this->System->PathItems) > 1)
     19    {
     20      if ($this->System->PathItems[1] == 'show-position') return ($this->ShowPosition());
     21      else return (PAGE_NOT_FOUND);
     22    } else return ($this->ShowMain());
    2323  }
    2424
     
    2626  {
    2727    $DbResult = $this->Database->select('MapPosition', '*', '`Id`='.$_GET['i']);
    28     if($DbResult->num_rows > 0)
     28    if ($DbResult->num_rows > 0)
    2929    {
    3030      $DbRow = $DbResult->fetch_assoc();
     
    4040      $MapApi->Markers[] = $Marker;
    4141      $Output = $MapApi->ShowPage($this);
    42       return($Output);
    43     } else return('Položka nenalezena');
     42      return ($Output);
     43    } else return ('Položka nenalezena');
    4444  }
    4545
     
    5959    'WHERE (`NetworkDevice`.`Used`=1) AND (`NetworkDevice`.`MapPosition` IS NOT NULL) '.
    6060    'GROUP BY `NetworkDevice`.`MapPosition`');
    61     while($Device = $DbResult->fetch_assoc())
     61    while ($Device = $DbResult->fetch_assoc())
    6262    {
    6363      $Pos = explode(';', $Device['Pos']);
     
    6969
    7070    $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)');
    71     while($Link = $DbResult->fetch_assoc())
     71    while ($Link = $DbResult->fetch_assoc())
    7272    {
    7373      $DbResult2 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '.
     
    7777        'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '.
    7878        'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface2'].')');
    79       if(($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))
     79      if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))
    8080      {
    8181        $Device1 = $DbResult2->fetch_assoc();
     
    8383        $Device2 = $DbResult3->fetch_assoc();
    8484        $Pos2 = explode(';', $Device2['Pos']);
    85         if(($Device1['Used'] == 1) and ($Device2['Used'] == 1))
     85        if (($Device1['Used'] == 1) and ($Device2['Used'] == 1))
    8686        {
    8787          $PolyLine = new MapPolyLine();
     
    146146        NetworkLinks = [';
    147147    $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)');
    148     while($Link = $DbResult->fetch_assoc())
     148    while ($Link = $DbResult->fetch_assoc())
    149149    {
    150150      $DbResult2 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '.
     
    154154        'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '.
    155155        'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface2'].')');
    156       if(($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))
     156      if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))
    157157      {
    158158        $Device1 = $DbResult2->fetch_assoc();
     
    160160        $Device2 = $DbResult3->fetch_assoc();
    161161        $Pos2 = explode(';', $Device2['Pos']);
    162         if(($Device1['Used'] == 1) and ($Device2['Used'] == 1))
     162        if (($Device1['Used'] == 1) and ($Device2['Used'] == 1))
    163163          $Output .= 'new google.maps.Polyline([new google.maps.LatLng('.$Pos1[0].', '.
    164164        $Pos1[1].'),new google.maps.LatLng('.$Pos2[0].', '.$Pos2[1].')], "#4F4FBF", 3, 0.8), ';
     
    198198      'WHERE (`NetworkDevice`.`Used`=1) AND (`NetworkDevice`.`MapPosition` IS NOT NULL) '.
    199199      'GROUP BY `NetworkDevice`.`MapPosition`');
    200     while($Device = $DbResult->fetch_assoc())
     200    while ($Device = $DbResult->fetch_assoc())
    201201    {
    202202      $Pos = explode(';', $Device['Pos']);
     
    236236                </table>';
    237237    */
    238     return($Output);
     238    return ($Output);
    239239  }
    240240}
     
    245245  {
    246246    $Output = parent::OnEdit($Item);
    247     if($this->FormManager->ShowRelation)
     247    if ($this->FormManager->ShowRelation)
    248248      $Output .=  '<img src="'.$this->FormManager->Root.'/images/select.png" alf="Vybrat" language="javascript" '.
    249249        'onclick="return popupwindow(&quot;'.$this->FormManager->Root.'/is/?a=mapselect&amp;r='.
    250250        $Item['Name'].'&quot;,&quot;test&quot;);" style="cursor:hand;cursor:pointer"/>';
    251     return($Output);
     251    return ($Output);
    252252  }
    253253}
  • trunk/Modules/Map/MapAPI.php

    r864 r873  
    3737  function Show()
    3838  {
    39     return('');
     39    return ('');
    4040  }
    4141}
     
    7878          if (point)
    7979          {
    80             set_return(point.lat() + ";" + point.lng(),"'.$this->OnClickObject.'");
     80            set_return (point.lat() + ";" + point.lng(),"'.$this->OnClickObject.'");
    8181            window.close();
    8282          }
     
    102102    </script>';
    103103    $Output .= '<div id="map_canvas" style="width: 100%; height: 98%;"></div>';
    104     return($Output);
     104    return ($Output);
    105105  }
    106106}
     
    162162          if (e)
    163163          {
    164             set_return(e.latlng.lat + ";" + e.latlng.lng,"'.$this->OnClickObject.'");
     164            set_return (e.latlng.lat + ";" + e.latlng.lng,"'.$this->OnClickObject.'");
    165165            window.close();
    166166          }
  • trunk/Modules/Meals/Meals.php

    r790 r873  
    1313  function Show()
    1414  {
    15     if(count($this->System->PathItems) > 1)
    16     {
    17       if($this->System->PathItems[1] == 'tisk') return($this->ShowPrint());
    18         else if($this->System->PathItems[1] == 'menuedit.php') return($this->ShowEdit());
    19         else return(PAGE_NOT_FOUND);
    20     } else return($this->ShowMenu());
     15    if (count($this->System->PathItems) > 1)
     16    {
     17      if ($this->System->PathItems[1] == 'tisk') return ($this->ShowPrint());
     18        else if ($this->System->PathItems[1] == 'menuedit.php') return ($this->ShowEdit());
     19        else return (PAGE_NOT_FOUND);
     20    } else return ($this->ShowMenu());
    2121  }
    2222
     
    2626    $Output = '<table align="center" class="WideTable"><tr><th>Den</th><th>Datum</th><th>Polévka</th><th>Hlavní jídlo</th></tr>';
    2727    $DbResult = $this->Database->select('Meals', '*, UNIX_TIMESTAMP(Date)','Date >= NOW() ORDER BY Date');
    28     while($Row = $DbResult->fetch_array())
    29     {
    30       if($Row['Status'] == 1) $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td>'.$Row['Soup'].'</td><td>'.$Row['Meal'].'</td></tr>';
    31       else if(($Row['Status' ] == 2) or ($Row['Status'] == 3))
     28    while ($Row = $DbResult->fetch_array())
     29    {
     30      if ($Row['Status'] == 1) $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td>'.$Row['Soup'].'</td><td>'.$Row['Meal'].'</td></tr>';
     31      else if (($Row['Status' ] == 2) or ($Row['Status'] == 3))
    3232      {
    3333        $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td colspan="2" align="center">'.$this->Status[$Row['Status']].'</td></tr>';
     
    4040    $Output .= 'Cena jednoho menu: '.$Row['Price'].' Kč<br />';
    4141    $Output .= $Row['Info'];
    42     return($Output);
     42    return ($Output);
    4343  }
    4444
     
    6666    $Date = explode('-', $_GET['date']);
    6767    $Time2 = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]);
    68     for($I = 0; $I < 5; $I++)
     68    for ($I = 0; $I < 5; $I++)
    6969    {
    7070      $Time = $Time2 + $I * 86400;
     
    7474      $Row = $DbResult->fetch_array();
    7575      $Output .= '<tr><td style="border-style: solid; border-color: black; border-width: 2; font-size: xx-large;" width="10%">'.$this->DayNamesShort[$DayOfWeek].'</td><td style="font-size: x-large; border-style: solid; border-color: black; border-width: 2;" width="90%">';
    76       if($Row['Status'] == 0) $Output .= '&nbsp;<br><br>&nbsp;';
    77       if($Row['Status'] == 1) $Output .= 'Polévka: '.$Row['Soup'].'<br><br>'.$Row['Meal'];
    78       else if(($Row['Status'] == 2) or ($Row['Status'] == 3))
     76      if ($Row['Status'] == 0) $Output .= '&nbsp;<br><br>&nbsp;';
     77      if ($Row['Status'] == 1) $Output .= 'Polévka: '.$Row['Soup'].'<br><br>'.$Row['Meal'];
     78      else if (($Row['Status'] == 2) or ($Row['Status'] == 3))
    7979      {
    8080        $Output .= '<br>'.$this->Status[$Row['Status']].'<br>&nbsp;';
     
    9191
    9292    $Output .= '</body></html>';
    93     return($Output);
     93    return ($Output);
    9494  }
    9595
     
    103103    $Week = date('w', mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]));
    104104    $WeekOfYear = date('W', mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]));
    105     if($WeekOfYear != $LastWeekOfYear)
     105    if ($WeekOfYear != $LastWeekOfYear)
    106106      $WeekRowSpan = '<td align="center" rowspan="'.(7 - (($Week + 7 - 1) % 7)).'">'.
    107107        $WeekOfYear.'<br /><a href="tisk/?date='.
     
    109109        '">Tisk</a></td>';
    110110      else $WeekRowSpan = '';
    111     if($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = '';
     111    if ($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = '';
    112112    $Output = '<tr><td'.$Color.'>'.$this->DayNames[$Week].'</td><td>'.HumanDate($Row['Date']).'</td>'.$WeekRowSpan.'
    113113    <td><input name="soup_'.$Row['Date'].'" size="30" value="'.$Row['Soup'].'"></td>
    114114    <td><input name="meal_'.$Row['Date'].'" size="30" value="'.$Row['Meal'].'"></td>
    115115    <td><select name="status_'.$Row['Date'].'">';
    116     for($I = 0; $I < 4; $I++) $Output .= '    <option '.$Selected[$I].'value="'.$I.'">'.$this->Status[$I].'</option>';
     116    for ($I = 0; $I < 4; $I++) $Output .= '    <option '.$Selected[$I].'value="'.$I.'">'.$this->Status[$I].'</option>';
    117117    $Output .= '</select></td></tr>';
    118118    $LastWeekOfYear = $WeekOfYear;
    119     return($Output);
     119    return ($Output);
    120120  }
    121121
     
    125125
    126126    $Output = '';
    127     if(array_key_exists('action', $_GET))
    128     {
    129       if($_GET['action'] == 'savemenu')
    130       {
    131         for($I = 0; $I < $this->DayCount; $I++)
     127    if (array_key_exists('action', $_GET))
     128    {
     129      if ($_GET['action'] == 'savemenu')
     130      {
     131        for ($I = 0; $I < $this->DayCount; $I++)
    132132        {
    133133          $Time = time() + $I * 86400;
     
    138138        $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'MenuSave');
    139139      }
    140       if($_GET['action'] == 'saveinfo')
     140      if ($_GET['action'] == 'saveinfo')
    141141      {
    142142        $this->Database->delete('MealsInfo', '1');
     
    149149<fieldset><legend>Jídlo pro jednotlivé dny</legend>
    150150<table align="center" class="WideTable"><tr><th>Den</th><th>Datum</th><th>Týden</th><th>Polévka</th><th>Hlavní jídlo</th><th>Stav</th></tr>';
    151     for($I = 0; $I < $this->DayCount; $I++)
     151    for ($I = 0; $I < $this->DayCount; $I++)
    152152    {
    153153      $Time = time() + $I * 86400;
    154154      $DbResult = $this->Database->select('Meals', '*', 'Date = "'.date('Y-m-d', $Time).'"');
    155       if($Row = $DbResult->fetch_array())
     155      if ($Row = $DbResult->fetch_array())
    156156        $Output .= $this->PrintTableRow($Row);
    157157      else
     
    173173'<div align="center"><input type="submit" value="Uložit údaje"></div>
    174174</fieldset></form>';
    175     return($Output);
     175    return ($Output);
    176176  }
    177177}
  • trunk/Modules/Meteostation/Download.php

    r548 r873  
    44
    55$MeteoStation = new MeteoStation($System->Database, $System);
    6 while(true)
     6while (true)
    77{
    88  $MeteoStation->DownloadAll();
  • trunk/Modules/Meteostation/Meteostation.php

    r747 r873  
    1111    $Output = 'Stav meteostanice:<br/>';
    1212    $Output .= '<img src="'.$this->System->Link('/Modules/Meteostation/cache/1.png').'" alt="stav meteostanice"/>';
    13     return($Output);
     13    return ($Output);
    1414  }
    1515}
     
    9191  {
    9292    $DbResult = $this->Database->select('MeteoStation', '*');
    93     while($DbRow = $DbResult->fetch_assoc())
     93    while ($DbRow = $DbResult->fetch_assoc())
    9494    {
    9595      $MeteoStation = new MeteoStation();
  • trunk/Modules/Network/HostList.php

    r833 r873  
    1111  function Show()
    1212  {
    13     if(!$this->System->User->CheckPermission('Network', 'ShowHostList'))
    14       return('Nemáte oprávnění');
     13    if (!$this->System->User->CheckPermission('Network', 'ShowHostList'))
     14      return ('Nemáte oprávnění');
    1515
    16     if(array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) ';
     16    if (array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) ';
    1717      else $Where = '';
    1818    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
     
    2222      'LEFT JOIN User ON Member.ResponsibleUser = User.Id '.
    2323      'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 '.$Where.'ORDER BY NetworkDevice.Name');
    24     while($Device = $DbResult->fetch_assoc())
     24    while ($Device = $DbResult->fetch_assoc())
    2525    {
    26       if($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
     26      if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
    2727      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE Device = '.$Device['Id']);
    2828      $DbRow = $DbResult2->fetch_row();
    29       if($DbRow[0] == 1)
     29      if ($DbRow[0] == 1)
    3030      {
    3131        $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
    3232        $Interface = $DbResult2->fetch_assoc();
    33         if($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = '&nbsp;';
    34         if($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
    35         if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
     33        if ($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = '&nbsp;';
     34        if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
     35        if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    3636        $InterfaceName = $Device['Name'];
    37         if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
     37        if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
    3838        $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>'.$Interface['ExternalIP'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>';
    3939      } else
     
    4141        $Output .= '<tr><td colspan="3" style="text-align: left; font-weight: bold; '.$Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>';
    4242        $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
    43         while($Interface = $DbResult2->fetch_assoc())
     43        while ($Interface = $DbResult2->fetch_assoc())
    4444        {
    45           if($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
    46           if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
     45          if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
     46          if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    4747          $InterfaceName = $Device['Name'];
    48           if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
     48          if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
    4949          $Output .= '<tr><td style="text-align: left; '.$Style.'">&nbsp;&nbsp;'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
    5050        }
     
    5252    }
    5353    $Output .= '</table></div>';
    54     return($Output);
     54    return ($Output);
    5555  }
    5656}
  • trunk/Modules/Network/Hosting.php

    r790 r873  
    1111    $Output = '<br /><table class="WideTable"><tr><th>Název projektu</th><th>Založeno</th><th>Umístění na serveru</th><th>Zodpovědná osoba</th></tr>';
    1212    $DbResult = $this->Database->query('SELECT NetworkDevice.Name as ServerName, HostedProject.Name, HostedProject.Homepage, HostedProject.TimeCreate, User.Name AS UserName FROM HostedProject JOIN User ON User.Id = HostedProject.User JOIN NetworkDevice ON NetworkDevice.Id = HostedProject.Server ORDER BY HostedProject.Name');
    13     while($DbRow = $DbResult->fetch_assoc())
     13    while ($DbRow = $DbResult->fetch_assoc())
    1414    {
    1515      $Output .= '<tr><td><a href="'.$DbRow['Homepage'].'">'.$DbRow['Name'].'</a></td><td>'.HumanDate($DbRow['TimeCreate']).'</td><td>'.$DbRow['ServerName'].'</td><td>'.$DbRow['UserName'].'</td></tr>';
    1616    }
    1717    $Output .= '</table>';
    18     return($Output);
     18    return ($Output);
    1919  }
    2020}
  • trunk/Modules/Network/Network.php

    r871 r873  
    2525    '<tr><th/><br/>SSID<br/><br/></th>';
    2626    $ChannelList = array();
    27     if(!array_key_exists('range', $_GET)) $_GET['range'] = 'a';
    28     if($_GET['range'] == 'a')
     27    if (!array_key_exists('range', $_GET)) $_GET['range'] = 'a';
     28    if ($_GET['range'] == 'a')
    2929    {
    3030      $Where = '(Frequency < 5000)';
    31       for($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;
     31      for ($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;
    3232    }
    33     if($_GET['range'] == 'bc')
     33    if ($_GET['range'] == 'bc')
    3434    {
    3535      $Where = '(Frequency >= 5000) AND (Frequency <= 5350)';
    36       for($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;
     36      for ($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;
    3737    }
    38     if($_GET['range'] == 'd')
     38    if ($_GET['range'] == 'd')
    3939    {
    4040      $Where = '(Frequency >= 5470)';
    41       for($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;
     41      for ($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;
    4242    }
    4343
    44     foreach($ChannelList as $Frequency)
     44    foreach ($ChannelList as $Frequency)
    4545    {
    4646      $Output .= '<th><div class="RotatedHeader">'.$Frequency.'<div></th>';
     
    4848    $Output .= '</tr>';
    4949    $DbResult = $this->Database->query('SELECT `Frequency` FROM `NetworkInterfaceWireless` WHERE '.$Where.' AND (`Mode`=0) GROUP BY `Frequency`');
    50     while($DbRow = $DbResult->fetch_assoc())
     50    while ($DbRow = $DbResult->fetch_assoc())
    5151    {
    5252      $DbResult2 = $this->Database->query('SELECT * FROM `NetworkInterfaceWireless` WHERE (`Frequency`='.$DbRow['Frequency'].') AND '.$Where);
    53       while($DbRow2 = $DbResult2->fetch_assoc())
     53      while ($DbRow2 = $DbResult2->fetch_assoc())
    5454      {
    5555        $LowFrequency = $DbRow['Frequency'] - $DbRow2['ChannelWidth'] / 2 - $DbRow2['ChannelWidthLower'];
    5656        $HighFrequency = $DbRow['Frequency'] + $DbRow2['ChannelWidth'] / 2 + $DbRow2['ChannelWidthUpper'];
    5757        $Output .= '<tr><td>'.$DbRow2['SSID'].'</td>';
    58         foreach($ChannelList as $Frequency)
     58        foreach ($ChannelList as $Frequency)
    5959        {
    60           if(($DbRow2['Frequency'] == $Frequency)) $Color = '#000000';
    61             else if(($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080';
    62             else if(($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0';
     60          if (($DbRow2['Frequency'] == $Frequency)) $Color = '#000000';
     61            else if (($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080';
     62            else if (($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0';
    6363            else $Color = '#ffffff';
    6464          $Output .= '<td style="background-color: '.$Color.';">&nbsp;</td>';
     
    6969    }
    7070    $Output .= '</table>';
    71     return($Output);
     71    return ($Output);
    7272  }
    7373}
     
    8181  function Show()
    8282  {
    83     if(count($this->System->PathItems) > 1)
     83    if (count($this->System->PathItems) > 1)
    8484    {
    8585      $Output = $this->PageNotFound();
    8686    } else $Output = $this->ShowInformation();
    87     return($Output);
     87    return ($Output);
    8888  }
    8989
    9090  function ShowInformation()
    9191  {
    92     if(!$this->System->User->CheckPermission('Network', 'ShowInfo'))
    93       return('Nemáte oprávnění');
     92    if (!$this->System->User->CheckPermission('Network', 'ShowInfo'))
     93      return ('Nemáte oprávnění');
    9494
    9595    $Output = '<a href="'.$this->System->Link('/network/frequency-plan/').'">Frekvenční plán</a><br />';
    9696    $Output .= '<a href="'.$this->System->Link('/network/subnet/').'">Výpis registrovaných podsítí</a><br />';
    9797    $Output .= '<a href="'.$this->System->Link('/network/hosts/').'">Registrované zařízení</a><br />';
    98     return($Output);
     98    return ($Output);
    9999  }
    100100}
     
    862862      '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkInterface`.`Enabled`=1)'.
    863863      'ORDER BY `Name` ASC');
    864     if($DbResult3->num_rows > 0)
     864    if ($DbResult3->num_rows > 0)
    865865    {
    866866      $Output .= $Title.'<br/>';
    867867      $Output .= '<table>'.
    868868        '<tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n";
    869       while($Item = $DbResult3->fetch_assoc())
     869      while ($Item = $DbResult3->fetch_assoc())
    870870      {
    871871        $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']);
     
    874874          sprintf('%02d', floor($Duration % 60));
    875875        $Days = floor($Duration / (60 * 60 * 24));
    876         if($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
     876        if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
    877877
    878878        $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
     
    895895    $Output .= $StillOffline['Report'];
    896896    $Offline = $this->OnlineList('Offline', 0, -1, 0);
    897     return(array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva'));
     897    return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva'));
    898898  }
    899899
     
    918918      $Output .= '<table>'.
    919919        '<tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n";
    920       while($Item = $DbResult3->fetch_assoc())
     920      while ($Item = $DbResult3->fetch_assoc())
    921921      {
    922922        $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']);
     
    925925          sprintf('%02d', floor($Duration % 60));
    926926        $Days = floor($Duration / (60 * 60 * 24));
    927         if($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
     927        if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
    928928
    929929        $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
     
    947947    $Output .= $StillOffline['Report'];
    948948    $Offline = $this->PortCheckList('Offline', 0, -1, 0);
    949     return(array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port'));
     949    return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port'));
    950950  }
    951951}
  • trunk/Modules/Network/Subnet.php

    r825 r873  
    3636
    3737    $DbResult = $this->Database->query($Query);
    38     while($Subnet = $DbResult->fetch_assoc())
     38    while ($Subnet = $DbResult->fetch_assoc())
    3939    {
    4040      $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE CompareNetworkPrefix(INET_ATON("'.$Subnet['AddressRange'].'"), INET_ATON(LocalIP), '.$Subnet['Mask'].')');
     
    5454    $Output .= '</table>';
    5555    $Output .= $PageList['Output'];
    56     return($Output);
     56    return ($Output);
    5757  }
    5858}
  • trunk/Modules/Network/UserHosts.php

    r738 r873  
    1515    global $Config;
    1616
    17     if($this->System->User->User['Id'] == '') return($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci'));
     17    if ($this->System->User->User['Id'] == '') return ($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci'));
    1818    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
    1919    $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>';
     
    2121      'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '.
    2222      'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->User->User['Id'].') ORDER BY NetworkDevice.Name');
    23     while($Device = $DbResult->fetch_assoc())
     23    while ($Device = $DbResult->fetch_assoc())
    2424    {
    25       if($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
     25      if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
    2626      $Output .= '<tr><td colspan="4" style="text-align: left; font-weight: bold; '.
    2727        $Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td></tr>';
    2828      $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
    29       while($Interface = $DbResult2->fetch_assoc())
     29      while ($Interface = $DbResult2->fetch_assoc())
    3030      {
    31         if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
     31        if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    3232        $InterfaceName = $Device['Name'];
    33         if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
     33        if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
    3434        $Output .= '<tr><td style="text-align: left; '.$Style.'">&nbsp;&nbsp;'.
    3535          $InterfaceName.'</td><td>'.NotBlank($Interface['LocalIP']).'</td><td>'.
     
    3939    }
    4040    $Output .= '</table></div>';
    41     return($Output);
     41    return ($Output);
    4242  }
    4343}
  • trunk/Modules/NetworkConfig/Generate.php

    r848 r873  
    11<?php
    22
    3 if(isset($_SERVER['REMOTE_ADDR'])) die();
     3if (isset($_SERVER['REMOTE_ADDR'])) die();
    44include_once(dirname(__FILE__).'/../../Application/System.php');
    55$System = new Core();
     
    99$Now = time();
    1010$DbResult = $System->Database->select('NetworkConfiguration', '*, UNIX_TIMESTAMP(`LastTime`)', '(`Changed` = 1) AND (`Enabled` = 1)');
    11 while($Service = $DbResult->fetch_assoc())
     11while ($Service = $DbResult->fetch_assoc())
    1212{
    13   if($Service['UNIX_TIMESTAMP(LastTime)'] < (time() - $Service['Period']))
     13  if ($Service['UNIX_TIMESTAMP(LastTime)'] < (time() - $Service['Period']))
    1414  {
    1515    $System->Database->update('NetworkConfiguration', '`Id`='.$Service['Id'], array('Changed' => 2));
     
    1919    $ExecuteParts = explode('|', $Service['Execute']);
    2020    $Output = array();
    21     foreach($ExecuteParts as $Command)
    22       if($Command != '')
     21    foreach ($ExecuteParts as $Command)
     22      if ($Command != '')
    2323      {
    2424        exec($Command, $Output);
  • trunk/Modules/NetworkConfig/NetworkConfig.php

    r820 r873  
    8080  {
    8181    $Output = '';
    82     if($Parameters >= 3)
     82    if ($Parameters >= 3)
    8383    {
    8484      $ConfigItemName = $Parameters[2];
    85       if(array_key_exists($ConfigItemName, $this->ConfigItems))
     85      if (array_key_exists($ConfigItemName, $this->ConfigItems))
    8686      {
    8787        $ClassName = $this->ConfigItems[$ConfigItemName];
     
    9090      } else $Output = 'Config item '.$ConfigItemName.' not found';
    9191    } else $Output = 'Not enough parameters';
    92     return($Output);
     92    return ($Output);
    9393  }
    9494}
  • trunk/Modules/NetworkConfigAirOS/Generators/SSHClient.php

    r856 r873  
    2525  {
    2626    $Commands = trim($Commands);
    27     if($Commands != '')
     27    if ($Commands != '')
    2828    {
    2929      $Commands = addslashes($Commands);
     
    3434      $Command = $this->SSHPath.' -oBatchMode=yes -o ConnectTimeout='.$this->Timeout.' -l '.
    3535        $this->UserName.$PrivKey.' '.$this->HostName.' "'.$Commands.'"';
    36       if($this->Debug) echo($Command);
     36      if ($this->Debug) echo($Command);
    3737      $Output = array();
    3838      exec($Command, $Output);
    3939    } else $Output = '';
    40     if($this->Debug) print_r($Output);
    41     return($Output);
     40    if ($this->Debug) print_r($Output);
     41    return ($Output);
    4242  }
    4343}
  • trunk/Modules/NetworkConfigAirOS/Generators/Signal.php

    r856 r873  
    1313      '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '.
    1414      'FROM `NetworkDevice` WHERE (`API` = 2) AND (`Used` = 1)');
    15     while($Device = $DbResult3->fetch_assoc())
     15    while ($Device = $DbResult3->fetch_assoc())
    1616    {
    1717      echo($Device['LocalIP']."");
     
    2525      //print_r($Array);
    2626      echo('-');
    27       foreach($Array as $Properties)
     27      foreach ($Array as $Properties)
    2828      {
    2929        $DbResult = $this->Database->select('NetworkInterface', 'Id', '`MAC`="'.$Properties['mac'].'"');
    30         if($DbResult->num_rows > 0)
     30        if ($DbResult->num_rows > 0)
    3131        {
    3232          $DbRow = $DbResult->fetch_assoc();
  • trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php

    r819 r873  
    77    $Timeout = 1;
    88    $State = 0;
    9     if($Protocol == 'tcp') $Prefix = '';
    10       else if($Protocol == 'udp') $Prefix = 'udp://';
     9    if ($Protocol == 'tcp') $Prefix = '';
     10      else if ($Protocol == 'udp') $Prefix = 'udp://';
    1111      else throw new Exception('Unsupported protocol "'.$Protocol.'"');
    12     if($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout))
     12    if ($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout))
    1313    {
    1414      fclose($Socket);
    1515      $State = 1;
    1616    }
    17     return($State);
     17    return ($State);
    1818  }
    1919 
     
    2929      'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id`=`NetworkPort`.`Interface` '.
    3030      'WHERE (`NetworkPort`.`Enabled`=1) AND (`NetworkInterface`.`LocalIP` !="")');
    31     while($DbRow = $DbResult->fetch_assoc())
     31    while ($DbRow = $DbResult->fetch_assoc())
    3232      $Ports[$DbRow['Id']] = $DbRow;
    3333
    34     foreach($Ports as $Index => $Port)
     34    foreach ($Ports as $Index => $Port)
    3535    {
    36       if($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp';
    37       if($Port['Protocol'] == 1) $Port['Protocol'] = 'udp';
     36      if ($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp';
     37      if ($Port['Protocol'] == 1) $Port['Protocol'] = 'udp';
    3838      $Port['NewOnline'] = $this->CheckPortStatus($Port['LocalIP'], $Port['Number'], $Port['Protocol']);
    3939
    4040      // Update last online time if still online
    41       if($Port['NewOnline'])
     41      if ($Port['NewOnline'])
    4242      {
    4343        $DbResult = $this->Database->update('NetworkPort', '`Id` = "'.$Port['Id'].'"',
     
    4646
    4747      // Update UpDown table
    48       if($Port['Online'] != $Port['NewOnline'])
     48      if ($Port['Online'] != $Port['NewOnline'])
    4949      {
    5050        // Online state changed
     
    6565    $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 1) AND '.
    6666      '(`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'")');
    67     while($DbRow = $DbResult->fetch_assoc())
     67    while ($DbRow = $DbResult->fetch_assoc())
    6868    {
    6969      echo('Port '.$DbRow['Number'].' online but time not updated.'."\n");
     
    7171    $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 0) AND '.
    7272      '(`LastOnline` >= "'.TimeToMysqlDateTime($StartTime).'")');
    73     while($DbRow = $DbResult->fetch_assoc())
     73    while ($DbRow = $DbResult->fetch_assoc())
    7474    {
    7575      echo('Port '.$DbRow['Number'].' not online but time updated.'."\n");
  • trunk/Modules/NetworkConfigLinux/Generators/DHCP.php

    r790 r873  
    11<?php
    22
    3 if(isset($_SERVER['REMOTE_ADDR'])) die();
     3if (isset($_SERVER['REMOTE_ADDR'])) die();
    44/*
    55include_once('../../global.php');
     
    2323'option netbios-scope "";'."\n".
    2424"server-identifier 192.168.0.1;\n\n");
    25 for($i = 0; $i <= $MaxSubnet; $i++)
     25for ($i = 0; $i <= $MaxSubnet; $i++)
    2626{
    2727  fputs($File, "subnet 192.168.".$i.".0 netmask 255.255.255.0 {\n".
     
    3030  "  option routers 192.168.".$i.".1;\n");
    3131  $DbResult = $Database->select('hosts', '*', "IP LIKE '192.168.".$i."%' ORDER BY IP");
    32   while($Row = $DbResult->fetch_array())
     32  while ($Row = $DbResult->fetch_array())
    3333  {
    3434    $Data = $Row['name'];
    35     if(strlen($Data) < 9) $Data .= "\t";
     35    if (strlen($Data) < 9) $Data .= "\t";
    3636    fputs($File, "  host ".$Data."\t{ fixed-address ".$Row['IP'].";\thardware ethernet ".$Row['MAC']."; }\n");
    3737  }
  • trunk/Modules/NetworkConfigLinux/Generators/DNS.php

    r854 r873  
    1818        "\t\t\t".$DNS['Minimum']."\t; minimum\n".
    1919        "\t\t\t)\n";
    20     foreach($DNS['NameServer'] as $NameServer)
     20    foreach ($DNS['NameServer'] as $NameServer)
    2121    {
    2222      $Output .= "\t\tIN\tNS\t".strtolower($NameServer).".\n";
     
    2626    // Mail server records
    2727    $Priority = 10;
    28     foreach($DNS['MailServer'] as $MailServer)
     28    foreach ($DNS['MailServer'] as $MailServer)
    2929    {
    3030      $Output .="\t\t\tMX\t".$Priority." ".strtolower($MailServer).".\n";
     
    3434        $DNS['Domain'].".\tIN\tTXT\t\"v=spf1 mx -all\"\n".
    3535        $DNS['Domain'].".\tIN\tSPF\t\"v=spf1 mx -all\"\n";
    36     foreach($DNS['MailServer'] as $MailServer)
     36    foreach ($DNS['MailServer'] as $MailServer)
    3737    {
    3838      $Output .= $MailServer.".\tIN\tTXT\t\"v=spf1 a -all\"\n".
     
    4545
    4646    // IPv4 host list
    47     foreach($DNS['Host'] as $Host)
    48     {
    49       if(strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
     47    foreach ($DNS['Host'] as $Host)
     48    {
     49      if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
    5050      $Output .= strtolower($Host['Name'])."\tIN\tA\t".$Host['Address']."\n";
    5151    }
    5252
    5353    // IPv6 host list
    54     foreach($DNS['Host'] as $Host)
    55     {
    56       if(strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
    57       if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
     54    foreach ($DNS['Host'] as $Host)
     55    {
     56      if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
     57      if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
    5858        $Output .= strtolower($Host['Name'])."\tIN\tAAAA\t".$Host['IPv6']."\n";
    5959    }
    6060
    6161    // Alias list
    62     foreach($DNS['Alias'] as $Alias)
    63     {
    64       if(strlen($Alias['Name']) < 8) $Alias['Name'] .= "\t";
     62    foreach ($DNS['Alias'] as $Alias)
     63    {
     64      if (strlen($Alias['Name']) < 8) $Alias['Name'] .= "\t";
    6565      $Output .= strtolower($Alias['Name'])."\tIN\tCNAME\t".strtolower($Alias['Target'])."\n";
    6666    }
     
    7171
    7272    // Generate reverse DNS records
    73     foreach($DNS['Network'] as $Network)
     73    foreach ($DNS['Network'] as $Network)
    7474    {
    7575      $Parts = explode('.', $Network);
     
    8383      "\t\t\t\t".$DNS['Minimum']."\t; minimum\n".
    8484      "\t\t\t\t)\n";
    85       foreach($DNS['ReverseNameServer'] as $NameServer)
     85      foreach ($DNS['ReverseNameServer'] as $NameServer)
    8686      {
    87         if(substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
     87        if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
    8888          $Output .= "@\tIN\tNS\t".$NameServer.".\n";
    8989        else $Output .= "\tIN\tNS\t".$NameServer.".\n";
    9090      }
    91       foreach($DNS['Host'] as $Host)
    92         if(substr($Host['Address'], 0, strlen($Network)) == $Network)
     91      foreach ($DNS['Host'] as $Host)
     92        if (substr($Host['Address'], 0, strlen($Network)) == $Network)
    9393        {
    9494          $AddressParts = explode('.', $Host['Address']);
     
    103103
    104104    // Generate reverse DNS IPv6 records
    105     foreach($DNS['IPv6Network'] as $Network)
     105    foreach ($DNS['IPv6Network'] as $Network)
    106106    {
    107107      $Parts = explode('/', $Network);
     
    117117      "\t\t\t\t".$DNS['Minimum']."\t; minimum\n".
    118118      "\t\t\t\t)\n";
    119       foreach($DNS['ReverseNameServer'] as $NameServer)
     119      foreach ($DNS['ReverseNameServer'] as $NameServer)
    120120      {
    121         if(substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
     121        if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
    122122          $Output .= "@\tIN\tNS\t".$NameServer.".\n";
    123123        else $Output .= "\tIN\tNS\t".$NameServer.".\n";
    124124      }
    125       foreach($DNS['Host'] as $Host)
    126         if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
     125      foreach ($DNS['Host'] as $Host)
     126        if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
    127127        {
    128128          $Addr = new NetworkAddressIPv6();
     
    161161    $BaseDir = '/var/cache/bind';
    162162    //$BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named';
    163     if(!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.');
     163    if (!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.');
    164164    $MailServer = 'centrala';
    165165
     
    193193      'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
    194194      'WHERE (`NetworkInterface`.`LocalIP` <> "") AND (`NetworkDevice`.`Used` = 1)');
    195     while($Interface = $DbResult->fetch_assoc())
    196     {
    197       $Name = $Interface['DeviceName'];
    198       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     195    while ($Interface = $DbResult->fetch_assoc())
     196    {
     197      $Name = $Interface['DeviceName'];
     198      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    199199      $LocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP'],
    200200          'IPv6' => $Interface['IPv6']);
     
    205205        'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
    206206        'WHERE (`NetworkInterface`.`ExternalIP` <> "") AND (`NetworkDevice`.`Used` = 1)');
    207     while($Interface = $DbResult->fetch_assoc())
    208     {
    209       $Name = $Interface['DeviceName'];
    210       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     207    while ($Interface = $DbResult->fetch_assoc())
     208    {
     209      $Name = $Interface['DeviceName'];
     210      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    211211      $LocalDNS['Host'][] = array('Name' => $Name.'-ext', 'Address' => $Interface['ExternalIP']);
    212212    }
     
    216216     $DbResult = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface '.
    217217     'JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.CZFreeIP <> ""');
    218      while($Interface = $DbResult->fetch_assoc())
     218     while ($Interface = $DbResult->fetch_assoc())
    219219     {
    220220     $Name = $Interface['DeviceName'];
    221      if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     221     if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    222222     $LocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['CZFreeIP']);
    223223     }
     
    226226    // Domain aliases
    227227    $DbResult = $this->Database->select('NetworkDomainAlias', '*');
    228     while($Alias = $DbResult->fetch_assoc())
     228    while ($Alias = $DbResult->fetch_assoc())
    229229    {
    230230      $LocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
     
    257257        'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE '.
    258258        '(`NetworkInterface`.`ExternalIP` != "") AND (`NetworkDevice`.`Used` = 1)');
    259     while($Interface = $DbResult->fetch_assoc())
    260     {
    261       $Name = $Interface['DeviceName'];
    262       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     259    while ($Interface = $DbResult->fetch_assoc())
     260    {
     261      $Name = $Interface['DeviceName'];
     262      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    263263      $ExternalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['ExternalIP'],
    264264          'IPv6' => $Interface['IPv6']);
     
    268268    $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`');
    269269    // JOIN `NetworkDevice` ON NetworkDomainAlias.Target LIKE NetworkDevice.Name AND NetworkInterface.ExternalIP != ""');
    270     while($Alias = $DbResult->fetch_assoc())
     270    while ($Alias = $DbResult->fetch_assoc())
    271271    {
    272272      $ExternalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
     
    302302        'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
    303303        'WHERE (`NetworkInterface`.`LocalIP` != "") AND (`NetworkDevice`.`Used` = 1)');
    304     while($Interface = $DbResult->fetch_assoc())
    305     {
    306       $Name = $Interface['DeviceName'];
    307       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     304    while ($Interface = $DbResult->fetch_assoc())
     305    {
     306      $Name = $Interface['DeviceName'];
     307      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    308308      $CZFreeDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']);
    309309    }
     
    312312    $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`');
    313313    // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""');
    314     while($Alias = $DbResult->fetch_assoc())
     314    while ($Alias = $DbResult->fetch_assoc())
    315315    {
    316316      $CZFreeDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
     
    344344    $DbResult = $this->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface` '.
    345345        'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE `NetworkInterface`.`LocalIP` != ""');
    346     while($Interface = $DbResult->fetch_assoc())
    347     {
    348       $Name = $Interface['DeviceName'];
    349       if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     346    while ($Interface = $DbResult->fetch_assoc())
     347    {
     348      $Name = $Interface['DeviceName'];
     349      if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    350350      //  $CZFreeLocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['LocalIP']);
    351351      $CZFreeLocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']);
     
    355355    $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`');
    356356    // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""');
    357     while($Alias = $DbResult->fetch_assoc())
     357    while ($Alias = $DbResult->fetch_assoc())
    358358    {
    359359      $CZFreeLocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']);
  • trunk/Modules/NetworkConfigLinux/Generators/IPTables.php

    r790 r873  
    11<?php
    2 if(isset($_SERVER['REMOTE_ADDR'])) die();
     2if (isset($_SERVER['REMOTE_ADDR'])) die();
    33include_once('../../../Common/Global.php');
    44
     
    1414// Blocking according IP address
    1515$DbResult = $Database->select('users', '*', 'inet = 0');
    16 while($User = $DbResult->fetch_array())
     16while ($User = $DbResult->fetch_array())
    1717{
    1818  $DbResult2 = $Database->select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']);
    19   while($Row = $DbResult2->fetch_array())
     19  while ($Row = $DbResult2->fetch_array())
    2020  {
    2121    exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local');
     
    2323}
    2424$DbResult = $Database->select('users', '*', 'inet = 1');
    25 while($User = $DbResult->fetch_array())
     25while ($User = $DbResult->fetch_array())
    2626{
    2727  $DbResult2 = $Database->select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']);
    28   while($Row = $DbResult2->fetch_array())
     28  while ($Row = $DbResult2->fetch_array())
    2929  {
    3030    exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local');
     
    3636// Blocking according MAC address
    3737$DbResult = $Database->select('users', '*');
    38 while($User = $DbResult->fetch_array())
     38while ($User = $DbResult->fetch_array())
    3939{
    4040  //echo($User['fullname']."\n");
    4141  $DbResult2 = $Database->select('hosts', '*', '(block < 2) AND (MAC != "") AND (user='.$User['id'].') AND (IP != external_ip) ORDER BY id DESC');
    42   while($Row = $DbResult2->fetch_array())
     42  while ($Row = $DbResult2->fetch_array())
    4343  {
    4444    //echo(' '.$Row['name']." ".$Row['MAC']." ");
    45     if($User['inet'] == 0)
     45    if ($User['inet'] == 0)
    4646    {
    47       //if(($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     47      //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    4848      //    else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
    4949    } else {
    50       if($Row['vpn'] == 0)
     50      if ($Row['vpn'] == 0)
    5151      {
    5252  $CZFreeLocalIP = $Row['IP'];
    5353        //echo($Row['external_ip']."\n");
    54   //if($Row['name'] == 'TBC')
     54  //if ($Row['name'] == 'TBC')
    5555  //{
    5656        //  exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725');
    5757        //  exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip'].':3724');
    5858  //}
    59         if(strtolower($Row['name']) != 'gate')
     59        if (strtolower($Row['name']) != 'gate')
    6060  {
    61       if($Row['external_ip'] != '')
     61      if ($Row['external_ip'] != '')
    6262          {
    6363            echo($Row['name'].'='.$Row['external_ip']."\n");
     
    7575 //echo('vpn');
    7676        //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP');
    77         if($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');
     77        if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');
    7878        exec('/sbin/iptables -t nat -A Block -s '.ToVpnIp($Row)." -j Proxy");
    7979
    80         //if($Row['vpn'] == 1)
     80        //if ($Row['vpn'] == 1)
    8181  //{
    8282    //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
    83         //} else if($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     83        //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    8484      }
    85       if($Row['czfree_ip'] != '')
     85      if ($Row['czfree_ip'] != '')
    8686      {
    8787        // CZFree
  • trunk/Modules/NetworkConfigLinux/Generators/Latency.php

    r852 r873  
    1414      'FROM `NetworkInterface` '.
    1515      'WHERE (`NetworkInterface`.`Enabled`=1) AND (`NetworkInterface`.`LocalIP` !="")');
    16     while($DbRow = $DbResult->fetch_assoc())
     16    while ($DbRow = $DbResult->fetch_assoc())
    1717    {
    1818      $Hosts[] = $DbRow['LocalIP'];
     
    2323
    2424    $Queries = array();
    25     foreach($Output as $Index => $Line)
     25    foreach ($Output as $Index => $Line)
    2626    {
    2727      $IP = substr($Line, 0, strPos($Line, ' '));
  • trunk/Modules/NetworkConfigLinux/Generators/NAT.php

    r790 r873  
    11<?php
    2 if(isset($_SERVER['REMOTE_ADDR'])) die();
     2if (isset($_SERVER['REMOTE_ADDR'])) die();
    33include_once('../../../Common/Global.php');
    44
     
    1414// Blocking according IP address
    1515$DbResult = $Database->select('users', '*', 'inet = 0');
    16 while($User = $DbResult->fetch_array())
     16while ($User = $DbResult->fetch_array())
    1717{
    1818  $DbResult2 = $Database->select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']);
    19   while($Row = $DbResult2->fetch_array())
     19  while ($Row = $DbResult2->fetch_array())
    2020  {
    2121    exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local');
     
    2323}
    2424$DbResult = $Database->select('users', '*', 'inet = 1');
    25 while($User = $DbResult->fetch_array())
     25while ($User = $DbResult->fetch_array())
    2626{
    2727  $DbResult2 = $Database->select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']);
    28   while($Row = $DbResult2->fetch_array())
     28  while ($Row = $DbResult2->fetch_array())
    2929  {
    3030    exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local');
     
    3636// Blocking according MAC address
    3737$DbResult = $Database->select('users', '*');
    38 while($User = $DbResult->fetch_array())
     38while ($User = $DbResult->fetch_array())
    3939{
    4040  //echo($User['fullname']."\n");
    4141  $DbResult2 = $Database->select('hosts','*','block<2 AND MAC!="" AND user='.$User['id'].' ORDER BY id DESC');
    42   while($Row = $DbResult2->fetch_array())
     42  while ($Row = $DbResult2->fetch_array())
    4343  {
    4444    //echo(' '.$Row['name']." ".$Row['MAC']." ");
    45     if($User['inet'] == 0)
     45    if ($User['inet'] == 0)
    4646    {
    47       //if(($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     47      //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    4848      //    else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
    4949    } else {
    50       if($Row['vpn'] == 0)
     50      if ($Row['vpn'] == 0)
    5151      {
    5252  $CZFreeLocalIP = $Row['IP'];
    5353        //echo($Row['external_ip']."\n");
    54   //if($Row['name'] == 'TBC')
     54  //if ($Row['name'] == 'TBC')
    5555  //{
    5656        //  exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725');
    5757        //  exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o eth1 -j SNAT --to-source '.$Row['external_ip'].':3724');
    5858  //}
    59         if(strtolower($Row['name']) != 'centrala')
     59        if (strtolower($Row['name']) != 'centrala')
    6060  {
    61       if($Row['external_ip'] != '')
     61      if ($Row['external_ip'] != '')
    6262          {
    6363            echo($Row['name'].'='.$Row['external_ip']."\n");
     
    7575 //echo('vpn');
    7676        //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP');
    77         if($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');
     77        if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');
    7878        exec('/sbin/iptables -t nat -A Block -s '.ToVpnIp($Row)." -j Proxy");
    7979
    80         //if($Row['vpn'] == 1)
     80        //if ($Row['vpn'] == 1)
    8181  //{
    8282    //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
    83         //} else if($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     83        //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    8484      }
    85       if($Row['czfree_ip'] != '')
     85      if ($Row['czfree_ip'] != '')
    8686      {
    8787        // CZFree
  • trunk/Modules/NetworkConfigLinux/Generators/TrafficShaping.php

    r790 r873  
    11<?php
    22
    3 if(isset($_SERVER['REMOTE_ADDR'])) die();
     3if (isset($_SERVER['REMOTE_ADDR'])) die();
    44
    55$Enabled = 1;
     
    3737  exec('/sbin/iptables -t mangle -F PREROUTING');
    3838  exec('/sbin/iptables -t mangle -F POSTROUTING');
    39   if($Enabled)
     39  if ($Enabled)
    4040  {
    4141    //exec('/sbin/iptables -t mangle -A FORWARD -j MARK --set-mark 0');
     
    4848  // In going traffic
    4949  fputs($File, "/sbin/tc qdisc del dev ".$InInterface." root\n");
    50   if($Enabled)
     50  if ($Enabled)
    5151  {
    5252    fputs($File, "/sbin/tc qdisc add dev ".$InInterface." root handle 1:0 htb default 2\n");
     
    5959  // Out going traffic
    6060  fputs($File, "/sbin/tc qdisc del dev ".$OutInterface." root\n");
    61   if($Enabled)
     61  if ($Enabled)
    6262  {
    6363    fputs($File, "/sbin/tc qdisc add dev ".$OutInterface." root handle 1:0 htb default 2\n");
     
    6969  }
    7070
    71   if(!$Enabled) die("Traffic shaping disabled\n");
    72 
    73   if($ClassesEnabled)
     71  if (!$Enabled) die("Traffic shaping disabled\n");
     72
     73  if ($ClassesEnabled)
    7474  {
    7575  $ClassId = 3;
     
    124124
    125125  $DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)');
    126   while($User = $DbResult->fetch_array())
     126  while ($User = $DbResult->fetch_array())
    127127  {
    128128    $UserClassId = $ClassId;
     
    152152
    153153    $DbResult2 = $Database->select('hosts','*',"block=0 AND MAC!='' AND user=".$User['id']);
    154     while($Host = $DbResult2->fetch_array())
    155     //if($Row['name'] != 'WOW')
     154    while ($Host = $DbResult2->fetch_array())
     155    //if ($Row['name'] != 'WOW')
    156156    {
    157157      $HostClassId = $ClassId;
     
    160160      fputs($FileClassInfo, '1:'.$HostClassId.' '.$Host['name']."\n");
    161161      //echo('  Host class id: '.$HostClassId."\n");
    162     //if($User['inet'] == 1)
     162    //if ($User['inet'] == 1)
    163163      {
    164164        $Prio = 1;
    165         if($Host['vpn'] == 1)
     165        if ($Host['vpn'] == 1)
    166166        {
    167           if($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip'];
     167          if ($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip'];
    168168          else $Host['IP'] = ToVpnIp($Host);
    169169        }
    170170
    171         //if($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5;
     171        //if ($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5;
    172172          //else
    173173        $SpeedDivider = 1;
    174174
    175         if($Host['name'] == 'centrala')
     175        if ($Host['name'] == 'centrala')
    176176        {
    177177          $Host['IP'] = $Host['external_ip'];
     
    183183           $TableIn = 'FORWARD';
    184184         }
    185         //if($Row['name'] == 'TERMINAL2') $Prio = 0;
    186         //  if($Row['name'] = 'TERMINAL2') $Prio = 0;
    187         if($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp';
     185        //if ($Row['name'] == 'TERMINAL2') $Prio = 0;
     186        //  if ($Row['name'] = 'TERMINAL2') $Prio = 0;
     187        if ($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp';
    188188        else $Protocol = '';
    189         //  if($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000;
     189        //  if ($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000;
    190190        /*
    191 if($Host['name'] == 'GAME')
     191if ($Host['name'] == 'GAME')
    192192        {
    193193          exec('/sbin/iptables -t mangle -F game-server');
     
    195195          $TableIn = 'game-server';
    196196        }*/
    197         //if($Host['name'] == 'TBC') continue;
     197        //if ($Host['name'] == 'TBC') continue;
    198198
    199199        // In going traffic
     
    213213      }
    214214      // Free inet
    215       if($Tarify[$User['inet_tarif_now']]['group_id'] == 3)
     215      if ($Tarify[$User['inet_tarif_now']]['group_id'] == 3)
    216216      {
    217217        //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$FreeInetClass);
     
    220220      // VoIP devices
    221221/*
    222       if(($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP'))
     222      if (($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP'))
    223223      {
    224224        exec('/sbin/iptables -t mangle -A '.$TableIn." -i eth1 -d ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId);
    225225        exec('/sbin/iptables -t mangle -A '.$TableOut." -o eth1 -s ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId);
    226226      } else
    227       if($Host['name'] == 'GAME')
     227      if ($Host['name'] == 'GAME')
    228228      {
    229229        exec('/sbin/iptables -t mangle -A FORWARD -o eth1 -s '.$Host['IP']." -j game-server");
  • trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php

    r738 r873  
    11<?php
    22
    3 if(isset($_SERVER['REMOTE_ADDR'])) die();
     3if (isset($_SERVER['REMOTE_ADDR'])) die();
    44include_once(dirname(__FILE__).'/../../../Common/Global.php');
    55include_once(dirname(__FILE__).'/../Routerboard.php');
     
    1111{
    1212  $TimeParts = explode(':', $Time);
    13   return($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]);
     13  return ($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]);
    1414}
    1515
     
    1919
    2020$DbResult3 = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`');
    21 while($Subnet = $DbResult3->fetch_assoc())
     21while ($Subnet = $DbResult3->fetch_assoc())
    2222{
    2323  echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");
    2424  $Routerboard->HostName = $Subnet['DHCP'];
    2525  $List = $Routerboard->ListGet($Path, array('address', 'active-mac-address', 'active-address', 'expires-after', 'server', 'dynamic'));
    26   foreach($List as $Properties)
     26  foreach ($List as $Properties)
    2727  {
    28     if($Properties['dynamic'] == 'true')
     28    if ($Properties['dynamic'] == 'true')
    2929    //and ($Properties['address'] != $Properties['active-address']))
    3030    {
     
    3232      echo('MAC: '.$Properties['active-mac-address']."\n");
    3333      $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"');
    34       if($DbRows2->num_rows > 0)
     34      if ($DbRows2->num_rows > 0)
    3535      {
    3636        $Interface = $DbRows2->fetch_assoc();
    3737        $InterfaceId = $Interface['Id'];
    3838        $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId);
    39         if($DbRows2->num_rows > 0)
     39        if ($DbRows2->num_rows > 0)
    4040        {
    4141          $System->Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1));
     
    5353$NATRule = array();
    5454$DbRows = $System->Database->query('SELECT NetworkDevice.Name AS DeviceName, NetworkInterface.Name AS InterfaceName, DynamicIP FROM `NetworkInterfacePortable` JOIN NetworkInterface ON NetworkInterface.Id=NetworkInterfacePortable.NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE `Update`=1');
    55 while($Portable = $DbRows->fetch_assoc())
     55while ($Portable = $DbRows->fetch_assoc())
    5656{
    5757  $Name = $Portable['DeviceName'];
    58   if($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName'];
     58  if ($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName'];
    5959  array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-in"] to-addresses='.$Portable['DynamicIP']);
    6060  array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-out"] src-address='.$Portable['DynamicIP']);
  • trunk/Modules/NetworkConfigRouterOS/Generators/Common.php

    r870 r873  
    66
    77  $DbResult = $Database->query('SELECT `Id` FROM `NetworkMark` WHERE `Comment`="'.$Comment.'"');
    8   if($DbResult->num_rows > 0)
     8  if ($DbResult->num_rows > 0)
    99  {
    1010    $DbRow = $DbResult->fetch_assoc();
    11     return($DbRow['Id']);
     11    return ($DbRow['Id']);
    1212  } else
    1313  {
    1414    $DbResult = $Database->query('INSERT INTO `NetworkMark` (`Comment`) VALUES ("'.$Comment.'")');
    15     return($Database->insert_id);
     15    return ($Database->insert_id);
    1616  }
    1717}
     
    2222
    2323  $DbResult = $Database->query('SELECT `Id` FROM `NetworkMangleSubgroup` WHERE `AddressRange`="'.$AddressRange.'"');
    24   if($DbResult->num_rows > 0)
     24  if ($DbResult->num_rows > 0)
    2525  {
    2626    $DbRow = $DbResult->fetch_assoc();
    27     return($DbRow['Id']);
     27    return ($DbRow['Id']);
    2828  } else
    2929  {
    3030    $DbResult = $Database->query('INSERT INTO `NetworkMangleSubgroup` (`AddressRange`) VALUES ("'.$AddressRange.'")');
    31     return($Database->insert_id);
     31    return ($Database->insert_id);
    3232  }
    3333}
     
    3838
    3939  $Found = false;
    40   foreach($Tree['Items'] as $Index => $Node)
     40  foreach ($Tree['Items'] as $Index => $Node)
    4141  {
    42     if($Node['Address']->Contain($Address))
     42    if ($Node['Address']->Contain($Address))
    4343    {
    4444      InsertToAddressTreeIPv4($Tree['Items'][$Index], $Address, $Name, true);
     
    4646    }
    4747  }
    48   if($Found == false)
     48  if ($Found == false)
    4949  {
    50     if($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and
     50    if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and
    5151    ($Address->Prefix > ($Tree['Address']->Prefix + 1)))
    5252    {
     
    6262      // Should be existed items placed under new node?
    6363      $Found = false;
    64       foreach($Tree['Items'] as $Index => $Node)
     64      foreach ($Tree['Items'] as $Index => $Node)
    6565      {
    66         if(($Node['Address']->Address == $NewNode['Address']->Address) and
     66        if (($Node['Address']->Address == $NewNode['Address']->Address) and
    6767        ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true;
    6868
    69         if($Address->Contain($Node['Address']))
     69        if ($Address->Contain($Node['Address']))
    7070        {
    7171          $NewNode['Items'][] = $Node;
     
    7373        }
    7474      }
    75       if($Found == false) $Tree['Items'][] = $NewNode;
     75      if ($Found == false) $Tree['Items'][] = $NewNode;
    7676    }
    7777  }
     
    8383
    8484  $Found = false;
    85   foreach($Tree['Items'] as $Index => $Node)
     85  foreach ($Tree['Items'] as $Index => $Node)
    8686  {
    87     if($Node['Address']->Contain($Address))
     87    if ($Node['Address']->Contain($Address))
    8888    {
    8989      InsertToAddressTreeIPv6($Tree['Items'][$Index], $Address, $Name, true);
     
    9191    }
    9292  }
    93   if($Found == false)
     93  if ($Found == false)
    9494  {
    95     if($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and
     95    if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and
    9696    ($Address->Prefix > ($Tree['Address']->Prefix + 1)))
    9797    {
     
    107107      // Should be existed items placed under new node?
    108108      $Found = false;
    109       foreach($Tree['Items'] as $Index => $Node)
     109      foreach ($Tree['Items'] as $Index => $Node)
    110110      {
    111         if(($Node['Address']->Address == $NewNode['Address']->Address) and
     111        if (($Node['Address']->Address == $NewNode['Address']->Address) and
    112112        ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true;
    113113
    114         if($Address->Contain($Node['Address']))
     114        if ($Address->Contain($Node['Address']))
    115115        {
    116116          $NewNode['Items'][] = $Node;
     
    118118        }
    119119      }
    120       if($Found == false) $Tree['Items'][] = $NewNode;
     120      if ($Found == false) $Tree['Items'][] = $NewNode;
    121121    }
    122122  }
     
    126126{
    127127  echo(str_repeat('  ', $Indent).$Node['Address']->AddressToString().'/'.$Node['Address']->Prefix.' '.$Node['Name']."\n");
    128   foreach($Node['Items'] as $Index => $Item)
     128  foreach ($Node['Items'] as $Index => $Item)
    129129  {
    130130    ShowSubnetNode($Item, $Indent + 1);
  • trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php

    r861 r873  
    1414
    1515    $DbResult = $this->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1');
    16     while($Subnet = $DbResult->fetch_assoc())
     16    while ($Subnet = $DbResult->fetch_assoc())
    1717    {
    1818      echo($Subnet['DHCP']);
     
    2424        'WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') '.
    2525        'AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`');
    26       while($Interface = $DbResult2->fetch_assoc())
     26      while ($Interface = $DbResult2->fetch_assoc())
    2727      {
    2828        $Name = $Interface['DeviceName'];
    29         if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     29        if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    3030        $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => $Server, 'comment' => $Name, 'lease-time' => '1d');
    3131      }
  • trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php

    r781 r873  
    1313
    1414    $DbResult = $this->Database->query('SELECT * FROM `NetworkDomain`');
    15     while($Domain = $DbResult->fetch_assoc())
     15    while ($Domain = $DbResult->fetch_assoc())
    1616    {
    1717      $DomainName = $Domain['Name'];
     
    1919      // Get full domain name from parent items
    2020      $CurrentDomain = $Domain;
    21       while($CurrentDomain['Parent'] > 0)
     21      while ($CurrentDomain['Parent'] > 0)
    2222      {
    2323        $DbResult2 = $this->Database->query('SELECT * FROM `NetworkDomain` WHERE `Id`='.$CurrentDomain['Parent']);
     
    3232          'JOIN `NetworkDevice` ON `NetworkInterface`.`Device`=`NetworkDevice`.`Id` '.
    3333          'WHERE (`NetworkDevice`.`Used`=1)');
    34       while($Interface = $DbResult2->fetch_assoc())
     34      while ($Interface = $DbResult2->fetch_assoc())
    3535      {
    3636        $Name = $Interface['DeviceName'];
    37         if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     37        if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    3838        $NameFull = $Name.'.'.$DomainName;
    3939        $NameExtFull = $Name.'-ext.'.$DomainName;
    40         if($Interface['LocalIP'] != '')
     40        if ($Interface['LocalIP'] != '')
    4141          $Items[] = array('name' => $NameFull, 'address' => $Interface['LocalIP']);
    42         if($Interface['IPv6'] != '')
     42        if ($Interface['IPv6'] != '')
    4343          $Items[] = array('name' => $NameFull, 'address' => $Interface['IPv6']);
    44         if($Interface['ExternalIP'] != '')
     44        if ($Interface['ExternalIP'] != '')
    4545          $Items[] = array('name' => $NameExtFull, 'address' => $Interface['ExternalIP']);
    4646      }
     
    5353          'WHERE (`NetworkDevice`.`Used`=1) AND '.
    5454          '(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) = `NetworkDomainAlias`.`Target`)');
    55       while($Alias = $DbResult2->fetch_assoc())
     55      while ($Alias = $DbResult2->fetch_assoc())
    5656      {
    5757        $Name = $Alias['Name'];
    5858        $NameFull = $Name.'.'.$DomainName;
    5959        $NameExtFull = $Name.'-ext.'.$DomainName;
    60         if($Alias['LocalIP'] != '')
     60        if ($Alias['LocalIP'] != '')
    6161          $Items[] = array('name' => $NameFull, 'address' => $Alias['LocalIP']);
    62         if($Alias['IPv6'] != '')
     62        if ($Alias['IPv6'] != '')
    6363          $Items[] = array('name' => $NameFull, 'address' => $Alias['IPv6']);
    64         if($Alias['ExternalIP'] != '')
     64        if ($Alias['ExternalIP'] != '')
    6565          $Items[] = array('name' => $NameExtFull, 'address' => $Alias['ExternalIP']);
    6666      }
    6767
    6868      $DbResult2 = $this->Database->query('SELECT * FROM `NetworkDomainServer` WHERE `Domain`='.$Domain['Id']);
    69       while($Server = $DbResult2->fetch_assoc())
     69      while ($Server = $DbResult2->fetch_assoc())
    7070      {
    7171        $Routerboard->HostName = $Server['Address'];
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php

    r831 r873  
    4242    // Insert blocked addresses
    4343    $DbResult = $this->Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id WHERE Member.Blocked=1');
    44     while($Member = $DbResult->fetch_assoc())
     44    while ($Member = $DbResult->fetch_assoc())
    4545    {
    4646      echo($Member['Name'].': ');
    4747      // Hosts
    4848      $DbResult2 = $this->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC');
    49       while($Interface = $DbResult2->fetch_assoc())
     49      while ($Interface = $DbResult2->fetch_assoc())
    5050      {
    5151        $Name = $Interface['DeviceName'];
    52         if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     52        if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    5353        $Name = RouterOSIdent($Name);
    5454        echo($Name.'('.$Interface['LocalIP'].'), ');
     
    5959      // Subnets
    6060      $DbResult2 = $this->Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']);
    61       while($Subnet = $DbResult2->fetch_assoc())
     61      while ($Subnet = $DbResult2->fetch_assoc())
    6262      {
    6363        $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);
     
    6767        $NewAddress->Prefix = $Subnet['ExtMask'];
    6868        $Range = $NewAddress->GetRange();
    69         if($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
     69        if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
    7070        else $Range = $Range['From']->AddressToString();
    71         if($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
     71        if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
    7272        else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask'];
    7373        $Items[] = array('chain' => 'forward', 'out-interface' => $InetInterface, 'src-address' => $Src, 'action' => 'drop','comment' => $Subnet['Name'].'-out-drop');
     
    7777        $NewAddress->Prefix = $Subnet['Mask'];
    7878        $Range = $NewAddress->GetRange();
    79         if($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
     79        if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
    8080        else $Range = $Range['From']->AddressToString();
    81         if($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];
     81        if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];
    8282        else $Dest = $Subnet['ExtAddressRange'].'/'.$Subnet['ExtMask'];
    8383        $Items[] = array('chain' => 'forward', 'in-interface' => $InetInterface, 'dst-address' => $Dest, 'action' => 'drop', 'comment' => $Subnet['Name'].'-in-drop');
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php

    r870 r873  
    77    global $InetInterface, $ItemsFirewall;
    88
    9     foreach($Node['Items'] as $Index => $Item)
    10     {
    11       if(count($Item['Items']) == 0)
     9    foreach ($Node['Items'] as $Index => $Item)
     10    {
     11      if (count($Item['Items']) == 0)
    1212      {
    1313        // Hosts
    1414        $ParentSubnetId = GetSubgroupByRange($Node['Address']->AddressToString().'/'.$Node['Address']->Prefix);
    1515        $Address = $Item['Address']->AddressToString();
    16         if($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;
     16        if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;
    1717
    1818        $PacketMark = GetMarkByComment($Item['Name'].'-out');
     
    2828
    2929        $Address = $Item['Address']->AddressToString();
    30         if($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;
     30        if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;
    3131
    3232        $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-out', 'src-address' => $Address, 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-out', 'comment' => $Item['Name'].'-out');
     
    3636      }
    3737    }
    38     if($Node['ForceMark'] == true)
     38    if ($Node['ForceMark'] == true)
    3939    {
    4040      // Mark member subnets
     
    7272    // Divide rules by subnet number
    7373    $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE `Member` IS NULL');
    74     while($Subnet = $DbResult->fetch_assoc())
     74    while ($Subnet = $DbResult->fetch_assoc())
    7575    {
    7676      $NewAddress = new NetworkAddressIPv4();
     
    8484        'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '.
    8585        'WHERE `Member`.`Blocked` = 0');
    86     while($Member = $DbResult->fetch_assoc())
     86    while ($Member = $DbResult->fetch_assoc())
    8787    {
    8888      $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] );
     
    9090
    9191      $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']);
    92       while($Device = $DbResult2->fetch_assoc())
     92      while ($Device = $DbResult2->fetch_assoc())
    9393      {
    9494        $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');
    95         while($Interface = $DbResult3->fetch_assoc())
     95        while ($Interface = $DbResult3->fetch_assoc())
    9696        {
    9797          $Name = $Device['Name'];
    98           if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     98          if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    9999          $Name = RouterOSIdent($Name);
    100100          echo($Name.', ');
     
    107107
    108108      $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRange != "")');
    109       while($Subnet = $DbResult2->fetch_assoc())
     109      while ($Subnet = $DbResult2->fetch_assoc())
    110110      {
    111111        $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);
     
    114114        $NewAddress->AddressFromString($Subnet['AddressRange']);
    115115        $NewAddress->Prefix = $Subnet['Mask'];
    116         if($Subnet['Member'] != 0) $ForceMark = true;
     116        if ($Subnet['Member'] != 0) $ForceMark = true;
    117117        else $ForceMark = false;
    118118        echo($ForceMark.', ');
     
    169169    $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRangeIPv6`, `MaskIPv6` FROM `NetworkSubnet` '.
    170170      'WHERE (`Member` IS NULL) AND (`AddressRangeIPv6` != "")');
    171     while($Subnet = $DbResult->fetch_assoc())
     171    while ($Subnet = $DbResult->fetch_assoc())
    172172    {
    173173      $NewAddress = new NetworkAddressIPv6();
     
    181181        'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '.
    182182        'WHERE `Member`.`Blocked` = 0');
    183     while($Member = $DbResult->fetch_assoc())
     183    while ($Member = $DbResult->fetch_assoc())
    184184    {
    185185      $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] );
     
    187187
    188188      $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']);
    189       while($Device = $DbResult2->fetch_assoc())
     189      while ($Device = $DbResult2->fetch_assoc())
    190190      {
    191191        $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `IPv6` != ""');
    192         while($Interface = $DbResult3->fetch_assoc())
     192        while ($Interface = $DbResult3->fetch_assoc())
    193193        {
    194194          $Name = $Device['Name'];
    195           if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     195          if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    196196          $Name = RouterOSIdent($Name);
    197197          echo($Name.', ');
     
    204204
    205205      $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRangeIPv6 != "")');
    206       while($Subnet = $DbResult2->fetch_assoc())
     206      while ($Subnet = $DbResult2->fetch_assoc())
    207207      {
    208208        $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);
     
    211211        $NewAddress->AddressFromString($Subnet['AddressRangeIPv6']);
    212212        $NewAddress->Prefix = $Subnet['MaskIPv6'];
    213         if($Subnet['Member'] != 0) $ForceMark = true;
     213        if ($Subnet['Member'] != 0) $ForceMark = true;
    214214        else $ForceMark = false;
    215215        echo($ForceMark.', ');
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php

    r860 r873  
    3939        'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '.
    4040        'WHERE `Member`.`Blocked` = 0');
    41     while($Member = $DbResult->fetch_assoc())
     41    while ($Member = $DbResult->fetch_assoc())
    4242    {
    4343      echo($Member['Name'].': ');
     
    4747          ' AND (`NetworkInterface`.`LocalIP` <> "")'.
    4848          ' AND (`NetworkDevice`.`Member` = '.$Member['Id'].') AND (`NetworkInterface`.`LocalIP` != `NetworkInterface`.`ExternalIP`) ORDER BY `id` DESC');
    49       while($Interface = $DbResult2->fetch_assoc())
     49      while ($Interface = $DbResult2->fetch_assoc())
    5050      {
    5151        $Name = $Interface['DeviceName'];
    52         if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     52        if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    5353        $Name = RouterOSIdent($Name);
    5454        echo($Name.'('.$Interface['LocalIP'].'), ');
    55         if($Member['Blocked'] == 0)
     55        if ($Member['Blocked'] == 0)
    5656        {
    5757          $Items[] = array('chain' => 'inet-out', 'src-address' => $Interface['LocalIP'], 'action' => 'src-nat',  'to-addresses' => $Interface['ExternalIP'], 'comment' => $Name.'-out');
    58           if($Interface['InboundNATPriority'] > 0)
     58          if ($Interface['InboundNATPriority'] > 0)
    5959            $Items[] = array('chain' => 'inet-in', 'dst-address' => $Interface['ExternalIP'], 'action' => 'dst-nat', 'to-addresses' => $Interface['LocalIP'], 'comment' => $Name.'-in');
    6060        } else
     
    6666      // Subnets
    6767      $DbResult2 = $this->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);
    68       while($Subnet = $DbResult2->fetch_assoc())
     68      while ($Subnet = $DbResult2->fetch_assoc())
    6969      {
    7070        $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);
    7171        echo($Subnet['Name'].'('.$Subnet['AddressRange'].'/'.$Subnet['Mask'].'), ');
    72         if($Member['Blocked'] == 0)
     72        if ($Member['Blocked'] == 0)
    7373        {
    7474          $NewAddress = new NetworkAddressIPv4();
     
    7676          $NewAddress->Prefix = $Subnet['ExtMask'];
    7777          $Range = $NewAddress->GetRange();
    78           if($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
     78          if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
    7979          else $Range = $Range['From']->AddressToString();
    80           if($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
     80          if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
    8181          else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask'];
    8282          $Items[] = array('chain' => 'inet-out', 'src-address' => $Src, 'action' => 'src-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-out');
     
    8686          $NewAddress->Prefix = $Subnet['Mask'];
    8787          $Range = $NewAddress->GetRange();
    88           if($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
     88          if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
    8989          else $Range = $Range['From']->AddressToString();
    90           if($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];
     90          if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];
    9191          else $Dest = $Subnet['ExtAddressRange'].'/'.$Subnet['ExtMask'];
    9292          $Items[] = array('chain' => 'inet-in', 'dst-address' => $Dest, 'action' => 'dst-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-in');
    9393        } else
    9494        {
    95           if($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
     95          if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
    9696          else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask'];
    9797          $Items[] = array('chain' => 'dstnat', 'src-address' => $Src, 'protocol' => 'tcp', 'dst-port' => 80, 'action' => 'dst-nat',  'to-addresses' => $IPCentrala, 'to-ports' => 81, 'comment' => $Subnet['Name'].'-out');
     
    124124     // Route public addresses localy
    125125     $DbResult = $this->Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id');
    126      while($Member = $DbResult->fetch_assoc())
     126     while ($Member = $DbResult->fetch_assoc())
    127127     {
    128128     echo($Member['Name'].': ');
    129129     // Hosts
    130130     $DbResult2 = $this->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC');
    131      while($Interface = $DbResult2->fetch_assoc())
     131     while ($Interface = $DbResult2->fetch_assoc())
    132132     {
    133133     $Name = $Interface['DeviceName'];
    134      if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     134     if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    135135     $Name = RouterOSIdent($Name);
    136136     echo($Name.'('.$Interface['LocalIP'].'), ');
  • trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php

    r835 r873  
    1313
    1414    $DbResult3 = $this->Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet` WHERE `Configure` = 1'); // WHERE `Member` = 0');
    15     while($Router = $DbResult3->fetch_assoc())
     15    while ($Router = $DbResult3->fetch_assoc())
    1616    {
    1717      echo($Router['DHCP']."\n");
     
    1919      $Items = array();
    2020      $DbResult = $this->Database->query('SELECT * FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`DHCP`="'.$Router['DHCP'].'")');
    21       while($Subnet = $DbResult->fetch_assoc())
     21      while ($Subnet = $DbResult->fetch_assoc())
    2222      {
    2323        $I = explode('.', $Subnet['AddressRange']);
     
    2626            ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')'.
    2727            ' AND (`NetworkDevice`.`Used` = 1) ORDER BY `NetworkInterface`.`LocalIP`');
    28         while($Interface = $DbResult2->fetch_assoc())
     28        while ($Interface = $DbResult2->fetch_assoc())
    2929        {
    3030          $Name = $Interface['DeviceName'];
    31           if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     31          if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    3232          echo($Name.', ');
    3333          $Items[] = array('host' => $Interface['LocalIP'], 'interval' => '00:00:10', 'comment' => $Name);
  • trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php

    r863 r873  
    1010    $Interfaces = array();
    1111    $DbResult = $this->Database->select('NetworkInterface', '`Id`, `LocalIP` AS `IP`, `Online`, 0 AS `NewOnline`');
    12     while($DbRow = $DbResult->fetch_assoc())
     12    while ($DbRow = $DbResult->fetch_assoc())
    1313      $Interfaces[$DbRow['IP']] = $DbRow;
    1414
     
    1616    $DbResult3 = $this->Database->query('SELECT `DHCP` FROM `NetworkSubnet` '.
    1717      'WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY `DHCP`');
    18     while($Subnet = $DbResult3->fetch_assoc())
     18    while ($Subnet = $DbResult3->fetch_assoc())
    1919    {
    2020      echo('router '.$Subnet['DHCP']."\n");
     
    2222      $Routerboard->Connect($Subnet['DHCP'], $this->System->Config['API']['UserName'],
    2323        $this->System->Config['API']['Password']);
    24       if(!$Routerboard->Connected) continue;
     24      if (!$Routerboard->Connected) continue;
    2525      $Routerboard->Write('/tool/netwatch/getall', false);
    2626      $Routerboard->Write('=.proplist=host,status');
    2727      $Read = $Routerboard->Read(false);
    2828      $List = $Routerboard->ParseResponse($Read);
    29       foreach($List as $Properties)
     29      foreach ($List as $Properties)
    3030      {
    3131        $IP = $Properties['host'];
    32         if($Properties['status'] == 'up') $Online = 1;
     32        if ($Properties['status'] == 'up') $Online = 1;
    3333          else $Online = 0;
    3434
    35         if($Online)
     35        if ($Online)
    3636        {
    37           if(array_key_exists($IP, $Interfaces))
     37          if (array_key_exists($IP, $Interfaces))
    3838            $Interfaces[$IP]['NewOnline'] = 1;
    3939            else echo('IP '.$IP.' not found.'."\n");
     
    4444    $Queries = array();
    4545    $QueriesInsert = array();
    46     foreach($Interfaces as $Index => $Interface)
     46    foreach ($Interfaces as $Index => $Interface)
    4747    {
    4848      // Update last online time if still online
    49       if($Interface['NewOnline'])
     49      if ($Interface['NewOnline'])
    5050        $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = '.$Interface['Id'],
    5151          array('LastOnline' => TimeToMysqlDateTime($StartTime)));
    5252
    53       if($Interface['Online'] != $Interface['NewOnline'])
     53      if ($Interface['Online'] != $Interface['NewOnline'])
    5454      {
    5555        // Online state changed
     
    7878    $DbResult = $this->Database->select('NetworkInterface', '*', '(`Online` = 1) AND '.
    7979      '(`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'")');
    80     while($DbRow = $DbResult->fetch_assoc())
     80    while ($DbRow = $DbResult->fetch_assoc())
    8181    {
    8282      echo('IP '.$DbRow['LocalIP'].' online but time not updated.'."\n");
     
    8484    $DbResult = $this->Database->select('NetworkInterface', '*', '(`Online` = 0) AND '.
    8585      '(`LastOnline` >= "'.TimeToMysqlDateTime($StartTime).'")');
    86     while($DbRow = $DbResult->fetch_assoc())
     86    while ($DbRow = $DbResult->fetch_assoc())
    8787    {
    8888      echo('IP '.$DbRow['LocalIP'].' not online but time updated.'."\n");
     
    9292    // Update device online state
    9393    $DbResult = $this->Database->select('NetworkInterface', '`Device`, SUM(`Online`) AS `SumOnline`', '`Online` = 1 GROUP BY `Device`');
    94     while($Device = $DbResult->fetch_assoc())
     94    while ($Device = $DbResult->fetch_assoc())
    9595    {
    96       if($Device['SumOnline'] > 0)
     96      if ($Device['SumOnline'] > 0)
    9797        $Queries[] = $this->Database->GetUpdate('NetworkDevice', 'Id='.$Device['Device'], array('LastOnline' => TimeToMysqlDateTime($StartTime), 'Online' => 1));
    9898    }
  • trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php

    r869 r873  
    4848  function CheckName($Name, &$UsedNames)
    4949  {
    50     if(in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);
     50    if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);
    5151      else $UsedNames[] = $Name;
    5252  }
     
    189189    $DbResult = $this->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '.
    190190      'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Blocked`=0');
    191     while($Member = $DbResult->fetch_assoc())
     191    while ($Member = $DbResult->fetch_assoc())
    192192    {
    193193      $ServiceIndex = 1;
     
    198198        'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '.
    199199        'AND (`Service`.`InternetSpeedMax` > 0) AND (`Service`.`InternetSpeedMin` > 0)');
    200       while($Service = $DbResult4->fetch_assoc())
     200      while ($Service = $DbResult4->fetch_assoc())
    201201      {
    202202        echo('Služba '.$Service['Name'].': ');
     
    231231        $Row = $DbResult2->fetch_row();
    232232        $HostCount = $Row[0];
    233         if($HostCount > 0)
     233        if ($HostCount > 0)
    234234        {
    235235          $HostSpeedIn = round($SpeedIn / $HostCount);
     
    242242
    243243        $DbResult2 = $this->Database->select('NetworkDevice', '*', $Filter);
    244         while($Device = $DbResult2->fetch_assoc())
     244        while ($Device = $DbResult2->fetch_assoc())
    245245        {
    246246          $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""');
    247           while($Interface = $DbResult3->fetch_assoc())
     247          while ($Interface = $DbResult3->fetch_assoc())
    248248          {
    249249            $DeviceName = $Device['Name'];
    250             if($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name'];
     250            if ($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name'];
    251251            $DeviceName = RouterOSIdent($DeviceName);
    252252            echo($DeviceName.', ');
     
    258258
    259259        $DbResult2 = $this->Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']);
    260         while($Subnet = $DbResult2->fetch_assoc())
     260        while ($Subnet = $DbResult2->fetch_assoc())
    261261        {
    262262          $SubnetName = RouterOSIdent('subnet-'.$Subnet['Name']);
     
    329329  {
    330330    $MinSpeed = 0;
    331     foreach($this->Devices[$DeviceId]['Childs'] as $DeviceChild)
     331    foreach ($this->Devices[$DeviceId]['Childs'] as $DeviceChild)
    332332    {
    333333      $this->UpdateMinSpeed($DeviceChild);
     
    335335    }
    336336    $this->Devices[$DeviceId]['MinSpeed'] = $MinSpeed;
    337     if($this->Devices[$DeviceId]['DeviceCount'] > 0)
     337    if ($this->Devices[$DeviceId]['DeviceCount'] > 0)
    338338      $this->Devices[$DeviceId]['MinSpeed'] += round($this->Devices[$DeviceId]['InternetSpeedMin'] / $this->Devices[$DeviceId]['DeviceCount']);
    339339  }
     
    349349      'LEFT JOIN `ServiceCustomerRel` ON `ServiceCustomerRel`.`Id`=`NetworkDevice`.`Service` '.
    350350      'LEFT JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service`');
    351     while($Device = $DbResult->fetch_assoc())
     351    while ($Device = $DbResult->fetch_assoc())
    352352    {
    353353      $Device['Interfaces'] = array();
     
    364364    $Interfaces = array();
    365365    $DbResult = $this->Database->query('SELECT `Device`,`Name`,`Id` FROM `NetworkInterface`');
    366     while($Interface = $DbResult->fetch_assoc())
     366    while ($Interface = $DbResult->fetch_assoc())
    367367    {
    368368      $Interface['Links'] = array();
     
    376376      '`NetworkLink`.`Interface2`,`NetworkLinkType`.`MaxRealSpeed` FROM `NetworkLink` '.
    377377      'LEFT JOIN `NetworkLinkType` ON `NetworkLinkType`.`Id`=`NetworkLink`.`Type`');
    378     while($Link = $DbResult->fetch_assoc())
     378    while ($Link = $DbResult->fetch_assoc())
    379379    {
    380380      $Links[$Link['Id']] = $Link;
     
    388388    $this->Devices[$RootDeviceId]['Calculated'] = true;
    389389
    390     while(count($DevicesToCheck) > 0)
     390    while (count($DevicesToCheck) > 0)
    391391    {
    392392      //echo('Pass'."\n");
    393393      $NewDevicesToCheck = array();
    394       foreach($DevicesToCheck as $DeviceId)
     394      foreach ($DevicesToCheck as $DeviceId)
    395395      {
    396396        //echo($this->Devices[$DeviceId]['Name'].': ');
    397         foreach($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId)
     397        foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId)
    398398        {
    399           foreach($Interfaces[$InterfaceId]['Links'] as $LinkId)
     399          foreach ($Interfaces[$InterfaceId]['Links'] as $LinkId)
    400400          {
    401401            $Link = $Links[$LinkId];
    402402            $Interface2Id = $Link['Interface1'];
    403             if($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2'];
     403            if ($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2'];
    404404
    405405            $Device2Id = $Interfaces[$Interface2Id]['Device'];
    406             if($this->Devices[$Device2Id]['Calculated'] == false)
     406            if ($this->Devices[$Device2Id]['Calculated'] == false)
    407407            {
    408408              $this->Devices[$Device2Id]['Calculated'] = true;
    409409              $NewMaxSpeed = $this->Devices[$DeviceId]['MaxSpeed'];
    410               if($NewMaxSpeed > $Link['MaxRealSpeed'])
     410              if ($NewMaxSpeed > $Link['MaxRealSpeed'])
    411411                $NewMaxSpeed = $Link['MaxRealSpeed'];
    412412              //echo($this->Devices[$Device2Id]['Name'].' '.$Device2Id.', ');
     
    431431
    432432    echo('Not linked network devices: ');
    433     foreach($this->Devices as $Device)
    434     {
    435       if($Device['MaxSpeed'] == 0) echo($Device['Name'].', ');
     433    foreach ($this->Devices as $Device)
     434    {
     435      if ($Device['MaxSpeed'] == 0) echo($Device['Name'].', ');
    436436    }
    437437    echo("\n");
     
    455455    $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$DeviceId.' AND `LocalIP` != ""');
    456456    $IntCount = $DbResult3->num_rows;
    457     while($Interface = $DbResult3->fetch_assoc())
     457    while ($Interface = $DbResult3->fetch_assoc())
    458458    {
    459459      $InterfaceName = $Device['Name'];
    460       if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
     460      if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
    461461        else $InterfaceName .= '-';
    462462      $InterfaceName = RouterOSIdent($InterfaceName);
     
    469469
    470470    // Process childs
    471     foreach($Device['Childs'] as $DeviceChild)
     471    foreach ($Device['Childs'] as $DeviceChild)
    472472    {
    473473      $this->BuildQueueItems($DeviceChild, $LimitDevice);
     
    505505
    506506    $DbResult = $this->Database->select('Service', '*', '(`ChangeAction` IS NULL) AND (`Id`='.TARIFF_FREE.')');
    507     if($DbResult->num_rows == 1)
     507    if ($DbResult->num_rows == 1)
    508508    {
    509509      $Service = $DbResult->fetch_array();
  • trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php

    r851 r873  
    1212        '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '.
    1313        'FROM `NetworkDevice` WHERE (`API` = 1) AND (`Used` = 1)');
    14     while($Device = $DbResult3->fetch_assoc())
     14    while ($Device = $DbResult3->fetch_assoc())
    1515    {
    1616      echo($Device['LocalIP']."\n");
     
    1919      //$Routerboard->Port = 8729;
    2020      $Routerboard->Connect($Device['LocalIP'], $this->System->Config['API']['UserName'], $this->System->Config['API']['Password']);
    21       if(!$Routerboard->Connected) continue;
     21      if (!$Routerboard->Connected) continue;
    2222      $Routerboard->Write('/interface/wireless/registration-table/getall', false);
    2323      $Routerboard->Write('=.proplist=signal-strength,mac-address,rx-rate,tx-rate', false);
     
    2525      $Read = $Routerboard->Read(false);
    2626      $Array = $Routerboard->ParseResponse($Read);
    27       foreach($Array as $Properties)
     27      foreach ($Array as $Properties)
    2828      {
    2929        $DbResult = $this->Database->select('NetworkInterface', 'Id', 'MAC="'.$Properties['mac-address'].'"');
    30         if($DbResult->num_rows > 0)
     30        if ($DbResult->num_rows > 0)
    3131        {
    3232          $DbRow = $DbResult->fetch_assoc();
     
    3434        } else $Interface = 'NULL';
    3535
    36         if(strpos($Properties['signal-strength'], '@') === false)
     36        if (strpos($Properties['signal-strength'], '@') === false)
    3737        {
    3838          $Strength = $Properties['signal-strength'];
    3939        } else {
    4040          $Parts = explode('@', $Properties['signal-strength']);
    41           if(substr($Parts[0], -3) == 'dBm')
     41          if (substr($Parts[0], -3) == 'dBm')
    4242            $Strength = substr($Parts[0], 0, -3); // without dBm
    4343            else $Strength = $Parts[0];
     
    5050        /*
    5151         $DbResult = $this->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"');
    52          if($DbResult->num_rows > 0)
     52         if ($DbResult->num_rows > 0)
    5353         {
    5454         $this->Database->insert('Measure', array('Name' => $Properties['mac-address']));
     
    7474    if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit   
    7575    if (substr($Value, -1, 1) == "M") $Value = substr($Value, 0, -1); // without M unit
    76     return($Value);
     76    return ($Value);
    7777  }
    7878
  • trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php

    r860 r873  
    7070    $IPAddress = GetRemoteAddress();
    7171    $Output = 'Vaše IP adresa je: '.$IPAddress.'<br/>';
    72     if(IsInternetAddr($IPAddress)) {
     72    if (IsInternetAddr($IPAddress)) {
    7373      $Output .= '<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>';
    74       return($Output);
     74      return ($Output);
    7575    }
    7676    $Time = time();
     
    7878    $DbResult = $this->Database->select('NetworkFreeAccess', '*', '(IPAddress="'.$IPAddress.
    7979      '") ORDER BY Time DESC LIMIT 1');
    80     if($DbResult->num_rows > 0)
     80    if ($DbResult->num_rows > 0)
    8181    {
    8282      $DbRow = $DbResult->fetch_assoc();
    8383      $ActivationTime = MysqlDateTimeToTime($DbRow['Time']);
    84       if(($ActivationTime + $this->Timeout) < $Time)
     84      if (($ActivationTime + $this->Timeout) < $Time)
    8585      {
    8686        $Activated = false;
     
    8888    } else $Activated = false;
    8989
    90     if(array_key_exists('a', $_GET))
     90    if (array_key_exists('a', $_GET))
    9191    {
    92       if($_GET['a'] == 'activate')
     92      if ($_GET['a'] == 'activate')
    9393      {
    94         if($Activated == false)
     94        if ($Activated == false)
    9595        {
    9696          $DbResult = $this->Database->insert('NetworkFreeAccess',
     
    108108
    109109    $PrefixMultiplier = new PrefixMultiplier();
    110     if($Activated) $Output .= 'Aktivováno. Vyprší za '.$PrefixMultiplier->Add($ActivationTime + $this->Timeout - $Time, '', 4, 'Time');
     110    if ($Activated) $Output .= 'Aktivováno. Vyprší za '.$PrefixMultiplier->Add($ActivationTime + $this->Timeout - $Time, '', 4, 'Time');
    111111      else $Output .= '<a href="?a=activate">Aktivovat</a>';
    112112
    113     return($Output);
     113    return ($Output);
    114114  }
    115115}
     
    122122    $Commands = array();
    123123    $DbResult = $this->Database->select('NetworkFreeAccess', '`Id`, `IPAddress`', '(`Configured`=0)');
    124     while($DbRow = $DbResult->fetch_assoc())
     124    while ($DbRow = $DbResult->fetch_assoc())
    125125    {
    126126      $Commands[] = '/ip firewall address-list add address='.$DbRow['IPAddress'].
     
    135135    $Routerboard->ExecuteBatch(implode(';', $Commands));
    136136
    137     return($Output);
     137    return ($Output);
    138138  }
    139139}
  • trunk/Modules/NetworkConfigRouterOS/Routerboard.php

    r860 r873  
    2222  {
    2323    $Output = array();
    24     if(is_array($Commands))
     24    if (is_array($Commands))
    2525    {
    2626      $I = 0;
    2727      $Batch = array();
    28       while($I < count($Commands))
    29       {
    30         if(($I % $this->MaxBurstLineCount) == 0)
    31         {
    32           if(count($Batch) > 0)
     28      while ($I < count($Commands))
     29      {
     30        if (($I % $this->MaxBurstLineCount) == 0)
     31        {
     32          if (count($Batch) > 0)
    3333            $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch)));
    3434          $Batch = array();
     
    3737        $I++;
    3838      }
    39       if(count($Batch) > 0)
     39      if (count($Batch) > 0)
    4040       $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch)));
    4141    } else
    4242      $Output = array_merge($Output, $this->ExecuteBatch($Commands));
    43     return($Output);
     43    return ($Output);
    4444  }
    4545
     
    4747  {
    4848    $Commands = trim($Commands);
    49     if($Commands != '')
     49    if ($Commands != '')
    5050    {
    5151      $Commands = addslashes($Commands);
     
    5757      $Command = $this->SSHPath.' -oBatchMode=no -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName.
    5858        $PrivKey.' '.$this->HostName.' "'.$Commands.'"';
    59       if($this->Debug) echo($Command);
     59      if ($this->Debug) echo($Command);
    6060      $Output = array();
    6161      exec($Command, $Output);
    6262    } else $Output = '';
    63     if($this->Debug) print_r($Output);
    64     return($Output);
     63    if ($this->Debug) print_r($Output);
     64    return ($Output);
    6565  }
    6666
     
    7070    array_pop($Result);
    7171    $List = array();
    72     foreach($Result as $ResultLine)
     72    foreach ($Result as $ResultLine)
    7373    {
    7474      $ResultLineParts = explode(' ', trim($ResultLine));
    75       if(count($ResultLineParts) > 1)
    76       {
    77         if($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes
     75      if (count($ResultLineParts) > 1)
     76      {
     77        if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes
    7878        $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1];
    7979      } else $List[substr($ResultLineParts[0], 0, -1)] = '';
    8080    }
    81     return($List);
     81    return ($List);
    8282  }
    8383
     
    8585  {
    8686    $PropertyList = '"';
    87     foreach($Properties as $Index => $Property)
     87    foreach ($Properties as $Index => $Property)
    8888    {
    8989      $PropertyList .= $Index.'=".[get $i '.$Property.']." ';
     
    9292
    9393    $ConditionList = '';
    94     foreach($Conditions as $Index => $Item)
    95     {
    96       if($Item == 'no') $ConditionList .= $Index.'='.$Item.' ';
     94    foreach ($Conditions as $Index => $Item)
     95    {
     96      if ($Item == 'no') $ConditionList .= $Index.'='.$Item.' ';
    9797      else $ConditionList .= $Index.'="'.$Item.'" ';
    9898    }
     
    101101    $Result = $this->Execute(implode(' ', $Path).' {:foreach i in=[find '.$ConditionList.'] do={:put ('.$PropertyList.')}}');
    102102    $List = array();
    103     foreach($Result as $ResultLine)
     103    foreach ($Result as $ResultLine)
    104104    {
    105105      $ResultLineParts = explode(' ', $ResultLine);
    106106      $ListItem = array();
    107       foreach($ResultLineParts as $ResultLinePart)
     107      foreach ($ResultLineParts as $ResultLinePart)
    108108      {
    109109        $Value = explode('=', $ResultLinePart);
    110         if(count($Value) > 1) $ListItem[$Properties[$Value[0]]] = $Value[1];
     110        if (count($Value) > 1) $ListItem[$Properties[$Value[0]]] = $Value[1];
    111111          else $ListItem[$Properties[$Value[0]]] = '';
    112112      }
    113113      $List[] = $ListItem;
    114114    }
    115     return($List);
     115    return ($List);
    116116  }
    117117
     
    119119  {
    120120    $ConditionList = '';
    121     foreach($Conditions as $Index => $Item)
     121    foreach ($Conditions as $Index => $Item)
    122122    {
    123123      $ConditionList .= $Index.'="'.$Item.'" ';
    124124    }
    125125    $ConditionList = substr($ConditionList, 0, -1);
    126     if(trim($ConditionList) != '')
     126    if (trim($ConditionList) != '')
    127127      $ConditionList = ' where '.$ConditionList;
    128128
    129129    $Result = $this->Execute(implode(' ', $Path).' print terse'.$ConditionList);
    130130    $List = array();
    131     foreach($Result as $ResultLine)
     131    foreach ($Result as $ResultLine)
    132132    {
    133133      $ResultLineParts = explode(' ', $ResultLine);
    134134      $ListItem = array();
    135       foreach($ResultLineParts as $ResultLinePart)
     135      foreach ($ResultLineParts as $ResultLinePart)
    136136      {
    137137        $Value = explode('=', $ResultLinePart);
    138         if(in_array($Value[0], $Properties))
    139         {
    140           if(count($Value) > 1)
     138        if (in_array($Value[0], $Properties))
     139        {
     140          if (count($Value) > 1)
    141141          {
    142             if($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1);
    143             //if(strlen($Value[1]) > 0)
     142            if ($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1);
     143            //if (strlen($Value[1]) > 0)
    144144            $ListItem[$Value[0]] = $Value[1];
    145145          } else $ListItem[$Value[0]] = '';
    146146        }
    147147      }
    148       if(count($ListItem) > 0) $List[] = $ListItem;
    149     }
    150     return($List);
     148      if (count($ListItem) > 0) $List[] = $ListItem;
     149    }
     150    return ($List);
    151151  }
    152152
     
    159159  {
    160160    // Get current list from routerboard
    161     if($UsePrint == 0)
     161    if ($UsePrint == 0)
    162162    {
    163163      $List = $this->ListGet($Path, $Properties, $Condition);
    164164      // Change boolean values yes/no to true/false
    165       foreach($List as $Index => $ListItem)
    166       {
    167         foreach($ListItem as $Index2 => $Item2)
    168         {
    169           if($Item2 == 'true') $List[$Index][$Index2] = 'yes';
    170           if($Item2 == 'false') $List[$Index][$Index2] = 'no';
     165      foreach ($List as $Index => $ListItem)
     166      {
     167        foreach ($ListItem as $Index2 => $Item2)
     168        {
     169          if ($Item2 == 'true') $List[$Index][$Index2] = 'yes';
     170          if ($Item2 == 'false') $List[$Index][$Index2] = 'no';
    171171        }
    172172      }
     
    178178
    179179    // Add empty properties to values
    180     foreach($Values as $Index => $Item)
    181     {
    182       foreach($Properties as $Property)
    183       {
    184         if(!array_key_exists($Property, $Item))
     180    foreach ($Values as $Index => $Item)
     181    {
     182      foreach ($Properties as $Property)
     183      {
     184        if (!array_key_exists($Property, $Item))
    185185           $Item[$Property] = '';
    186186      }
    187187      $Values[$Index] = $Item;
    188188    }
    189     foreach($List as $Index => $Item)
    190     {
    191       foreach($Properties as $Property)
    192       {
    193         if(!array_key_exists($Property, $Item))
     189    foreach ($List as $Index => $Item)
     190    {
     191      foreach ($Properties as $Property)
     192      {
     193        if (!array_key_exists($Property, $Item))
    194194           $Item[$Property] = '';
    195195      }
     
    198198
    199199    // Sort properties
    200     foreach($Values as $Index => $Item)
     200    foreach ($Values as $Index => $Item)
    201201    {
    202202      ksort($Values[$Index]);
    203203    }
    204     foreach($List as $Index => $Item)
     204    foreach ($List as $Index => $Item)
    205205    {
    206206      ksort($List[$Index]);
    207207    }
    208     if($this->Debug) print_r($List);
    209     if($this->Debug) print_r($Values);
     208    if ($this->Debug) print_r($List);
     209    if ($this->Debug) print_r($Values);
    210210
    211211    // Erase all items not existed in $Values
    212     foreach($List as $Index => $ListItem)
    213     {
    214       if(!in_array($ListItem, $Values))
     212    foreach ($List as $Index => $ListItem)
     213    {
     214      if (!in_array($ListItem, $Values))
    215215      {
    216216        $Prop = '';
    217         foreach($ListItem as $Index => $Property)
    218         {
    219           if($Property != '')
     217        foreach ($ListItem as $Index => $Property)
     218        {
     219          if ($Property != '')
    220220          {
    221             if(($Property == 'yes') or ($Property == 'no')) $Prop .= $Index.'='.$Property.' ';
     221            if (($Property == 'yes') or ($Property == 'no')) $Prop .= $Index.'='.$Property.' ';
    222222              else $Prop .= $Index.'="'.$Property.'" ';
    223223          }
    224224        }
    225225        $Prop = substr($Prop, 0, -1);
    226         if(trim($Prop) != '')
     226        if (trim($Prop) != '')
    227227          $Commands[] = implode(' ', $Path).' remove [find '.$Prop.']';
    228228      }
     
    230230
    231231    // Add new items
    232     foreach($Values as $ListItem)
    233     {
    234       if(!in_array($ListItem, $List))
     232    foreach ($Values as $ListItem)
     233    {
     234      if (!in_array($ListItem, $List))
    235235      {
    236236        $Prop = '';
    237         foreach($ListItem as $Index => $Property)
    238         {
    239           if($Property != '') $Prop .= $Index.'="'.$Property.'" ';
     237        foreach ($ListItem as $Index => $Property)
     238        {
     239          if ($Property != '') $Prop .= $Index.'="'.$Property.'" ';
    240240        }
    241241        $Prop = substr($Prop, 0, -1);
     
    243243      }
    244244    }
    245     if($this->Debug) print_r($Commands);
    246     return($this->Execute($Commands));
     245    if ($this->Debug) print_r($Commands);
     246    return ($this->Execute($Commands));
    247247  }
    248248}
  • trunk/Modules/NetworkConfigRouterOS/Routerboard2.php

    r738 r873  
    1313  function Execute($Commands)
    1414  {
    15     if(is_array($Commands)) $Commands = implode(';', $Commands);
    16     return(parent::Execute($Commands));
     15    if (is_array($Commands)) $Commands = implode(';', $Commands);
     16    return (parent::Execute($Commands));
    1717  }
    1818
     
    2222    array_pop($Result);
    2323    $List = array();
    24     foreach($Result as $ResultLine)
     24    foreach ($Result as $ResultLine)
    2525    {
    2626      $ResultLineParts = explode(' ', trim($ResultLine));
    27       if($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes
     27      if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes
    2828      $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1];
    2929    }
    30     return($List);
     30    return ($List);
    3131  }
    3232
     
    3434  {
    3535    $PropertyList = '"';
    36     foreach($Properties as $Property)
     36    foreach ($Properties as $Property)
    3737    {
    3838      $PropertyList .= $Property.'=".[get $i '.$Property.']." ';
     
    4141    $Result = $this->Execute($Command.' {:foreach i in=[find] do={:put ('.$PropertyList.')}}');
    4242    $List = array();
    43     foreach($Result as $ResultLine)
     43    foreach ($Result as $ResultLine)
    4444    {
    4545      $ResultLineParts = explode(' ', $ResultLine);
    4646      $ListItem = array();
    47       foreach($ResultLineParts as $ResultLinePart)
     47      foreach ($ResultLineParts as $ResultLinePart)
    4848      {
    4949        $Value = explode('=', $ResultLinePart);
     
    5252      $List[] = $ListItem;
    5353    }
    54     return($List);
     54    return ($List);
    5555  }
    5656
    5757  function GetSystemResource()
    5858  {
    59     return($this->GetItem('/system resource print'));
     59    return ($this->GetItem('/system resource print'));
    6060  }
    6161
    6262  function GetFirewallFilterList()
    6363  {
    64     return($this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes')));
     64    return ($this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes')));
    6565  }
    6666
    6767  function GetDHCPServerLeasesList()
    6868  {
    69     return($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name')));
     69    return ($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name')));
    7070  }
    7171}
  • trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php

    r861 r873  
    4040    } else if ($Length >= 0x10000000)
    4141      $Length = chr(0xF0).chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF);
    42     return($Length);
     42    return ($Length);
    4343  }
    4444
    4545  function ConnectOnce($IP, $Login, $Password)
    4646  {
    47     if($this->Connected) $this->Disconnect();
    48     if($this->SSL)
     47    if ($this->Connected) $this->Disconnect();
     48    if ($this->SSL)
    4949    {
    5050      $IP = 'ssl://'.$IP;
    5151    }
    5252    $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout);
    53     if($this->Socket)
     53    if ($this->Socket)
    5454    {
    5555      socket_set_timeout($this->Socket, $this->Timeout);
     
    5858      $this->Write('=password='.$Password);
    5959      $Response = $this->Read(false);
    60       if((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true;
    61       if(!$this->Connected) fclose($this->Socket);
     60      if ((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true;
     61      if (!$this->Connected) fclose($this->Socket);
    6262    }
    6363  }
     
    6565  function Connect($IP, $Login, $Password)
    6666  {
    67     for($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)
     67    for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)
    6868    {
    6969      $this->ConnectOnce($IP, $Login, $Password);
    70       if($this->Connected) break;
     70      if ($this->Connected) break;
    7171      sleep($this->Delay);
    7272    }
    73     return($this->Connected);
     73    return ($this->Connected);
    7474  }
    7575
    7676  function Disconnect()
    7777  {
    78     if($this->Connected)
     78    if ($this->Connected)
    7979    {
    8080      fclose($this->Socket);
     
    183183        $Response[] = $Line;
    184184      }
    185       if($this->Debug) echo($Line);
     185      if ($this->Debug) echo($Line);
    186186      // If we get a !done, make a note of it.
    187187      if ($Line == "!done") $ReceivedDone = true;
     
    192192        break;
    193193    }
    194     if($Parse) $Response = $this->ParseResponse($Response);
     194    if ($Parse) $Response = $this->ParseResponse($Response);
    195195    return $Response;
    196196  }
     
    198198  function Write($Command, $Param2 = true)
    199199  {
    200     if($Command)
     200    if ($Command)
    201201    {
    202202      $Data = explode("\n", $Command);
     
    234234      $this->Write($el, $Last);
    235235    }
    236     return($this->Read());
     236    return ($this->Read());
    237237  }
    238238}
  • trunk/Modules/NetworkConfigRouterOS/SSH.php

    r738 r873  
    1818  {
    1919    echo($Commands);
    20     if(!function_exists("ssh2_connect")) die("Function ssh2_connect doesn't exist");
    21     if(!($this->Session = ssh2_connect($this->HostName, 22, $this->Methods))) echo("Fail: Unable to establish connection to host\n");
     20    if (!function_exists("ssh2_connect")) die("Function ssh2_connect doesn't exist");
     21    if (!($this->Session = ssh2_connect($this->HostName, 22, $this->Methods))) echo("Fail: Unable to establish connection to host\n");
    2222    else
    2323    {
    24       if(!ssh2_auth_password($this->Session, $this->UserName, $this->Password)) echo("Fail: unable to authenticate\n");
     24      if (!ssh2_auth_password($this->Session, $this->UserName, $this->Password)) echo("Fail: unable to authenticate\n");
    2525      else
    2626      {
    27         //if(!($Stream = ssh2_shell($this->Session, 'xterm', null, 80, 40, SSH2_TERM_UNIT_CHARS))) echo("Fail: unable to execute command\n");
    28         if(!($Stream = ssh2_exec($this->Session, $Commands))) echo("Fail: unable to execute command\n");
     27        //if (!($Stream = ssh2_shell($this->Session, 'xterm', null, 80, 40, SSH2_TERM_UNIT_CHARS))) echo("Fail: unable to execute command\n");
     28        if (!($Stream = ssh2_exec($this->Session, $Commands))) echo("Fail: unable to execute command\n");
    2929        else
    3030        {
    3131          $Response = '';
    3232          stream_set_blocking($Stream, true);
    33           while($Buffer = fread($Stream, 4000))
     33          while ($Buffer = fread($Stream, 4000))
    3434          {
    3535            $Response .= $Buffer;
     
    3737            /*
    3838            //echo(') '.strlen($Buffer).' '.ord($Buffer{0}).'(');
    39             for($I = 0; $I < strlen($Buffer); $I++)
     39            for ($I = 0; $I < strlen($Buffer); $I++)
    4040            {
    41               if(((ord($Buffer{$I}) >= 32) and (ord($Buffer{$I}) <= 128)) or ($Buffer{$I} = "\n") or ($Buffer{$I} = "\r")) echo($Buffer{$I});
    42               if($Buffer{$I} == '>')
     41              if (((ord($Buffer{$I}) >= 32) and (ord($Buffer{$I}) <= 128)) or ($Buffer{$I} = "\n") or ($Buffer{$I} = "\r")) echo($Buffer{$I});
     42              if ($Buffer{$I} == '>')
    4343              {
    4444                fwrite($Stream, $Commands."\n\r");
     
    5454    }
    5555    echo($Response);
    56     return(explode("\n", substr($Response, 0, -1)));
     56    return (explode("\n", substr($Response, 0, -1)));
    5757  }
    5858}
  • trunk/Modules/NetworkShare/SharePage.php

    r790 r873  
    2222  function ShowTime()
    2323  {
    24     return(date("H:i:s")."<br />\n");
     24    return (date("H:i:s")."<br />\n");
    2525  }
    2626
     
    4141    $Cesta = ''; //$Row['name'];
    4242    $i = 0;
    43     while(($Otec > 1) && ($i < $this->MaxNesting))
     43    while (($Otec > 1) && ($i < $this->MaxNesting))
    4444    {
    4545      $DbResult = $this->Database->query('SELECT Id,Name,Parent FROM NetworkShareItem WHERE Id='.$Otec);
     
    5050      $i++;
    5151    }
    52     if($i >= $this->MaxNesting) $Cesta = '?'.'\\'.$Cesta;
    53     return('\\\\'.$Cesta);
     52    if ($i >= $this->MaxNesting) $Cesta = '?'.'\\'.$Cesta;
     53    return ('\\\\'.$Cesta);
    5454  }
    5555
     
    5858  {
    5959    $Jednotky = array('B','kB','MB','GB','TB','PB','EB');
    60     while($Velikost >= 1024)
     60    while ($Velikost >= 1024)
    6161    {
    6262      $Velikost = round($Velikost / 1024 * 10) / 10;
    6363      array_shift($Jednotky);
    6464    }
    65     return($Velikost.'&nbsp;'.$Jednotky[0]);
     65    return ($Velikost.'&nbsp;'.$Jednotky[0]);
    6666  }
    6767
    6868  function Show()
    6969  {
    70     if(!$this->System->User->CheckPermission('NetworkShare', 'Display')) return('Nemáte oprávnění');
     70    if (!$this->System->User->CheckPermission('NetworkShare', 'Display')) return ('Nemáte oprávnění');
    7171
    7272    // If not only online checkbox checked
    73     if(array_key_exists('view', $_POST) and !array_key_exists('online', $_POST)) $_POST['online'] = 'off';
     73    if (array_key_exists('view', $_POST) and !array_key_exists('online', $_POST)) $_POST['online'] = 'off';
    7474
    7575    // Default host list view
    76     if((count($_POST) == 0) and (count($_GET) == 0))
     76    if ((count($_POST) == 0) and (count($_GET) == 0))
    7777    {
    7878      $_POST['view'] = 1;
     
    8181
    8282    // Toggle order direction
    83     if(array_key_exists('order', $_GET) and ($_SESSION['order'] == $_GET['order'])) $_GET['order'] .= ' DESC';
     83    if (array_key_exists('order', $_GET) and ($_SESSION['order'] == $_GET['order'])) $_GET['order'] .= ' DESC';
    8484
    8585    //print_r($_POST);
    86     foreach($this->Promene as $Index => $Prvek)
    87     {
    88       if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $this->Promene[$Index];
    89       if(array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
    90       if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
    91       if(($Index == 'keyword') and (array_key_exists('view', $_GET))) $_SESSION[$Index] = $this->Promene[$Index];
    92       if(($Index == 'view') and ((array_key_exists('keyword', $_POST)) or (array_key_exists('keyword', $_GET)))) $_SESSION[$Index] = '';
     86    foreach ($this->Promene as $Index => $Prvek)
     87    {
     88      if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $this->Promene[$Index];
     89      if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
     90      if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
     91      if (($Index == 'keyword') and (array_key_exists('view', $_GET))) $_SESSION[$Index] = $this->Promene[$Index];
     92      if (($Index == 'view') and ((array_key_exists('keyword', $_POST)) or (array_key_exists('keyword', $_GET)))) $_SESSION[$Index] = '';
    9393      $$Index = $_SESSION[$Index];
    9494      //echo('$'.$Index.' = '.$_SESSION[$Index].'<br>');
    9595    }
    9696    //echo($keyword);
    97     //if($keyword)
    98     //if($keyword != '') $view = '';
     97    //if ($keyword)
     98    //if ($keyword != '') $view = '';
    9999
    100100    //$this->Database->select_db('share');
    101101
    102102    // Log search
    103     if(array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET))
     103    if (array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET))
    104104      $this->System->ModuleManager->Modules['Log']->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']);
    105105
     
    139139    </select>&nbsp;';
    140140
    141     if($online == 'on') $Selected = 'checked '; else $Selected = '';
     141    if ($online == 'on') $Selected = 'checked '; else $Selected = '';
    142142    $Output .= '<input type="checkbox" '.$Selected.'name="online">Pouze aktivní uživatele<br>
    143143    </form>';
    144144
    145145    //$Output .= $view;
    146     if($view != '')
     146    if ($view != '')
    147147    {
    148148      // Zobrazení obsahu vybrané složky
     
    170170        "(ext LIKE 'iso') OR (ext LIKE 'nrg') OR (ext LIKE 'ccd') OR (ext LIKE 'bin') OR (ext LIKE 'mds')",
    171171      );
    172       if($file_type > 0) $Podminka .= ' AND ('.$Pripony[$file_type].')';
     172      if ($file_type > 0) $Podminka .= ' AND ('.$Pripony[$file_type].')';
    173173
    174174      //Hledání podle velikosti
    175175      $Jednotky = array(1, 1024, 1048576, 1073741824);
    176       if(is_numeric($size))
     176      if (is_numeric($size))
    177177      {
    178178        $Metoda = array('=', '>', '<');
     
    184184    // Omezení na online/offline uživatele
    185185    //$this->Database->select_db('is');
    186     if($online == 'on') $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice WHERE Online=1 AND Member IS NOT NULL');
     186    if ($online == 'on') $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice WHERE Online=1 AND Member IS NOT NULL');
    187187      else $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice');
    188188    $Vyber = '';
    189     while($Row = $DbResult->fetch_array()) $Vyber .= $Row['Id'].',';
     189    while ($Row = $DbResult->fetch_array()) $Vyber .= $Row['Id'].',';
    190190    $Podminka .= ' AND (Host IN ('.substr($Vyber, 0, -1).'))';
    191191    //echo($Podminka.'<br>');
     
    200200
    201201    // Zobrazení [..]
    202     if(($view != '') && ($page == 0) && ($Nahoru > 0))
     202    if (($view != '') && ($page == 0) && ($Nahoru > 0))
    203203    {
    204204      $DbResult = $this->Database->query('SELECT * FROM NetworkShareItem WHERE Id='.$view);
     
    212212    $PerPage = 30;
    213213    $Dotaz = "SELECT COUNT(*) FROM NetworkShareItem WHERE (".$Podminka.")";
    214     if($order != '') $Dotaz .= ' ORDER BY '.$order;
     214    if ($order != '') $Dotaz .= ' ORDER BY '.$order;
    215215    $Dotaz .= " LIMIT ".($page * $PerPage).",".$PerPage;
    216216    $DbResult = $this->Database->query($Dotaz);
     
    218218    $Pocet = $Row[0];
    219219
    220     if($Pocet > 0)
     220    if ($Pocet > 0)
    221221    {
    222222      $Output .= 'Nalezeno celkem: '.$Pocet.' položek<br />';
    223223    } else
    224224    $Output .= 'Podle zadaných podmínek nic nenalezeno';
    225     if(($Pocet > 0) || ($upstr))
     225    if (($Pocet > 0) || ($upstr))
    226226    {
    227227      $Output .= '<table width="100%" style="font-size: 8pt;" border="0" cellpadding="2" cellspacing="2">
    228228      <tr><th bgcolor="#E0E0FF"><a href="index.php?order=name">Soubor</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=ext">Přípona</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=size">Velikost</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=date">Datum</a></th><th bgcolor="#E0E0FF">Umístění</th></tr>';
    229229      $Output .= $upstr;
    230       if($Pocet > 0)
     230      if ($Pocet > 0)
    231231      {
    232232        // Zobrazení tabulky s výsledky
     
    235235
    236236        // Zobrazení poloľek
    237         while($Row = $DbResult->fetch_array())
     237        while ($Row = $DbResult->fetch_array())
    238238        {
    239239          // Loguj('Radek '.$Row['name']);
     
    244244          // Zobrazení řádku
    245245          $Cesta2 = strtr($Cesta.$Radek['Name'], '\\', '/');
    246           if($Radek['Ext'] != '') $Cesta2 .= '.'.$Radek['Ext'];
    247           if($Radek['Type'] != 0) $Adresa = 'index.php?view='.$Radek['Id'].'">['.$Radek['Name'].']';
     246          if ($Radek['Ext'] != '') $Cesta2 .= '.'.$Radek['Ext'];
     247          if ($Radek['Type'] != 0) $Adresa = 'index.php?view='.$Radek['Id'].'">['.$Radek['Name'].']';
    248248          else
    249249          {
    250             if(strstr($_SERVER['HTTP_USER_AGENT'], 'Linux')) $Adresa = 'smb:'.$Cesta2.'">'.$Radek['Name'];
     250            if (strstr($_SERVER['HTTP_USER_AGENT'], 'Linux')) $Adresa = 'smb:'.$Cesta2.'">'.$Radek['Name'];
    251251            else $Adresa = 'file:///'.$Cesta2.'">'.$Radek['Name'];
    252252          }
     
    260260      }
    261261    }
    262     if($Pocet > 0)
     262    if ($Pocet > 0)
    263263    {
    264264      // Celkový přehled
    265       if($view == 1)
     265      if ($view == 1)
    266266      {
    267267        $DbResult = $this->Database->query('SELECT SUM(Size) FROM NetworkShareItem WHERE (Parent=1) AND (Host IN ('.substr($Vyber,0,-1).'))');
     
    285285        $Host = strtoupper(substr($Host, 0, strpos($Host, '.')));
    286286        $DbResult = $this->Database->select('NetworkShareError', '*', 'Host="'.$Host.'"');
    287         if($DbResult->num_rows > 0) $Output .= '<strong>Výpis chybových hlášení pro počítač '.$Host.':</strong><br />';
     287        if ($DbResult->num_rows > 0) $Output .= '<strong>Výpis chybových hlášení pro počítač '.$Host.':</strong><br />';
    288288        //echo('host="'.$Host.'"');
    289         while($Row = $DbResult->fetch_array())
     289        while ($Row = $DbResult->fetch_array())
    290290        {
    291291          $Row['Message'] = str_replace('/', '\\', $Row['Message']);
     
    295295
    296296      // Zobrazení seznamu stránek
    297       if($Pages > 1)
     297      if ($Pages > 1)
    298298      {
    299         if($page > 0) $Output .= '<a href="index.php?page=0">&lt;&lt;</a> ';
    300         if($page > 0) $Output .= '<a href="index.php?page='.($page-1).'">&lt;</a> ';
     299        if ($page > 0) $Output .= '<a href="index.php?page=0">&lt;&lt;</a> ';
     300        if ($page > 0) $Output .= '<a href="index.php?page='.($page-1).'">&lt;</a> ';
    301301        $PagesMax = $Pages;
    302302        $PagesMin = 0;
    303         if($PagesMax > ($page + 10)) $PagesMax = $page + 10;
    304         if($PagesMin < ($page - 10))
     303        if ($PagesMax > ($page + 10)) $PagesMax = $page + 10;
     304        if ($PagesMin < ($page - 10))
    305305        {
    306306          $Output .= ' .. ';
    307307          $PagesMin = $page - 10;
    308308        }
    309         for($i = $PagesMin; $i <= $PagesMax; $i++)
     309        for ($i = $PagesMin; $i <= $PagesMax; $i++)
    310310        {
    311           if($i == $page) $Output .= '<strong>';
     311          if ($i == $page) $Output .= '<strong>';
    312312          $Output .= '<a href="index.php?page='.$i.'">'.($i + 1).'</a> ';
    313           if($i == $page) $Output .= '</strong>';
     313          if ($i == $page) $Output .= '</strong>';
    314314        }
    315         if($PagesMax < $Pages) $Output .= ' .. ';
    316         if($page < $Pages) $Output .= '<a href="index.php?page='.($page + 1).'">&gt;</a> ';
    317         if($page < $Pages) $Output .= '<a href="index.php?page='.$Pages.'">&gt;&gt;</a>';
     315        if ($PagesMax < $Pages) $Output .= ' .. ';
     316        if ($page < $Pages) $Output .= '<a href="index.php?page='.($page + 1).'">&gt;</a> ';
     317        if ($page < $Pages) $Output .= '<a href="index.php?page='.$Pages.'">&gt;&gt;</a>';
    318318      }
    319319    }
    320     return($Output);
     320    return ($Output);
    321321  }
    322322}
  • trunk/Modules/NetworkShare/browse.php

    r790 r873  
    99$MountDir = '/tmp/browse/host'; // Složka, kde se dočasně připojují síťové disky
    1010$TempDir = '/tmp/browse/';  // Složka, kde se dočasně připojují síťové disky
    11 if(!is_dir($TempDir)) mkdir($TempDir, 0777);
    12 if(!is_dir($MountDir)) mkdir($MountDir, 0777);
     11if (!is_dir($TempDir)) mkdir($TempDir, 0777);
     12if (!is_dir($MountDir)) mkdir($MountDir, 0777);
    1313
    1414// Nacteni seznamu sdileni
    1515$Host = strtoupper(getenv('browse_host'));
    16 if($Host=='') die("Musite nastavit browse_host!\n");
     16if ($Host=='') die("Musite nastavit browse_host!\n");
    1717$HostID = getenv('browse_id');
    18 if($HostID=='') die("Musite nastavit browse_id!\n");
     18if ($HostID=='') die("Musite nastavit browse_id!\n");
    1919//echo("\n================== Prochazec sdileni =================\n\n");
    2020echo("Nacitam seznam sdileni pro ".$Host.'('.$HostID.')...');
     
    2323echo("OK\n");
    2424//print_r($Output);
    25 if($Output[0]=='Connection to '.$Host.' failed') die('Pocitac '.$Host." nenalezen!\n");
     25if ($Output[0]=='Connection to '.$Host.' failed') die('Pocitac '.$Host." nenalezen!\n");
    2626$Output = array_slice($Output,3);
    2727$Shares = array();
    28 foreach($Output as $Radek)
    29 {
    30   if($Radek=='') break;
     28foreach ($Output as $Radek)
     29{
     30  if ($Radek=='') break;
    3131  //$Radek = iconv('UTF-8','ISO-8859-2',$Radek);
    3232  $Title = trim(substr($Radek,1,16));
     
    3434  $Desc = trim(substr($Radek,26));
    3535  //echo($Title.','.$Type.','.$Desc."\n");
    36   if(($Type=='Disk') && (substr($Title,-1,1)!='$')) array_push($Shares,$Title);
     36  if (($Type=='Disk') && (substr($Title,-1,1)!='$')) array_push($Shares,$Title);
    3737  //ShowArray($Radek);
    3838}
     
    6161    //echo(strlen($Nazev).",");
    6262    array_push($Files,$Nazev);
    63   } while(($Nazev != "\n") && (!feof($Soubor)));
     63  } while (($Nazev != "\n") && (!feof($Soubor)));
    6464  array_pop($Files);
    65   //if(($Pocet-floor($Pocet/10)*10)==9)
     65  //if (($Pocet-floor($Pocet/10)*10)==9)
    6666  $Hotovo = floor(ftell($Soubor) / $FileSize * $MaxProgress);
    67   if($Hotovo >= $Pocet)
     67  if ($Hotovo >= $Pocet)
    6868  {
    6969    echo(str_repeat('#', $Hotovo-$Pocet));
     
    7171  }
    7272  //echo('['.memory_get_usage().'] '.$Cesta."\n");
    73   foreach($Files as $Radek)
     73  foreach ($Files as $Radek)
    7474  {
    7575    //echo($Radek."");
    7676    $Radek = substr($Radek,0,-1);
    7777    //echo($Radek.",\n");
    78     if($Radek[0] == 'd') $Type = 2; else $Type = 0;
     78    if ($Radek[0] == 'd') $Type = 2; else $Type = 0;
    7979    $Prava = substr($Radek,0,strpos($Radek,' '));
    8080    $Radek = ltrim(substr($Radek,strlen($Prava)+1));
     
    9494    //echo($Date.','.$Time.','.$Radek.' ');
    9595
    96     if((strpos($Nazev,'.') > 0) && ($Type != 2))
     96    if ((strpos($Nazev,'.') > 0) && ($Type != 2))
    9797    {
    9898      $Ext = substr($Nazev,strrpos($Nazev,'.')+1);
     
    114114    $Citac = $Citac + 1;
    115115    // Pokud jde o sloľku, tak projdi jeji obsah a aktualizuj velikost
    116     if($Type == 2)
     116    if ($Type == 2)
    117117    {
    118118      //echo($Vlozit);
    119     //  if($Vlozit!='') DB_Query($Vlozit);  // Vloz vsechny polozky
     119    //  if ($Vlozit!='') DB_Query($Vlozit);  // Vloz vsechny polozky
    120120    //  $Vlozit = '';
    121121      $VelikostSlozky += Vetev($Cesta.$Nazev.'/',$Zanoreni+1);
     
    123123  }
    124124  //echo($Vlozit);
    125   //if($Vlozit!='') DB_Query($Vlozit);  // Vloz vsechny polozky
     125  //if ($Vlozit!='') DB_Query($Vlozit);  // Vloz vsechny polozky
    126126
    127127  // Aktualizuj velikost
     
    130130  $Database->update('NetworkShareItem', 'id='.$Parent, array('size' => $VelikostSlozky));
    131131  //closedir($Dir);
    132   return($VelikostSlozky);
     132  return ($VelikostSlozky);
    133133}
    134134
     
    152152$Parent = $Row[0];
    153153
    154 foreach($Shares as $Share)
     154foreach ($Shares as $Share)
    155155{
    156156  $Pocet = 0;
     
    163163//  echo($SambaSbinDir."mount.cifs '".$ShareFull."' ".$MountDir.' -o guest,codepage=cp852,iocharset=iso8859-2');
    164164  passthru('ls -A -R -X -l --time-style=+"%Y-%m-%d %I:%M:%S" '.$MountDir.'>'.$TempDir.$Host.'.list 2>'.$TempDir.'errors/'.$Host.'_'.$Share.'.err',$Result);
    165   //if($Result==0)
     165  //if ($Result==0)
    166166  //{
    167167    echo("OK\n");
    168168
    169     if(file_exists($TempDir.$Host.'.list'))
     169    if (file_exists($TempDir.$Host.'.list'))
    170170    {
    171171      // Přidej poloľku sdílení do datanáze
     
    215215$DbResult = $Database->query('SELECT id FROM hosts');
    216216$Vyber = '';
    217 while($Row = $DbResult->fetch_array())
     217while ($Row = $DbResult->fetch_array())
    218218  $Vyber .= $Row['id'].',';
    219219
     
    226226echo("Chyby sdílení...\n");
    227227$Database->delete('NetworkShareError', 'host="'.$Host.'"');
    228 if(is_dir($TempDir.'errors'))
     228if (is_dir($TempDir.'errors'))
    229229{
    230230  $Dir = scandir($TempDir.'errors');
    231   foreach($Dir as $File)
     231  foreach ($Dir as $File)
    232232  {
    233     if(substr($File, 0, strpos($File, '_')) == $Host)
     233    if (substr($File, 0, strpos($File, '_')) == $Host)
    234234    {
    235235      $Share = substr($File, strpos($File, '_')+1, -4);
    236236      $ShareFull = '//'.$Host.'/'.$Share;
    237       if(filesize($TempDir.'errors/'.$File) > 0)
     237      if (filesize($TempDir.'errors/'.$File) > 0)
    238238      {
    239239        $ErrorFile = fopen($TempDir.'errors/'.$File, 'r+');
    240         while(!feof($ErrorFile))
     240        while (!feof($ErrorFile))
    241241        {
    242242          $Row = fgets($ErrorFile);
    243           if($Row != '')
     243          if ($Row != '')
    244244          {
    245245            $Row = substr($ShareFull.'/'.substr($Row, 39), 0, -1);
  • trunk/Modules/NetworkShare/firefox.php

    r790 r873  
    1010  var msg="Přidání vyhledávacího modulu selhalo - ";
    1111
    12   if((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){
    13     if(engineURL == null || engineURL == ""){
     12  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){
     13    if (engineURL == null || engineURL == ""){
    1414      alert(msg + "nebyla zadána jeho URL.");
    1515      return false;
    1616    }
    17     if(iconURL == null || iconURL == ""){
     17    if (iconURL == null || iconURL == ""){
    1818      alert(msg + "nebyla zadána URL ikony.");
    1919      return false;
    2020    }
    21     if(engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1){
     21    if (engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1){
    2222      alert(msg + "nebyla zadána platná URL.");
    2323      return false;
    2424    }
    25     if(iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1){
     25    if (iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1){
    2626      alert(msg + " nebyla platná URL ikony.");
    2727      return false;
    2828    }
    29     if(suggestedTitle == null) suggestedTitle = "";
    30     if(suggestedCategory == null) suggestedCategory = "";
     29    if (suggestedTitle == null) suggestedTitle = "";
     30    if (suggestedCategory == null) suggestedCategory = "";
    3131    window.sidebar.addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory);
    3232  }else{
  • trunk/Modules/NetworkShare/online.php

    r790 r873  
    33//$Database->select_db('share');
    44echo("\n====================== Kontrola online pocitacu ============================\n\n");
    5 //while(true)
     5//while (true)
    66{
    77  echo('Nacitam strom sdileni...');
     
    1313  array_shift($Output);
    1414  $Online = array();    // Seznam online pocitacu
    15   foreach($Output as $Radek)
     15  foreach ($Output as $Radek)
    1616  {
    17     if(ord($Radek[0])!=9) continue;
     17    if (ord($Radek[0])!=9) continue;
    1818    $Host = explode(' ',substr($Radek,3));
    1919    $Host = $Host[0];
     
    2121    $Section = 0;
    2222    // Zjisti IP a MAC adresu
    23     if($Host=='CENTRALA')
     23    if ($Host=='CENTRALA')
    2424    {
    2525      $MAC = '00:E0:4C:20:64:22';
     
    2727      $Section = 0;
    2828    } else
    29     if($Host=='CENTRALA2')
     29    if ($Host=='CENTRALA2')
    3030    {
    3131      $MAC = '00:E0:4C:20:64:22';
     
    3838      //echo('arping -c 1 '.$Host);
    3939      exec('arping -c 1 '.$Host,$Output);
    40       if(count($Output)!=4)
     40      if (count($Output)!=4)
    4141      {
    4242        $Output = array();
    4343        exec('arping -I wlan0 -c 1 '.$Host,$Output);
    44         if(count($Output)!=4)
     44        if (count($Output)!=4)
    4545        {
    4646          $Output = array();
    4747          exec('arping -I wlan1 -c 1 '.$Host,$Output);
    48           if(count($Output)!=4)
     48          if (count($Output)!=4)
    4949          {
    5050            $Output = array();
    5151            exec('arping -I wlan2 -c 1 '.$Host,$Output);
    52             if(count($Output)!=4)
     52            if (count($Output)!=4)
    5353            {
    5454              $Output = array();
    5555              exec('arping -I eth2 -c 1 '.$Host,$Output);
    56               if(count($Output)!=4) continue;
     56              if (count($Output)!=4) continue;
    5757              else $Section = 4;
    5858            } else $Section = 3;
     
    7474  //print_r($Online);
    7575  // Aktivuj online pocitace
    76   foreach($Online as $Item)
     76  foreach ($Online as $Item)
    7777  {
    7878    $DbResult = $Database->query("SELECT * FROM hosts WHERE name='".$Item['host']."'");
    79     if($DbResult->num_rows > 0)
     79    if ($DbResult->num_rows > 0)
    8080    {
    8181      $Database->update('hosts',"name='".$Item['host']."'",array( 'IP' => $Item['IP'], 'MAC' => $Item['MAC'], 'online' => 1, 'lastdate' => 'NOW()', 'section' => $Section));
     
    8585  echo("\nSeznam offline pocitacu:\n");
    8686  $DbResult = $Database->query("SELECT * FROM hosts WHERE online=0");
    87   while($Row = $DbResult->fetch_array())
     87  while ($Row = $DbResult->fetch_array())
    8888  {
    8989    echo($Row['name'].", ");
  • trunk/Modules/NetworkShare/playlist.php

    r790 r873  
    66$Vyber = '';
    77$Podminka = '';
    8 while($Row = $DbResult->fetch_array())
     8while ($Row = $DbResult->fetch_array())
    99  $Vyber .= $Row['id'].',';
    1010$Podminka .= ' AND (host IN ('.substr($Vyber,0,-1).'))';
     
    2525  $Cesta = ''; //$Row['name'];
    2626  $i = 0;
    27   while(($Otec>1)&&($i<$MaxNesting))
     27  while (($Otec>1)&&($i<$MaxNesting))
    2828  {
    2929    $DbResult = $Database->query("SELECT id,name,parent FROM items WHERE id=$Otec");
     
    3333    $i++;
    3434  }
    35   if($i >= $MaxNesting) $Cesta = '?'.'\\'.$Cesta;
    36   return('\\\\'.$Cesta);
     35  if ($i >= $MaxNesting) $Cesta = '?'.'\\'.$Cesta;
     36  return ('\\\\'.$Cesta);
    3737}
    3838
     
    4040{
    4141  //$FileInfo = new finfo(FILEINFO_MIME);
    42   //return($FileInfo->file($FileName));
    43   return('');
     42  //return ($FileInfo->file($FileName));
     43  return ('');
    4444}
    4545
     
    5151$Dir = '';
    5252$DbResult = $Database->select('items', '*', 'ext="mp3"'.$Podminka); //.' LIMIT 0,1000');
    53 while($Row = $DbResult->fetch_array())
     53while ($Row = $DbResult->fetch_array())
    5454{
    55   if($Parent != $Row['parent']) $Dir = PlnaCesta($Row); //echo('d'.PlnaCesta($Row)."\n");
     55  if ($Parent != $Row['parent']) $Dir = PlnaCesta($Row); //echo('d'.PlnaCesta($Row)."\n");
    5656  $Parent = $Row['parent'];
    5757  echo($Dir.$Row['name'].'.'.$Row['ext']."\n");
  • trunk/Modules/NetworkShare/update.php

    r790 r873  
    44
    55$Dnes = date('Y-m-d');
    6 //while(1)
     6//while (1)
    77//{
    88  $Hosts = array();
    99  $StartTime = GetMicrotime();
    1010  $DbResult = $Database->query("SELECT * FROM NetworkDevice WHERE Online=1 AND (Block=0 OR Name='centrala') AND (Name!='GATE') AND User>0");
    11   while($Row = $DbResult->fetch_array())
     11  while ($Row = $DbResult->fetch_array())
    1212  {
    1313    //echo('Host: '.$Host."...\n");
     
    1616    $HostID = 100;
    1717    $StartTime2 = GetMicrotime();
    18     if($Dnes != $Row['last_share_check'])
     18    if ($Dnes != $Row['last_share_check'])
    1919    {
    2020      echo("Kontroluji ".$Row['Name']."...\n");
  • trunk/Modules/NetworkTopology/NetworkTopology.php

    r738 r873  
    1010  function Show()
    1111  {
    12     if(count($this->System->PathItems) > 1)
     12    if (count($this->System->PathItems) > 1)
    1313    {
    14       if($this->System->PathItems[1] == 'topologie.png') return($this->ShowImage());
    15         else return(PAGE_NOT_FOUND);
     14      if ($this->System->PathItems[1] == 'topologie.png') return ($this->ShowImage());
     15        else return (PAGE_NOT_FOUND);
    1616
    17     } else return($this->ShowOverview());
     17    } else return ($this->ShowOverview());
    1818  }
    1919
     
    2323    $this->FormatHTML = false;
    2424
    25     if(array_key_exists('debug', $_GET)) $debug = $_GET['debug'];
     25    if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];
    2626      else $debug = 0;
    2727
     
    5454      'FROM NetworkTopology LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkTopology.Host '.
    5555      'LEFT JOIN NetworkDeviceType ON NetworkDevice.Type = NetworkDeviceType.Id');
    56     while($item = $DbResult->fetch_array())
     56    while ($item = $DbResult->fetch_array())
    5757    {
    5858      $id = $item['Id'];
     
    6262      $vlast = $item['Last'];
    6363      $xpos = $vleft * $spacex;
    64       if(($vtop > 0) or ($item['Name'] == $this->TopHostName))
     64      if (($vtop > 0) or ($item['Name'] == $this->TopHostName))
    6565      {
    66         if($vtop > 0) imageline($im, $xpos + $halfx, $vtop * $spacey, $xpos + $halfx, $vtop * $spacey + 8, $black);
    67         if($vfirst >= 0)
     66        if ($vtop > 0) imageline($im, $xpos + $halfx, $vtop * $spacey, $xpos + $halfx, $vtop * $spacey + 8, $black);
     67        if ($vfirst >= 0)
    6868        {
    6969          imageline($im, $vfirst*$spacex + $halfx, $vtop * $spacey + $spacey, $vlast*$spacex + $halfx, $vtop * $spacey + $spacey, $black);
     
    7171        }
    7272        //    $ip = explode('.',$item['IP']);
    73         //    if(!array_key_exists(3, $ip)) $ip[3] = '';
    74         if($item['IconName'] == 'comp')
     73        //    if (!array_key_exists(3, $ip)) $ip[3] = '';
     74        if ($item['IconName'] == 'comp')
    7575        {
    76           if($item['Online'] == 1) $color = $green;
     76          if ($item['Online'] == 1) $color = $green;
    7777          else $color = $black;
    7878          $image = $im_comp;
    7979        } else $image = $im_dev;
    80         if($item['IconName'] == 'device')
     80        if ($item['IconName'] == 'device')
    8181        {
    82           if($item['Online'] == 1) $color = $green;
     82          if ($item['Online'] == 1) $color = $green;
    8383          else $color = $red;
    8484          $image = $im_dev;
    8585        }
    86         if($item['ShowOnline'] == 0)
     86        if ($item['ShowOnline'] == 0)
    8787        {
    8888          $color = $gray;
     
    100100
    101101    // === Sestavení výsledného souboru ============================================
    102     if($debug == 0)
     102    if ($debug == 0)
    103103    {
    104104      Header("Content-type: image/png");
     
    109109      imagedestroy($im_dev);
    110110    }
    111     return('');
     111    return ('');
    112112  }
    113113
     
    126126zařízení, které jsou přes něj připojeny. U zařízení, kde není stav možné
    127127zjišťovat je použita <span style="color:gray">šedá barvou</span>.</p>';
    128     return($Output);
     128    return ($Output);
    129129  }
    130130}
  • trunk/Modules/NetworkTopology/topologie-gen.php

    r548 r873  
    66global $Database, $debug;
    77
    8 if(array_key_exists('debug', $_GET)) $debug = $_GET['debug'];
     8if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];
    99else $debug = 0;
    1010//$debug = 0;
     
    110110        $markskip = 0;
    111111      }
    112     } while($level >= 1);
     112    } while ($level >= 1);
    113113  }
    114114
     
    128128      $Database->query("INSERT INTO NetworkTopology (Host, Depth, Pos, First, Last) '.
    129129        'VALUES (".$node->index.','.$node->level.','.$this->calc_pos($node).','.$first.','.$last.");");
    130       foreach($node->children as $key => $value) {
     130      foreach ($node->children as $key => $value) {
    131131        $this->store_node($value);
    132132      }
     
    149149        $this->setborder($node->level, $this->border[$node->level+1]+1);
    150150      }
    151       foreach($node->children as $key => $value) {
     151      foreach ($node->children as $key => $value) {
    152152        if ($key == count($node->children)-1) {
    153           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     153          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    154154        }
    155155        $this->left_align($value);
    156156        if ($key == 0) {
    157           if($this->border[$node->level] <= $this->border[$node->level+1]) {
     157          if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    158158            $node->pos = $this->border[$node->level+1]-1;
    159159            $this->setborder($node->level, $this->border[$node->level+1]);
     
    174174        $this->setborder($node->level, $this->border[$node->level+1]+1);
    175175      }
    176       for($key=count($node->children)-1;$key>=0;$key--) {
     176      for ($key=count($node->children)-1;$key>=0;$key--) {
    177177        $value = $node->children[$key];
    178178        if ((count($value->children)>0) && count($node->order)>0) {
     
    180180        }
    181181        if ($key == 0) {
    182           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     182          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    183183        }
    184184        $this->right_align($value);
    185185        if ($key == count($node->children)-1) {
    186           if($this->border[$node->level] <= $this->border[$node->level+1]) {
     186          if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    187187            $node->rpos = $this->border[$node->level+1]-1;
    188188            $this->setborder($node->level, $this->border[$node->level+1]);
     
    196196  /** Reset construction border **/
    197197  function reset_border() {
    198     foreach($this->border as $key => $value) $this->border[$key] = 0;
     198    foreach ($this->border as $key => $value) $this->border[$key] = 0;
    199199    $this->maxborder = 0;
    200200  }
     
    214214      $target = 0; // Index cílového uzlu
    215215      $lastindex = 0; // Index poslední vydličky
    216       foreach($node->children as $key => $value) {
     216      foreach ($node->children as $key => $value) {
    217217        if (count($value->children)>0) {
    218218          array_push($forkmap,$value);
     
    221221        }
    222222      }
    223       for($i=0;$i<$node->forkcnt-1;$i++) {
    224         for($j=0;$j<count($forkmap);$j++) {
     223      for ($i=0;$i<$node->forkcnt-1;$i++) {
     224        for ($j=0;$j<count($forkmap);$j++) {
    225225          $this->border = $preborder;
    226226          $this->maxborder = $premax;
    227227          $k = 0; // index zpracovávané vydličky
    228           foreach($node->children as $key => $value) {
     228          foreach ($node->children as $key => $value) {
    229229            if (count($value->children)>0) {
    230230              if ($order[$value->index]) {
     
    241241            }
    242242            if ($key == count($node->children)-1) {
    243               if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     243              if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    244244            }
    245245            $this->left_align($value);
    246246            if ($key == 0) {
    247               if($this->border[$node->level] <= $this->border[$node->level+1]) {
     247              if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    248248                $node->pos = $this->border[$node->level+1]-1;
    249249                $this->setborder($node->level, $this->border[$node->level+1]);
     
    272272        $this->setborder($node->level, $this->border[$node->level+1]+1);
    273273      }
    274       foreach($node->children as $key => $value) {
     274      foreach ($node->children as $key => $value) {
    275275        if ((count($value->children)>0) && count($order)>0) {
    276276          $value = $order[$value->index];
    277277        }
    278278        if ($key == count($node->children)-1) {
    279           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     279          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    280280        }
    281281        $this->reorder($value);
    282282        if ($key == 0) {
    283           if($this->border[$node->level] <= $this->border[$node->level+1]) {
     283          if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    284284            $node->pos = $this->border[$node->level+1]-1;
    285285            $this->setborder($node->level, $this->border[$node->level+1]);
     
    301301      }
    302302      $forkcnt = 0; // Fork counter
    303       foreach($node->children as $key => $value) {
     303      foreach ($node->children as $key => $value) {
    304304        if ($forkcnt == count($node->children)-1) {
    305           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     305          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    306306        }
    307307        if (count($value->children)>0) {
    308308          $this->left_stub($value);
    309309          if ($forkcnt == 0) {
    310             if($this->border[$node->level] <= $this->border[$node->level+1]) {
     310            if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    311311              $node->pos = $this->border[$node->level+1]-1;
    312312              $this->setborder($node->level, $this->border[$node->level+1]);
     
    335335      $lastindex = 0; // Index poslední vydličky
    336336      $fact = 1; // Faktoriál kombinací vydliček
    337       foreach($node->children as $key => $value) {
     337      foreach ($node->children as $key => $value) {
    338338        if (count($value->children)>0) {
    339339          if ($key>0) $fact = $fact * ($key+1);
     
    343343        }
    344344      }
    345       for($i=0;$i<$node->forkcnt-1;$i++) {
    346         for($j=0;$j<count($forkmap);$j++) {
     345      for ($i=0;$i<$node->forkcnt-1;$i++) {
     346        for ($j=0;$j<count($forkmap);$j++) {
    347347          $this->border = $preborder;
    348348          $this->maxborder = $premax;
    349349          $k = 0; // index zpracovávané vydličky
    350           foreach($node->children as $key => $value) {
     350          foreach ($node->children as $key => $value) {
    351351            if (count($value->children)>0) {
    352352              if ($order[$value->index]) {
     
    363363            }
    364364            if ($key == count($node->children)-1) {
    365               if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     365              if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    366366            }
    367367            $this->left_align($value);
    368368            if ($key == 0) {
    369               if($this->border[$node->level] <= $this->border[$node->level+1]) {
     369              if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    370370                $node->pos = $this->border[$node->level+1]-1;
    371371                $this->setborder($node->level, $this->border[$node->level+1]);
     
    395395        $this->setborder($node->level, $this->border[$node->level+1]+1);
    396396      }
    397       foreach($node->children as $key => $value) {
     397      foreach ($node->children as $key => $value) {
    398398        if ((count($value->children)>0) && count($order)>0) {
    399399          $value = $order[$value->index];
    400400        }
    401401        if ($key == count($node->children)-1) {
    402           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     402          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    403403        }
    404404        $this->reorder($value);
    405405        if ($key == 0) {
    406           if($this->border[$node->level] <= $this->border[$node->level+1]) {
     406          if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    407407            $node->pos = $this->border[$node->level+1]-1;
    408408            $this->setborder($node->level, $this->border[$node->level+1]);
  • trunk/Modules/NetworkTopology/topologie-img.php

    r738 r873  
    33include('../global.php');
    44
    5 if(array_key_exists('debug', $_GET)) $debug = $_GET['debug'];
     5if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];
    66else $debug = 0;
    77$TopHostName = 'nix-router';
     
    1313  global $debug, $bbound;
    1414
    15   if(!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;
    16   if($i = $vfirst[$id])
     15  if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;
     16  if ($i = $vfirst[$id])
    1717  {
    1818    //if ($debug==2) echo $id.':'.@$i.','.@$vpred[$i].'-'.@$vleft[@$vpred[$i]]."\n";
     
    3737      $vleft[$i]+=$diff;
    3838      $limit = balance($i,$level+1, $vlast,$vleft,$vpred, $vfirst,$vnext,$tbound, $width, $limit) + 2;
    39       if(!array_key_exists($i, $vnext)) $vnext[$i] = 0;
     39      if (!array_key_exists($i, $vnext)) $vnext[$i] = 0;
    4040      $i = $vnext[$i];
    4141    }
     
    9191    $item = $DbResult->fetch_array();
    9292    //print_r($item);
    93     if($item)
     93    if ($item)
    9494    {
    9595  // --- Zpracování položky z DB -----------------------------------------------
    96       if($position[$level] > 0)
     96      if ($position[$level] > 0)
    9797      {
    9898        $vnext[$curr] = $item['id']; // Neprvní položka, nastav předchozí
     
    103103      $vlast[$parent[$level]] = $curr;
    104104      $vtop[$curr] = $level;
    105       if(!array_key_exists($level, $tbound)) $tbound[$level] = 0;
     105      if (!array_key_exists($level, $tbound)) $tbound[$level] = 0;
    106106      $vleft[$curr] = $tbound[$level];
    107       if(!array_key_exists($level, $tranger)) $tranger[$level] = 0;
     107      if (!array_key_exists($level, $tranger)) $tranger[$level] = 0;
    108108      $vpred[$curr] = $tranger[$level];
    109109      $tranger[$level] = $curr;
     
    117117      {
    118118        // Uzelový vrchol
    119         if(array_key_exists($level + 1, $tbound))
    120           if($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1];
     119        if (array_key_exists($level + 1, $tbound))
     120          if ($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1];
    121121      }
    122122      $tbound[$level] = $vleft[$curr] + 2;
     
    133133    {
    134134  // --- Zarovnávání prvků kvůli vzhledu
    135       if(!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0;
    136       if(!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0;
     135      if (!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0;
     136      if (!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0;
    137137      if ($vleft[$vfirst[$parent[$level]]] > $vleft[$parent[$level]])
    138138      {
     
    146146      }
    147147      $level--;
    148       if(!array_key_exists($level, $parent)) $parent[$level] = 0;
    149       if(!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0;
     148      if (!array_key_exists($level, $parent)) $parent[$level] = 0;
     149      if (!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0;
    150150      $curr = $vlast[$parent[$level]];
    151151
    152       if(!array_key_exists($level, $tbound)) $tbound[$level] = 0;
    153       if(!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0;
    154       if($tbound[$level] > $tbound[$level + 1]) $tbound[$level + 1] = $tbound[$level];
    155     }
    156   } while($level >= 0);
     152      if (!array_key_exists($level, $tbound)) $tbound[$level] = 0;
     153      if (!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0;
     154      if ($tbound[$level] > $tbound[$level + 1]) $tbound[$level + 1] = $tbound[$level];
     155    }
     156  } while ($level >= 0);
    157157  $data = compact('tbound', 'count', 'tbound', 'vfirst', 'vlast', 'vtop', 'vleft', 'height', 'width', 'index', 'maxindex');
    158   return($data);
     158  return ($data);
    159159};
    160160
     
    164164$data = gentree(1);
    165165$datawidth = $data['width'];
    166 for($i = 0; $i <= $maxindex; $i++)
    167 {
    168   if(!array_key_exists($i, $vleft)) $vleft[$i] = 0;
    169   if(!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0;
     166for ($i = 0; $i <= $maxindex; $i++)
     167{
     168  if (!array_key_exists($i, $vleft)) $vleft[$i] = 0;
     169  if (!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0;
    170170  $vleft[$i] = .2 + ($vleft[$i] + ($datawidth - $data['vleft'][$i])) / 2;
    171171}
     
    179179$IconList = array();
    180180$DbResult = $Database->query('SELECT * FROM HostType');
    181 while($HostType = $DbResult->fetch_assoc())
     181while ($HostType = $DbResult->fetch_assoc())
    182182  $IconList[$HostType['Id']] = imagecreatefrompng('images/'.$HostType['IconName'].'.png');
    183183
     
    194194{
    195195  global $vleft, $spacex;
    196   return($vleft[$id] * $spacex);
     196  return ($vleft[$id] * $spacex);
    197197}
    198198
    199199$DbResult = $Database->query('SELECT * FROM hosts JOIN HostType ON HostType.Id = hosts.type WHERE hosts.used=1');
    200 while($item = $DbResult->fetch_array())
     200while ($item = $DbResult->fetch_array())
    201201{
    202202  $id = $item['id'];
    203   if(!array_key_exists($id, $vtop)) $vtop[$id] = 0;
    204   if(($vtop[$id] > 0) || ($item['name'] == $TopHostName))
     203  if (!array_key_exists($id, $vtop)) $vtop[$id] = 0;
     204  if (($vtop[$id] > 0) || ($item['name'] == $TopHostName))
    205205  {
    206     if($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black);
    207     if(!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;
    208     if($vfirst[$id] > 0)
     206    if ($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black);
     207    if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;
     208    if ($vfirst[$id] > 0)
    209209    {
    210210      imageline($im, xpos($vfirst[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, xpos($vlast[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, $black);
     
    213213
    214214    $image = $IconList[$item['type']];
    215     if($item['IP'] == '')
     215    if ($item['IP'] == '')
    216216    {
    217217      $color = $gray;
    218218    } else
    219     if($item['ShowOnline'] == 1)
    220     {
    221       if($item['online'] == 1) $color = $green; else $color = $black;
    222     } else
    223     {
    224       if($item['online'] == 1) $color = $green; else $color = $red;
     219    if ($item['ShowOnline'] == 1)
     220    {
     221      if ($item['online'] == 1) $color = $green; else $color = $black;
     222    } else
     223    {
     224      if ($item['online'] == 1) $color = $green; else $color = $red;
    225225    }
    226226//      $text='IP: '.$ip[0];
     
    228228    imagecopy($im, $image, xpos($id) + $halfx - 15, $vtop[$id] * $spacey + 12, 0, 0, 30, 30);
    229229//    imagerectangle($im,xpos($id)+$halfx-6,$vtop[$id]*$spacey+16,xpos($id)+$halfx+6,$vtop[$id]*$spacey+28,$color);
    230     if($debug)
     230    if ($debug)
    231231    {
    232232      imagestring($im, 2, xpos($id) + ($spacex - strlen($item['id']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), $item['id'], $color);
     
    237237
    238238// === Sestavení výsledného souboru ============================================
    239 if(!($debug > 1))
     239if (!($debug > 1))
    240240{
    241241  header('Content-type: image/png');
  • trunk/Modules/NetworkTopology/topologie2.php

    r858 r873  
    2929    $Hosts = array();
    3030    $DbResult = $Database->select('hosts', 'id, name, ip, parent, online', 'used=1');
    31     while($DbRow = $DbResult->fetch_array())
     31    while ($DbRow = $DbResult->fetch_array())
    3232    {
    33       if(!array_key_exists($DbRow['id'], $Hosts)) $Hosts[$DbRow['id']] = array('subitems' => array());
     33      if (!array_key_exists($DbRow['id'], $Hosts)) $Hosts[$DbRow['id']] = array('subitems' => array());
    3434      $Hosts[$DbRow['id']] = array('id' => $DbRow['id'], 'name' => $DbRow['name'], 'parent' => $DbRow['parent'], 'online' => $DbRow['online'], 'subitems' => $Hosts[$DbRow['id']]['subitems']);
    35       if(!array_key_exists($DbRow['parent'], $Hosts)) $Hosts[$DbRow['parent']] = array('subitems' => array());
     35      if (!array_key_exists($DbRow['parent'], $Hosts)) $Hosts[$DbRow['parent']] = array('subitems' => array());
    3636      $Hosts[$DbRow['parent']]['subitems'][] = &$Hosts[$DbRow['id']];
    3737      $Hosts[$DbRow['id']]['parent_node'] = &$Hosts[$DbRow['parent']];
     
    4444  {
    4545    $Result = array('min' => $Host['displacement'], 'max' => $Host['displacement']);
    46     foreach($Host['subitems'] as $Index => $SubHost)
     46    foreach ($Host['subitems'] as $Index => $SubHost)
    4747    {
    4848      $SubitemResult = $this->CalculateDimension($Host['subitems'][$Index]);
     
    5050      $Result['max'] = max($SubitemResult['max'], $Result['max']);
    5151    }
    52     return($Result);
     52    return ($Result);
    5353  }
    5454
    5555  function CalculateDisplacement(&$Host, $Level = 0)
    5656  {
    57     if(!array_key_exists('displacement', $Host)) $Host['displacement'] = 0;
     57    if (!array_key_exists('displacement', $Host)) $Host['displacement'] = 0;
    5858    $Host['level'] = $Level;
    59     foreach($Host['subitems'] as $Index => $SubHost)
     59    foreach ($Host['subitems'] as $Index => $SubHost)
    6060    {
    6161      $Host['subitems'][$Index]['rel_displacement'] = (-(count($Host['subitems']) - 1) * 0.5 + $Index) * $this->HostWidth;
     
    6868  {
    6969    $Host['displacement'] = $Host['displacement'] + $Displacement;
    70     foreach($Host['subitems'] as $Index => $SubHost)
     70    foreach ($Host['subitems'] as $Index => $SubHost)
    7171    {
    7272      $this->MoveNode($Host['subitems'][$Index], $Displacement);
     
    7676  function CheckColision()
    7777  {
    78     foreach($this->Levels as $Index => $Level)
     78    foreach ($this->Levels as $Index => $Level)
    7979    {
    80       for($I = 0; $I < count($Level) - 1; $I++)
    81         if($Level[$I]['displacement'] >= $Level[$I + 1]['displacement'])
     80      for ($I = 0; $I < count($Level) - 1; $I++)
     81        if ($Level[$I]['displacement'] >= $Level[$I + 1]['displacement'])
    8282        {
    8383          // Search for common parent
    8484          $LeftHost = $Level[$I];
    8585          $RightHost = $Level[$I + 1];
    86           while(($LeftHost['level'] > 0) and ($LeftHost['parent'] != $RightHost['parent']))
     86          while (($LeftHost['level'] > 0) and ($LeftHost['parent'] != $RightHost['parent']))
    8787          {
    8888            $LeftHost = $LeftHost['parent_node'];
     
    9191          $Host = $RightHost['parent_node']['subitems'][0];
    9292          $II = 0;
    93           while($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++;
    94           while($II < count($RightHost['parent_node']['subitems']))
     93          while ($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++;
     94          while ($II < count($RightHost['parent_node']['subitems']))
    9595          {
    9696            $this->MoveNode($RightHost['parent_node']['subitems'][$II], $Level[$I]['displacement'] - $Level[$I + 1]['displacement']);
     
    104104  {
    105105    $this->Levels[$Host['level']][] = &$Host;
    106     foreach($Host['subitems'] as $Index => $SubHost)
     106    foreach ($Host['subitems'] as $Index => $SubHost)
    107107    {
    108108      $this->BuildLevels($Host['subitems'][$Index]);
     
    113113  {
    114114    $ParentHostPos = array('x' => -$this->RelPos['min'] + $Host['displacement'], 'y' => $Host['level'] * $this->HostHeight);
    115     foreach($Host['subitems'] as $Index => $SubHost)
     115    foreach ($Host['subitems'] as $Index => $SubHost)
    116116    {
    117117      $HostPos = array('x' => -$this->RelPos['min'] + $SubHost['displacement'], 'y' => $SubHost['level'] * $this->HostHeight);
  • trunk/Modules/News/ImportKinoVatra.php

    r790 r873  
    1616$doc = new DOMDocument();
    1717$doc->load($SourceURL);
    18 foreach($doc->getElementsByTagName('item') as $node)
     18foreach ($doc->getElementsByTagName('item') as $node)
    1919{
    2020  $Title = $node->getElementsByTagName('title')->item(0)->nodeValue;
     
    2626  $Description = str_replace("\r", '', $Description);
    2727  $Description = str_replace("\n", '<br>', $Description);
    28   //if(($CommaPos = strpos($Date, ',')) !== FALSE)
     28  //if (($CommaPos = strpos($Date, ',')) !== FALSE)
    2929  //  $Date = substr($Date, $CommaPos + 1);
    3030  $Date = TimeToMysqlDateTime(strtotime($Date));
     
    3232  $Query = 'SELECT Id FROM News WHERE (`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")';
    3333  $DbResult = $System->Database->query($Query);
    34   if($DbResult->num_rows == 0)
     34  if ($DbResult->num_rows == 0)
    3535  {
    3636    $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/ImportObecHovezi.php

    r827 r873  
    1616$doc = new DOMDocument();
    1717@$doc->load($SourceURL);
    18 foreach($doc->getElementsByTagName('item') as $node)
     18foreach ($doc->getElementsByTagName('item') as $node)
    1919{
    2020  $Title = $node->getElementsByTagName('title')->item(0)->nodeValue;
     
    2626  $Description = str_replace("\r", '', $Description);
    2727  $Description = str_replace("\n", '<br>', $Description);
    28   //if(($CommaPos = strpos($Date, ',')) !== FALSE)
     28  //if (($CommaPos = strpos($Date, ',')) !== FALSE)
    2929  //  $Date = substr($Date, $CommaPos + 1);
    3030  $Date = TimeToMysqlDateTime(strtotime($Date));
     
    3333  $DbResult = $System->Database->select('News', 'Id', '(`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")');
    3434  //echo($System->Database->LastQuery);
    35   if($DbResult->num_rows == 0)
     35  if ($DbResult->num_rows == 0)
    3636  {
    3737    $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
     
    4444//$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250'));
    4545$Content = file_get_contents($SourceURL);
    46 while(strpos($Content, $StartText) !== false)
     46while (strpos($Content, $StartText) !== false)
    4747{
    4848  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
     
    7474  $DbResult = $System->Database->select('News', 'Id', '(`Title`="'.$Title.'") AND (`Category`='.$Category.') AND (`Content` = "'.$Description.'") AND (`Link` = "'.$Link.'")');
    7575  //echo($System->Database->LastQuery);
    76   if($DbResult->num_rows == 0)
     76  if ($DbResult->num_rows == 0)
    7777  {
    7878    $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/ImportTvBeskyd.php

    r827 r873  
    1717//$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250'));
    1818$Content = @file_get_contents($SourceURL);
    19 while(strpos($Content, $StartText) !== false)
     19while (strpos($Content, $StartText) !== false)
    2020{
    2121  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
     
    3737  $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Category`='.$Category);
    3838  //echo($System->Database->LastQuery);
    39   if($DbResult->num_rows == 0)
     39  if ($DbResult->num_rows == 0)
    4040  {
    4141    $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/ImportZdechovCzNews.php

    r827 r873  
    1616$Author = 'Automat';
    1717$Content = @file_get_contents($SourceURL);
    18 while(strpos($Content, $StartText) !== false)
     18while (strpos($Content, $StartText) !== false)
    1919{
    2020  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
     
    2525  $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink));
    2626  $Link = substr($Content, 0, strpos($Content, '"'));
    27   if(substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
     27  if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
    2828  $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle));
    2929  $Title = substr($Content, 0, strpos($Content, '<'));
     
    4040  $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category);
    4141  //echo($System->Database->LastQuery);
    42   if($DbResult->num_rows == 0)
     42  if ($DbResult->num_rows == 0)
    4343  {
    4444    $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/ImportZdechovCzRecords.php

    r827 r873  
    1616$Author = 'Automat';
    1717$Content = @file_get_contents($SourceURL);
    18 while(strpos($Content, $StartText) !== false)
     18while (strpos($Content, $StartText) !== false)
    1919{
    2020  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
     
    2222  $Date = substr($Content, 0, strpos($Content, '<'));
    2323  $DateParts = explode('.', $Date);
    24   if(count($DateParts) >= 3)
     24  if (count($DateParts) >= 3)
    2525    $Date = $DateParts[2].'-'.$DateParts[1].'-'.$DateParts[0];
    2626      else break;
    2727  $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink));
    2828  $Link = substr($Content, 0, strpos($Content, '"'));
    29   if(substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
     29  if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
    3030  $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle));
    3131  $Title = substr($Content, 0, strpos($Content, '<'));
     
    4242  $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category);
    4343  //echo($System->Database->LastQuery);
    44   if($DbResult->num_rows == 0)
     44  if ($DbResult->num_rows == 0)
    4545  {
    4646    $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/News.php

    r790 r873  
    55function CategoryItemCompare($Item1, $Item2)
    66{
    7   if ($Item1['Index'] == $Item2['Index']) return(0);
     7  if ($Item1['Index'] == $Item2['Index']) return (0);
    88  return ($Item1['Index'] > $Item2['Index']) ? -1 : 1;
    99}
     
    8181    ));
    8282
    83     if($this->System->ModuleManager->ModulePresent('Search'))
     83    if ($this->System->ModuleManager->ModulePresent('Search'))
    8484    {
    8585      $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content'));
     
    9595    $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption'];
    9696    $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>';
    97     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))
     97    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))
    9898      $Output .= ' <a href="aktuality/?action=add&amp;category='.$Category.'">Přidat</a>';
    9999    $Output .= '</div></div><div class="Content">';
     
    102102    $Index = 0;
    103103    $FontSize = 12;
    104     if($DbResult->num_rows > 0)
     104    if ($DbResult->num_rows > 0)
    105105    {
    106106      $Output .= '<table class="NewsTable">';
    107       while($Row = $DbResult->fetch_array())
    108       {
    109         if($Row['Name'] == '') $Author = $Row['Author'];
     107      while ($Row = $DbResult->fetch_array())
     108      {
     109        if ($Row['Name'] == '') $Author = $Row['Author'];
    110110          else $Author = $Row['Name'];
    111111        $Output .= '<tr><td onclick="window.location=\'aktuality/?action=view&amp;id='.$Row['Id'].
     
    114114          '<td align="right" style="font-size: '.$FontSize.'pt">'.$Author.' ('.HumanDate($Row['Date']).')</td></tr></table>';
    115115        $Output .= '<div id="new'.$Category.$Index.'" class="NewsTableItem">'.$this->ModifyContent($Row['Content']);
    116         if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    117 
    118         if($Row['Enclosure'] != '')
     116        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
     117
     118        if ($Row['Enclosure'] != '')
    119119        {
    120120          $Output .= '<br />Přílohy: ';
    121121          $Enclosures = explode(';', $Row['Enclosure']);
    122           foreach($Enclosures as $Enclosure)
     122          foreach ($Enclosures as $Enclosure)
    123123          {
    124             if(file_exists($this->UploadedFilesFolder.$Enclosure))
     124            if (file_exists($this->UploadedFilesFolder.$Enclosure))
    125125              $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>';
    126126          }
     
    133133    }
    134134    $Output .= '</div></div>';
    135     return($Output);
     135    return ($Output);
    136136  }
    137137
     
    142142    $I = 1;
    143143    $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY Sequence');
    144     while($NewsCategory = $DbResult->fetch_array())
     144    while ($NewsCategory = $DbResult->fetch_array())
    145145    {
    146146      $this->NewsSetting[] = array('CategoryId' => $NewsCategory['Id'], 'Index' => $I, 'Enabled' => 1,
     
    149149    }
    150150    // Merge defaults with user setting
    151     if(array_key_exists('NewsSetting', $_COOKIE))
     151    if (array_key_exists('NewsSetting', $_COOKIE))
    152152    {
    153153      $NewsSettingCookie = unserialize($_COOKIE['NewsSetting']);
    154       foreach($this->NewsSetting as $Index => $this->NewSetting)
    155       {
    156         if(array_key_exists($Index, $NewsSettingCookie))
     154      foreach ($this->NewsSetting as $Index => $this->NewSetting)
     155      {
     156        if (array_key_exists($Index, $NewsSettingCookie))
    157157          $this->NewsSetting[$Index] = array_merge($this->NewSetting, $NewsSettingCookie[$Index]);
    158158      }
     
    166166    $this->LoadSettingsFromCookies();
    167167
    168     if(array_key_exists('Action', $_GET))
     168    if (array_key_exists('Action', $_GET))
    169169    {
    170170      // Show news customize menu
    171       if($_GET['Action'] == 'CustomizeNews')
     171      if ($_GET['Action'] == 'CustomizeNews')
    172172      {
    173173        $Output .= $this->ShowCustomizeMenu();
     
    179179    $ColumnCount = 2;
    180180    $Output .= '<table style="width: 100%"><tr>';
    181     for($Column = 1; $Column <= $ColumnCount; $Column++)
     181    for ($Column = 1; $Column <= $ColumnCount; $Column++)
    182182    {
    183183      $Output .= '<td style="vertical-align: top; width: '.round(100 / $ColumnCount).'%;">';
    184       foreach($this->NewsSetting as $SettingItem)
    185         if(($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column))
     184      foreach ($this->NewsSetting as $SettingItem)
     185        if (($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column))
    186186          $Output .= $this->ShowNews($SettingItem['CategoryId'], $SettingItem['ItemCount'], $SettingItem['DaysAgo']);
    187187      $Output .= '</td>';
     
    191191    $Output .= '<a href="aktuality/subscription"><img class="RSSIcon" src="images/rss20.png" alt="Aktuality přes RSS" /></a>  <a href="aktuality/subscription">Automatické sledování novinek</a>';
    192192    $Output .= '</div>';
    193     return($Output);
     193    return ($Output);
    194194  }
    195195
     
    200200    $Output .= '<tr><th>Kategorie</th><th>Pozice</th><th>Zobrazit</th><th>Max. počet</th><th>Posledních dnů</th><th>Sloupec</th></tr>';
    201201    $I = 0;
    202     foreach($this->NewsSetting as $SettingItem)
     202    foreach ($this->NewsSetting as $SettingItem)
    203203    {
    204204      $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$SettingItem['CategoryId']);
    205205      $NewsCategory = $DbResult->fetch_array();
    206206      $Output .= '<tr><td>'.$NewsCategory['Caption'].'</td><td align="center"><input type="text" size="2" name="NewsCategoryIndex'.$I.'" value="'.$SettingItem['Index'].'" /></td><td align="center"><input type="checkbox" name="NewsCategoryEnabled'.$I.'"';
    207       if($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"';
     207      if ($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"';
    208208      $Output .= ' /></td>'.
    209209      '<td align="center"><input type="text" size="2" name="NewsCategoryCount'.$I.'" value="'.$SettingItem['ItemCount'].'" />'.
     
    214214    }
    215215    $Output .= '</table><input type="hidden" name="NewsCategoryCount" value="'.count($this->NewsSetting).'" /><input type="submit" value="Uložit" /></form></td></tr></table><br>';
    216     return($Output);
     216    return ($Output);
    217217  }
    218218
     
    221221    $Checkbox = array('' => 0, 'on' => 1);
    222222    $Setting = array();
    223     for($I = 0; $I < $_POST['NewsCategoryCount']; $I++)
    224     {
    225       if(($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0;
    226       if(($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0;
    227       if(($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1;
    228       if(!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = '';
     223    for ($I = 0; $I < $_POST['NewsCategoryCount']; $I++)
     224    {
     225      if (($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0;
     226      if (($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0;
     227      if (($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1;
     228      if (!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = '';
    229229      $Setting[] = array('CategoryId' => $_POST['NewsCategoryId'.$I], 'Enabled' => $Checkbox[$_POST['NewsCategoryEnabled'.$I]], 'ItemCount' => ($_POST['NewsCategoryCount'.$I]*1), 'DaysAgo' => ($_POST['NewsCategoryDaysAgo'.$I]*1), 'Index' => ($_POST['NewsCategoryIndex'.$I]*1),
    230230      'Group' => $_POST['NewsColumn'.$I]);
     
    234234    $Setting = array_reverse($Setting);
    235235    // Normalize indexes
    236     foreach($Setting as $Index => $Item)
     236    foreach ($Setting as $Index => $Item)
    237237      $Setting[$Index]['Index'] = $Index + 1;
    238238
     
    248248    // Make HTML link from URL
    249249    $I = 0;
    250     while(strpos($Content, 'http://') !== false)
     250    while (strpos($Content, 'http://') !== false)
    251251    {
    252252      $I = strpos($Content, 'http://');
    253       if(($I > 0) and ($Content{$I - 1} != '"'))
     253      if (($I > 0) and ($Content{$I - 1} != '"'))
    254254      {
    255255        $Result .= substr($Content, 0, $I);
    256256        $Content = substr($Content, $I);
    257         if(strpos($Content, ' ') !== false)
     257        if (strpos($Content, ' ') !== false)
    258258          $URL = substr($Content, 0, strpos($Content, ' '));
    259259        else $URL = substr($Content, 0);
     
    267267    }
    268268    $Result .= $Content;
    269     return($Result);
     269    return ($Result);
    270270  }
    271271}
  • trunk/Modules/News/NewsPage.php

    r839 r873  
    1111  {
    1212    $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder;
    13     if(count($this->System->PathItems) > 1)
    14     {
    15       if($this->System->PathItems[1] == 'subscription') return($this->ShowSubscription());
    16         else if($this->System->PathItems[1] == 'rss') return($this->ShowRSS());
    17         else return(PAGE_NOT_FOUND);
    18     } else return($this->ShowMain());
     13    if (count($this->System->PathItems) > 1)
     14    {
     15      if ($this->System->PathItems[1] == 'subscription') return ($this->ShowSubscription());
     16        else if ($this->System->PathItems[1] == 'rss') return ($this->ShowRSS());
     17        else return (PAGE_NOT_FOUND);
     18    } else return ($this->ShowMain());
    1919  }
    2020
     
    2222  {
    2323    $Output = '';
    24     if(!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
     24    if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
    2525    else
    2626    {
    2727      $Category = $this->GetCategory();
    28       if(array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;
     28      if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;
    2929      $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
    3030        'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id);
    31       if($DbResult->num_rows > 0)
     31      if ($DbResult->num_rows > 0)
    3232      {
    3333        $Row = $DbResult->fetch_array();
    34         if($Row['Name'] == '') $Author = $Row['Author'];
     34        if ($Row['Name'] == '') $Author = $Row['Author'];
    3535          else $Author = $Row['Name'];
    3636        $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')';
    37         if(($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
     37        if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
    3838        {
    3939          $Output .= '<div class="Action">';
     
    4343        }
    4444        $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';
    45         if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    46         if($Row['Enclosure'] != '')
     45        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
     46        if ($Row['Enclosure'] != '')
    4747        {
    4848          $Output .= '<br />Přílohy: ';
    4949          $Enclosures = explode(';', $Row['Enclosure']);
    50           foreach($Enclosures as $Enclosure)
     50          foreach ($Enclosures as $Enclosure)
    5151          {
    52             if(file_exists($this->UploadedFilesFolder.$Enclosure))
     52            if (file_exists($this->UploadedFilesFolder.$Enclosure))
    5353              $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    5454          }
     
    5757      } else $Output .= 'Položka nenalezena.';
    5858    }
    59     return($Output);
     59    return ($Output);
    6060  }
    6161
     
    6464    $Output = '';
    6565    $Category = $this->GetCategory();
    66     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     66    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    6767    {
    6868      $this->System->PageHeaders[] = array($this, 'GetPageHeader');
    6969      $Output = '<strong>Vložení nové aktuality:</strong><br />';
    7070      // TODO: Static reference to dynamic category item
    71       if($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.';
     71      if ($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.';
    7272      $Output .= '<form enctype="multipart/form-data" action="?action=add2" method="post">'.
    7373        'Kategorie: <select name="category">';
    7474      $DbResult = $this->Database->select('NewsCategory', '*');
    75       while($DbRow = $DbResult->fetch_array())
    76       {
    77         if($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
    78         {
    79           if($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';
     75      while ($DbRow = $DbResult->fetch_array())
     76      {
     77        if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
     78        {
     79          if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';
    8080            else $Selected = '';
    8181          $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>';
     
    9393        '</form>';
    9494    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    95     return($Output);
     95    return ($Output);
    9696  }
    9797
     
    101101    $RemoteAddr = GetRemoteAddress();
    102102    $Category = $this->GetCategory();
    103     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     103    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    104104    {
    105105      // Process uploaded file
     
    107107      $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3');
    108108      $Enclosures = '';
    109       foreach($EnclosureFileNames as $EnclosureName)
    110         if(array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))
     109      foreach ($EnclosureFileNames as $EnclosureName)
     110        if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))
    111111        {
    112112          $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);
    113           if(move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
     113          if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
    114114          {
    115115            $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' byl uložen na serveru.<br />';
     
    130130        $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id);
    131131    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    132     return($Output);
     132    return ($Output);
    133133  }
    134134
    135135  function GetPageHeader()
    136136  {
    137     return('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.
     137    return ('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.
    138138        "<script>tinymce.init({
    139139  selector: 'textarea',
     
    156156    $Output = '';
    157157    $Category = $this->GetCategory();
    158     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     158    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    159159    {
    160160      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
    161161      $Row = $DbResult->fetch_array();
    162       if(($this->System->User->User['Id'] == $Row['User']))
     162      if (($this->System->User->User['Id'] == $Row['User']))
    163163      {
    164164        $this->System->PageHeaders[] = array($this, 'GetPageHeader');
     
    174174      } else $Output .= 'Nepovolená operace!';
    175175    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    176     return($Output);
     176    return ($Output);
    177177  }
    178178
     
    182182    $RemoteAddr = GetRemoteAddress();
    183183    $Category = $this->GetCategory();
    184     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     184    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    185185    {
    186186      $_POST['id'] = $_POST['id'] * 1;
    187187      $DbResult = $this->Database->select('News', '*', '`Id`='.$_POST['id']);
    188       if($DbResult->num_rows > 0)
     188      if ($DbResult->num_rows > 0)
    189189      {
    190190        $Row = $DbResult->fetch_array();
    191         if($this->System->User->User['Id'] == $Row['User'])
     191        if ($this->System->User->User['Id'] == $Row['User'])
    192192        {
    193193          $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'],
     
    198198      } else $Output .= 'ID nenalezeno!';
    199199    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    200     return($Output);
     200    return ($Output);
    201201  }
    202202
     
    205205    $Output = '';
    206206    $Category = $this->GetCategory();
    207     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     207    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    208208    {
    209209      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
    210210      $Row = $DbResult->fetch_array();
    211       if($this->System->User->User['Id'] == $Row['User'])
     211      if ($this->System->User->User['Id'] == $Row['User'])
    212212      {
    213213        // TODO: Make upload using general File class
    214         if($Row['Enclosure'] != '')
     214        if ($Row['Enclosure'] != '')
    215215        {
    216216          $Output .= '<br />Přílohy: ';
    217217          $Enclosures = explode(';', $Row['Enclosure']);
    218           foreach($Enclosures as $Enclosure)
     218          foreach ($Enclosures as $Enclosure)
    219219          {
    220             if(file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);
     220            if (file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);
    221221          }
    222222        }
     
    225225      } else $Output .= 'Nemáte oprávnění.';
    226226    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    227     return($Output);
     227    return ($Output);
    228228  }
    229229
     
    232232    $Output = '';
    233233    $Category = $this->GetCategory();
    234     if($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id']))
     234    if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id']))
    235235    {
    236236      $PerPage = 20;
     
    238238      $RowTotal = $DbResult->fetch_array();
    239239      $PageMax = $RowTotal[0];
    240       if(array_key_exists('page', $_GET)) $Page = $_GET['page'];
     240      if (array_key_exists('page', $_GET)) $Page = $_GET['page'];
    241241        else $Page = 0; //round($PageMax/$PerPage);
    242242      $Output .= '<strong>Seznam aktualit kategorie '.$Category['Caption'].':</strong><div style="font-size: small;">';
     
    245245      $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
    246246        'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage);
    247       while($Row = $DbResult->fetch_array())
    248       {
    249         if($Row['Name'] == '') $Author = $Row['Author'];
     247      while ($Row = $DbResult->fetch_array())
     248      {
     249        if ($Row['Name'] == '') $Author = $Row['Author'];
    250250          else $Author = $Row['Name'];
    251251        $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&amp;id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')';
    252         if(($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
     252        if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
    253253        {
    254254          $Output .= '<div class="Action">';
     
    258258        }
    259259        $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';
    260         if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    261         if($Row['Enclosure'] != '')
     260        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
     261        if ($Row['Enclosure'] != '')
    262262        {
    263263          $Output .= '<br />Přílohy: ';
    264264          $Enclosures = explode(';', $Row['Enclosure']);
    265           foreach($Enclosures as $Enclosure)
     265          foreach ($Enclosures as $Enclosure)
    266266          {
    267             if(file_exists($this->UploadedFilesFolder.$Enclosure))
     267            if (file_exists($this->UploadedFilesFolder.$Enclosure))
    268268              $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    269269          }
     
    274274      $Output .= '</div>';
    275275    } else $Output .= 'Nemáte oprávnění.';
    276     return($Output);
     276    return ($Output);
    277277  }
    278278
     
    280280  {
    281281    $Category = array('Id' => 1); // Default category
    282     if(array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1;
    283     if(array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1;
    284     //if(is_null($Category)) throw new Exception('Kategorie neurčena');
     282    if (array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1;
     283    if (array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1;
     284    //if (is_null($Category)) throw new Exception('Kategorie neurčena');
    285285    else
    286286    {
    287287      $DbResult = $this->Database->select('NewsCategory', '*', '`Id`='.$Category['Id'].' ORDER BY `Sequence`');
    288       if($DbResult->num_rows > 0) $Category = $DbResult->fetch_array();
     288      if ($DbResult->num_rows > 0) $Category = $DbResult->fetch_array();
    289289        else $Category = array('Id' => 0); //throw new Exception('Kategorie nenalezena');
    290290    }
    291     return($Category);
     291    return ($Category);
    292292  }
    293293
     
    295295  {
    296296    $Output = '';
    297     if(array_key_exists('action',$_GET)) $Action = $_GET['action'];
     297    if (array_key_exists('action',$_GET)) $Action = $_GET['action'];
    298298      else $Action = '';
    299     if($Action == 'view') $Output .= $this->ShowView();
    300     else if($Action == 'add') $Output .= $this->ShowAdd();
    301     else if($Action == 'add2') $Output .= $this->ShowAdd2();
    302     else if($Action == 'edit') $Output .= $this->ShowEdit();
    303     else if($Action == 'update') $Output .= $this->ShowUpdate();
    304     else if($Action == 'del') $Output .= $this->ShowDelete();
     299    if ($Action == 'view') $Output .= $this->ShowView();
     300    else if ($Action == 'add') $Output .= $this->ShowAdd();
     301    else if ($Action == 'add2') $Output .= $this->ShowAdd2();
     302    else if ($Action == 'edit') $Output .= $this->ShowEdit();
     303    else if ($Action == 'update') $Output .= $this->ShowUpdate();
     304    else if ($Action == 'del') $Output .= $this->ShowDelete();
    305305    else $Output .= $this->ShowList();
    306     return($Output);
     306    return ($Output);
    307307  }
    308308
    309309  function ShowSubscription()
    310310  {
    311     if(array_key_exists('build', $_GET))
     311    if (array_key_exists('build', $_GET))
    312312    {
    313313      $Select = '';
    314       foreach($_POST as $Index => $Item)
    315       {
    316         if(substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8);
     314      foreach ($_POST as $Index => $Item)
     315      {
     316        if (substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8);
    317317      }
    318318      $Select = $this->System->Config['Web']['RootFolder'].'/aktuality/rss/?select='.substr($Select, 1);
     
    324324      $Output .= '<form action="?build=1" method="post">';
    325325      $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY `Caption`');
    326       while($Category = $DbResult->fetch_array())
     326      while ($Category = $DbResult->fetch_array())
    327327      {
    328328        $Output .= '<input type="checkbox" name="category'.$Category['Id'].'" />'.$Category['Caption'].'<br />';
     
    331331        '</form>';
    332332    }
    333     return($Output);
     333    return ($Output);
    334334  }
    335335
     
    349349
    350350    // Prepare WHERE condition
    351     if(array_key_exists('select', $_GET))
     351    if (array_key_exists('select', $_GET))
    352352    {
    353353      $Where = '';
    354354      $Parts = explode('-', $_GET['select']);
    355       foreach($Parts as $Part)
     355      foreach ($Parts as $Part)
    356356      {
    357357        $Where .= 'OR (`Category`='.($Part * 1).')';
     
    363363    $Categories = array();
    364364    $DbResult = $this->Database->select('NewsCategory', '*');
    365     while($Category = $DbResult->fetch_array())
     365    while ($Category = $DbResult->fetch_array())
    366366    {
    367367      $Categories[$Category['Id']] = $Category['Caption'];
     
    375375    $Index = 0;
    376376    //echo(DB_NumRows().',');
    377     while($Row = $DbResult->fetch_array())
     377    while ($Row = $DbResult->fetch_array())
    378378    {
    379379      $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
     
    390390      //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
    391391      $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
    392       if($DbResult2->num_rows == 0) //echo('.'); else echo('x');
     392      if ($DbResult2->num_rows == 0) //echo('.'); else echo('x');
    393393        $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));
    394394        //echo($Date);
     
    400400    // Get news from database by selected categories
    401401    $DbResult = $this->Database->query('SELECT *, UNIX_TIMESTAMP(`Date`) AS `UnixTime` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE '.$Where.' ORDER BY News.Date DESC LIMIT 0,'.$NewsCount);
    402     while($Row = $DbResult->fetch_assoc())
     402    while ($Row = $DbResult->fetch_assoc())
    403403    {
    404404      $EnclosuresText = '';
    405       if($Row['Enclosure'] != '')
     405      if ($Row['Enclosure'] != '')
    406406      {
    407407        $EnclosuresText .= '<br />Přílohy: ';
    408408        $Enclosures = explode(';', $Row['Enclosure']);
    409         foreach($Enclosures as $Enclosure)
    410         {
    411           if(file_exists($this->UploadedFilesFolder.$Enclosure))
     409        foreach ($Enclosures as $Enclosure)
     410        {
     411          if (file_exists($this->UploadedFilesFolder.$Enclosure))
    412412            $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    413413        }
    414414      }
    415       if($Row['Name'] == '') $Author = $Row['Author'];
     415      if ($Row['Name'] == '') $Author = $Row['Author'];
    416416        else $Author = $Row['Name'];
    417417      $Items[] = array(
     
    429429    $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail'];
    430430    $RSS->Items = $Items;
    431     return($RSS->Generate());
     431    return ($RSS->Generate());
    432432  }
    433433}
  • trunk/Modules/Notify/Notify.php

    r868 r873  
    4646  function RegisterCheck($Name, $Callback)
    4747  {
    48     if(array_key_exists($Name, $this->Checks))
     48    if (array_key_exists($Name, $this->Checks))
    4949      throw new Exception('Check function "'.$Name.'" already registered.');
    5050    $this->Checks[$Name] = array('Callback' => $Callback);
     
    5353  function UnregisterCheck($Name)
    5454  {
    55     if(!array_key_exists($Name, $this->Checks))
     55    if (!array_key_exists($Name, $this->Checks))
    5656      throw new Exception('Check function "'.$Name.'" not registered.');
    5757    unset($this->Checks[$Name]);
     
    8888      'LEFT JOIN `User` ON `User`.`Id` = `NotifyUser`.`User` '.
    8989      'LEFT JOIN `Contact` ON `Contact`.`Id` = `NotifyUser`.`Contact`');
    90     while($User = $DbResult->fetch_assoc())
     90    while ($User = $DbResult->fetch_assoc())
    9191    {
    9292      $Output .= 'User '.$User['Name'].'<br/>';
     
    9494      $this->Database->update('NotifyUser', '`Id`='.$User['Id'], array('LastTime' => TimeToMysqlDateTime($Time)));
    9595
    96       if(($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content != ''))
     96      if (($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content != ''))
    9797      {
    9898        $Mail = new Mail();
     
    120120    }
    121121
    122     return($Output);
     122    return ($Output);
    123123  }
    124124
     
    178178      ' ORDER BY `Time` DESC LIMIT '.$Count;
    179179    $DbResult = $this->System->Database->query($sql);
    180     while($Line = $DbResult->fetch_assoc())
     180    while ($Line = $DbResult->fetch_assoc())
    181181    {
    182182      $Items[] = array
     
    195195    $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail'];
    196196    $RSS->Items = $Items;
    197     return($RSS->Generate());
     197    return ($RSS->Generate());
    198198  }
    199199}
  • trunk/Modules/OpeningHours/OpeningHours.php

    r738 r873  
    1515    $Hours = floor($Time / 60);
    1616    $Minutes = $Time - $Hours * 60;
    17     if($Minutes < 10) $Minutes = '0'.$Minutes;
     17    if ($Minutes < 10) $Minutes = '0'.$Minutes;
    1818    $Hours = $Hours % 24;
    19     return($Hours.':'.$Minutes);
     19    return ($Hours.':'.$Minutes);
    2020  }
    2121
     
    2828    $Minutes = $Time;
    2929    $Output = '';
    30     if($Days > 0) $Output .= $Days.' dnů, ';
    31     if($Hours > 0) $Output .= $Hours.' hodin, ';
    32     if($Minutes > 0) $Output .= $Minutes.' minut';
    33     return($Output);
     30    if ($Days > 0) $Output .= $Days.' dnů, ';
     31    if ($Hours > 0) $Output .= $Hours.' hodin, ';
     32    if ($Minutes > 0) $Output .= $Minutes.' minut';
     33    return ($Output);
    3434  }
    3535
    3636  function EditSubject($Id)
    3737  {
    38     if($this->System->User->CheckPermission('OpeningHours', 'Edit'))
     38    if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))
    3939    {
    4040      $Output = '<div class="Centred">';
     
    4646      $Day = array();
    4747      $DbResult = $this->Database->query('SELECT * FROM SubjectOpenTimeDay WHERE Subject = '.$Id);
    48       while($DbRow = $DbResult->fetch_assoc())
     48      while ($DbRow = $DbResult->fetch_assoc())
    4949        $Day[$DbRow['Day']] = $DbRow;
    50       foreach($this->DaysOfWeek as $Index => $Name)
    51       {
    52         if(!array_key_exists($Index, $Day)) $Day[$Index] = array('Open1' => 0, 'Close1' => 0, 'Open2' => 0, 'Close2' => 0);
     50      foreach ($this->DaysOfWeek as $Index => $Name)
     51      {
     52        if (!array_key_exists($Index, $Day)) $Day[$Index] = array('Open1' => 0, 'Close1' => 0, 'Open2' => 0, 'Close2' => 0);
    5353        $Output .= '<tr><td>'.$Name.'</td>'.
    5454          '<td><input type="text" name="day'.$Index.'_open1_h" value="'.floor($Day[$Index]['Open1'] / 60).'" size="2" />'.
     
    7070      '</form></div>';
    7171    } else $Output = 'Nemáte oprávnění';
    72     return($Output);
     72    return ($Output);
    7373  }
    7474
     
    7878
    7979    $Output = '';
    80     if($this->System->User->CheckPermission('OpeningHours', 'Edit'))
     80    if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))
    8181    {
    8282      $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id);
    83       foreach($this->DaysOfWeek as $Index => $Name)
    84       {
    85         if($_POST['day'.$Index.'_open1_h'] > 24) $_POST['day'.$Index.'_open1_h'] = 24;
    86         if($_POST['day'.$Index.'_close1_h'] > 24) $_POST['day'.$Index.'_close1_h'] = 24;
    87         if($_POST['day'.$Index.'_open2_h'] > 24) $_POST['day'.$Index.'_open2_h'] = 24;
    88         if($_POST['day'.$Index.'_close2_h'] > 24) $_POST['day'.$Index.'_close2_h'] = 24;
    89         if($_POST['day'.$Index.'_open1_m'] > 59) $_POST['day'.$Index.'_open1_m'] = 59;
    90         if($_POST['day'.$Index.'_close1_m'] > 59) $_POST['day'.$Index.'_close1_m'] = 59;
    91         if($_POST['day'.$Index.'_open2_m'] > 59) $_POST['day'.$Index.'_open2_m'] = 59;
    92         if($_POST['day'.$Index.'_close2_m'] > 59) $_POST['day'.$Index.'_close2_m'] = 59;
     83      foreach ($this->DaysOfWeek as $Index => $Name)
     84      {
     85        if ($_POST['day'.$Index.'_open1_h'] > 24) $_POST['day'.$Index.'_open1_h'] = 24;
     86        if ($_POST['day'.$Index.'_close1_h'] > 24) $_POST['day'.$Index.'_close1_h'] = 24;
     87        if ($_POST['day'.$Index.'_open2_h'] > 24) $_POST['day'.$Index.'_open2_h'] = 24;
     88        if ($_POST['day'.$Index.'_close2_h'] > 24) $_POST['day'.$Index.'_close2_h'] = 24;
     89        if ($_POST['day'.$Index.'_open1_m'] > 59) $_POST['day'.$Index.'_open1_m'] = 59;
     90        if ($_POST['day'.$Index.'_close1_m'] > 59) $_POST['day'.$Index.'_close1_m'] = 59;
     91        if ($_POST['day'.$Index.'_open2_m'] > 59) $_POST['day'.$Index.'_open2_m'] = 59;
     92        if ($_POST['day'.$Index.'_close2_m'] > 59) $_POST['day'.$Index.'_close2_m'] = 59;
    9393        $Day = array('Subject' => $Id, 'Day' => $Index);
    9494        $Day['Open1'] = $_POST['day'.$Index.'_open1_m'] + $_POST['day'.$Index.'_open1_h'] * 60;
     
    111111      $this->Database->update('SubjectOpenTime', 'Subject='.$Id, array('UpdateTime' => 'NOW()', 'Notice' => $_POST['notice'], 'Photo' => $FileId));
    112112    } else $Output = 'Nemáte oprávnění';
    113     return($Output);
     113    return ($Output);
    114114  }
    115115
     
    118118    $Output = '<div class="Centred">';
    119119    $DbResult = $this->Database->query('SELECT SubjectOpenTime.*, DATE_FORMAT(SubjectOpenTime.UpdateTime, "%e.%c.%Y") as UpdateTime, Subject.Id, Subject.Name as Name FROM SubjectOpenTime JOIN Subject ON Subject.Id = SubjectOpenTime.Subject ORDER BY Name');
    120     while($Subject = $DbResult->fetch_assoc())
     120    while ($Subject = $DbResult->fetch_assoc())
    121121    {
    122122      $Output .= '<strong>'.$Subject['Name'].':</strong><br />';
     
    125125      $Events = array();
    126126      $DbResult2 = $this->Database->query('SELECT * FROM `SubjectOpenTimeDay` WHERE Subject='.$Subject['Subject'].' ORDER BY Day ASC');
    127       while($DbRow = $DbResult2->fetch_assoc())
    128       {
    129         if(($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))
     127      while ($DbRow = $DbResult2->fetch_assoc())
     128      {
     129        if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))
    130130        {
    131131          $Events[] = array('Time' => $DbRow['Open1'] + $DbRow['Day'] * 24 * 60, 'Type' => 1);
    132132          $Events[] = array('Time' => $DbRow['Close1'] + $DbRow['Day'] * 24 * 60, 'Type' => 2);
    133133        }
    134         if(($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))
     134        if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))
    135135        {
    136136          $Events[] = array('Time' => $DbRow['Open2'] + $DbRow['Day'] * 24 * 60, 'Type' => 1);
     
    141141
    142142      // Calculate time to next event
    143       if(count($Events) > 0)
     143      if (count($Events) > 0)
    144144      {
    145145        $CurrentTime = ((date('w') + 6) % 7) * 24 * 60 + date('G') * 60 + date('i');
    146146
    147147        $I = 0;
    148         while(($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime))
     148        while (($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime))
    149149          $I++;
    150         if($I < count($Events))
     150        if ($I < count($Events))
    151151        {
    152152          $NextTime = $Events[$I]['Time'];
     
    160160        $TimeDelta = $NextTime - $CurrentTime;
    161161        //$Output .= $CurrentTime.' '.$NextTime;
    162         if($NextEventType == 2) $Output .= 'Zavírá za '.$this->ToHumanTime2($TimeDelta);
     162        if ($NextEventType == 2) $Output .= 'Zavírá za '.$this->ToHumanTime2($TimeDelta);
    163163          else $Output .= 'Otevírá za '.$this->ToHumanTime2($TimeDelta);
    164164      }
     
    166166      // Show time inteval table
    167167      $Output .= '<table class="WideTable"><tr><th>Den</th><th>Čas</th></tr>';
    168       foreach($this->DaysOfWeek as $DayIndex => $DayOfWeek)
     168      foreach ($this->DaysOfWeek as $DayIndex => $DayOfWeek)
    169169      {
    170170        $DbResult2 = $this->Database->query('SELECT * FROM SubjectOpenTimeDay WHERE Subject = '.$Subject['Subject'].' AND Day='.$DayIndex);
    171171        $Output .= '<tr><td>'.$DayOfWeek.'</td><td align="center">';
    172         if($DbResult2->num_rows)
     172        if ($DbResult2->num_rows)
    173173        {
    174174          $DbRow = $DbResult2->fetch_assoc();
    175           if(($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))
     175          if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))
    176176          {
    177177            $Output .= $this->ToHumanTime($DbRow['Open1']).' - '.$this->ToHumanTime($DbRow['Close1']).' &nbsp;&nbsp; ';
    178178          }
    179           if(($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))
     179          if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))
    180180          {
    181181            $Output .= $this->ToHumanTime($DbRow['Open2']).' - '.$this->ToHumanTime($DbRow['Close2']).'';
     
    186186      }
    187187      $Output .= '</table>Aktualizováno: '.$Subject['UpdateTime'].'<br />';
    188       if($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />';
    189 
    190       if($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> ';
    191 
    192       if($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
     188      if ($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />';
     189
     190      if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> ';
     191
     192      if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
    193193        $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />';
    194194      $Output .= '<br />';
    195195    }
    196196    $Output .= '</div>';
    197     return($Output);
     197    return ($Output);
    198198  }
    199199
    200200  function Show()
    201201  {
    202     if(count($this->System->PathItems) > 1)
    203     {
    204       if($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']);
    205       else if($this->System->PathItems[1] == 'save')
     202    if (count($this->System->PathItems) > 1)
     203    {
     204      if ($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']);
     205      else if ($this->System->PathItems[1] == 'save')
    206206      {
    207207        $Output = $this->SaveSubject($_GET['Subject']);
     
    209209      } else $Output = PAGE_NOT_FOUND;
    210210    } else $Output = $this->ShowAll();
    211     return($Output);
     211    return ($Output);
    212212  }
    213213}
  • trunk/Modules/Portal/Portal.php

    r860 r873  
    6060    $DbResult = $this->Database->query('SELECT `Id` FROM `Action` '.
    6161      'WHERE (`Action`.`Group`='.$ActionGroup['Id'].') AND (`Action`.`Enable` = 1)');
    62     while($Action = $DbResult->fetch_assoc())
     62    while ($Action = $DbResult->fetch_assoc())
    6363    {
    6464      $Output .= $this->System->ShowAction($Action['Id']).'<br/>';
    6565    }
    66     return($this->Panel($ActionGroup['Name'], $Output));
     66    return ($this->Panel($ActionGroup['Name'], $Output));
    6767  }
    6868
     
    9898    //$Output .= 'Server běží: '.$this->GetServerUptime().' &nbsp;  &nbsp; ';
    9999
    100     if($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
     100    if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
    101101    {
    102102      $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.$this->System->User->User['Id'].')');
    103       if($DbResult->num_rows > 0)
     103      if ($DbResult->num_rows > 0)
    104104      {
    105105        $DbRow = $DbResult->fetch_assoc();
     
    109109
    110110    $Output = '<div class="Navigation"><span class="MenuItem">'.$Output.'</span><div class="MenuItem2">&nbsp;'.$Output2.'</div></div>';
    111     return($Output);
     111    return ($Output);
    112112  }
    113113
     
    115115  {
    116116    $Output = '<a href="'.$this->System->Link('/user/?Action=UserOptions').'">Profil</a><br />';
    117     if($this->System->User->CheckPermission('Finance', 'MemberOptions'))
     117    if ($this->System->User->CheckPermission('Finance', 'MemberOptions'))
    118118      $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Fakturační adresa</a><br />';
    119     if($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
     119    if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
    120120      $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />';
    121     if($this->System->User->CheckPermission('Network', 'RegistredHostList'))
     121    if ($this->System->User->CheckPermission('Network', 'RegistredHostList'))
    122122      $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />';
    123     if($this->System->User->CheckPermission('News', 'Insert'))
     123    if ($this->System->User->CheckPermission('News', 'Insert'))
    124124      $Output .= '<a href="'.$this->System->Link('/aktuality/?action=add').'">Vložení aktuality</a><br />';
    125     if($this->System->User->CheckPermission('EatingPlace', 'Edit'))
     125    if ($this->System->User->CheckPermission('EatingPlace', 'Edit'))
    126126      $Output .= '<a href="'.$this->System->Link('/jidelna/menuedit.php').'">Úprava jídelníčků</a><br />';
    127     if($this->System->User->CheckPermission('Finance', 'Manage'))
     127    if ($this->System->User->CheckPermission('Finance', 'Manage'))
    128128      $Output .= '<a href="'.$this->System->Link('/finance/sprava/').'">Správa financí</a><br />';
    129     if($this->System->User->CheckPermission('IS', 'Manage'))
     129    if ($this->System->User->CheckPermission('IS', 'Manage'))
    130130      $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />';
    131     return($Output);
     131    return ($Output);
    132132  }
    133133
     
    135135  {
    136136    $Output = $this->System->ModuleManager->Modules['WebCam']->ShowImage();
    137     return($Output);
     137    return ($Output);
    138138  }
    139139
     
    141141  {
    142142    $Output = '<a href="https://stat.zdechov.net/meteo/?Measure=28" title="Klikněte pro detailní informace a předpověď"><img src="https://www.zdechov.net/meteo/koliba.png" border="0" alt="Počasí - Meteostanice Zděchov" width="150" height="150" /></a>';
    143     return($Output);
     143    return ($Output);
    144144  }
    145145
     
    150150      'LEFT JOIN `NetworkDeviceType` ON `NetworkDeviceType`.`Id` = `NetworkDevice`.`Type` '.
    151151      'WHERE (`NetworkDeviceType`.`ShowOnline` = 1) AND (`NetworkDevice`.`Online` = 1) ORDER BY `NetworkDevice`.`Name`');
    152     while($Device = $DbResult->fetch_array())
     152    while ($Device = $DbResult->fetch_array())
    153153    {
    154154      $Output .= $Device['Name'].'<br />';
    155155    }
    156156    $Output .= '</span>';
    157     return($Output);
     157    return ($Output);
    158158  }
    159159
     
    162162    $Output .= '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">';
    163163    $DbResult = $Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money');
    164     while($Row = $DbResult->fetch_array())
     164    while ($Row = $DbResult->fetch_array())
    165165    {
    166166      $Output .= $Row['Name'].'<br />';
    167167    }
    168168    $Output .= '</span>';
    169     return($Output);
     169    return ($Output);
    170170  }
    171171
    172172  function Panel($Title, $Content, $Menu = array())
    173173  {
    174     if(count($Menu) > 0)
    175       foreach($Menu as $Item)
     174    if (count($Menu) > 0)
     175      foreach ($Menu as $Item)
    176176        $Title .= '<div class="Action">'.$Item.'</div>';
    177     return('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');
     177    return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');
    178178  }
    179179
     
    181181  {
    182182    $Output = '';
    183     if(array_key_exists('Action', $_GET))
     183    if (array_key_exists('Action', $_GET))
    184184    {
    185185      $Action = $_GET['Action'];
    186       if($Action == 'CustomizeNewsSave')
     186      if ($Action == 'CustomizeNewsSave')
    187187      {
    188188        $Output .= $this->System->ModuleManager->Modules['News']->CustomizeSave();
    189189      } else
    190       if($Action == 'MemberOptions')
     190      if ($Action == 'MemberOptions')
    191191      {
    192192        $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '.
    193193          'WHERE `User`='.$this->System->User->User['Id']);
    194         while($CustomerUserRel = $DbResult->fetch_assoc())
     194        while ($CustomerUserRel = $DbResult->fetch_assoc())
    195195        {
    196196          $DbResult2 = $this->Database->query('SELECT `Member`.`Id`, '.
     
    202202          $Form->SetClass('MemberOptions');
    203203          $DbRow = $DbResult2->fetch_array();
    204           foreach($Form->Definition['Items'] as $Index => $Item)
     204          foreach ($Form->Definition['Items'] as $Index => $Item)
    205205          {
    206206            $Form->Values[$Index] = $DbRow[$Index];
     
    210210        }
    211211      } else
    212       if($Action == 'MemberOptionsSave')
     212      if ($Action == 'MemberOptionsSave')
    213213      {
    214214        $Form = new Form($this->System->FormManager);
    215215        $Form->SetClass('MemberOptions');
    216216        $Form->LoadValuesFromForm();
    217         if($Form->Values['FamilyMemberCount'] < 0)
     217        if ($Form->Values['FamilyMemberCount'] < 0)
    218218          $Form->Values['FamilyMemberCount'] = 0;
    219219
     
    235235          'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->User->User['Member']);
    236236        $DbRow = $DbResult->fetch_array();
    237         foreach($Form->Definition['Items'] as $Index => $Item)
     237        foreach ($Form->Definition['Items'] as $Index => $Item)
    238238        {
    239239          $Form->Values[$Index] = $DbRow[$Index];
     
    243243      }
    244244    } else $Output = $this->ShowMain();
    245     return($Output);
     245    return ($Output);
    246246  }
    247247
     
    250250    $Output = '';
    251251    $DbResult = $this->Database->query('SELECT * FROM `ActionGroup`');
    252     while($DbRow = $DbResult->fetch_assoc())
     252    while ($DbRow = $DbResult->fetch_assoc())
    253253      $ActionGroups[$DbRow['Id']] = $DbRow;
    254254
    255255    // Show pannels
    256     //if(IsInternetAddr()) echo('Internet'); else echo('LAN');
     256    //if (IsInternetAddr()) echo('Internet'); else echo('LAN');
    257257    //$Output .= $this->InfoBar();
    258258    $Output .= '<table id="MainTable"><tr>';
    259259    $DbResult = $this->Database->select('PanelColumn', '*');
    260     while($PanelColumn =  $DbResult->fetch_assoc())
    261     {
    262       if($PanelColumn != '') $Width = ' width="'.$PanelColumn['Width'].'"';
     260    while ($PanelColumn =  $DbResult->fetch_assoc())
     261    {
     262      if ($PanelColumn != '') $Width = ' width="'.$PanelColumn['Width'].'"';
    263263        else $Width = '';
    264264      $Output .= '<td valign="top"'.$Width.'>';
    265265      $DbResult2 = $this->Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`');
    266       while($Panel = $DbResult2->fetch_assoc())
    267       {
    268         if($Panel['Module'] == 'ActionGroup') $Output .= $this->ShowActions($ActionGroups[$Panel['Parameters']]);
    269         else if($Panel['Module'] == 'OnlineHostList') $Output .= $this->Panel('Online počítače', $this->OnlineHostList());
    270         else if($Panel['Module'] == 'UserOptions')
     266      while ($Panel = $DbResult2->fetch_assoc())
     267      {
     268        if ($Panel['Module'] == 'ActionGroup') $Output .= $this->ShowActions($ActionGroups[$Panel['Parameters']]);
     269        else if ($Panel['Module'] == 'OnlineHostList') $Output .= $this->Panel('Online počítače', $this->OnlineHostList());
     270        else if ($Panel['Module'] == 'UserOptions')
    271271        {
    272           //if($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
     272          //if ($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
    273273        } else
    274         if($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());
    275         if($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel());
    276         else if($Panel['Module'] == 'NewsGroupList')
     274        if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());
     275        if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel());
     276        else if ($Panel['Module'] == 'NewsGroupList')
    277277          $Output .= $this->Panel('Aktuality', $this->System->ModuleManager->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));
    278278      }
     
    280280    }
    281281    $Output .= '</tr></table>';
    282     return($Output);
     282    return ($Output);
    283283  }
    284284}
  • trunk/Modules/RSS/RSS.php

    r840 r873  
    2727    $this->RSSChannels[$Channel['Channel']] = $Channel;
    2828
    29     if(is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];
     29    if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];
    3030    else {
    3131      array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']);
     
    4242  {
    4343    $Output = '';
    44     foreach($this->RSSChannels as $Channel)
     44    foreach ($this->RSSChannels as $Channel)
    4545    {
    46       //if($this->System->User->Licence($Channel['Permission']))
     46      //if ($this->System->User->Licence($Channel['Permission']))
    4747        $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'.
    4848          $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />';
    4949    }
    50     return($Output);
     50    return ($Output);
    5151  }
    5252}
     
    5858    $this->ClearPage = true;
    5959
    60     if(array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];
     60    if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];
    6161      else $ChannelName = '';
    62     if(array_key_exists('token', $_GET)) $Token = $_GET['token'];
     62    if (array_key_exists('token', $_GET)) $Token = $_GET['token'];
    6363      else $Token = '';
    64     if(array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels))
     64    if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels))
    6565    {
    6666      $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName];
    67       if($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or
     67      if ($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or
    6868      $this->System->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token))
    6969      {
    70         if(is_string($Channel['Callback'][0]))
     70        if (is_string($Channel['Callback'][0]))
    7171        {
    7272          $Class = new $Channel['Callback'][0]($this->System);
     
    7676      } else $Output = 'Nemáte oprávnění';
    7777    } else $Output = 'Kanál nenalezen';
    78     return($Output);
     78    return ($Output);
    7979  }
    8080}
  • trunk/Modules/Scheduler/Scheduler.php

    r830 r873  
    6161  function Run($Parameters)
    6262  {
    63     while(true)
     63    while (true)
    6464    {
    6565      $DbResult = $this->Database->query('SELECT `Scheduler`.*, `SchedulerAction`.`Class` AS `Class` FROM `Scheduler` '.
     
    6868        '(`Scheduler`.`ScheduledTime` < "'.TimeToMysqlDateTime(time()).'") OR '.
    6969        '(`Scheduler`.`ScheduledTime` IS NULL))');
    70       while($DbRow = $DbResult->fetch_assoc())
     70      while ($DbRow = $DbResult->fetch_assoc())
    7171      {
    7272        echo('Executing '.$DbRow['Name']."\n");
    7373        $Output = '';
    7474        $StartTime = time();
    75         if(class_exists($DbRow['Class']))
     75        if (class_exists($DbRow['Class']))
    7676        {
    7777          $Class = new $DbRow['Class']($this->System);
     
    8888          array('Log' => $Output, 'LastExecutedTime' => TimeToMysqlDateTime($StartTime),
    8989            'Duration' => $Duration));
    90         if($DbRow['Period'] != '') {
    91           if($DbRow['ScheduledTime'] == '') $NewScheduledTime = $StartTime + $DbRow['Period'];
     90        if ($DbRow['Period'] != '') {
     91          if ($DbRow['ScheduledTime'] == '') $NewScheduledTime = $StartTime + $DbRow['Period'];
    9292            else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period'];
    93           if($NewScheduledTime < $StopTime) $NewScheduledTime = $StopTime + $DbRow['Period'];
     93          if ($NewScheduledTime < $StopTime) $NewScheduledTime = $StopTime + $DbRow['Period'];
    9494          $this->Database->update('Scheduler', 'Id='.$DbRow['Id'],
    9595            array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime)));
     
    115115  {
    116116    $Output = '#';
    117     return($Output);
     117    return ($Output);
    118118  }
    119119}
  • trunk/Modules/Search/Search.php

    r738 r873  
    1414  {
    1515    $Output = '';
    16     if(array_key_exists('t', $_GET)) $Text = $_GET['t'];
     16    if (array_key_exists('t', $_GET)) $Text = $_GET['t'];
    1717      else $Text = '';
    1818    $Output .= '<form action="?" method="get">'.
     
    2020    '<input type="submit" value="Hledat"/>'.
    2121    '</form>';
    22     if($Text != '')
    23     foreach($this->System->ModuleManager->Modules['Search']->Items as $Item)
     22    if ($Text != '')
     23    foreach ($this->System->ModuleManager->Modules['Search']->Items as $Item)
    2424    {
    2525      $Columns = '';
    2626      $Condition = '';
    27       foreach($Item['Columns'] as $Column)
     27      foreach ($Item['Columns'] as $Column)
    2828      {
    2929        $Columns .= ', `'.$Column.'`';
     
    3434      $DbResult = $this->Database->Select($Item['Table'], $Columns, $Condition.' LIMIT '.
    3535        $this->System->ModuleManager->Modules['Search']->MaxItemCount);
    36       if($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>';
    37       while($Row = $DbResult->fetch_assoc())
     36      if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>';
     37      while ($Row = $DbResult->fetch_assoc())
    3838      {
    3939        $Output .= '<p>';
    40         foreach($Item['Columns'] as $Column)
     40        foreach ($Item['Columns'] as $Column)
    4141          $Output .= $Row[$Column].'<br/>';
    4242        $Output .= '</p>';
    4343      }
    4444    }
    45     return($Output);
     45    return ($Output);
    4646  }
    4747}
  • trunk/Modules/SpeedTest/SpeedTest.php

    r738 r873  
    3939  function Show()
    4040  {
    41     if(count($this->System->PathItems) > 1)
     41    if (count($this->System->PathItems) > 1)
    4242    {
    43       if($this->System->PathItems[1] == 'download.php') return($this->ShowDownload());
    44       //else if($this->System->PathItems[1] == 'rss') return($this->ShowRSS());
    45       else return(PAGE_NOT_FOUND);
    46     } else return($this->ShowMain());
     43      if ($this->System->PathItems[1] == 'download.php') return ($this->ShowDownload());
     44      //else if ($this->System->PathItems[1] == 'rss') return ($this->ShowRSS());
     45      else return (PAGE_NOT_FOUND);
     46    } else return ($this->ShowMain());
    4747  }
    4848
     
    6262
    6363## Redirect immediately to download.php if auto_start = 1
    64 if($config->{'general'}->{'auto_start'}) {
     64if ($config->{'general'}->{'auto_start'}) {
    6565    Header("Location: ".$config['general']['base_url']."/download.php");
    6666    exit;
     
    7777<body>';
    7878
    79 if(file_exists("header.html")) {
     79if (file_exists("header.html")) {
    8080    ## Include "header.html" for a custom header, if the file exists
    8181    include("header.html");
     
    8686$Output .= '<div id="speedtest_content">';
    8787
    88 if(file_exists("welcome.html")) {
     88if (file_exists("welcome.html")) {
    8989    ## Include "welcome.html" for a custom welcome page, if the file exists
    9090    include("welcome.html");
     
    107107</div>';
    108108
    109 if(file_exists("footer.html")) {
     109if (file_exists("footer.html")) {
    110110    ## Include "footer.html" for a custom footer, if the file exists
    111111    include("footer.html");
     
    114114    print "</center>\n";
    115115}
    116     return($Output);
     116    return ($Output);
    117117  }
    118118}
  • trunk/Modules/SpeedTest/common.php

    r560 r873  
    1818    foreach ($lines as $line_num => $line) {
    1919        $line = rtrim(preg_replace("/#.*/","",$line));
    20         if(preg_match("/\[.*\]/", $line, $parts)) {
     20        if (preg_match("/\[.*\]/", $line, $parts)) {
    2121            $section = $parts[0];
    2222            $section = preg_replace("/[\[\]]/","",$section);
     
    3434function Debug($message) {
    3535    global $config;
    36     if($config->{'general'}->{'debug'}) {
     36    if ($config->{'general'}->{'debug'}) {
    3737        BCLog($message);
    3838    }
     
    4343    global $config;
    4444    $logfile = $config->{'general'}->{'logfile'};
    45     if(! $logfile) {
     45    if (! $logfile) {
    4646        return;
    4747    }
  • trunk/Modules/SpeedTest/download.php

    r738 r873  
    1919$disallow = $config->{'general'}->{'disallow'};
    2020$allow = $config->{'general'}->{'allow'};
    21 if( $allow && (! preg_match("/$allow/",$remote_addr)) ) {
     21if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) {
    2222    include("unallowed.html");
    2323    exit;
    24 } elseif( $disallow && preg_match("/$disallow/", $remote_addr) ) {
     24} elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) {
    2525    include("unallowed.html");
    2626    exit;
     
    3333## on initial results
    3434$config_auto_size = $config->{'general'}->{'auto_size'};
    35 if($config_auto_size) {
     35if ($config_auto_size) {
    3636    ## We're using the auto_size functionality
    37     if( isset($_GET['auto_size']) && $_GET['auto_size']) {
     37    if ( isset($_GET['auto_size']) && $_GET['auto_size']) {
    3838        ## Intial test is done.  Set down/upload sizes to the same as
    3939        ## our initial measured speeds.   That way the test should take
     
    5555
    5656## Make sure sizes are below our configured limits
    57 if($down_kbytes > $config->{'download'}->{'max_kbytes'}) {
     57if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) {
    5858    $down_kbytes = $config->{'download'}->{'max_kbytes'};
    5959}
    60 if($up_kbytes > $config->{'upload'}->{'max_kbytes'}) {
     60if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) {
    6161    $up_kbytes = $config->{'upload'}->{'max_kbytes'};
    6262}
    6363
    64 if($config->{'upload'}->{'skip_upload'}) {
     64if ($config->{'upload'}->{'skip_upload'}) {
    6565    $up_kbytes = 0;
    6666}
     
    9292
    9393<?php
    94 if(file_exists("header.html")) {
     94if (file_exists("header.html")) {
    9595    ## Include "header.html" for a custom header, if the file exists
    9696    include("header.html");
     
    103103
    104104<?php
    105 if( ($config_auto_size) && (! isset($_GET['auto_size'])) ) {
     105if ( ($config_auto_size) && (! isset($_GET['auto_size'])) ) {
    106106    ## auto_size is performing the initial, small test
    107107    print "<div>Calculating appropriate file sizes for testing</div>\n";
     
    137137</div>
    138138
    139 <?php if(file_exists("footer.html")) { include("footer.html"); } ?>
     139<?php if (file_exists("footer.html")) { include("footer.html"); } ?>
    140140
    141141<?php /* Begin JavaScript functions that we'll need */ ?>
     
    144144function StartUpload() {
    145145    uploadDiv = document.getElementById('upload_message');
    146     if(uploadDiv) {
     146    if (uploadDiv) {
    147147        uploadDiv.style.visibility='visible';
    148148        uploadDiv.style.display='block';
    149         <?php if($pretty_version) { ?>
     149        <?php if ($pretty_version) { ?>
    150150        setInterval("IncrementUploadBar()",200);
    151151        <?php } ?>
     
    158158function IncrementDownloadBar() {
    159159    download_barElement = document.getElementById('download_bar');
    160     if(download_barElement) {
     160    if (download_barElement) {
    161161        download_bar_current_width += <?php echo $download_progress_bar_increment; ?>;
    162         if(download_bar_current_width <= <?php echo $progress_bar_width; ?>) {
     162        if (download_bar_current_width <= <?php echo $progress_bar_width; ?>) {
    163163            download_barElement.style.width = download_bar_current_width +"px";
    164164        }
     
    176176function IncrementUploadBar() {
    177177    upload_barElement = document.getElementById('upload_bar');
    178     if(upload_barElement) {
     178    if (upload_barElement) {
    179179        upload_bar_current_width += <?php echo $upload_progress_bar_increment; ?>;
    180         if(upload_bar_current_width < <?php echo $progress_bar_width; ?>) {
     180        if (upload_bar_current_width < <?php echo $progress_bar_width; ?>) {
    181181            upload_barElement.style.width = upload_bar_current_width +"px";
    182182        }
     
    186186function CompleteDownloadBar() {
    187187    download_barElement = document.getElementById('download_bar');
    188     if(download_barElement) {
     188    if (download_barElement) {
    189189        download_barElement.style.width = "100%";
    190190    }
     
    209209<?php
    210210
    211 if($pretty_version) {
     211if ($pretty_version) {
    212212print "
    213213//-->
     
    225225    $extra_down_kbytes = $down_kbytes - $up_kbytes;
    226226    $total_kbytes = 0;
    227     while($total_kbytes <= $extra_down_kbytes) {
    228         if($pretty_version) {
     227    while ($total_kbytes <= $extra_down_kbytes) {
     228        if ($pretty_version) {
    229229        print "
    230230<script language=\"javascript\">
     
    240240        $total_kbytes += $each_chunk;
    241241    }
    242     if(!$pretty_version) {
     242    if (!$pretty_version) {
    243243        print "dataElement.value=\"$data\";";
    244244        print "CompleteDownloadBar();\n";
     
    254254    ## Now, download the remaining bytes ($up_kbytes)  and save it into a
    255255    ## form variable that we will post back to test the upload speed
    256     while($total_kbytes <= $down_kbytes) {
    257         if($pretty_version) {
     256    while ($total_kbytes <= $down_kbytes) {
     257        if ($pretty_version) {
    258258        print "
    259259<script language=\"javascript\">
     
    270270    }
    271271
    272     if(!$pretty_version) {
     272    if (!$pretty_version) {
    273273        #print "\";";
    274274    } else {
     
    288288      downloadtime = (endtime - starttime)/1000;
    289289  }
    290     <?php if(! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?>
     290    <?php if (! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?>
    291291
    292292  down_size = <?php echo $total_kbytes; ?>;
     
    297297
    298298<?php
    299 if($config_auto_size && (! isset($_GET['auto_size'])) ) {
     299if ($config_auto_size && (! isset($_GET['auto_size'])) ) {
    300300    $params_auto_size = "&auto_size=1";
    301301} else {
    302302    $params_auto_size = "";
    303303}
    304 if($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) {
     304if ($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) {
    305305    $next_url = $config->{'general'}->{'base_url'}."results.php";
    306306} else {
  • trunk/Modules/SpeedTest/results.php

    r786 r873  
    1616
    1717## Save the results of this speedtest to the database, if enabled
    18 if($config->{'database'}->{'enable'}) {
     18if ($config->{'database'}->{'enable'}) {
    1919    $ip_matches = $config->{'database'}->{'ip_matches'};
    20     if( (! $ip_matches) || ($ip_matches && preg_match("/$ip_matches/",$_SERVER['REMOTE_ADDR'])) ) {
     20    if ( (! $ip_matches) || ($ip_matches && preg_match("/$ip_matches/",$_SERVER['REMOTE_ADDR'])) ) {
    2121        Debug("Saving to database");
    2222        $dbh = mysql_connect(
     
    5757
    5858<?php
    59 if(file_exists("header.html")) {
     59if (file_exists("header.html")) {
    6060    ## Include "header.html" for a custom header, if the file exists
    6161    include("header.html");
     
    7575    print "<h2>Download Speed: $clean_down</h2>\n";
    7676    ## Find the biggest value
    77     foreach($config->{'comparisons-download'} as $key=>$value) {
    78         if($value > $download_biggest) {
     77    foreach ($config->{'comparisons-download'} as $key=>$value) {
     78        if ($value > $download_biggest) {
    7979            $download_biggest = $value;
    8080        }
     
    8282    ## Print a pretty table with a graph of the results
    8383    print "<center><table>\n";
    84     foreach($config->{'comparisons-download'} as $key=>$value) {
     84    foreach ($config->{'comparisons-download'} as $key=>$value) {
    8585        $this_bar_width = $bar_width / $download_biggest * $value;
    8686        print "<tr><td>$key</td><td>".CleanSpeed($value)."</td><td width=\"400\">\n";
     
    9797
    9898    ## Don't display the upload stuff if we didn't get a speed to compare with
    99     if(isset($_GET['upspeed'])) {
     99    if (isset($_GET['upspeed'])) {
    100100        $clean_up = CleanSpeed($_GET['upspeed']);
    101101        $upload_biggest = $_GET['upspeed'];
    102102        print "<h2>Upload Speed: $clean_up</h2>\n";
    103         foreach($config->{'comparisons-upload'} as $key=>$value) {
    104             if($value > $upload_biggest) {
     103        foreach ($config->{'comparisons-upload'} as $key=>$value) {
     104            if ($value > $upload_biggest) {
    105105                $upload_biggest = $value;
    106106            }
    107107        }
    108108        print "<table>\n";
    109         foreach($config->{'comparisons-upload'} as $key=>$value) {
     109        foreach ($config->{'comparisons-upload'} as $key=>$value) {
    110110            $this_bar_width = $bar_width / $upload_biggest * $value;
    111111            print "<tr><td>$key</td><td>".CleanSpeed($value)."</td>\n";
     
    128128</div>
    129129
    130 <?php if(file_exists("footer.html")) { include("footer.html"); } ?>
     130<?php if (file_exists("footer.html")) { include("footer.html"); } ?>
    131131
    132132</body>
     
    136136## Convert the raw speed value to a nicer value
    137137function CleanSpeed($kbps) {
    138     if($kbps > 1024)   {
     138    if ($kbps > 1024)   {
    139139        $cleanspeed = round($kbps / 1024,2) . " Mbps";
    140140    } else {
  • trunk/Modules/Stock/Stock.php

    r807 r873  
    248248  function BeforeInsertStockMove($Form)
    249249  {
    250     if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
     250    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    251251      else $Year = date("Y", $Form->Values['ValidFrom']);
    252252    $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup');
    253253    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    254     return($Form->Values);
     254    return ($Form->Values);
    255255  }
    256256}
  • trunk/Modules/Subject/Subject.php

    r761 r873  
    184184    $DbRow = $DbResult->fetch_row();
    185185    $Output = 'Subjektů: '.$DbRow['0'].'<br/>';
    186     return($Output);
     186    return ($Output);
    187187  }
    188188}
  • trunk/Modules/System/System.php

    r825 r873  
    3939
    4040    $DbResult = $this->Database->query($Query);
    41     while($Module = $DbResult->fetch_assoc())
    42     {
    43       if($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies'];
     41    while ($Module = $DbResult->fetch_assoc())
     42    {
     43      if ($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies'];
    4444      else $Dependencies = '&nbsp;';
    45       if($Module['Installed'] == 1) $Installed = 'Ano';
     45      if ($Module['Installed'] == 1) $Installed = 'Ano';
    4646      else $Installed = 'Ne';
    47       if($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&amp;Id='.$Module['Id'].'">Odinstalovat</a>';
     47      if ($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&amp;Id='.$Module['Id'].'">Odinstalovat</a>';
    4848      else $Actions = '<a href="?A=Install&amp;Id='.$Module['Id'].'">Instalovat</a>';
    4949      $Output .= '<tr><td>'.$Module['Name'].'</td>'.
     
    5959    $Output .= $PageList['Output'];
    6060    $Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';
    61     return($Output);
     61    return ($Output);
    6262  }
    6363
     
    6565  {
    6666    $Output = '';
    67     if(array_key_exists('A', $_GET))
    68     {
    69       if($_GET['A'] == 'SaveToDb')
     67    if (array_key_exists('A', $_GET))
     68    {
     69      if ($_GET['A'] == 'SaveToDb')
    7070      {
    7171        $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase();
    7272        $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován');
    7373      } else
    74       if($_GET['A'] == 'Install')
     74      if ($_GET['A'] == 'Install')
    7575      {
    7676        $this->System->ModuleManager->LoadModules(false);
    7777        $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']);
    78         if($ModuleName != '')
     78        if ($ModuleName != '')
    7979        {
    8080          $this->System->Modules[$ModuleName]->Install();
     
    8383
    8484      } else
    85       if($_GET['A'] == 'Uninstall')
     85      if ($_GET['A'] == 'Uninstall')
    8686      {
    8787        $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']);
    88         if($ModuleName != '')
     88        if ($ModuleName != '')
    8989        {
    9090          $this->System->ModuleManager->Modules[$ModuleName]->UnInstall();
     
    9494    }
    9595    $Output .= $this->ShowList();
    96     return($Output);
     96    return ($Output);
    9797  }
    9898}
     
    408408  function IsInstalled()
    409409  {
    410     if($this->InstalledChecked == false)
     410    if ($this->InstalledChecked == false)
    411411    {
    412412      $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables
    413413WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";');
    414       if($DbResult->num_rows > 0) $this->Installed = true;
     414      if ($DbResult->num_rows > 0) $this->Installed = true;
    415415        else $this->Installed = false;
    416416      $this->InstalledChecked = true;
    417417    }
    418     return($this->Installed);
     418    return ($this->Installed);
    419419  }
    420420
    421421  function ModuleChange($Module)
    422422  {
    423     //if($this->IsInstalled())
    424     {
    425 
    426       if($Module->IsInstalled()) $Installed = 1;
     423    //if ($this->IsInstalled())
     424    {
     425
     426      if ($Module->IsInstalled()) $Installed = 1;
    427427        else $Installed = 0;
    428428      $this->Database->query('UPDATE `Module` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"');
     
    436436    $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`';
    437437    $DbResult = $this->Database->query($Query);
    438     while($Module = $DbResult->fetch_array())
     438    while ($Module = $DbResult->fetch_array())
    439439    {
    440440      //echo($Module['Name'].',');
     
    453453    $Modules = array();
    454454    $DbResult = $this->Database->query('SELECT * FROM `Module`');
    455     while($DbRow = $DbResult->fetch_assoc())
     455    while ($DbRow = $DbResult->fetch_assoc())
    456456    {
    457457      $Modules[$DbRow['Name']] = $DbRow;
    458       if($this->System->ModuleManager->ModulePresent($DbRow['Name']))
     458      if ($this->System->ModuleManager->ModulePresent($DbRow['Name']))
    459459        $this->System->ModuleManager->Modules[$DbRow['Name']]->Id = $DbRow['Id'];
    460460    }
    461461
    462462    // Add missing
    463     foreach($this->System->ModuleManager->Modules as $Module)
    464     {
    465       if(!array_key_exists($Module->Name, $Modules))
     463    foreach ($this->System->ModuleManager->Modules as $Module)
     464    {
     465      if (!array_key_exists($Module->Name, $Modules))
    466466      {
    467467        $this->Database->insert('Module', array('Name' => $Module->Name,
     
    480480
    481481    // Remove exceeding
    482     foreach($Modules as $Module)
    483     if(!$this->System->ModuleManager->ModulePresent($Module['Name']))
     482    foreach ($Modules as $Module)
     483    if (!$this->System->ModuleManager->ModulePresent($Module['Name']))
    484484    {
    485485      $Output .= 'Removing module '.$Module['Name'].' from list</br/>';
     
    487487      $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']);
    488488      $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']);
    489       while($DbRow = $DbResult->fetch_assoc())
     489      while ($DbRow = $DbResult->fetch_assoc())
    490490      {
    491491        $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']);
     
    495495      $this->Database->query('DELETE FROM `Model` WHERE `Module` = '.$Module['Id']);
    496496      $DbResult = $this->Database->query('SELECT Id FROM `Model` WHERE `Module` = '.$Module['Id']);
    497       while($DbRow = $DbResult->fetch_assoc())
     497      while ($DbRow = $DbResult->fetch_assoc())
    498498        $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']);
    499499      $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']);
     
    503503    $DbDependency = array();
    504504    $DbResult = $this->Database->query('SELECT * FROM `ModuleLink`');
    505     while($DbRow = $DbResult->fetch_assoc())
     505    while ($DbRow = $DbResult->fetch_assoc())
    506506      $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule'];
    507507
    508     foreach($this->System->ModuleManager->Modules as $Module)
     508    foreach ($this->System->ModuleManager->Modules as $Module)
    509509    {
    510510      // Add missing
    511       foreach($Module->Dependencies as $Dependency)
    512       {
    513         if(!array_key_exists($Module->Id, $DbDependency) or
     511      foreach ($Module->Dependencies as $Dependency)
     512      {
     513        if (!array_key_exists($Module->Id, $DbDependency) or
    514514        !in_array($this->System->ModuleManager->Modules[$Dependency]->Id, $DbDependency[$Module->Id]))
    515515        {
    516           if(array_key_exists($Dependency, $this->System->ModuleManager->Modules))
     516          if (array_key_exists($Dependency, $this->System->ModuleManager->Modules))
    517517            $DependencyId = $this->System->ModuleManager->Modules[$Dependency]->Id;
    518518            else throw new Exception('Dependent module '.$Dependency.' not found');
     
    523523
    524524      // Remove exceeding
    525       if(array_key_exists($Module->Id, $DbDependency))
    526       foreach($DbDependency[$Module->Id] as $Dep)
     525      if (array_key_exists($Module->Id, $DbDependency))
     526      foreach ($DbDependency[$Module->Id] as $Dep)
    527527      {
    528528        $DepModName = $this->System->ModuleManager->SearchModuleById($Dep);
    529         if(!in_array($DepModName, $Module->Dependencies))
     529        if (!in_array($DepModName, $Module->Dependencies))
    530530        $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '.
    531531          $Module->Id.' AND LinkedModule='.$Dep);
    532532      }
    533533    }
    534     return($Output);
     534    return ($Output);
    535535  }
    536536}
  • trunk/Modules/TV/TV.php

    r825 r873  
    1111  function Show()
    1212  {
    13     if(count($this->System->PathItems) > 1)
     13    if (count($this->System->PathItems) > 1)
    1414    {
    15       if($this->System->PathItems[1] == 'playlist.m3u') return($this->ShowPlayList());
    16         else return(PAGE_NOT_FOUND);
    17     } else return($this->ShowChannelList());
     15      if ($this->System->PathItems[1] == 'playlist.m3u') return ($this->ShowPlayList());
     16        else return (PAGE_NOT_FOUND);
     17    } else return ($this->ShowChannelList());
    1818  }
    1919
     
    5151
    5252    $DbResult = $this->Database->query($Query);
    53     while($Line = $DbResult->fetch_assoc())
     53    while ($Line = $DbResult->fetch_assoc())
    5454    {
    55       if($Line['Stream'] <> '') $Line['Show'] = '<a href="playlist.m3u?id='.$Line['ShortName'].'">Naladit</a>';
     55      if ($Line['Stream'] <> '') $Line['Show'] = '<a href="playlist.m3u?id='.$Line['ShortName'].'">Naladit</a>';
    5656      else
    57       if($Line['StreamWeb'] <> '') $Line['Show'] = '<a href="'.$Line['StreamWeb'].'">Naladit</a>';
     57      if ($Line['StreamWeb'] <> '') $Line['Show'] = '<a href="'.$Line['StreamWeb'].'">Naladit</a>';
    5858        else $Line['Show'] = '&nbsp;';
    5959
     
    7272    $Output .= 'Další online TV na webu: <a href="http://www.tvinfo.cz/live/televize/evropa/cz">TV info</a><br/>';
    7373
    74     return($Output);
     74    return ($Output);
    7575  }
    7676
     
    8383
    8484    echo('#EXTM3U'."\n");
    85     if(array_key_exists('id', $_GET))
     85    if (array_key_exists('id', $_GET))
    8686    {
    8787      $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") ');
    88       if($DbResult->num_rows > 0)
     88      if ($DbResult->num_rows > 0)
    8989      {
    9090        $Channel = $DbResult->fetch_array();
     
    9595    {
    9696      $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` ');
    97       while($Channel = $DbResult->fetch_array())
     97      while ($Channel = $DbResult->fetch_array())
    9898      {
    9999        echo('#EXTINF:0,'.$Channel['Name']."\n");
  • trunk/Modules/TV/tkr.php

    r738 r873  
    1212'<tr><th>Číslo</th<th>Jméno stanice</th><th>Frekvence [MHz]</th><th>Jazyk</th></tr>';
    1313    $DbResult = $this->Database->select('TV', '*', ' 1 ORDER BY Id');
    14     while($Row = $DbResult->fetch_array())
     14    while ($Row = $DbResult->fetch_array())
    1515    {
    1616      $Output .= '<tr><td>'.$Row['Id'].'</td><td><a href="'.$Row['Homepage'].'">'.$Row['Name'].'</a></td><td align="right">'.($Row['Frequency'] / 1000).'</td><td>'.$Row['Language'].'</td></tr>';
    1717    }
    1818    $Output .= '</table>Aktualizováno dne 17.12.2007<br></div>';
    19     return($Output);
     19    return ($Output);
    2020  }
    2121}
  • trunk/Modules/TimeMeasure/Graph.php

    r738 r873  
    2020  {
    2121    $this->ClearPage = true;
    22     return($this->Render());
     22    return ($this->Render());
    2323  }
    2424
     
    2727    $PrefixMultiplier = new PrefixMultiplier();
    2828
    29     if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
     29    if (array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
    3030      else $Debug = 0;
    3131
    32     if(!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku');
     32    if (!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku');
    3333    $StartTime = addslashes($_GET['From']);
    34     if(!array_key_exists('To', $_GET)) die('Musíte zadat čas konce');
     34    if (!array_key_exists('To', $_GET)) die('Musíte zadat čas konce');
    3535    $EndTime = addslashes($_GET['To']);
    36     if($EndTime < $StartTime) $EndTime = $StartTime + 60;
     36    if ($EndTime < $StartTime) $EndTime = $StartTime + 60;
    3737    $TimeDifference = $EndTime - $StartTime;
    38     if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
     38    if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
    3939    $MeasureId = addslashes($_GET['Measure']);
    40     if(!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
     40    if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
    4141      else $Width = addslashes($_GET['Width']);
    42     if(!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
     42    if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
    4343      else $Height = addslashes($_GET['Height']);
    44     if(!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];
     44    if (!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];
    4545      else $Differential = addslashes($_GET['Differential']);
    4646    $VerticalLinesCount = round($Height / ($this->FontSize + 4));
     
    6363
    6464    $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1;
    65     if($Level < 0) $Level = 0;
    66     if($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;
     65    if ($Level < 0) $Level = 0;
     66    if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;
    6767    //$Level = 0;
    6868
    6969    $Points = $Measure->GetValues($StartTime, $EndTime, $Level);
    7070
    71     if($Debug) echo('Points count: '.count($Points).'<br/>');
    72     //if($Debug) foreach($Points as $Index => $Item)
     71    if ($Debug) echo('Points count: '.count($Points).'<br/>');
     72    //if ($Debug) foreach ($Points as $Index => $Item)
    7373    // echo($Index.': '.$Item['min'].'<br>');
    7474
     
    7777    $AvgValue = 0;
    7878    $MinValue = 1000000000000000000;
    79     foreach($Points as $Index => $Item)
     79    foreach ($Points as $Index => $Item)
    8080    {
    8181      //$Points[$Index]['min'] =  $Points[$Index]['min'] / $Measure['Divider'];
    8282      //$Points[$Index]['avg'] =  $Points[$Index]['avg'] / $Measure['Divider'];
    8383      //$Points[$Index]['max'] =  $Points[$Index]['max'] / $Measure['Divider'];
    84       if($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];
    85       if($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];
    86       if($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];
    87       if($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];
     84      if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];
     85      if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];
     86      if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];
     87      if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];
    8888      $AvgValue = $AvgValue + $Points[$Index]['Avg'];
    8989    }
     
    9696    $PointsAvg = array(0, $Height - 1);
    9797    $PointsMax = array(0, $Height - 1);
    98     if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
     98    if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
    9999    {
    100       foreach($Points as $Index => $Item)
     100      foreach ($Points as $Index => $Item)
    101101      {
    102102        $PointsMin[] = $Index * $Width / $Measure->DivisionCount;
     
    128128
    129129    // Generate image
    130     if(!$Debug)
     130    if (!$Debug)
    131131    {
    132132      Header('Content-type: image/png');
     
    153153      $TimeRange = $EndTime - $StartTime;
    154154      $TimeMarksIndex = 0;
    155       while(($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1;
    156       if($TimeMarksIndex < 2) $TimeMarksIndex = 2;
     155      while (($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1;
     156      if ($TimeMarksIndex < 2) $TimeMarksIndex = 2;
    157157      $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1];
    158158      $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2];
     
    163163      // Zobraz měřítko Y
    164164      $VerticalLinesDistance = $Height / $VerticalLinesCount;
    165       for($I = 1; $I <= $VerticalLinesCount; $I++)
     165      for ($I = 1; $I <= $VerticalLinesCount; $I++)
    166166      {
    167167        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    168         for($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
     168        for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
    169169        //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    170170      }
     
    174174      // Zobraz měřítko X
    175175      $LastTextEnd = 0;
    176       for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
     176      for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
    177177      {
    178178        $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
    179179        //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    180         if(($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift);
     180        if (($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift);
    181181          else $Text = date('j.n.Y G:i', $Time + $TimeShift);
    182182        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    183         if($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
     183        if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
    184184        {
    185           for($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
     185          for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
    186186          imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,  $Height - 2, $Black, $FontFile, $Text);
    187187          $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2;
    188188        }
    189         else for($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
     189        else for ($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
    190190      }
    191191
    192192      // Popisky osy Y
    193       for($I = 1; $I <= $VerticalLinesCount; $I++)
     193      for ($I = 1; $I <= $VerticalLinesCount; $I++)
    194194      {
    195195        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
     
    199199          $this->ValueToImageHeigthCoefficient * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3);
    200200        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    201         if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     201        if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
    202202          imagettftext($Image, $FontSize, 0, 2,  $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text);
    203203      }
  • trunk/Modules/TimeMeasure/Main.php

    r825 r873  
    6262    // Day selection
    6363    $Output .= '<select name="Day">';
    64     for($I = 1; $I < 32; $I++)
    65     {
    66       if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
     64    for ($I = 1; $I < 32; $I++)
     65    {
     66      if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
    6767      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    6868    }
     
    7171    // Month selection
    7272    $Output .= '<select name="Month">';
    73     foreach($MonthNames as $Index => $Month)
    74     {
    75       if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
    76       if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
     73    foreach ($MonthNames as $Index => $Month)
     74    {
     75      if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
     76      if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
    7777    }
    7878    $Output .= '</select>. ';
     
    8080    // Day selection
    8181    $Output .= '<select name="Year">';
    82     for($I = 2000; $I < 2010; $I++)
    83     {
    84       if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
     82    for ($I = 2000; $I < 2010; $I++)
     83    {
     84      if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
    8585      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    8686    }
     
    8989    // Hour selection
    9090    $Output .= '<select name="Hour">';
    91     for($I = 0; $I < 24; $I++)
    92     {
    93       if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
     91    for ($I = 0; $I < 24; $I++)
     92    {
     93      if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
    9494      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    9595    }
     
    9898    // Minute selection
    9999    $Output .= '<select name="Minute">';
    100     for($I = 0; $I < 60; $I++)
    101     {
    102       if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
     100    for ($I = 0; $I < 60; $I++)
     101    {
     102      if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
    103103      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    104104    }
     
    111111    $Output .= '</form>';
    112112
    113     return($Output);
     113    return ($Output);
    114114  }
    115115
     
    118118    $Debug = 0;
    119119
    120     foreach($this->DefaultVariables as $Index => $Variable)
    121     {
    122       if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
    123       if(array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
    124       if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
     120    foreach ($this->DefaultVariables as $Index => $Variable)
     121    {
     122      if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
     123      if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
     124      if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
    125125      //$$Index = $_SESSION[$Index];
    126126    }
    127127
    128     if($_SESSION['TimeSpecify'] == 0)
     128    if ($_SESSION['TimeSpecify'] == 0)
    129129    {
    130130      $_SESSION['TimeEnd'] = time() - 60;
     
    134134    $Output = '<div style="text-align: center;">';
    135135
    136     if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
    137     switch($_GET['Operation'])
     136    if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     137    switch ($_GET['Operation'])
    138138    {
    139139      case 'SetTime':
    140         if(array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and
     140        if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and
    141141          array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST))
    142142        {
    143           if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     143          if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
    144144          {
    145145            $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'],
     
    150150        break;
    151151      case 'SetTimeNow':
    152         if(array_key_exists('Time', $_GET))
     152        if (array_key_exists('Time', $_GET))
    153153        {
    154           if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     154          if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
    155155          {
    156156            $_SESSION[$_GET['Time']] = time();
     
    162162    $Output .= '<strong>Časový úsek:</strong><br>';
    163163    // Show graf time range menu
    164     if($_SESSION['TimeSpecify'] == 0)
     164    if ($_SESSION['TimeSpecify'] == 0)
    165165    {
    166166      $Output .= 'Délka úseku: ';
    167       foreach($this->GraphTimeRanges as $Index => $Item)
     167      foreach ($this->GraphTimeRanges as $Index => $Item)
    168168        $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a>&nbsp;';
    169169      $Output .= '<br/>';
     
    179179
    180180    $Output .= '<br/>'.$this->MeasureTable();
    181     return($Output);
     181    return ($Output);
    182182  }
    183183
     
    191191    $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&amp;TimeStart='.
    192192      $_SESSION['TimeStart'].'&amp;TimeEnd='.$_SESSION['TimeEnd'].'&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>';
    193     return($Output);
     193    return ($Output);
    194194  }
    195195
     
    212212      array('Name' => 'Description', 'Title' => 'Popis'),
    213213    );
    214     if(array_key_exists('Debug', $_GET))
     214    if (array_key_exists('Debug', $_GET))
    215215    {
    216216      $TableColumns[] = array('Name' => 'ItemCount', 'Title' => 'Počet položek');
     
    221221
    222222    $Result = $this->Database->select('Measure', '*', '`Enabled`=1 '.$Order['SQL'].$PageList['SQLLimit']);
    223     while($Measure = $Result->fetch_array())
     223    while ($Measure = $Result->fetch_array())
    224224    {
    225225      $DbResult2 = $this->Database->select('MeasureMethod', '*', '`Id`='.$Measure['Method']);
    226226      $MeasureMethod = $DbResult2->fetch_assoc();
    227227      $StopWatchStart = GetMicrotime();
    228       if(array_key_exists('Debug', $_GET))
     228      if (array_key_exists('Debug', $_GET))
    229229      {
    230230        $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', 'Measure='.$Measure['Id']);
     
    233233      }
    234234      $Result2 = $this->Database->select($Measure['DataTable'], 'Time, Avg', 'Measure='.$Measure['Id'].' AND Level=0 ORDER BY Time DESC LIMIT 1');
    235       if($Result2->num_rows > 0)
     235      if ($Result2->num_rows > 0)
    236236      {
    237237        $Row = $Result2->fetch_array();
     
    243243        $LastMeasureValue = '&nbsp;';
    244244      }
    245       if($Measure['Continuity'] == 1) $Interpolate = 'Ano';
     245      if ($Measure['Continuity'] == 1) $Interpolate = 'Ano';
    246246        else $Interpolate = 'Ne';
    247       //if($Measure['Description'] == '') $Measure['Description'] = '&nbsp;';
     247      //if ($Measure['Description'] == '') $Measure['Description'] = '&nbsp;';
    248248      $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    249249      $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&amp;Differential=0">'.$Measure['Name'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Description'].'</td>';
    250       if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
     250      if (array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
    251251      $Output .= '</tr>';
    252252    }
     
    260260    //echo($PrefixMultiplier->Add('-0.000000071112345', 'B'));
    261261    $Output .= '</div>';
    262     return($Output);
     262    return ($Output);
    263263  }
    264264}
     
    271271
    272272    $Output = '';
    273     if(!array_key_exists('MeasureId', $_GET)) return('Nebylo zadáno Id měření.');
    274     if(!array_key_exists('Value', $_GET)) return('Nebyla zadána hodnota.');
     273    if (!array_key_exists('MeasureId', $_GET)) return ('Nebylo zadáno Id měření.');
     274    if (!array_key_exists('Value', $_GET)) return ('Nebyla zadána hodnota.');
    275275    $Measure = new Measure($this->System);
    276276    $Measure->Load($_GET['MeasureId']);
    277     if(!isset($Measure->Data['Id'])) return('Měření s Id '.$_GET['MeasureId'].' nenalezeno.');
     277    if (!isset($Measure->Data['Id'])) return ('Měření s Id '.$_GET['MeasureId'].' nenalezeno.');
    278278    $Measure->AddValue(array('Min' => $_GET['Value'], 'Avg' => $_GET['Value'], 'Max' => $_GET['Value']));
    279     return($Output);
     279    return ($Output);
    280280  }
    281281}
  • trunk/Modules/TimeMeasure/Measure.php

    r790 r873  
    1515  {
    1616    $Result = $this->Database->select('Measure', '*', 'Id='.$Id);
    17     if($Result->num_rows > 0)
     17    if ($Result->num_rows > 0)
    1818    {
    1919      $this->Data = $Result->fetch_assoc();
    20       if($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
     20      if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
    2121        else $this->Data['ContinuityEnabled'] = 2;    // continuous graph
    2222    } else throw new Exception('Measure not found');
     
    2525  function TimeSegment($Base, $Level)
    2626  {
    27     return(pow($this->LevelReducing, $Level) * $Base);
     27    return (pow($this->LevelReducing, $Level) * $Base);
    2828  }
    2929
    3030  function StatTableName($Level)
    3131  {
    32     if($Level == 0) return('Data');
    33       else return('DataCache');
     32    if ($Level == 0) return ('Data');
     33      else return ('DataCache');
    3434  }
    3535
    3636  function AlignTime($Time, $TimeSegment)
    3737  {
    38     return(round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment + $this->ReferenceTime);
     38    return (round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment + $this->ReferenceTime);
    3939  }
    4040
    4141  function AddValue($Value = array('Min' => 0, 'Avg' => 0, 'Max' => 0), $Level = 0, $Time = 0)
    4242  {
    43     if($Time == 0) $Time = time();
     43    if ($Time == 0) $Time = time();
    4444
    4545    $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.
    4646      $this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2');
    47     if($Result->num_rows == 0)
     47    if ($Result->num_rows == 0)
    4848    {
    4949       $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
    5050         'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
    5151         'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time), 'Continuity' => 0));
    52     } else if($Result->num_rows == 1)
     52    } else if ($Result->num_rows == 1)
    5353    {
    5454      $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     
    5959      $LastValue = $Result->fetch_assoc();
    6060      $NextToLastValue = $Result->fetch_assoc();
    61       if((($Time - MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0))
     61      if ((($Time - MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0))
    6262      {
    6363        echo('Too short period. Minimal period is '.(0.75 * $this->Data['Period'])." seconds\n");
    6464      } else
    6565      {
    66         if(($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1;
     66        if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1;
    6767          else $Continuity = 0;
    68         if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] ==
     68        if (($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] ==
    6969          $Value['Min']) and ($LastValue['Avg'] == $NextToLastValue['Avg']) and
    7070          ($LastValue['Avg'] == $Value['Avg']) and ($LastValue['Max'] == $NextToLastValue['Max'])
     
    8282
    8383      // Update next level
    84       if($Level < $this->MaxLevel)
     84      if ($Level < $this->MaxLevel)
    8585      {
    8686        $Level = $Level + 1;
    8787        $TimeSegment = $this->TimeSegment($this->Data['Period'], 1);
    8888        $EndTime = $this->AlignTime($Time, $TimeSegment);
    89         //if($EndTime < $Time) $EndTime = $EndTime + $TimeSegment;
     89        //if ($EndTime < $Time) $EndTime = $EndTime + $TimeSegment;
    9090        $StartTime = $EndTime - $TimeSegment;
    9191
     
    9696          TimeToMysqlDateTime($StartTime).'") AND (Time < "'.TimeToMysqlDateTime($EndTime).
    9797            '") AND (Measure='.$this->Data['Id'].') AND (Level='.($Level - 1).') ORDER BY Time');
    98         while($Row = $Result->fetch_assoc())
     98        while ($Row = $Result->fetch_assoc())
    9999        {
    100100          $Row['Time'] = MysqlDateTimeToTime($Row['Time']);
    101101          $Values[] = $Row;
    102102        }
    103         //if(count($Values) > 2)
     103        //if (count($Values) > 2)
    104104        {
    105105          //array_pop($Values);
     
    124124  {
    125125    $Y = ($Y2 - $Y1) / ($X2 - $X1) * ($X - $X1) + $Y1;
    126     return($Y);
     126    return ($Y);
    127127  }
    128128
     
    132132
    133133    // Trim outside parts
    134     foreach($this->ValueTypes as $ValueType)
     134    foreach ($this->ValueTypes as $ValueType)
    135135    {
    136136      $Values[0][$ValueType] = $this->Interpolation($Values[0]['Time'], $Values[0][$ValueType], $Values[1]['Time'], $Values[1][$ValueType], $LeftTime);
    137137    }
    138138    $Values[0]['Time'] = $LeftTime;
    139     foreach($this->ValueTypes as $ValueType)
     139    foreach ($this->ValueTypes as $ValueType)
    140140    {
    141141        $Values[count($Values) - 1][$ValueType] = $this->Interpolation($Values[count($Values) - 2]['Time'], $Values[count($Values) - 2][$ValueType],
     
    145145
    146146    // Perform computation
    147     foreach($this->ValueTypes as $ValueType)
     147    foreach ($this->ValueTypes as $ValueType)
    148148    {
    149149      // Compute new value
    150       for($I = 0; $I < (count($Values) - 1); $I++)
    151       {
    152         if($ValueType == 'Avg')
    153         {
    154           if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']);
    155           else if($this->Differential == 0)
     150      for ($I = 0; $I < (count($Values) - 1); $I++)
     151      {
     152        if ($ValueType == 'Avg')
     153        {
     154          if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']);
     155          else if ($this->Differential == 0)
    156156          {
    157157            $NewValue[$ValueType] = $NewValue[$ValueType] + ($Values[$I + 1]['Time'] - $Values[$I]['Time']) *
     
    163163          }
    164164        }
    165         else if($ValueType == 'Max')
    166         {
    167           if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
    168           {
    169             if(0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
     165        else if ($ValueType == 'Max')
     166        {
     167          if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
     168          {
     169            if (0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
    170170          } else
    171171          {
    172             if($this->Differential == 0)
     172            if ($this->Differential == 0)
    173173            {
    174               if($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];
     174              if ($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];
    175175            } else {
    176176              $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType];
    177               if($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
     177              if ($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
    178178            }
    179179          }
    180180        }
    181         else if($ValueType == 'Min')
    182         {
    183           if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
    184           {
    185             if(0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
     181        else if ($ValueType == 'Min')
     182        {
     183          if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
     184          {
     185            if (0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
    186186          } else
    187187          {
    188             if($this->Differential == 0)
     188            if ($this->Differential == 0)
    189189            {
    190               if($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];
     190              if ($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];
    191191            } else {
    192192              $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType];
    193               if($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
     193              if ($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
    194194            }
    195195          }
     
    198198      $NewValue[$ValueType] = $NewValue[$ValueType];
    199199    }
    200     //if(($RightTime - $LeftTime) > 0)
    201     if($this->Data['Cumulative'] == 0)
     200    //if (($RightTime - $LeftTime) > 0)
     201    if ($this->Data['Cumulative'] == 0)
    202202    {
    203203      $NewValue['Avg'] = $NewValue['Avg'] / ($RightTime - $LeftTime);
    204204    }
    205     return($NewValue);
     205    return ($NewValue);
    206206  }
    207207
     
    210210    // Get first and last time
    211211    $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time LIMIT 1');
    212     if($Result->num_rows > 0)
     212    if ($Result->num_rows > 0)
    213213    {
    214214      $Row = $Result->fetch_assoc();
     
    217217
    218218    $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1');
    219     if($Result->num_rows > 0)
     219    if ($Result->num_rows > 0)
    220220    {
    221221      $Row = $Result->fetch_assoc();
     
    223223    } else $AbsoluteRightTime = 0;
    224224
    225     if($this->Debug)
     225    if ($this->Debug)
    226226    {
    227227      echo('AbsoluteLeftTime: '.$AbsoluteLeftTime.'('.TimeToMysqlDateTime($AbsoluteLeftTime).')<br>');
    228228      echo('AbsoluteRightTime: '.$AbsoluteRightTime.'('.TimeToMysqlDateTime($AbsoluteRightTime).')<br>');
    229229    }
    230     return(array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime));
     230    return (array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime));
    231231  }
    232232
     
    235235    $Result = array();
    236236    $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1');
    237     if($DbResult->num_rows > 0)
     237    if ($DbResult->num_rows > 0)
    238238    {
    239239      $Row = $DbResult->fetch_assoc();
    240240      $Row['Time'] = MysqlDateTimeToTime($Row['Time']);
    241       return(array($Row));
     241      return (array($Row));
    242242    } else
    243243    {
     
    247247      $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'.
    248248        TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1');
    249       if($DbResult->num_rows > 0)
     249      if ($DbResult->num_rows > 0)
    250250      {
    251251        $Row = $DbResult->fetch_assoc();
    252252        array_unshift($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) + 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));
    253253      }
    254      // if($Debug) print_r($Result);
    255       return($Result);
     254     // if ($Debug) print_r($Result);
     255      return ($Result);
    256256    }
    257257  }
     
    262262    $DbResult = $this->Database->select($this->Data['DataTable'], '*', '(Time < "'.
    263263      TimeToMysqlDateTime($Time).'") AND (Measure='.$this->Data['Id'].') AND (Level='.$Level.') ORDER BY Time DESC LIMIT 1');
    264     if($DbResult->num_rows > 0)
     264    if ($DbResult->num_rows > 0)
    265265    {
    266266      $Row = $DbResult->fetch_assoc();
    267267      $Row['Time'] = MysqlDateTimeToTime($Row['Time']);
    268       return(array($Row));
     268      return (array($Row));
    269269    } else
    270270    {
    271271      //$Time = $Values[0]['Time'] - 60;
    272272      //array_unshift($Values, array('Time' => $Time, 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));
    273       if($this->Debug) echo($this->TimeSegment($this->Data['Period'], $Level));
     273      if ($this->Debug) echo($this->TimeSegment($this->Data['Period'], $Level));
    274274      $Result[] = array('Time' => ($Time - $this->TimeSegment($this->Data['Period'], $Level)), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0);
    275275
    276276      $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1');
    277       if($DbResult->num_rows > 0)
     277      if ($DbResult->num_rows > 0)
    278278      {
    279279        $Row = $DbResult->fetch_assoc();
    280280        array_push($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) - 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));
    281281      }
    282       return($Result);
     282      return ($Result);
    283283    }
    284284  }
     
    286286  function GetValues($TimeFrom, $TimeTo, $Level)
    287287  {
    288     if($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>');
    289     if($this->Debug) echo('TimeTo: '.$TimeTo.'('.TimeToMysqlDateTime($TimeTo).')<br>');
     288    if ($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>');
     289    if ($this->Debug) echo('TimeTo: '.$TimeTo.'('.TimeToMysqlDateTime($TimeTo).')<br>');
    290290
    291291    //$AbsoluteTime = GetTimeRange($MeasureId);
    292292
    293     //  if(($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and
     293    //  if (($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and
    294294    //    ($TimeTo > $AbsoluteLeftTime) and ($TimeTo < $AbsoluteRightTime))
    295295    //  {
     
    304304    //  echo(DB_NumRows());
    305305    //  $III = 0;
    306     while($Row = $Result->fetch_assoc())
     306    while ($Row = $Result->fetch_assoc())
    307307    {
    308308      //    echo($III.' '.$Row['Time'].' '.memory_get_usage().',');
     
    314314    //  echo('abc');
    315315    //  die();
    316     if($this->Debug) echo('Item count: '.count($Values));
     316    if ($this->Debug) echo('Item count: '.count($Values));
    317317
    318318    $Points = array();
    319     if(count($Values) > 0)
     319    if (count($Values) > 0)
    320320    {
    321321      $Values = array_merge($this->LoadLeftSideValue($Level, $TimeFrom), $Values, $this->LoadRightSideValue($Level, $TimeTo));
    322322      $StartIndex = 0;
    323323      $Points = array();
    324       if($this->Debug) print_r($Values);
    325       for($I = 0; $I < $this->DivisionCount; $I++)
     324      if ($this->Debug) print_r($Values);
     325      for ($I = 0; $I < $this->DivisionCount; $I++)
    326326      {
    327327        $TimeStart = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * $I;
    328328        $TimeEnd = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * ($I + 1);
    329         if($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.TimeToMysqlDateTime($TimeEnd).')<br>');
     329        if ($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.TimeToMysqlDateTime($TimeEnd).')<br>');
    330330
    331331        $EndIndex = $StartIndex;
    332         while(($Values[$EndIndex]['Time'] < $TimeEnd) and ($EndIndex < count($Values))) $EndIndex = $EndIndex + 1;
    333         //while(($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1;
     332        while (($Values[$EndIndex]['Time'] < $TimeEnd) and ($EndIndex < count($Values))) $EndIndex = $EndIndex + 1;
     333        //while (($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1;
    334334        $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    335335        $Points[] = $this->ComputeOneValue($TimeStart, $TimeEnd, $SubValues, $Level);
    336336        $StartIndex = $EndIndex - 1;
    337337      }
    338       if($this->Debug) print_r($Points);
     338      if ($this->Debug) print_r($Points);
    339339    } else $Points[] = array('Min' => 0, 'Avg' => 0, 'Max' => 0);
    340     return($Points);
     340    return ($Points);
    341341  }
    342342
     
    344344  {
    345345    echo('Veličina '.$this->Data['Name']."<br>\n");
    346     if($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
     346    if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
    347347      else $this->Data['ContinuityEnabled'] = 2;    // continuous graph
    348348
     
    354354    echo("<br>\n");
    355355
    356     for($Level = 1; $Level <= $this->MaxLevel; $Level++)
     356    for ($Level = 1; $Level <= $this->MaxLevel; $Level++)
    357357    {
    358358      echo('Uroven '.$Level."<br>\n");
     
    363363      $BurstCount = 500;
    364364      echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."<br>\n");
    365       for($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++)
     365      for ($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++)
    366366      {
    367367        echo($I.' ');
     
    371371        $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.
    372372          TimeToMysqlDateTime($StartTime2).'" AND Time < "'.TimeToMysqlDateTime($EndTime2).'" AND Measure='.$this->Data['Id'].' AND Level='.($Level - 1).' ORDER BY Time');
    373         while($Row = $DbResult->fetch_assoc())
     373        while ($Row = $DbResult->fetch_assoc())
    374374        {
    375375          $Row['Time'] = MysqlDateTimeToTime($Row['Time']);
     
    377377        }
    378378
    379         if(count($Values) > 0)
     379        if (count($Values) > 0)
    380380        {
    381381          $Values = array_merge($this->LoadLeftSideValue($Level - 1, $StartTime2),
     
    383383
    384384          $StartIndex = 0;
    385           for($B = 0; $B < $BurstCount; $B++)
     385          for ($B = 0; $B < $BurstCount; $B++)
    386386          {
    387387            echo('.');
     
    390390
    391391            $EndIndex = $StartIndex;
    392             while($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;
     392            while ($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;
    393393            $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    394             if(count($SubValues) > 2)
     394            if (count($SubValues) > 2)
    395395            {
    396396              $Point = $this->ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Level);
     
    420420    $Measures = array();
    421421    $Result = $Database->select('Measure', '*');
    422     while($Row = $Result->fetch_assoc())
     422    while ($Row = $Result->fetch_assoc())
    423423    {
    424424      $Measures = new Measure();
     
    426426    }
    427427
    428     foreach($Measures as $Measure)
     428    foreach ($Measures as $Measure)
    429429    {
    430430      $Measure->RebuildMeasureCache();
  • trunk/Modules/TimeMeasure/Measurement/MeasureClient.php

    r738 r873  
    88  {
    99    $DbResult = $this->Database->select('MeasureClient', '*');
    10     while($MeasureClient = $DbResult->fetch_assoc())
     10    while ($MeasureClient = $DbResult->fetch_assoc())
    1111    {
    1212      $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$MeasureClient['Method']);
     
    1515      include_once(dirname(__FILE__).'/'.$MeasureMethod['MeasureClass'].'.php');
    1616      $MeasureMethod['MeasureClass'] .= 'Measurement';
    17       if(class_exists($MeasureMethod['MeasureClass']))
     17      if (class_exists($MeasureMethod['MeasureClass']))
    1818      {
    1919        $MeasureClass = new $MeasureMethod['MeasureClass']($this->System);
    20         if(method_exists($MeasureClass, $MeasureMethod['Method']))
     20        if (method_exists($MeasureClass, $MeasureMethod['Method']))
    2121        {
    22           if($MeasureClient['Parameter'] != '') $Value = $Measure->$MeasureMethod['Method']($MeasureClient['Parameter']);
     22          if ($MeasureClient['Parameter'] != '') $Value = $Measure->$MeasureMethod['Method']($MeasureClient['Parameter']);
    2323            else $Value = $MeasureClass->$MeasureMethod['Method']();
    2424          echo(file_get_contents('http://'.$MeasureClient['Host'].$MeasureClient['Path'].'/?M=Add&MeasureId='.$MeasureClient['MeasureId'].'&Value='.addslashes($Value)));
  • trunk/Modules/TimeMeasure/Measurement/System.php

    r660 r873  
    1111    set_error_handler('ErrorHandler');
    1212    //error_reporting(0);
    13     if($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout))
     13    if ($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout))
    1414    {
    1515      fclose($Fp1);
    16       return(TRUE);
     16      return (TRUE);
    1717    } else
    1818    {
    1919      //echo($ERROR_NO.','.$ERROR_STR);
    20       return(FALSE);
     20      return (FALSE);
    2121    }
    2222    restore_error_handler();
     
    3030    // c - ping count
    3131    $Parts = explode(' ', $Row[0]);
    32     if(count($Parts) > 6)
     32    if (count($Parts) > 6)
    3333    {
    3434      $Time = $Parts[7];
    3535      $TimeParts = explode('=', $Time);
    36       return($TimeParts[1]);
    37     } else return(0);
     36      return ($TimeParts[1]);
     37    } else return (0);
    3838  }
    3939
     
    4343    exec('free -b', $Output);
    4444    $Row = $Output[2];
    45     while(strpos($Row, '  ') !== false) $Row = str_replace('  ', ' ', $Row);
     45    while (strpos($Row, '  ') !== false) $Row = str_replace('  ', ' ', $Row);
    4646    $RowParts = explode(' ', $Row);
    4747    $Row = $Output[3];
    48     while(strpos($Row, '  ') !== false) $Row = str_replace('  ', ' ', $Row);
     48    while (strpos($Row, '  ') !== false) $Row = str_replace('  ', ' ', $Row);
    4949    $RowParts2 = explode(' ', $Row);
    50     return($RowParts[2] + $RowParts2[2]);
     50    return ($RowParts[2] + $RowParts2[2]);
    5151  }
    5252
     
    8181    }
    8282    file_put_contents($CpuStateFileName, serialize($CpuUsage));
    83     return(100 - round($CpuUsagePercent['Idle'], 2));
     83    return (100 - round($CpuUsagePercent['Idle'], 2));
    8484  }
    8585
     
    9393    array_shift($Output); // Skip header
    9494    array_shift($Output); // Skip header
    95     foreach($Output as $Item)
     95    foreach ($Output as $Item)
    9696    {
    97       while(strpos($Item, '  ') !== false) $Item = str_replace('  ', ' ', $Item);  // Rrmove multiple spaces
     97      while (strpos($Item, '  ') !== false) $Item = str_replace('  ', ' ', $Item);  // Rrmove multiple spaces
    9898      $Item = explode(':', $Item);
    9999      $Interface = trim($Item[0]);
    100100      $Item = explode(' ', trim($Item[1]));
    101101      $NetworkState[$Interface] = array('Down' => $Item[0], 'Up' => $Item[8]);
    102       if(array_key_exists($Interface, $LastNetworkState))
     102      if (array_key_exists($Interface, $LastNetworkState))
    103103      {
    104104        $Period = time() - $LastNetworkState['Time'];
     
    110110        $NetworkState[$Interface]['UpAverage'] = 0;
    111111      }
    112       if($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0;
    113       if($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0;
     112      if ($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0;
     113      if ($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0;
    114114    }
    115115    file_put_contents($NetworkStateFile, serialize($NetworkState));
    116     return($NetworkState);
     116    return ($NetworkState);
    117117  }
    118118
     
    120120  {
    121121    $NetworkState = $this->GetNetworkState();
    122     return($NetworkState['Interface']['DownAverage']);
     122    return ($NetworkState['Interface']['DownAverage']);
    123123  }
    124124
     
    126126  {
    127127    $NetworkState = $this->GetNetworkState();
    128     return($NetworkState['Interface']['UpAverage']);
     128    return ($NetworkState['Interface']['UpAverage']);
    129129  }
    130130
     
    134134    $Output = array();
    135135    exec('cat /proc/net/nf_conntrack|grep "dst='.$HostIP.' "|grep "dport='.$Port.' "|grep "ASSURED"', $Output);
    136     return(count($Output));
     136    return (count($Output));
    137137  }
    138138
     
    142142    exec('iostat -d '.$Device.' -x -m 2 2', $Output);   // 2 second measure delay
    143143    $Row = $Output[6];
    144     while(strpos($Row, '  ') !== false) $Row = str_replace('  ', ' ', $Row);
     144    while (strpos($Row, '  ') !== false) $Row = str_replace('  ', ' ', $Row);
    145145    $Parts = explode(' ', $Row);
    146146    $Value = str_replace(',', '.', $Parts[11]);
    147     return($Value);
     147    return ($Value);
    148148  }
    149149
    150150  function DiskFree($Path)
    151151  {
    152     return(disk_free_space($Path));
     152    return (disk_free_space($Path));
    153153  }
    154154
     
    157157    $Output = array();
    158158    exec('/usr/bin/sensors', $Output);
    159     foreach($Output as $Line)
     159    foreach ($Output as $Line)
    160160    {
    161       if(substr($Line, 0, strlen($Sensor)) == $Sensor)
     161      if (substr($Line, 0, strlen($Sensor)) == $Sensor)
    162162      {
    163163        $Line = substr($Line, strpos($Line, '+') + 1);
    164164        $Line = substr($Line, 0, strpos($Line, '°'));
    165         return($Line);
     165        return ($Line);
    166166      }
    167167    }
    168     return(0);
     168    return (0);
    169169  }
    170170
     
    175175    fclose($File);
    176176    $UptimeParts = explode(' ', $Uptime);
    177     return($UptimeParts[0]);
     177    return ($UptimeParts[0]);
    178178  }
    179179}
  • trunk/Modules/TimeMeasure/Measurement/WoW.php

    r738 r873  
    1212    $DbResult = $Database->query('SELECT COUNT(*) FROM account WHERE online=1');
    1313    $Row = $DbResult->fetch_array();
    14     return($Row[0]);
     14    return ($Row[0]);
    1515  }
    1616
     
    2020    $DbResult = $Database->query('SELECT COUNT(*) FROM account WHERE online=1 AND gmlevel > 0');
    2121    $Row = $DbResult->fetch_array();
    22     return($Row[0]);
     22    return ($Row[0]);
    2323  }
    2424
     
    2828    $DbResult = $Database->query('SELECT COUNT(*) FROM account');
    2929    $Row = $DbResult->fetch_array();
    30     return($Row[0]);
     30    return ($Row[0]);
    3131  }
    3232
     
    3636    $DbResult = $Database->query('SELECT COUNT(*) FROM guild');
    3737    $Row = $DbResult->fetch_array();
    38     return($Row[0]);
     38    return ($Row[0]);
    3939  }
    4040
     
    4444    $DbResult = $Database->query('SELECT COUNT(*) FROM `characters`');
    4545    $Row = $DbResult->fetch_array();
    46     return($Row[0]);
     46    return ($Row[0]);
    4747  }
    4848
     
    5252    $DbResult = $Database->query('SELECT COUNT(*) FROM uptime');
    5353    $Row = $DbResult->fetch_array();
    54     return($Row[0]);
     54    return ($Row[0]);
    5555  }
    5656
    5757  function WoWEmulatorAvailability()
    5858  {
    59     if(CheckPortStatus('localhost', 8085)) return(100); else return(0);
     59    if (CheckPortStatus('localhost', 8085)) return (100); else return (0);
    6060  }
    6161
     
    6969    $Row = $DbResult->fetch_array();
    7070    $Value = $Row[0];
    71     return($Value);
     71    return ($Value);
    7272  }
    7373}
  • trunk/Modules/User/User.php

    r858 r873  
    122122    /*
    123123
    124      if($this->InstalledVersion == '1.0') {
     124     if ($this->InstalledVersion == '1.0') {
    125125      $this->System->Database->Query('SELECT * FROM User WHERE Id=1');
    126126      $this->InstalledVersion = '1.1';
     
    132132  {
    133133    $this->System->User = new User($this->System);
    134     if(isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();
     134    if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();
    135135    $this->System->RegisterPage('userlist', 'PageUserList');
    136136    $this->System->RegisterPage('user', 'PageUser');
     
    290290  function TopBarCallback()
    291291  {
    292     if($this->System->User->User['Id'] == null)
     292    if ($this->System->User->User['Id'] == null)
    293293    {
    294294      $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '.
     
    301301      //   <a href="'.$this->System->Link('/?Action=UserOptions').'">Nastavení</a>';
    302302    }
    303     return($Output);
     303    return ($Output);
    304304  }
    305305}
  • trunk/Modules/User/UserList.php

    r833 r873  
    99  function Show()
    1010  {
    11     if(!$this->System->User->CheckPermission('User', 'ShowList'))
    12       return('Nemáte oprávnění');
     11    if (!$this->System->User->CheckPermission('User', 'ShowList'))
     12      return ('Nemáte oprávnění');
    1313
    1414    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `User`');
     
    3030
    3131    $DbResult = $this->Database->query($Query);
    32     while($User = $DbResult->fetch_assoc())
     32    while ($User = $DbResult->fetch_assoc())
    3333    {
    3434      $Devices = array();
    3535      $DbResult2 = $this->Database->query('SELECT `Id` FROM `Member` WHERE `Member`.`ResponsibleUser` = '.$User['Id']);
    36       while($Member = $DbResult2->fetch_assoc())
     36      while ($Member = $DbResult2->fetch_assoc())
    3737      {
    3838        $DbResult3 = $this->Database->query('SELECT `Name`, `Id` FROM `NetworkDevice` '.
    3939          'WHERE `Member` = '.$Member['Id'].' AND `Used`=1 ORDER BY `Name`');
    40         while($Device = $DbResult3->fetch_assoc())
     40        while ($Device = $DbResult3->fetch_assoc())
    4141        {
    4242          $Devices[] = $Device['Name'];
     
    5252    $Output .= $PageList['Output'];
    5353
    54     return($Output);
     54    return ($Output);
    5555  }
    5656}
  • trunk/Modules/User/UserModel.php

    r828 r873  
    3030  function Hash($Password, $Salt)
    3131  {
    32     return(sha1(sha1($Password).$Salt));
     32    return (sha1(sha1($Password).$Salt));
    3333  }
    3434
    3535  function Verify($Password, $Salt, $StoredHash)
    3636  {
    37     return($this->Hash($Password, $Salt) == $StoredHash);
     37    return ($this->Hash($Password, $Salt) == $StoredHash);
    3838  }
    3939
     
    7171    // Lookup user record
    7272    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    73     if($Query->num_rows > 0)
     73    if ($Query->num_rows > 0)
    7474    {
    7575      // Refresh time of last access
     
    8181
    8282    // Logged permanently?
    83     if(array_key_exists('LoginHash', $_COOKIE))
     83    if (array_key_exists('LoginHash', $_COOKIE))
    8484    {
    8585      $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId'].
    8686        ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"');
    87       if($DbResult->num_rows > 0)
     87      if ($DbResult->num_rows > 0)
    8888      {
    8989        $DbRow = $DbResult->fetch_assoc();
    90         if(sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])
     90        if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])
    9191        {
    9292          $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"');
     
    9999    $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"');
    100100    $Row = $Query->fetch_assoc();
    101     if($Row['User'] != '')
     101    if ($Row['User'] != '')
    102102    {
    103103      $Query = $this->Database->query('SELECT `User`.*, `UserCustomerRel`.`Customer` AS `Member` FROM `User` '.
     
    114114    // Remove nonactive users
    115115    $DbResult = $this->Database->select('UserOnline', '`Id`, `User`', '(`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.$this->OnlineStateTimeout.' SECOND)) AND (`StayLogged` = 0)');
    116     while($DbRow = $DbResult->fetch_array())
     116    while ($DbRow = $DbResult->fetch_array())
    117117    {
    118118      $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']);
    119       if($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');
     119      if ($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');
    120120    }
    121121    //$this->LoadPermission($this->User['Role']);
     
    127127  function Register($Login, $Password, $Password2, $Email, $Name)
    128128  {
    129     if(($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '')  || ($Name == '')) $Result = DATA_MISSING;
    130     else if($Password != $Password2) $Result = PASSWORDS_UNMATCHED;
     129    if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '')  || ($Name == '')) $Result = DATA_MISSING;
     130    else if ($Password != $Password2) $Result = PASSWORDS_UNMATCHED;
    131131    else
    132132    {
    133133      // Is user registred yet?
    134134      $Query = $this->Database->select('User', '*', 'Login = "'.$Login.'"');
    135       if($Query->num_rows > 0) $Result = LOGIN_USED;
     135      if ($Query->num_rows > 0) $Result = LOGIN_USED;
    136136      else
    137137      {
    138138        $Query = $this->Database->select('User', '*', 'Name = "'.$Name.'"');
    139         if($Query->num_rows > 0) $Result = NAME_USED;
     139        if ($Query->num_rows > 0) $Result = NAME_USED;
    140140        else
    141141        {
    142142          $Query = $this->Database->select('User', '*', 'Email = "'.$Email.'"');
    143           if($Query->num_rows > 0) $Result = EMAIL_USED;
     143          if ($Query->num_rows > 0) $Result = EMAIL_USED;
    144144          else
    145145          {
     
    177177      }
    178178    }
    179     return($Result);
     179    return ($Result);
    180180  }
    181181
     
    183183  {
    184184    $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id);
    185     if($DbResult->num_rows > 0)
     185    if ($DbResult->num_rows > 0)
    186186    {
    187187      $Row = $DbResult->fetch_array();
    188188      $NewPassword = substr(sha1(strtoupper($Row['Login'])), 0, 7);
    189       if($Hash == $NewPassword)
     189      if ($Hash == $NewPassword)
    190190      {
    191191        $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0));
     
    195195      } else $Output = PASSWORDS_UNMATCHED;
    196196    } else $Output = USER_NOT_FOUND;
    197     return($Output);
     197    return ($Output);
    198198  }
    199199
    200200  function Login($Login, $Password, $StayLogged = false)
    201201  {
    202     if($StayLogged) $StayLogged = 1; else $StayLogged = 0;
     202    if ($StayLogged) $StayLogged = 1; else $StayLogged = 0;
    203203    $SID = session_id();
    204204    $Query = $this->Database->select('User', '*', 'Login="'.$Login.'"');
    205     if($Query->num_rows > 0)
     205    if ($Query->num_rows > 0)
    206206    {
    207207      $Row = $Query->fetch_assoc();
    208208      $PasswordHash = new PasswordHash();
    209       if(!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD;
    210       else if($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;
     209      if (!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD;
     210      else if ($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;
    211211      else
    212212      {
     
    217217        $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array(
    218218          'User' => $Row['Id'], 'StayLogged' => $StayLogged, 'StayLoggedHash' => $StayLoggedSalt));
    219         if($StayLogged)
     219        if ($StayLogged)
    220220        {
    221221          setcookie('LoginUserId', $Row['Id'], time()+365*24*60*60, $this->System->Link('/'));
     
    231231      }
    232232    } else $Result = USER_NOT_REGISTRED;
    233     return($Result);
     233    return ($Result);
    234234  }
    235235
     
    240240    $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']);
    241241    $this->Check();
    242     return(USER_LOGGED_OUT);
     242    return (USER_LOGGED_OUT);
    243243  }
    244244
     
    247247    $this->Roles = array();
    248248    $DbResult = $this->Database->select('UserRole', '*');
    249     while($DbRow = $DbResult->fetch_array())
     249    while ($DbRow = $DbResult->fetch_array())
    250250      $this->Roles[] = $DbRow;
    251251  }
     
    255255    $this->User['Permission'] = array();
    256256    $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role);
    257     if($DbResult->num_rows > 0)
    258     while($DbRow = $DbResult->fetch_array())
     257    if ($DbResult->num_rows > 0)
     258    while ($DbRow = $DbResult->fetch_array())
    259259      $this->User['Permission'][$DbRow['Operation']] = $DbRow;
    260260  }
     
    264264    $Result = array();
    265265    $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description`, `UserRole`.`Title` FROM `UserRolePermission` LEFT JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` LEFT JOIN `UserRole` ON `UserRole`.`Id` = `UserRolePermission`.`Role`');
    266     while($DbRow = $DbResult->fetch_array())
     266    while ($DbRow = $DbResult->fetch_array())
    267267    {
    268268      $Value = '';
    269       if($DbRow['Read']) $Value .= 'R';
    270       if($DbRow['Write']) $Value .= 'W';
     269      if ($DbRow['Read']) $Value .= 'R';
     270      if ($DbRow['Write']) $Value .= 'W';
    271271      $Result[$DbRow['Description']][$DbRow['Title']] = $Value;
    272272    }
    273     return($Result);
     273    return ($Result);
    274274  }
    275275
     
    278278    $PermissionExists = false;
    279279    // First try to check cache group-group relation
    280     if(array_key_exists($GroupId, $this->PermissionGroupCache))
     280    if (array_key_exists($GroupId, $this->PermissionGroupCache))
    281281    {
    282282      $PermissionExists = true;
     
    287287        '") AND (`AssignedGroup` IS NOT NULL)');
    288288      $DbRow = array();
    289       while($DbRow[] = $DbResult->fetch_array());
     289      while ($DbRow[] = $DbResult->fetch_array());
    290290        $this->PermissionGroupCache[$GroupId] = $DbRow;
    291291      $PermissionExists = true;
    292292    }
    293     if($PermissionExists)
    294     {
    295       foreach($this->PermissionGroupCache[$GroupId] as $DbRow)
    296       {
    297         if($DbRow['AssignedGroup'] != '')
    298         if($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);
     293    if ($PermissionExists)
     294    {
     295      foreach ($this->PermissionGroupCache[$GroupId] as $DbRow)
     296      {
     297        if ($DbRow['AssignedGroup'] != '')
     298        if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return (true);
    299299      }
    300300    }
    301301
    302302    // Check group-operation relation
    303     if(array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp))
     303    if (array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp))
    304304    {
    305305      $PermissionExists = true;
     
    308308      // If no permission combination exists in cache, do new check of database items
    309309      $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"');
    310       if($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true;
     310      if ($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true;
    311311        else $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = false;
    312312      $PermissionExists = true;
    313313    }
    314     if($PermissionExists)
    315     {
    316       return($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]);
    317     }
    318     return(false);
     314    if ($PermissionExists)
     315    {
     316      return ($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]);
     317    }
     318    return (false);
    319319  }
    320320
     
    323323    // Get module id
    324324    $DbResult = $this->Database->select('Module', 'Id', '`Name`="'.$Module.'"');
    325     if($DbResult->num_rows > 0)
     325    if ($DbResult->num_rows > 0)
    326326    {
    327327      $DbRow = $DbResult->fetch_assoc();
    328328      $ModuleId = $DbRow['Id'];
    329     } else return(false);
     329    } else return (false);
    330330
    331331    // First try to check cache
    332     if(in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))
     332    if (in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))
    333333    {
    334334      $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemIndex), $this->PermissionCache);
     
    339339      $DbResult = $this->Database->select('PermissionOperation', 'Id', '(`Module`="'.$ModuleId.
    340340        '") AND (`Item`="'.$ItemType.'") AND (`ItemId`='.$ItemIndex.') AND (`Operation`="'.$Operation.'")');
    341       if($DbResult->num_rows > 0)
     341      if ($DbResult->num_rows > 0)
    342342      {
    343343        $DbRow = $DbResult->fetch_array();
     
    352352    }
    353353
    354     if($PermissionExists)
    355     {
    356       if($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)';
     354    if ($PermissionExists)
     355    {
     356      if ($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)';
    357357        else $UserCondition = '(`User`="'.$this->User['Id'].'")';
    358358      // Check user-operation relation
    359359      $DbResult = $this->Database->select('PermissionUserAssignment', '*', $UserCondition.' AND (`AssignedOperation`="'.$OperationId.'")');
    360       if($DbResult->num_rows > 0) return(true);
     360      if ($DbResult->num_rows > 0) return (true);
    361361
    362362      // Check user-group relation
    363363      $DbResult = $this->Database->select('PermissionUserAssignment', 'AssignedGroup', $UserCondition);
    364       while($DbRow = $DbResult->fetch_array())
    365       {
    366        if($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);
    367       }
    368       return(false);
    369     } else return(false);
     364      while ($DbRow = $DbResult->fetch_array())
     365      {
     366       if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return (true);
     367      }
     368      return (false);
     369    } else return (false);
    370370  }
    371371
     
    373373  {
    374374    $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"');
    375     if($DbResult->num_rows > 0)
     375    if ($DbResult->num_rows > 0)
    376376    {
    377377      $Row = $DbResult->fetch_array();
     
    394394      $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
    395395    } else $Output = USER_PASSWORD_RECOVERY_FAIL;
    396     return($Output);
     396    return ($Output);
    397397  }
    398398
     
    400400  {
    401401    $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id);
    402     if($DbResult->num_rows > 0)
     402    if ($DbResult->num_rows > 0)
    403403    {
    404404      $Row = $DbResult->fetch_array();
    405405      $NewPassword2 = substr(sha1(strtoupper($Row['Login'])), 0, 7);
    406       if(($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))
     406      if (($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))
    407407      {
    408408        $PasswordHash = new PasswordHash();
     
    414414      } else $Output = PASSWORDS_UNMATCHED;
    415415    } else $Output = USER_NOT_FOUND;
    416     return($Output);
     416    return ($Output);
    417417  }
    418418
     
    420420  {
    421421    $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"');
    422     if($DbResult->num_rows > 0)
     422    if ($DbResult->num_rows > 0)
    423423    {
    424424      $DbRow = $DbResult->fetch_assoc();
    425425      $User = new User($this->System);
    426426      $User->User = array('Id' => $DbRow['User']);
    427       return($User->CheckPermission($Module, $Operation));
    428     } else return(false);
     427      return ($User->CheckPermission($Module, $Operation));
     428    } else return (false);
    429429  }
    430430}
  • trunk/Modules/User/UserPage.php

    r828 r873  
    99  function Panel($Title, $Content, $Menu = array())
    1010  {
    11     if(count($Menu) > 0)
    12       foreach($Menu as $Item)
     11    if (count($Menu) > 0)
     12      foreach ($Menu as $Item)
    1313        $Title .= '<div class="Action">'.$Item.'</div>';
    14     return('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');
     14    return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');
    1515  }
    1616
     
    3939
    4040    $DbResult = $this->Database->query($Query);
    41     while($Contact = $DbResult->fetch_assoc())
     41    while ($Contact = $DbResult->fetch_assoc())
    4242    {
    4343      $Output .= '<tr>'.
     
    5050    $Output .= $PageList['Output'];
    5151
    52     return($Output);
     52    return ($Output);
    5353  }
    5454
     
    5656  {
    5757    $Output = '';
    58     if($this->System->User->User['Id'] != null)
     58    if ($this->System->User->User['Id'] != null)
    5959    {
    6060      $Actions = '';
    61       foreach($this->System->ModuleManager->Modules['User']->UserPanel as $Action)
    62       {
    63         if(is_string($Action[0]))
     61      foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action)
     62      {
     63        if (is_string($Action[0]))
    6464        {
    6565          $Class = new $Action[0]($this->System);
     
    7171      $Output .= $this->Panel('Nabídka uživatele', $Actions);
    7272      $Output .= '</td><td style="vertical-align:top;">';
    73       if($this->System->User->User['Id'] != null)
     73      if ($this->System->User->User['Id'] != null)
    7474        {
    7575          $Form = new Form($this->System->FormManager);
     
    8585      $Output .= '</td></tr></table></div>';
    8686    } else $Output .= $this->SystemMessage('Oprávnění', 'Nejste přihlášen');
    87     return($Output);
     87    return ($Output);
    8888  }
    8989
     
    9191  {
    9292    $Output = '';
    93     if(array_key_exists('Action', $_GET))
     93    if (array_key_exists('Action', $_GET))
    9494    {
    9595      $Action = $_GET['Action'];
    96       if($Action == 'LoginForm')
     96      if ($Action == 'LoginForm')
    9797      {
    9898        $Form = new Form($this->System->FormManager);
     
    103103        '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
    104104      } else
    105       if($Action == 'Login')
    106       {
    107         if(array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST))
     105      if ($Action == 'Login')
     106      {
     107        if (array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST))
    108108        {
    109109          $Form = new Form($this->System->FormManager);
    110110          $Form->SetClass('UserLogin');
    111111          $Form->OnSubmit = '?Action=Login';
    112           if(array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true;
     112          if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true;
    113113            else $StayLogged = false;
    114114          $Result = $this->System->User->Login($_POST['Username'], $_POST['Password'], $StayLogged);
    115115          $Output .= $this->SystemMessage('Přihlášení', $Result);
    116           if($Result <> USER_LOGGED_IN)
     116          if ($Result <> USER_LOGGED_IN)
    117117          {
    118118            $Form->LoadValuesFromForm();
     
    128128        } else $Output .= $this->SystemMessage('Přihlášení', 'Nezadány přihlašovací údaje');
    129129      } else
    130       if($Action == 'Logout')
    131       {
    132         if($this->System->User->User['Id'] != null)
     130      if ($Action == 'Logout')
     131      {
     132        if ($this->System->User->User['Id'] != null)
    133133        {
    134134          $Output .= $this->SystemMessage('Odhlášení', $this->System->User->Logout());
    135135        } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen');
    136136      } else
    137       if($Action == 'UserOptions')
    138       {
    139         if($this->System->User->User['Id'] != null)
     137      if ($Action == 'UserOptions')
     138      {
     139        if ($this->System->User->User['Id'] != null)
    140140        {
    141141          $Form = new Form($this->System->FormManager);
     
    146146        } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen');
    147147      } else
    148       if($Action == 'UserOptionsSave')
     148      if ($Action == 'UserOptionsSave')
    149149      {
    150150        $Form = new Form($this->System->FormManager);
     
    158158        $Output .= $Form->ShowEditForm();
    159159      } else
    160       if($Action == 'UserRegister')
     160      if ($Action == 'UserRegister')
    161161      {
    162162        $Form = new Form($this->System->FormManager);
     
    166166        $Output .= $Form->ShowEditForm();
    167167      } else
    168       if($Action == 'UserRegisterConfirm')
     168      if ($Action == 'UserRegisterConfirm')
    169169      {
    170170        $Output .= $this->SystemMessage('Potvrzení registrace',
    171171          $this->System->User->RegisterConfirm($_GET['User'], $_GET['H']));
    172172      } else
    173       if($Action == 'PasswordRecovery')
     173      if ($Action == 'PasswordRecovery')
    174174      {
    175175        $Form = new Form($this->System->FormManager);
     
    178178        $Output .= $Form->ShowEditForm();
    179179      } else
    180       if($Action == 'PasswordRecovery2')
     180      if ($Action == 'PasswordRecovery2')
    181181      {
    182182        $Form = new Form($this->System->FormManager);
     
    185185        $Result = $this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
    186186        $Output .= $this->SystemMessage('Obnova hesla', $Result);
    187         if($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
     187        if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
    188188        {
    189189          $Output .= $Form->ShowEditForm();
    190190        }
    191191      } else
    192       if($Action == 'PasswordRecoveryConfirm')
     192      if ($Action == 'PasswordRecoveryConfirm')
    193193      {
    194194        $Output .= $this->SystemMessage('Obnova hesla', $this->System->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
    195195      } else
    196       if($Action == 'UserRegisterSave')
     196      if ($Action == 'UserRegisterSave')
    197197      {
    198198        $Form = new Form($this->System->FormManager);
     
    202202          $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']);
    203203        $Output .= $this->SystemMessage('Registrace nového účtu', $Result);
    204         if($Result <> USER_REGISTRATED)
     204        if ($Result <> USER_REGISTRATED)
    205205        {
    206206          $Form->OnSubmit = '?Action=UserRegisterSave';
     
    208208        }
    209209      } else
    210       if($Action == 'UserMenu')
     210      if ($Action == 'UserMenu')
    211211      {
    212212        $Output = $this->ShowUserPanel();
    213213      } else $Output = $this->ShowMain();
    214214    } else $Output = $this->ShowMain();
    215     return($Output);
     215    return ($Output);
    216216  }
    217217
     
    219219  {
    220220    $Output = 'Nebyla vybrána akce';
    221     return($Output);
     221    return ($Output);
    222222  }
    223223}
  • trunk/Modules/WebCam/WebCam.php

    r860 r873  
    99  function Show()
    1010  {
    11     if(file_exists($this->System->ModuleManager->Modules['WebCam']->ImageFileName))
     11    if (file_exists($this->System->ModuleManager->Modules['WebCam']->ImageFileName))
    1212    {
    1313      $Output = '<script language="JavaScript">
     
    3838      '<a href="http://www.mestovsetin.cz/vismo/dokumenty2.asp?id_org=18676&id=480245">Webové kamery ve Vsetíně</a><br />';
    3939
    40     return($Output);
     40    return ($Output);
    4141  }
    4242}
     
    7272    $Output .= '<a href="//www.zdechov.net/kamery/?Id=3"><img alt="Skiareál, motokrosová grapa" width="140" height="79" src="//www.zdechov.net/images/webcam/webcam3.jpg" /></a>';
    7373    $Output .= '<a href="//www.zdechov.net/kamery/?Id=4"><img alt="Fotbalové hřiště" width="140" height="79" src="//www.zdechov.net/images/webcam/webcam4.jpg" /></a>';
    74     return($Output);
     74    return ($Output);
    7575  }
    7676}
  • trunk/Modules/WebCam/webcam_refresh.php

    r738 r873  
    33
    44$Config['Web']['ShowPHPError'] = true;
    5 while(1)
     5while (1)
    66{
    77  $ModifyTime = filemtime('webcam.jpg');
    8   if((time() - $Config['Web']['WebcamRefresh']) >= $ModifyTime)
     8  if ((time() - $Config['Web']['WebcamRefresh']) >= $ModifyTime)
    99  {
    1010//    $Output = shell_exec('wget "http://kamera-stred/Webcam.jpg?MobilePass='.$Config['Web']['WebcamPassword'].'&V=2&Q=2&B=2&U=0" -O webcam_cache.jpg -T '.($Config['Web']['WebcamRefresh']).' --limit-rate=200k');
    1111    $Output = shell_exec('wget "http://kamera-knihovna/cgi-bin/viewer/video.jpg" -O webcam_cache.jpg -T '.($Config['Web']['WebcamRefresh']).' --limit-rate=200k');
    1212
    13     if((strpos($Output, 'failed') === false) and (strpos($Output, 'error') === false))
     13    if ((strpos($Output, 'failed') === false) and (strpos($Output, 'error') === false))
    1414      shell_exec('mv -f webcam_cache.jpg webcam.jpg');
    1515  }
  • trunk/Modules/Wiki/Wiki.php

    r825 r873  
    6060  {
    6161    $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1');
    62     while($DbRow = $DbResult->fetch_assoc())
     62    while ($DbRow = $DbResult->fetch_assoc())
    6363    {
    6464      $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
     
    8282  function Show()
    8383  {
    84     if(array_key_exists('Action', $_GET))
    85     {
    86       if($_GET['Action'] == 'Edit') $Output = $this->EditContent();
    87       else if($_GET['Action'] == 'EditSave') $Output = $this->SaveContent();
    88       else if($_GET['Action'] == 'History') $Output = $this->ShowHistory();
     84    if (array_key_exists('Action', $_GET))
     85    {
     86      if ($_GET['Action'] == 'Edit') $Output = $this->EditContent();
     87      else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent();
     88      else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory();
    8989      else $Output = $this->ShowContent();
    9090    } else $Output = $this->ShowContent();
    91     return($Output);
     91    return ($Output);
    9292  }
    9393
     
    9696    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
    9797    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    98     if($DbResult->num_rows > 0)
     98    if ($DbResult->num_rows > 0)
    9999    {
    100100      $DbRow = $DbResult->fetch_assoc();
    101       if(array_key_exists('ver', $_GET))
     101      if (array_key_exists('ver', $_GET))
    102102      {
    103103        $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1);
    104         if($DbResult2->num_rows > 0)
     104        if ($DbResult2->num_rows > 0)
    105105        {
    106106          $DbRow2 = $DbResult2->fetch_assoc();
    107107          $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>';
    108108          $Output .= $DbRow2['Content'];
    109           if($this->System->User->Licence(LICENCE_MODERATOR))
     109          if ($this->System->User->Licence(LICENCE_MODERATOR))
    110110            $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>';
    111111        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    113113      {
    114114        $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1');
    115         if($DbResult2->num_rows > 0)
     115        if ($DbResult2->num_rows > 0)
    116116        {
    117117          $DbRow2 = $DbResult2->fetch_assoc();
    118118          $Output = '<h3>'.$DbRow['Name'].'</h3>';
    119119          $Output .= $DbRow2['Content'];
    120           if($this->System->User->Licence(LICENCE_MODERATOR))
     120          if ($this->System->User->Licence(LICENCE_MODERATOR))
    121121            $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>';
    122122        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    123123      }
    124124    } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    125     return($Output);
     125    return ($Output);
    126126  }
    127127
    128128  function EditContent()
    129129  {
    130     if($this->System->User->Licence(LICENCE_MODERATOR))
     130    if ($this->System->User->Licence(LICENCE_MODERATOR))
    131131    {
    132132    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
    133133    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    134     if($DbResult->num_rows > 0)
     134    if ($DbResult->num_rows > 0)
    135135    {
    136136      $DbRow = $DbResult->fetch_assoc();
    137137      $Output = '<h3>Úprava '.$DbRow['Name'].'</h3>';
    138138      $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1');
    139       if($DbResult2->num_rows > 0)
     139      if ($DbResult2->num_rows > 0)
    140140      {
    141141        $DbRow2 = $DbResult2->fetch_assoc();
     
    148148    } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    149149    } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL);
    150     return($Output);
     150    return ($Output);
    151151  }
    152152
    153153  function SaveContent()
    154154  {
    155     if($this->System->User->Licence(LICENCE_MODERATOR))
     155    if ($this->System->User->Licence(LICENCE_MODERATOR))
    156156    {
    157157    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
    158158    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    159     if($DbResult->num_rows > 0)
     159    if ($DbResult->num_rows > 0)
    160160    {
    161161      $DbRow = $DbResult->fetch_assoc();
    162       if(array_key_exists('content', $_POST) and array_key_exists('save', $_POST))
     162      if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST))
    163163      {
    164164        $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),
     
    169169    } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    170170    } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL);
    171     return($Output);
     171    return ($Output);
    172172  }
    173173
    174174  function ShowHistory()
    175175  {
    176     if($this->System->User->Licence(LICENCE_MODERATOR))
     176    if ($this->System->User->Licence(LICENCE_MODERATOR))
    177177    {
    178178      $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
    179179      $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    180       if($DbResult->num_rows > 0)
     180      if ($DbResult->num_rows > 0)
    181181      {
    182182        $DbRow = $DbResult->fetch_assoc();
     
    202202          ' FROM `WikiPageContent` WHERE Page='.
    203203          $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']);
    204         while($PageContent = $DbResult2->fetch_assoc())
     204        while ($PageContent = $DbResult2->fetch_assoc())
    205205        {
    206206          $Output .= '<tr>'.
     
    215215      } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    216216    } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL);
    217     return($Output);
     217    return ($Output);
    218218  }
    219219
     
    242242    $text = str_replace("\r\n", '<br/>', $text);
    243243    $text = '<p>'.$text.'</p>';
    244     return($text);
     244    return ($text);
    245245  }
    246246}
Note: See TracChangeset for help on using the changeset viewer.