Changeset 873 for trunk


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

Legend:

Unmodified
Added
Removed
  • trunk/Application/DefaultConfig.php

    r791 r873  
    66  {
    77    $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1'));
    8     return(array
     8    return (array
    99    (
    1010        array('Name' => 'SystemPassword', 'Type' => 'PasswordEncoded', 'Default' => '', 'Title' => 'Systémové heslo'),
  • trunk/Application/System.php

    r858 r873  
    22
    33$ConfigFileName = dirname(__FILE__).'/../Config/Config.php';
    4 if(file_exists($ConfigFileName)) include_once($ConfigFileName);
     4if (file_exists($ConfigFileName)) include_once($ConfigFileName);
    55
    66include_once(dirname(__FILE__).'/Version.php');
     
    4040    $this->ConfigManager = new Config();
    4141    $this->RootURLFolder = $_SERVER['SCRIPT_NAME'];
    42     if(substr($this->RootURLFolder, -10, 10) == '/index.php')
     42    if (substr($this->RootURLFolder, -10, 10) == '/index.php')
    4343      $this->RootURLFolder = substr($this->RootURLFolder, 0, -10);
    4444    $this->CommandLine = array();
     
    4848  function RegisterPage($Path, $Handler)
    4949  {
    50     if(is_array($Path))
     50    if (is_array($Path))
    5151    {
    5252      $Page = &$this->Pages;
    5353      $LastKey = array_pop($Path);
    54       foreach($Path as $PathItem)
     54      foreach ($Path as $PathItem)
    5555      {
    5656        $Page = &$Page[$PathItem];
    5757      }
    58       if(!is_array($Page)) $Page = array('' => $Page);
     58      if (!is_array($Page)) $Page = array('' => $Page);
    5959      $Page[$LastKey] = $Handler;
    6060    } else $this->Pages[$Path] = $Handler;
     
    6868  function SearchPage($PathItems, $Pages)
    6969  {
    70     if(count($PathItems) > 0) $PathItem = $PathItems[0];
     70    if (count($PathItems) > 0) $PathItem = $PathItems[0];
    7171      else $PathItem = '';
    72     if(array_key_exists($PathItem, $Pages))
    73     {
    74       if(is_array($Pages[$PathItem]))
     72    if (array_key_exists($PathItem, $Pages))
     73    {
     74      if (is_array($Pages[$PathItem]))
    7575      {
    7676        array_shift($PathItems);
    77         return($this->SearchPage($PathItems, $Pages[$PathItem]));
    78       } else return($Pages[$PathItem]);
    79     } else return('');
     77        return ($this->SearchPage($PathItems, $Pages[$PathItem]));
     78      } else return ($Pages[$PathItem]);
     79    } else return ('');
    8080  }
    8181
    8282  function PageNotFound()
    8383  {
    84     return('Page '.implode('/', $this->PathItems).' not found.');
     84    return ('Page '.implode('/', $this->PathItems).' not found.');
    8585  }
    8686
     
    9191    /* @var $Page Page */
    9292    $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
    93     if($ClassName != '')
     93    if ($ClassName != '')
    9494    {
    9595      $Page = new $ClassName($this);
     
    102102  function ModulePresent($Name)
    103103  {
    104     return(array_key_exists($Name, $this->Modules));
     104    return (array_key_exists($Name, $this->Modules));
    105105  }
    106106
     
    112112  function HumanDate($Time)
    113113  {
    114     return(date('j.n.Y', $Time));
     114    return (date('j.n.Y', $Time));
    115115  }
    116116
    117117  function Link($Target)
    118118  {
    119     return($this->RootURLFolder.$Target);
     119    return ($this->RootURLFolder.$Target);
    120120  }
    121121
     
    126126      'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
    127127      'WHERE (`Action`.`Id`='.$Id.')');
    128     if($DbResult->num_rows > 0)
     128    if ($DbResult->num_rows > 0)
    129129    {
    130130      $Action = $DbResult->fetch_assoc();
    131       if($Action['Icon'] == '') $Action['Icon'] = 'clear.png';
    132       if(substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = $this->Link($Action['URL']);
    133       if(!defined('NEW_PERMISSION') or $this->User->CheckPermission('System', 'Read', 'Item', $Id))
     131      if ($Action['Icon'] == '') $Action['Icon'] = 'clear.png';
     132      if (substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = $this->Link($Action['URL']);
     133      if (!defined('NEW_PERMISSION') or $this->User->CheckPermission('System', 'Read', 'Item', $Id))
    134134        $Output .= '<img alt="'.$Action['Title'].'" src="'.$this->Link('/images/favicons/'.$Action['Icon']).
    135135        '" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a>';
    136136    }
    137     return($Output);
     137    return ($Output);
    138138  }
    139139
     
    148148
    149149    // SQL injection hack protection
    150     foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
    151     foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
    152 
    153     if(isset($_SERVER['REMOTE_ADDR'])) session_start();
     150    foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
     151    foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
     152
     153    if (isset($_SERVER['REMOTE_ADDR'])) session_start();
    154154
    155155    $ConfigFileName = dirname(dirname(__FILE__)).'/config.php';
    156     if(file_exists($ConfigFileName))
     156    if (file_exists($ConfigFileName))
    157157      $this->ConfigManager->LoadFromFile($ConfigFileName);
    158158    //$this->Config = $this->ConfigManager->GetAsArray();
     
    166166      $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError'];
    167167      $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery'];
    168       if(isset($this->Config['Web']['LogSQLQuery']))
     168      if (isset($this->Config['Web']['LogSQLQuery']))
    169169        $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery'];
    170170    } catch (Exception $E) {
     
    181181    $this->LinkLocaleExceptions = array('images', 'style', 'files');
    182182
    183     if(isset($this->Config['Web']['RootFolder']))
     183    if (isset($this->Config['Web']['RootFolder']))
    184184      $this->RootURLFolder = $this->Config['Web']['RootFolder'];
    185185    $this->FormManager->Root = $this->RootURLFolder;
     
    193193    $this->Setup = new Setup($this);
    194194    $this->Setup->Start();
    195     if($this->Setup->CheckState())
     195    if ($this->Setup->CheckState())
    196196    {
    197197      $this->ModuleManager->Start();
     
    202202  {
    203203    $this->RunCommon();
    204     if($this->ShowPage)
     204    if ($this->ShowPage)
    205205    {
    206206      $this->PathItems = ProcessURL();
    207207
    208208      // Detect interface locale
    209       if(isset($this->Config['Web']['Locale']))
     209      if (isset($this->Config['Web']['Locale']))
    210210        $this->LocaleManager->DefaultLangCode = $this->Config['Web']['Locale'];
    211211      $this->LocaleManager->LangCode = $this->LocaleManager->DefaultLangCode;
    212       if(count($this->PathItems) > 0)
     212      if (count($this->PathItems) > 0)
    213213      {
    214214         $NewLangCode = $this->PathItems[0];
    215          if(array_key_exists($NewLangCode, $this->LocaleManager->Available))
     215         if (array_key_exists($NewLangCode, $this->LocaleManager->Available))
    216216         {
    217217           array_shift($this->PathItems);
     
    219219         }
    220220      }
    221       if(array_key_exists($this->LocaleManager->LangCode, $this->LocaleManager->Available))
     221      if (array_key_exists($this->LocaleManager->LangCode, $this->LocaleManager->Available))
    222222        $this->LocaleManager->LoadLocale($this->LocaleManager->LangCode);
    223223
     
    231231
    232232    $this->RunCommon();
    233     if(count($argv) > 1)
    234     {
    235       if(array_key_exists($argv[1], $this->CommandLine))
     233    if (count($argv) > 1)
     234    {
     235      if (array_key_exists($argv[1], $this->CommandLine))
    236236      {
    237237        $Command = $this->CommandLine[$argv[1]];
     
    282282  {
    283283    Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
    284     return('<h3 align="center">Požadovaná stránka neexistuje.</h3>');
     284    return ('<h3 align="center">Požadovaná stránka neexistuje.</h3>');
    285285  }
    286286}
  • trunk/Application/UpdateTrace.php

    r870 r873  
    203203  $ServiceCategoryHire = $Manager->Database->insert_id;
    204204  $DbResult = $Manager->Execute("SELECT * FROM Member WHERE Hire>0");
    205   while($Member = $DbResult->fetch_assoc())
     205  while ($Member = $DbResult->fetch_assoc())
    206206  {
    207207    $Manager->Execute("INSERT INTO `Service` (
     
    308308  // Set all string collation to utf8 general
    309309  $DbResult = $Manager->Execute("SHOW TABLES");
    310   while($DbRow = $DbResult->fetch_row())
     310  while ($DbRow = $DbResult->fetch_row())
    311311  {
    312312    $Manager->Execute("ALTER TABLE `".$DbRow[0]."` CONVERT TO CHARACTER SET utf8");
     
    871871  $ActionId = $Manager->Database->insert_id;
    872872  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Nabídky"');
    873   if($DbResult->num_rows > 0)
     873  if ($DbResult->num_rows > 0)
    874874  {
    875875    $DbRow = $DbResult->fetch_assoc();
     
    889889  // Convert monthly plus payment for consumption to regular service
    890890  $DbResult = $Manager->Execute('SELECT `MonthlyPlus`, `Member` FROM `MemberPayment` WHERE `MonthlyPlus` > 0');
    891   while($DbRow = $DbResult->fetch_assoc)
     891  while ($DbRow = $DbResult->fetch_assoc)
    892892  {
    893893    $Manager->Execute("INSERT INTO `Service` (`Id` ,`Name` ,`Category` ,`Price` ,`VAT`) ".
     
    987987  $ActionId = $Manager->Database->insert_id;
    988988  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Sklad"');
    989   if($DbResult->num_rows > 0)
     989  if ($DbResult->num_rows > 0)
    990990  {
    991991    $DbRow = $DbResult->fetch_assoc();
     
    10251025  $ActionId = $Manager->Database->insert_id;
    10261026  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Finance"');
    1027   if($DbResult->num_rows > 0)
     1027  if ($DbResult->num_rows > 0)
    10281028  {
    10291029    $DbRow = $DbResult->fetch_assoc();
     
    10471047  // IS menu item
    10481048  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Příjmy a výdaje"');
    1049   if($DbResult->num_rows > 0)
     1049  if ($DbResult->num_rows > 0)
    10501050  {
    10511051    $DbRow = $DbResult->fetch_assoc();
     
    10891089  // IS menu item
    10901090  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Závazky a pohledávky"');
    1091   if($DbResult->num_rows > 0)
     1091  if ($DbResult->num_rows > 0)
    10921092  {
    10931093    $DbRow = $DbResult->fetch_assoc();
     
    11201120  $SearchText = 'Připojení k síti';
    11211121  $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";');
    1122   while($DbRow = $DbResult->fetch_assoc())
     1122  while ($DbRow = $DbResult->fetch_assoc())
    11231123  {
    11241124    $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1));
     
    11341134  $SearchText = 'Připojení k Internetu';
    11351135  $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";');
    1136   while($DbRow = $DbResult->fetch_assoc())
     1136  while ($DbRow = $DbResult->fetch_assoc())
    11371137  {
    11381138    $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1));
     
    11411141    $PeriodFrom = $PeriodFrom[2].'-'.$PeriodFrom[1].'-'.$PeriodFrom[0];
    11421142    $Text[1] = trim($Text[1]);
    1143     if(strpos($Text[1], ' ') !== false) $Text[1] = substr($Text[1], 0, strpos($Text[1], ' '));
     1143    if (strpos($Text[1], ' ') !== false) $Text[1] = substr($Text[1], 0, strpos($Text[1], ' '));
    11441144    $PeriodTo = explode('.', trim($Text[1]));
    11451145    $PeriodTo = $PeriodTo[2].'-'.$PeriodTo[1].'-'.$PeriodTo[0];
     
    11991199  $ActionId = $Manager->Database->insert_id;
    12001200  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Systém"');
    1201   if($DbResult->num_rows > 0)
     1201  if ($DbResult->num_rows > 0)
    12021202  {
    12031203    $DbRow = $DbResult->fetch_assoc();
     
    12501250  $ActionId = $Manager->Database->insert_id;
    12511251  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"');
    1252   if($DbResult->num_rows > 0)
     1252  if ($DbResult->num_rows > 0)
    12531253  {
    12541254    $DbRow = $DbResult->fetch_assoc();
     
    14571457    'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
    14581458    'WHERE `FinanceOperation`.`BillCodeText`!=""');
    1459   while($DbRow = $DbResult->fetch_assoc())
     1459  while ($DbRow = $DbResult->fetch_assoc())
    14601460  {
    1461     if($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
     1461    if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
    14621462    $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
    14631463      'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
     
    14751475    'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '.
    14761476    'WHERE `FinanceInvoice`.`BillCodeText`!=""');
    1477   while($DbRow = $DbResult->fetch_assoc())
     1477  while ($DbRow = $DbResult->fetch_assoc())
    14781478  {
    1479     if($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
     1479    if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
    14801480        $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
    14811481      'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
     
    15121512{
    15131513  $DbResult = $Manager->Database->query('SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(`Price` * `Quantity`) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value`');
    1514   while($DbRow = $DbResult->fetch_assoc())
     1514  while ($DbRow = $DbResult->fetch_assoc())
    15151515  {
    15161516    $Manager->Database->query('UPDATE `FinanceInvoiceItem` SET `Price` = -`Price` WHERE `FinanceInvoice`='.$DbRow['Id']);
     
    16241624  $ActionId = $Manager->Database->insert_id;
    16251625  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Zákazníci"');
    1626   if($DbResult->num_rows > 0)
     1626  if ($DbResult->num_rows > 0)
    16271627  {
    16281628    $DbRow = $DbResult->fetch_assoc();
     
    18121812    'FROM `Contract` '.
    18131813    'WHERE `Contract`.`BillCodeText`!=""');
    1814   while($DbRow = $DbResult->fetch_assoc())
     1814  while ($DbRow = $DbResult->fetch_assoc())
    18151815  {
    1816     if($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
     1816    if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
    18171817    $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
    18181818      'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
     
    18771877    'LEFT JOIN `StockMoveGroup` ON `StockMoveGroup`.`Id` = `StockMove`.`Group` '.
    18781878    'WHERE `StockMove`.`BillCodeText`!=""');
    1879   while($DbRow = $DbResult->fetch_assoc())
     1879  while ($DbRow = $DbResult->fetch_assoc())
    18801880  {
    1881    if($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
     1881   if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';
    18821882   $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '.
    18831883     'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");');
     
    19401940  $ActionId = $Manager->Database->insert_id;
    19411941  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Pokladny"');
    1942   if($DbResult->num_rows > 0)
     1942  if ($DbResult->num_rows > 0)
    19431943  {
    19441944    $DbRow = $DbResult->fetch_assoc();
     
    20962096  $ActionId = $Manager->Database->insert_id;
    20972097  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"');
    2098   if($DbResult->num_rows > 0)
     2098  if ($DbResult->num_rows > 0)
    20992099  {
    21002100    $DbRow = $DbResult->fetch_assoc();
     
    21152115  function Get()
    21162116  {
    2117     return(array(
     2117    return (array(
    21182118      491 => array('Revision' => 493, 'Function' => 'UpdateTo493'),
    21192119      493 => array('Revision' => 494, 'Function' => 'UpdateTo494'),
  • trunk/Application/Version.php

    r872 r873  
    11<?php
    22
    3 $Revision = 872; // Subversion revision
     3$Revision = 873; // Subversion revision
    44$DatabaseRevision = 870; // SQL structure revision
    55$ReleaseTime = strtotime('2020-04-06');
  • trunk/Application/View.php

    r796 r873  
    2626
    2727    // TODO: Move to external code
    28     if(isset($this->System->Config['Web']['FormatHTML']))
     28    if (isset($this->System->Config['Web']['FormatHTML']))
    2929      $this->FormatHTML = $this->System->Config['Web']['FormatHTML'];
    30     if(isset($this->System->Config['Web']['ShowRuntimeInfo']))
     30    if (isset($this->System->Config['Web']['ShowRuntimeInfo']))
    3131      $this->ShowRuntimeInfo = $this->System->Config['Web']['ShowRuntimeInfo'];
    32     if(isset($this->System->Config['Web']['Charset']))
     32    if (isset($this->System->Config['Web']['Charset']))
    3333      $this->Encoding = $this->System->Config['Web']['Charset'];
    34     if(isset($this->System->Config['Web']['Style']))
     34    if (isset($this->System->Config['Web']['Style']))
    3535      $this->Style = $this->System->Config['Web']['Style'];
    3636  }
     
    3838  function SystemMessage($Title, $Text)
    3939  {
    40     return('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>');
     40    return ('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>');
    4141    //ShowFooter();
    4242    //die();
     
    4545  function ShowNavigation($Page)
    4646  {
    47     if(array_key_exists('REQUEST_URI', $_SERVER))
     47    if (array_key_exists('REQUEST_URI', $_SERVER))
    4848      $ScriptName = $_SERVER['REQUEST_URI'];
    4949      else $ScriptName = '';
    50     while(strpos($ScriptName, '//') !== false)
     50    while (strpos($ScriptName, '//') !== false)
    5151      $ScriptName = str_replace('//', '/', $ScriptName);
    52     if(strpos($ScriptName, '?') !== false)
     52    if (strpos($ScriptName, '?') !== false)
    5353      $ScriptName = substr($ScriptName, 0, strrpos($ScriptName, '?'));
    5454    $ScriptName = substr($ScriptName, strlen($this->System->Link('')));
    55     if(substr($ScriptName, -1, 1) == '/') $ScriptName = substr($ScriptName, 0, -1);
     55    if (substr($ScriptName, -1, 1) == '/') $ScriptName = substr($ScriptName, 0, -1);
    5656
    5757    $Output = '';
    58     while($Page)
     58    while ($Page)
    5959    {
    6060      $Output = ' &gt; <a href="'.$this->System->Link($ScriptName).'/">'.$Page->ShortTitle.'</a>'.$Output;
    6161
    62       if(class_exists($Page->ParentClass))
     62      if (class_exists($Page->ParentClass))
    6363      {
    6464        $PageClass = $Page->ParentClass;
     
    6868    }
    6969    $Output = substr($Output, 6);
    70     return($Output);
     70    return ($Output);
    7171  }
    7272
     
    7979
    8080    $BodyParam = '';
    81     if(isset($Page->Load)) $BodyParam .= ' onload="'.$Page->Load.'"';
    82     if(isset($Page->Unload)) $BodyParam .= ' onunload="'.$Page->Unload.'"';
     81    if (isset($Page->Load)) $BodyParam .= ' onload="'.$Page->Load.'"';
     82    if (isset($Page->Unload)) $BodyParam .= ' onunload="'.$Page->Unload.'"';
    8383    $Output = '<?xml version="1.0" encoding="'.$this->Encoding.'"?>'."\n".
    8484    '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
     
    9191    // Show page headers
    9292    $Bar = '';
    93     foreach($this->System->PageHeaders as $Item)
     93    foreach ($this->System->PageHeaders as $Item)
    9494      $Output .= call_user_func($Item);
    9595
    9696    $Output .= '</head><body'.$BodyParam.'>';
    97     if($this->BasicHTML == false)
     97    if ($this->BasicHTML == false)
    9898    {
    9999      //$Output .= '<div class="MainTitle">'.$Title.'</div>';
    100100      $Output .= '<div class="MainTitle"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">';
    101101      $Bar = '';
    102       foreach($this->System->Bars['Top'] as $BarItem)
     102      foreach ($this->System->Bars['Top'] as $BarItem)
    103103        $Bar .= call_user_func($BarItem);
    104       if(trim($Bar) != '') $Output .= $Bar;
     104      if (trim($Bar) != '') $Output .= $Bar;
    105105        else $Output .= '&nbsp;';
    106106      $Output .= '</div></div>';
    107107    }
    108     return($Output);
     108    return ($Output);
    109109  }
    110110
     
    115115    $Time = round(GetMicrotime() - $ScriptTimeStart, 2);
    116116    $Output = '';
    117     if($this->BasicHTML == false)
     117    if ($this->BasicHTML == false)
    118118    {
    119119      $Output .= '<div id="Footer">'.
    120120      '<i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' | '.
    121121      ' Verze: '.$Revision.' ('.$this->System->HumanDate($ReleaseTime).') |';
    122       if($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').
     122      if ($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').
    123123        ' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |';
    124124      $Output .= '</i></div>';
    125125    }
    126126    $Output .= '</body></html>';
    127     return($Output);
     127    return ($Output);
    128128  }
    129129
     
    133133
    134134    $Output = $Page->Show();
    135     if($Page->ClearPage == false)
     135    if ($Page->ClearPage == false)
    136136    {
    137137      $Output = $this->ShowHeader($Page).$Output.$this->ShowFooter();
    138       if($this->FormatHTML == true) $Output = $this->FormatOutput($Output);
     138      if ($this->FormatHTML == true) $Output = $this->FormatOutput($Output);
    139139    }
    140     return($Output);
     140    return ($Output);
    141141  }
    142142
     
    147147    $Page->Database = $this->Database;
    148148    $Page->FormatHTML = $this->FormatHTML;
    149     return($Page);
     149    return ($Page);
    150150  }
    151151
     
    156156    $nn = 0;
    157157    $n = 0;
    158     while($s != '')
     158    while ($s != '')
    159159    {
    160160      $start = strpos($s, '<');
    161161      $end = strpos($s, '>');
    162       if($start != 0)
     162      if ($start != 0)
    163163      {
    164164        $end = $start - 1;
     
    166166      }
    167167      $line = trim(substr($s, $start, $end + 1));
    168       if(strlen($line) > 0)
    169       if($line[0] == '<')
     168      if (strlen($line) > 0)
     169      if ($line[0] == '<')
    170170      {
    171         if($s[$start + 1] == '/')
     171        if ($s[$start + 1] == '/')
    172172        {
    173173          $n = $n - 2;
     
    175175        } else
    176176        {
    177           if(strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1);
     177          if (strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1);
    178178          else $cmd = substr($line, 1, strlen($line) - 2);
    179179          //echo('['.$cmd.']');
    180           if(strpos($s, '</'.$cmd.'>')) $n = $n + 2;
     180          if (strpos($s, '</'.$cmd.'>')) $n = $n + 2;
    181181        }
    182182      }// else $line = '['.$line.']';
    183       //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
    184       if($line != '') $out .= (str_repeat(' ', $nn).$line."\n");
     183      //if ($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
     184      if ($line != '') $out .= (str_repeat(' ', $nn).$line."\n");
    185185      $s = substr($s, $end + 1, strlen($s));
    186186      $nn = $n;
    187187    }
    188     return($out);
     188    return ($out);
    189189  }
    190190}
  • trunk/Common/Form/Form.php

    r872 r873  
    6767  {
    6868    $Item = $this->Definition['Items'][$Index];
    69     if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    70     {
    71       if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     69    if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     70    {
     71      if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    7272        $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]);
    73       if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     73      if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    7474        $UseType = 'OneToMany';
    75       else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     75      else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    7676        $UseType = 'Enumeration';
    7777    } else $UseType = $Item['Type'];
     
    8888      'Rows' => array(),
    8989    );
    90     foreach($this->Definition['Items'] as $Index => $Item)
    91     if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
    92     if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     90    foreach ($this->Definition['Items'] as $Index => $Item)
     91    if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
     92    if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    9393    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    9494    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    9595    {
    96       if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    97       {
    98         if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     96      if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     97      {
     98        if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    9999          $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]);
    100         if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     100        if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    101101          $UseType = 'OneToMany';
    102         else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     102        else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    103103          $UseType = 'Enumeration';
    104104      } else $UseType = $Item['Type'];
     
    107107        'Type' => $Item['Type'], 'Values' => $this->Values,
    108108        'Filter' => $this->ValuesFilter[$Index]));
    109       if(array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];
    110       if(!$this->FormManager->Type->IsHidden($UseType))
     109      if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];
     110      if (!$this->FormManager->Type->IsHidden($UseType))
    111111        array_push($Table['Rows'], array($Item['Caption'].':', $Edit));
    112112    }
    113113    $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.Table($Table).
    114114    '</fieldset>';
    115     return($Output);
     115    return ($Output);
    116116  }
    117117
    118118  function ShowEditForm()
    119119  {
    120     if(!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';
     120    if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';
    121121    $Output = '<form enctype="multipart/form-data" class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock().
    122122      '<div><input name="submit" type="submit" value="'.$this->Definition['SubmitText'].'" /> '.
    123123      '<input type="button" value="Zrušit" onclick="location.href=\'?\'"/></div></form>';
    124     return($Output);
     124    return ($Output);
    125125  }
    126126
     
    184184  function LoadValuesFromDatabase($Id)
    185185  {
    186     foreach($this->Definition['Items'] as $Index => $Item)
    187     if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     186    foreach ($this->Definition['Items'] as $Index => $Item)
     187    if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    188188    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    189189    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    190190    {
    191         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    192         {
    193           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     191        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     192        {
     193          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    194194            $this->FormManager->Type->RegisterType($Item['Type'], '',
    195195              $this->FormManager->FormTypes[$Item['Type']]);
    196           if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     196          if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    197197            $UseType = 'OneToMany';
    198           else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     198          else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    199199            $UseType = 'Enumeration';
    200200        } else $UseType = $Item['Type'];
    201       if(!array_key_exists('SQL', $Item)) $Item['SQL'] = '';
     201      if (!array_key_exists('SQL', $Item)) $Item['SQL'] = '';
    202202        else $Item['SQL'] = str_replace('#Id', $Id, $Item['SQL']);
    203203      $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery',
     
    205205    }
    206206    $Columns = implode(',', $Columns);
    207     if(array_key_exists('SQL', $this->Definition))
     207    if (array_key_exists('SQL', $this->Definition))
    208208      $SourceTable = '('.$this->Definition['SQL'].') AS `TX`';
    209209      else $SourceTable = '`'.$this->Definition['Table'].'` AS `TX`';
    210210    $DbResult = $this->Database->query('SELECT '.$Columns.' FROM '.$SourceTable.' WHERE `TX`.`Id`='.$Id);
    211211    $DbRow = $DbResult->fetch_array();
    212     foreach($this->Definition['Items'] as $Index => $Item)
    213     if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     212    foreach ($this->Definition['Items'] as $Index => $Item)
     213    if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    214214    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    215215    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    216216    {
    217         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    218         {
    219           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     217        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     218        {
     219          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    220220            $this->FormManager->Type->RegisterType($Item['Type'], '',
    221221              $this->FormManager->FormTypes[$Item['Type']]);
    222           if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     222          if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    223223            $UseType = 'OneToMany';
    224           else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     224          else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    225225            $UseType = 'Enumeration';
    226226        } else $UseType = $Item['Type'];
     
    235235  {
    236236    $Values = array();
    237     foreach($this->Definition['Items'] as $Index => $Item)
    238     {
    239       if(array_key_exists($Index, $this->Values))
    240       if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     237    foreach ($this->Definition['Items'] as $Index => $Item)
     238    {
     239      if (array_key_exists($Index, $this->Values))
     240      if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    241241      (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    242242      ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
     
    245245          'Type' => $Item['Type'], 'Values' => $this->Values);
    246246
    247         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    248         {
    249           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     247        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     248        {
     249          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    250250            $this->FormManager->Type->RegisterType($Item['Type'], '',
    251251              $this->FormManager->FormTypes[$Item['Type']]);
    252           if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
     252          if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')
    253253          {
    254254            $UseType = 'OneToMany';
    255255          }
    256           else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
     256          else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')
    257257            $UseType = 'Enumeration';
    258258        } else $UseType = $Item['Type'];
    259259        $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters);
    260         if(($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);
    261       }
    262     }
    263     if($Id == 0)
     260        if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);
     261      }
     262    }
     263    if ($Id == 0)
    264264    {
    265265      $Values['Id'] = $Id;
     
    316316      }
    317317    }
    318     return($Values);
     318    return ($Values);
    319319  }
    320320
     
    322322  {
    323323    $Valid = true;
    324     foreach($this->Definition['Items'] as $Index => $Item)
    325     if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
     324    foreach ($this->Definition['Items'] as $Index => $Item)
     325    if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    326326    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
    327327    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and
     
    330330    ($Item['ReadOnly'] != true))))
    331331    {
    332         //if(array_key_exists($Context.$Index, $_POST))
    333         if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))
    334         {
    335           if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
     332        //if (array_key_exists($Context.$Index, $_POST))
     333        if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))
     334        {
     335          if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))
    336336            $this->FormManager->Type->RegisterType($Item['Type'], '',
    337337              $this->FormManager->FormTypes[$Item['Type']]);
    338338          $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type'];
    339           if($CustomType == 'Reference')
     339          if ($CustomType == 'Reference')
    340340            $UseType = 'OneToMany';
    341           else if($CustomType == 'Enumeration')
     341          else if ($CustomType == 'Enumeration')
    342342            $UseType = 'Enumeration';
    343343        } else $UseType = $Item['Type'];
    344344
    345345        $Parameters = array('Value' => $this->Values[$Index]);
    346         if(array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];
     346        if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];
    347347          else $Parameters['Null'] = false;
    348         if(!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate',
     348        if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate',
    349349          $Parameters)) {
    350350            $this->ValuesValidate[$Index] = true;
     
    352352          }
    353353    }
    354     if($Valid == false) throw new Exception('not validated');
    355     return($Valid);
     354    if ($Valid == false) throw new Exception('not validated');
     355    return ($Valid);
    356356  }
    357357}
     
    360360function MakeLink($Target, $Title)
    361361{
    362   return('<a href="'.$Target.'">'.$Title.'</a>');
     362  return ('<a href="'.$Target.'">'.$Title.'</a>');
    363363}
    364364
     
    366366{
    367367  $Result = '<table class="BasicTable">';
    368   if(array_key_exists('Header', $Table))
     368  if (array_key_exists('Header', $Table))
    369369  {
    370370    $Result .= '<tr>';
    371     foreach($Table['Header'] as $Item)
     371    foreach ($Table['Header'] as $Item)
    372372      $Result .= '<th>'.$Item.'</th>';
    373373    $Result .= '</tr>';
    374374  }
    375   foreach($Table['Rows'] as $Row)
     375  foreach ($Table['Rows'] as $Row)
    376376  {
    377377    $Result .= '<tr>';
    378     foreach($Row as $Index => $Item)
    379     {
    380       if($Index == 0) $Class = ' class="Header"'; else $Class = '';
     378    foreach ($Row as $Index => $Item)
     379    {
     380      if ($Index == 0) $Class = ' class="Header"'; else $Class = '';
    381381      $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>';
    382382    }
     
    384384  }
    385385  $Result .= '</table>';
    386   return($Result);
     386  return ($Result);
    387387}
    388388
     
    432432    $this->Database->query('DELETE FROM DataType');
    433433
    434     foreach($this->Type->TypeDefinitionList as $Name => $Type)
     434    foreach ($this->Type->TypeDefinitionList as $Name => $Type)
    435435    {
    436436      $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Name.'"');
    437       if($DbResult->num_rows == 0)
     437      if ($DbResult->num_rows == 0)
    438438      {
    439439        $this->Database->insert('DataType', array('Name' => $Name,
     
    447447    }
    448448
    449     foreach($this->Classes as $Class)
    450     if(!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))
     449    foreach ($this->Classes as $Class)
     450    if (!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))
    451451    {
    452452      $DbResult = $this->Database->query('SELECT * FROM information_schema.tables  WHERE table_schema = "centrala_big"
    453453          AND table_name = "'.$Class['Table'].'" LIMIT 1');
    454       if($DbResult->num_rows == 0) continue;
     454      if ($DbResult->num_rows == 0) continue;
    455455
    456456      echo($Class['Table'].'<br>');
    457457      $Module = 1;
    458458      $DbResult = $this->Database->select('Model', 'Id', 'Name="'.$Class['Table'].'"');
    459       if($DbResult->num_rows == 0)
     459      if ($DbResult->num_rows == 0)
    460460      {
    461461        $this->Database->insert('Model', array('Name' => $Class['Table'], 'Title' => $Class['Title'], 'Module' => $Module));
     
    469469      }
    470470
    471       foreach($Class['Items'] as $Name => $Field)
     471      foreach ($Class['Items'] as $Name => $Field)
    472472      {
    473473        echo($Name.', ');
    474474        $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Field['Type'].'"');
    475         if($DbResult->num_rows > 0)
     475        if ($DbResult->num_rows > 0)
    476476        {
    477477          $DbRow = $DbResult->fetch_assoc();
     
    482482          // Search parent type
    483483          $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Type['Type'].'"');
    484           if($DbResult->num_rows > 0)
     484          if ($DbResult->num_rows > 0)
    485485          {
    486486            $DbRow = $DbResult->fetch_assoc();
     
    494494
    495495        $DbResult = $this->Database->select('ModelField', 'Id', '(Name="'.$Name.'") AND (Model='.$Model.')');
    496         if($DbResult->num_rows == 0)
     496        if ($DbResult->num_rows == 0)
    497497        {
    498498          $this->Database->insert('ModelField', array('Name' => $Name,
  • trunk/Common/Form/Types/Base.php

    r738 r873  
    1717  function OnView($Item)
    1818  {
    19     return('');
     19    return ('');
    2020  }
    2121
    2222  function OnEdit($Item)
    2323  {
    24     return('');
     24    return ('');
    2525  }
    2626
    2727  function OnLoad($Item)
    2828  {
    29     return('');
     29    return ('');
    3030  }
    3131
    3232  function OnLoadDb($Item)
    3333  {
    34     return($Item['Value']);
     34    return ($Item['Value']);
    3535  }
    3636
    3737  function OnSaveDb($Item)
    3838  {
    39     return($Item['Value']);
     39    return ($Item['Value']);
    4040  }
    4141
    4242  function DatabaseEscape($Value)
    4343  {
    44     return(addslashes($Value));
     44    return (addslashes($Value));
    4545  }
    4646
    4747  function OnFilterName($Item)
    4848  {
    49     if(array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
     49    if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
    5050      $SQL = '('.$Item['SQL'].') AS ';
    5151      else $SQL = '';
    52     return($SQL.'`'.$Item['Name'].'`');
     52    return ($SQL.'`'.$Item['Name'].'`');
    5353  }
    5454
    5555  function OnFilterNameQuery($Item)
    5656  {
    57     if(array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
     57    if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
    5858      $Output = '('.$Item['SQL'].') AS `'.$Item['Name'].'`, ('.$Item['SQL'].') AS `'.$Item['Name'].'_Filter`';
    5959      else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`';
    60     return($Output);
     60    return ($Output);
    6161  }
    6262
    6363  function Validate($Item)
    6464  {
    65     return(true);
     65    return (true);
    6666  }
    6767
    6868  function GetValidationFormat()
    6969  {
    70     return('');
     70    return ('');
    7171  }
    7272}
  • trunk/Common/Form/Types/Boolean.php

    r738 r873  
    99  function OnView($Item)
    1010  {
    11     if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
    12     return('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>');
     11    if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
     12    return ('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>');
    1313  }
    1414
    1515  function OnEdit($Item)
    1616  {
    17     if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
    18     return('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>');
     17    if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
     18    return ('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>');
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     if(array_key_exists($Item['Name'], $_POST)) return(1);
    24       else return(0);
     23    if (array_key_exists($Item['Name'], $_POST)) return (1);
     24      else return (0);
    2525  }
    2626}
  • trunk/Common/Form/Types/Color.php

    r548 r873  
    1010  {
    1111    $Output = '<span style="background-color: #'.$Item['Value'].'">&nbsp;&nbsp;&nbsp;&nbsp;</span>';
    12     return($Output);
     12    return ($Output);
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return ($Output);
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     return($_POST[$Item['Name']]);
     23    return ($_POST[$Item['Name']]);
    2424  }
    2525}
  • trunk/Common/Form/Types/Date.php

    r872 r873  
    1111    global $MonthNames;
    1212
    13     if($Item['Value'] == null) return('');
    14     if((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
     13    if ($Item['Value'] == null) return ('');
     14    if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
    1515    $Parts = getdate($Item['Value']);
    1616
    1717    $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year'];
    18     return($Output);
     18    return ($Output);
    1919  }
    2020
     
    3232    $Output = '';
    3333    $Style = '';
    34     if(array_key_exists('Null', $Item) and $Item['Null'])
     34    if (array_key_exists('Null', $Item) and $Item['Null'])
    3535    {
    36       if(!$IsNull)
     36      if (!$IsNull)
    3737      {
    3838        $Checked = ' checked="1"';
     
    4949    // Day
    5050    $Output .= '<select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>';
    51     for($I = 1; $I <= 31; $I++)
     51    for ($I = 1; $I <= 31; $I++)
    5252    {
    53       if($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     53      if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    5454      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    5555    }
     
    5757    // Month
    5858   $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>';
    59    for($I = 1; $I <= 12; $I++)
     59   for ($I = 1; $I <= 12; $I++)
    6060    {
    61       if($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     61      if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    6262      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>';
    6363    }
     
    6565    // Year
    6666    $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>';
    67     for($I = 1900; $I < 2100; $I++)
     67    for ($I = 1900; $I < 2100; $I++)
    6868    {
    69       if($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     69      if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    7070      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    7171    }
    7272    $Output .= '</select>';
    73     return($Output);
     73    return ($Output);
    7474  }
    7575
    7676  function OnLoad($Item)
    7777  {
    78     if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);
    79       else return(mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']));
     78    if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return (null);
     79      else return (mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']));
    8080  }
    8181
    8282  function OnLoadDb($Item)
    8383  {
    84     return(MysqlDateToTime($Item['Value']));
     84    return (MysqlDateToTime($Item['Value']));
    8585  }
    8686
    8787  function OnSaveDb($Item)
    8888  {
    89     if($Item['Value'] == null) return(null);
    90       else return(date('Y-m-d', $Item['Value']));
     89    if ($Item['Value'] == null) return (null);
     90      else return (date('Y-m-d', $Item['Value']));
    9191  }
    9292
    9393  function DatabaseEscape($Value)
    9494  {
    95     return('"'.addslashes($Value).'"');
     95    return ('"'.addslashes($Value).'"');
    9696  }
    9797}
  • trunk/Common/Form/Types/Enumeration.php

    r738 r873  
    88  {
    99    $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
    10     if(array_key_exists($Item['Value'], $Type['Parameters']['States']))
     10    if (array_key_exists($Item['Value'], $Type['Parameters']['States']))
    1111      $Output = $Type['Parameters']['States'][$Item['Value']];
    1212      else $Output = $Item['Value'];
    13     return($Output);
     13    return ($Output);
    1414  }
    1515
     
    1818    $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
    1919    $Output = '<select name="'.$Item['Name'].'">';
    20       if(array_key_exists('Null', $Item) and $Item['Null'])
     20      if (array_key_exists('Null', $Item) and $Item['Null'])
    2121    {
    22       if($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
     22      if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
    2323      $Output .= '<option value=""'.$Selected.'></option>';
    2424    }
    25     foreach($Type['Parameters']['States'] as $Index => $StateName)
     25    foreach ($Type['Parameters']['States'] as $Index => $StateName)
    2626    {
    27       if($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = '';
     27      if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = '';
    2828      $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$StateName.'</option>';
    2929    }
    3030    $Output .= '</select>';
    31     return($Output);
     31    return ($Output);
    3232  }
    3333
    3434  function OnLoad($Item)
    3535  {
    36     if($_POST[$Item['Name']] == '') return(NULL);
    37     return($_POST[$Item['Name']]);
     36    if ($_POST[$Item['Name']] == '') return (NULL);
     37    return ($_POST[$Item['Name']]);
    3838  }
    3939
    4040  function OnLoadDb($Item)
    4141  {
    42     if($Item['Value'] == '') return(NULL);
    43     else return($Item['Value']);
     42    if ($Item['Value'] == '') return (NULL);
     43    else return ($Item['Value']);
    4444  }
    4545}
  • trunk/Common/Form/Types/File.php

    r738 r873  
    1616    $Result = $FileInfo->file($this->FileName);
    1717    //$FileInfo->close();
    18     return($Result);
     18    return ($Result);
    1919  }
    2020
     
    2222  {
    2323    $FileName = $this->GetFullName($Item);
    24     if(file_exists($FileName)) $Result = filesize($FileName);
     24    if (file_exists($FileName)) $Result = filesize($FileName);
    2525      else $Result = 0;
    26     return($Result);
     26    return ($Result);
    2727  }
    2828
     
    3030  {
    3131    $ParentId = $this->Directory;
    32     while($ParentId != null)
     32    while ($ParentId != null)
    3333    {
    3434      $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$ParentId);
     
    3838    }
    3939    $Result = $this->UploadFileFolder.'/'.$Path.$File->Name;
    40     return($Result);
     40    return ($Result);
    4141  }
    4242
    4343  function GetExt()
    4444  {
    45     return(substr($this->Name, 0, strpos($this->Name, '.') - 1));
     45    return (substr($this->Name, 0, strpos($this->Name, '.') - 1));
    4646  }
    4747
    4848  function Delete()
    4949  {
    50     if(file_exists($this->GetFullName())) unlink($this->GetFullName());
     50    if (file_exists($this->GetFullName())) unlink($this->GetFullName());
    5151  }
    5252
    5353  function GetContent()
    5454  {
    55     if($this->TempName != '') $Content = file_get_contents($this->TempName);
     55    if ($this->TempName != '') $Content = file_get_contents($this->TempName);
    5656      else $Content = file_get_contents($this->GetFullName());
    57     return($Content);
     57    return ($Content);
    5858  }
    5959}
     
    7575  {
    7676    $File = &$Item['Value'];
    77     return('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'.
     77    return ('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'.
    7878      $File.'</a> ('.HumanSize($File->Size).')');
    7979  }
     
    8686    $File = &$Item['Value'];
    8787    $Output = '<input type="file" name="'.$Item['Name'].'" value="'.$File->Name.'">';
    88     return($Output);
     88    return ($Output);
    8989  }
    9090
    9191  function OnLoad($Item)
    9292  {
    93     if(!is_object($Item['Value'])) $Item['Value'] = new DbFile();
     93    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
    9494    $File = &$Item['Value'];
    95     if(array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))
     95    if (array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))
    9696    {
    9797      $UploadFile = $_FILES[$Item['Name']];
    98       if(file_exists($UploadFile['tmp_name']))
     98      if (file_exists($UploadFile['tmp_name']))
    9999      {
    100100        $File->Name = $UploadFile['name'];
     
    103103      }
    104104    }
    105     return($File);
     105    return ($File);
    106106  }
    107107
    108108  function OnLoadDb($Item)
    109109  {
    110     if(!is_object($Item['Value'])) $Item['Value'] = new DbFile();
     110    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
    111111    $File = &$Item['Value'];
    112112    $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id);
    113     if($DbResult->num_rows() > 0)
     113    if ($DbResult->num_rows() > 0)
    114114    {
    115115      $DbRow = $DbResult->fetch_assoc();
     
    118118      $File->Directory = $DbRow['Directory'];
    119119    }
    120     return($File);
     120    return ($File);
    121121  }
    122122
    123123  function OnSaveDb($Item)
    124124  {
    125     if(!is_object($Item['Value'])) $Item['Value'] = new DbFile();
     125    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
    126126    $File = &$Item['Value'];
    127127    $Properties = array('Name' => $File->Name,
    128128      'Size' => $File->GetSize(), 'Directory' => $File->Directory);
    129129    $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id);
    130     if($DbResult->num_rows() > 0)
     130    if ($DbResult->num_rows() > 0)
    131131    {
    132132      $DbRow = $DbResult->fetch_assoc();
    133       if($File->TempName != '')
     133      if ($File->TempName != '')
    134134      {
    135135        $FileName = $File->GetFullName();
     
    142142      $File->Id = $this->Database->insert_id;
    143143    }
    144     if(!move_uploaded_file($File->TempName, $FileName))
     144    if (!move_uploaded_file($File->TempName, $FileName))
    145145      SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!');
    146146  }
  • trunk/Common/Form/Types/Float.php

    r548 r873  
    1010  {
    1111    $Output = $Item['Value'];
    12     return($Output);
     12    return ($Output);
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return ($Output);
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     return($_POST[$Item['Name']]);
     23    return ($_POST[$Item['Name']]);
    2424  }
    2525}
  • trunk/Common/Form/Types/GPS.php

    r548 r873  
    1010
    1111    $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
    12     if($DbResult->num_rows > 0)
     12    if ($DbResult->num_rows > 0)
    1313    {
    1414      $DbRow = $DbResult->fetch_assoc();
     
    1717      $Output = '<a href="http://www.mapy.cz/?st=search&fr=loc:'.$DbRow['Latitude'].' '.$DbRow['Longitude'].'">'.$Latitude[0].'°'.$Latitude[1]."'".$Latitude[2].'" '.$Longitude[0].'°'.$Longitude[1]."'".$Longitude[2].'"</a>';
    1818    }
    19     return($Output);
     19    return ($Output);
    2020  }
    2121
     
    2424    global $Database;
    2525
    26     if($Item['Value'] != '')
     26    if ($Item['Value'] != '')
    2727    {
    2828      $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
    29       if($DbResult->num_rows > 0)
     29      if ($DbResult->num_rows > 0)
    3030      {
    3131        $DbRow = $DbResult->fetch_assoc();
     
    4040    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'"/>\'';
    4141    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'"/>"';
    42     return($Output);
     42    return ($Output);
    4343  }
    4444
     
    5050    $Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']);
    5151    $Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")');
    52     return($Database->insert_id);
     52    return ($Database->insert_id);
    5353  }
    5454
     
    6161    $Float = ($Float - intval($Float)) * 60;
    6262    $Seconds = round($Float, 3);
    63     return(array($Degrees, $Minutes, $Seconds));
     63    return (array($Degrees, $Minutes, $Seconds));
    6464  }
    6565
    6666  function Implode($Degrees, $Minutes, $Seconds)
    6767  {
    68     if($Degrees < 0) return(-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60));
    69     else return($Degrees + ($Minutes + $Seconds / 60) / 60);
     68    if ($Degrees < 0) return (-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60));
     69    else return ($Degrees + ($Minutes + $Seconds / 60) / 60);
    7070  }
    7171}
  • trunk/Common/Form/Types/Hidden.php

    r738 r873  
    1414  {
    1515    $Output = $Item['Value'];
    16     return($Output);
     16    return ($Output);
    1717  }
    1818
     
    2020  {
    2121    $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />';
    22     return($Output);
     22    return ($Output);
    2323  }
    2424
    2525  function OnLoad($Item)
    2626  {
    27     return($_POST[$Item['Name']]);
     27    return ($_POST[$Item['Name']]);
    2828  }
    2929}
  • trunk/Common/Form/Types/Hyperlink.php

    r548 r873  
    88  {
    99    $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>';
    10     return($Output);
     10    return ($Output);
    1111  }
    1212
     
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    16     return($Output);
     16    return ($Output);
    1717  }
    1818
    1919  function OnLoad($Item)
    2020  {
    21     return($_POST[$Item['Name']]);
     21    return ($_POST[$Item['Name']]);
    2222  }
    2323}
  • trunk/Common/Form/Types/IPv4Address.php

    r738 r873  
    88  {
    99    $Output = $Item['Value'];
    10     return($Output);
     10    return ($Output);
    1111  }
    1212
     
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    16     return($Output);
     16    return ($Output);
    1717  }
    1818
    1919  function OnLoad($Item)
    2020  {
    21     return($_POST[$Item['Name']]);
     21    return ($_POST[$Item['Name']]);
    2222  }
    2323
    2424  function Validate($Item)
    2525  {
    26     if($Item['Null'] and ($Item['Value'] == '')) return(true);
    27     return(filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)));
     26    if ($Item['Null'] and ($Item['Value'] == '')) return (true);
     27    return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)));
    2828  }
    2929
    3030  function GetValidationFormat()
    3131  {
    32     return('x.x.x.x kde x je hodnota 0..255');
     32    return ('x.x.x.x kde x je hodnota 0..255');
    3333  }
    3434}
  • trunk/Common/Form/Types/IPv6Address.php

    r738 r873  
    88  {
    99    $Output = $Item['Value'];
    10     return($Output);
     10    return ($Output);
    1111  }
    1212
     
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    16     return($Output);
     16    return ($Output);
    1717  }
    1818
    1919  function OnLoad($Item)
    2020  {
    21     return($_POST[$Item['Name']]);
     21    return ($_POST[$Item['Name']]);
    2222  }
    2323
    2424  function Validate($Item)
    2525  {
    26     if($Item['Null'] and ($Item['Value'] == '')) return(true);
    27     return(filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)));
     26    if ($Item['Null'] and ($Item['Value'] == '')) return (true);
     27    return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)));
    2828  }
    2929
    3030  function GetValidationFormat()
    3131  {
    32     return('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f');
     32    return ('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f');
    3333  }
    3434}
  • trunk/Common/Form/Types/Image.php

    r738 r873  
    77    global $System;
    88
    9     return('<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']);
     9    return ('<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']);
    1010  }
    1111}
  • trunk/Common/Form/Types/Integer.php

    r738 r873  
    1010  {
    1111    $Output = $Item['Value'];
    12     return($Output);
     12    return ($Output);
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return ($Output);
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     return($_POST[$Item['Name']]);
     23    return ($_POST[$Item['Name']]);
    2424  }
    2525
    2626  function Validate($Item)
    2727  {
    28     if($Item['Null'] and ($Item['Value'] == '')) return(true);
    29     return(preg_match('/^\-*[0-9\.]+$/', $Item['Value']));
     28    if ($Item['Null'] and ($Item['Value'] == '')) return (true);
     29    return (preg_match('/^\-*[0-9\.]+$/', $Item['Value']));
    3030  }
    3131
    3232  function GetValidationFormat()
    3333  {
    34     return('číselná hodnota');
     34    return ('číselná hodnota');
    3535  }
    3636}
  • trunk/Common/Form/Types/MacAddress.php

    r738 r873  
    1010  {
    1111    $Output = $Item['Value'];
    12     return($Output);
     12    return ($Output);
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return ($Output);
    1919  }
    2020
     
    2222  {
    2323    //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>');
    24     return(strtoupper($_POST[$Item['Name']]));
     24    return (strtoupper($_POST[$Item['Name']]));
    2525  }
    2626
    2727  function DatabaseEscape($Value)
    2828  {
    29     return('"'.addslashes($Value).'"');
     29    return ('"'.addslashes($Value).'"');
    3030  }
    3131
    3232  function Validate($Item)
    3333  {
    34     if($Item['Null'] and ($Item['Value'] == '')) return(true);
    35     return(preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value']));
     34    if ($Item['Null'] and ($Item['Value'] == '')) return (true);
     35    return (preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value']));
    3636  }
    3737
    3838  function GetValidationFormat()
    3939  {
    40     return('XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F');
     40    return ('XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F');
    4141  }
    4242}
  • trunk/Common/Form/Types/OneToMany.php

    r738 r873  
    1010  {
    1111    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
    12     if($Item['Value'] != '')
     12    if ($Item['Value'] != '')
    1313    {
    1414      $Output = '<a href="?t='.$Type['Parameters']['Table'].'&amp;a='.
    1515        'view'.'&amp;i='.$Item['Value'].'">'.$Item['Filter'].'</a>';
    1616    } else $Output = '';
    17     return($Output);
     17    return ($Output);
    1818  }
    1919
     
    2222    $Output = '<select name="'.$Item['Name'].'" id="'.$Item['Name'].'">';
    2323    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
    24     if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
     24    if (array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
    2525      else $Where = '';
    26     if(array_key_exists('Null', $Item) and $Item['Null'])
     26    if (array_key_exists('Null', $Item) and $Item['Null'])
    2727    {
    28       if($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
     28      if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
    2929      $Output .= '<option value=""'.$Selected.'></option>';
    3030    }
    31     if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
     31    if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
    3232      else $Table = $Type['Parameters']['Table'];
    3333    $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`');
    34     while($DbRow = $DbResult->fetch_assoc())
     34    while ($DbRow = $DbResult->fetch_assoc())
    3535    {
    36       if($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';
     36      if ($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';
    3737      $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>';
    3838    }
    3939    $Output .= '</select>';
    40     if($this->FormManager->ShowRelation)
     40    if ($this->FormManager->ShowRelation)
    4141    {
    4242      $URL = '';
    43       if(array_key_exists('OnPreset', $Item))
     43      if (array_key_exists('OnPreset', $Item))
    4444      {
    4545        $Preset = call_user_func($Item['OnPreset'], $Item['Values']);
     
    5151        'onclick="return popupwindow(&quot;'.$this->FormManager->Root.'/is/?a=select&amp;t='.$Table.'&amp;r='.$Item['Name'].'&quot;,&quot;test&quot;);" style="cursor:hand;cursor:pointer"/>';
    5252    }
    53     return($Output);
     53    return ($Output);
    5454  }
    5555
    5656  function OnLoad($Item)
    5757  {
    58     if($_POST[$Item['Name']] == '') return(NULL);
    59       else return($_POST[$Item['Name']]);
     58    if ($_POST[$Item['Name']] == '') return (NULL);
     59      else return ($_POST[$Item['Name']]);
    6060  }
    6161
    6262  function OnLoadDb($Item)
    6363  {
    64     if($Item['Value'] == '') return(NULL);
    65       else return($Item['Value']);
     64    if ($Item['Value'] == '') return (NULL);
     65      else return ($Item['Value']);
    6666  }
    6767
    6868  function OnFilterName($Item)
    6969  {
    70     return('`'.$Item['Name'].'_Filter`');
     70    return ('`'.$Item['Name'].'_Filter`');
    7171  }
    7272
     
    7474  {
    7575    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
    76     //if($Item['Value'] != '')
     76    //if ($Item['Value'] != '')
    7777    //{
    78       if(array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
     78      if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];
    7979        else $Table = $Type['Parameters']['Table'];
    8080      $Output = '`'.$Item['Name'].'`, (SELECT '.$Type['Parameters']['Name'].''.
     
    8282        $Type['Parameters']['Id'].'`=`TX`.`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`';
    8383    //} else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`';
    84     return($Output);
     84    return ($Output);
    8585  }
    8686}
  • trunk/Common/Form/Types/OneToMany2.php

    r548 r873  
    88  {
    99    $Output = '<a href="?Action=ShowList&amp;TableId='.$Item['TypeDefinition'].'&amp;ParentTable='.$Item['SourceTable'].'&amp;ParentColumn='.$Item['SourceItemId'].'">Seznam</a>';
    10     return($Output);
     10    return ($Output);
    1111  }
    1212
     
    1414  {
    1515    $Output = '<a href="?Action=ShowList&amp;TableId='.$Item['TypeDefinition'].'&amp;ParentTable='.$Item['SourceTable'].'&amp;ParentColumn='.$Item['SourceItemId'].'">Seznam</a>';
    16     return($Output);
     16    return ($Output);
    1717  }
    1818
    1919  function OnLoad($Item)
    2020  {
    21     return($_POST[$Item['Name']]);
     21    return ($_POST[$Item['Name']]);
    2222  }
    2323}
  • trunk/Common/Form/Types/Password.php

    r738 r873  
    1010  {
    1111    $Output = '';
    12     for($I = 0; $I < 6; $I++)
     12    for ($I = 0; $I < 6; $I++)
    1313      $Output .= '*';
    14     return($Output);
     14    return ($Output);
    1515  }
    1616
     
    1818  {
    1919    $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>';
    20     return($Output);
     20    return ($Output);
    2121  }
    2222
     
    2727    $Result = $_POST[$Item['Name']];
    2828    /*
    29     if(!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);
     29    if (!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);
    3030    else
    3131    {
    3232      $DbRestult = $Database->query('SELECT '.$Item['Name'].' FROM '.$Item['SourceTable'].' WHERE Id='.$Item['SourceItemId']);
    33       if($DbResult->num_rows > 0)
     33      if ($DbResult->num_rows > 0)
    3434      {
    3535        $DbRow = $DbResult->fetch_assoc();
    36         if($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']];
     36        if ($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']];
    3737        else $Result = sha1($_POST[$Item['Name']]);
    3838      } else $Result = sha1($_POST[$Item['Name']]);
    3939    }
    4040    */
    41     return($Result);
     41    return ($Result);
    4242  }
    4343
    4444  function OnSaveDb($Item)
    4545  {
    46     if($Item['Value'] == '') return('');
     46    if ($Item['Value'] == '') return ('');
    4747    else {
    4848      $PasswordHash = new PasswordHash();
    49       return($PasswordHash->Hash($Item['Value'], $Item['Values']['Salt']));
     49      return ($PasswordHash->Hash($Item['Value'], $Item['Values']['Salt']));
    5050    }
    5151  }
     
    5353  function OnLoadDb($Item)
    5454  {
    55     return('');
     55    return ('');
    5656  }
    5757}
  • trunk/Common/Form/Types/RandomHash.php

    r738 r873  
    1414  {
    1515    $Output = $Item['Value'];
    16     return($Output);
     16    return ($Output);
    1717  }
    1818
    1919  function OnEdit($Item)
    2020  {
    21     if($Item['Value'] == '')
     21    if ($Item['Value'] == '')
    2222    {
    2323      // Create only once
     
    2626    }
    2727    $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />';
    28     return($Output);
     28    return ($Output);
    2929  }
    3030
    3131  function OnLoad($Item)
    3232  {
    33     return($_POST[$Item['Name']]);
     33    return ($_POST[$Item['Name']]);
    3434  }
    3535}
  • trunk/Common/Form/Types/String.php

    r574 r873  
    1010  {
    1111    $Output = $Item['Value'];
    12     return($Output);
     12    return ($Output);
    1313  }
    1414
     
    1616  {
    1717    $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    18     return($Output);
     18    return ($Output);
    1919  }
    2020
     
    2222  {
    2323    //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>');
    24     return($_POST[$Item['Name']]);
     24    return ($_POST[$Item['Name']]);
    2525  }
    2626
    2727  function DatabaseEscape($Value)
    2828  {
    29     return('"'.addslashes($Value).'"');
     29    return ('"'.addslashes($Value).'"');
    3030  }
    3131}
  • trunk/Common/Form/Types/Text.php

    r799 r873  
    1010  {
    1111    $Output = str_replace("\n", '<br/>', strip_tags($Item['Value']));
    12     return($Output);
     12    return ($Output);
    1313  }
    1414
     
    1616  {
    1717    $Output = '<textarea name="'.$Item['Name'].'">'.$Item['Value'].'</textarea>';
    18     return($Output);
     18    return ($Output);
    1919  }
    2020
    2121  function OnLoad($Item)
    2222  {
    23     return($_POST[$Item['Name']]);
     23    return ($_POST[$Item['Name']]);
    2424  }
    2525
    2626  function DatabaseEscape($Value)
    2727  {
    28     return('"'.addslashes($Value).'"');
     28    return ('"'.addslashes($Value).'"');
    2929  }
    3030}
  • trunk/Common/Form/Types/Time.php

    r872 r873  
    99  function OnView($Item)
    1010  {
    11     if($Item['Value'] == 0) return('');
    12     if((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
     11    if ($Item['Value'] == 0) return ('');
     12    if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
    1313    $TimeParts = getdate($Item['Value']);
    1414
    1515    $Output = sprintf('%02d', $TimeParts['hours']).':'.sprintf('%02d', $TimeParts['minutes']).':'.sprintf('%02d', $TimeParts['seconds']);
    16     return($Output);
     16    return ($Output);
    1717  }
    1818
     
    2828    $Output = '';
    2929    $Style = '';
    30     if(array_key_exists('Null', $Item) and $Item['Null'])
     30    if (array_key_exists('Null', $Item) and $Item['Null'])
    3131    {
    32       if($IsNull)
     32      if ($IsNull)
    3333      {
    3434        $Checked = ' checked="1"';
     
    4545    // Hour
    4646    $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>';
    47     for($I = 1; $I <= 24; $I++)
     47    for ($I = 1; $I <= 24; $I++)
    4848    {
    49       if($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     49      if ($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    5050      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    5151    }
     
    5353    // Minute
    5454    $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>';
    55     for($I = 1; $I <= 60; $I++)
     55    for ($I = 1; $I <= 60; $I++)
    5656    {
    57       if($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     57      if ($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    5858      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    5959    }
     
    6161    // Second
    6262    $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>';
    63     for($I = 1; $I <= 60; $I++)
     63    for ($I = 1; $I <= 60; $I++)
    6464    {
    65       if($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';
     65      if ($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';
    6666      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    6767    }
    6868    $Output .= '</select>';
    69     return($Output);
     69    return ($Output);
    7070  }
    7171
    7272  function OnLoad($Item)
    7373  {
    74     if(!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);
    75       return(mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second']));
     74    if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return (null);
     75      return (mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second']));
    7676  }
    7777
    7878  function OnLoadDb($Item)
    7979  {
    80     return(MysqlTimeToTime($Item['Value']));
     80    return (MysqlTimeToTime($Item['Value']));
    8181  }
    8282
    8383  function OnSaveDb($Item)
    8484  {
    85     if($Item['Value'] == null) return(null);
    86       else return(date('H:i:s', $Item['Value']));
     85    if ($Item['Value'] == null) return (null);
     86      else return (date('H:i:s', $Item['Value']));
    8787  }
    8888
    8989  function DatabaseEscape($Value)
    9090  {
    91     return('"'.addslashes($Value).'"');
     91    return ('"'.addslashes($Value).'"');
    9292  }
    9393}
  • trunk/Common/Form/Types/TimeDiff.php

    r660 r873  
    77  function OnView($Item)
    88  {
    9     if($Item['Value'] == null) $Output = '';
     9    if ($Item['Value'] == null) $Output = '';
    1010    else {
    1111      $Output = sprintf('%02d', floor($Item['Value'] / 3600 % 24)).':'.
     
    1313        sprintf('%02d', floor($Item['Value'] % 60));
    1414      $Days = floor($Item['Value'] / (60 * 60 * 24));
    15       if($Days > 0) $Output = $Days.' dnů '.$Output;
     15      if ($Days > 0) $Output = $Days.' dnů '.$Output;
    1616    }
    17     return($Output);
     17    return ($Output);
    1818  }
    1919}
  • trunk/Common/Form/Types/Type.php

    r738 r873  
    6767  function ExecuteTypeEvent($TypeName, $Event, $Parameters = array())
    6868  {
    69     if(array_key_exists($TypeName, $this->TypeDefinitionList))
     69    if (array_key_exists($TypeName, $this->TypeDefinitionList))
    7070    {
    7171      $Type = $this->TypeDefinitionList[$TypeName];
    7272      $TypeClass = 'Type'.$Type['Class'];
    7373      $TypeObject = new $TypeClass($this->FormManager);
    74       if(is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));
    75         else return($TypeName.'->'.$Event.'('.serialize($Parameters).')');
    76     } else return($TypeName);
     74      if (is_callable(array($TypeObject, $Event))) return ($TypeObject->$Event($Parameters));
     75        else return ($TypeName.'->'.$Event.'('.serialize($Parameters).')');
     76    } else return ($TypeName);
    7777  }
    7878
    7979  function IsHidden($TypeName)
    8080  {
    81     if(array_key_exists($TypeName, $this->TypeDefinitionList))
     81    if (array_key_exists($TypeName, $this->TypeDefinitionList))
    8282    {
    8383      $Type = $this->TypeDefinitionList[$TypeName];
    8484      $TypeClass = 'Type'.$Type['Class'];
    8585      $TypeObject = new $TypeClass($this->FormManager);
    86       return($TypeObject->Hidden);
    87     } else return(false);
     86      return ($TypeObject->Hidden);
     87    } else return (false);
    8888  }
    8989
    9090  function RegisterType($Name, $ParentType, $Parameters)
    9191  {
    92     if($ParentType != '')
     92    if ($ParentType != '')
    9393    {
    9494      $Type = $this->TypeDefinitionList[$ParentType];
     
    9797    $Type['Name'] = $Name;
    9898    $Type['Class'] = $Name;
    99     if(array_key_exists('Parameters', $Type))
     99    if (array_key_exists('Parameters', $Type))
    100100      $Type['Parameters'] = array_merge($Type['Parameters'], $Parameters);
    101101      else $Type['Parameters'] = $Parameters;
     
    111111  function GetTypeDefinition($TypeName)
    112112  {
    113     return($this->TypeDefinitionList[$TypeName]);
     113    return ($this->TypeDefinitionList[$TypeName]);
    114114  }
    115115}
  • trunk/Common/Global.php

    r869 r873  
    2525
    2626  $UnitIndex = 0;
    27   while($Value > 1024)
     27  while ($Value > 1024)
    2828  {
    2929    $Value = round($Value / 1024, 3);
    3030    $UnitIndex++;
    3131  }
    32   return($Value.' '.$UnitNames[$UnitIndex]);
     32  return ($Value.' '.$UnitNames[$UnitIndex]);
    3333}
    3434
     
    4848function HumanDate($Time)
    4949{
    50   if($Time != '') {
     50  if ($Time != '') {
    5151    $Date = explode(' ', $Time);
    5252    $Parts = explode('-', $Date[0]);
    53     if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
    54     else return('&nbsp;');
    55   } else return('&nbsp;');
     53    if ($Date != '0000-00-00') return (($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
     54    else return ('&nbsp;');
     55  } else return ('&nbsp;');
    5656}
    5757
     
    6262  $Around = 10;
    6363  $Result = '';
    64   if($Count>1)
    65   {
    66     if($Page>0)
     64  if ($Count>1)
     65  {
     66    if ($Page>0)
    6767    {
    6868      $Result.= '<a href="'.$URL.'0">&lt;&lt;</a> ';
     
    7171    $PagesMax = $Count-1;
    7272    $PagesMin = 0;
    73     if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
    74     if($PagesMin<($Page-$Around))
     73    if ($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
     74    if ($PagesMin<($Page-$Around))
    7575    {
    7676      $Result.= ' .. ';
    7777      $PagesMin = $Page-$Around;
    7878    }
    79     for($i=$PagesMin;$i<=$PagesMax;$i++)
    80     {
    81       if($i==$Page) $Result.= '<strong>';
     79    for ($i=$PagesMin;$i<=$PagesMax;$i++)
     80    {
     81      if ($i==$Page) $Result.= '<strong>';
    8282      $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
    83       if($i==$Page) $Result.= '</strong>';
    84     }
    85     if($PagesMax<($Count-1)) $Result .= ' .. ';
    86     if($Page<($Count-1))
     83      if ($i==$Page) $Result.= '</strong>';
     84    }
     85    if ($PagesMax<($Count-1)) $Result .= ' .. ';
     86    if ($Page<($Count-1))
    8787    {
    8888      $Result.= '<a href="'.$URL.($Page+1).'">&gt;</a> ';
     
    9090    }
    9191  }
    92   return($Result);
     92  return ($Result);
    9393}
    9494
    9595function ExtractTime($Time)
    9696{
    97   return(array(
     97  return (array(
    9898    'Year' => date('Y', $Time),
    9999    'Month' => date('n', $Time),
     
    109109  $Result = array();
    110110  $Parts = explode('&', $QueryString);
    111   foreach($Parts as $Part)
    112   {
    113     if($Part != '')
    114     {
    115       if(!strpos($Part, '=')) $Part .= '=';
     111  foreach ($Parts as $Part)
     112  {
     113    if ($Part != '')
     114    {
     115      if (!strpos($Part, '=')) $Part .= '=';
    116116      $Item = explode('=', $Part);
    117117      $Result[$Item[0]] = $Item[1];
    118118    }
    119119  }
    120   return($Result);
     120  return ($Result);
    121121}
    122122
     
    124124{
    125125  $Parts = array();
    126   foreach($QueryStringArray as $Index => $Item)
     126  foreach ($QueryStringArray as $Index => $Item)
    127127  {
    128128    $Parts[] = $Index.'='.$Item;
    129129  }
    130   return(implode('&amp;', $Parts));
     130  return (implode('&amp;', $Parts));
    131131}
    132132
     
    138138
    139139  $Result = '';
    140   if(array_key_exists('all', $QueryItems))
     140  if (array_key_exists('all', $QueryItems))
    141141  {
    142142    $PageCount = 1;
     
    149149  }
    150150
    151   if(!array_key_exists($ObjectName.'Page', $_SESSION)) $_SESSION[$ObjectName.'Page'] = 0;
    152   if(array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName)) {
    153     if(array_key_exists('page', $_GET)) $_SESSION[$ObjectName.'Page'] = $_GET['page'] * 1;
    154   }
    155   if($_SESSION[$ObjectName.'Page'] < 0) $_SESSION[$ObjectName.'Page'] = 0;
    156   if($_SESSION[$ObjectName.'Page'] >= $PageCount) $_SESSION[$ObjectName.'Page'] = $PageCount - 1;
     151  if (!array_key_exists($ObjectName.'Page', $_SESSION)) $_SESSION[$ObjectName.'Page'] = 0;
     152  if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName)) {
     153    if (array_key_exists('page', $_GET)) $_SESSION[$ObjectName.'Page'] = $_GET['page'] * 1;
     154  }
     155  if ($_SESSION[$ObjectName.'Page'] < 0) $_SESSION[$ObjectName.'Page'] = 0;
     156  if ($_SESSION[$ObjectName.'Page'] >= $PageCount) $_SESSION[$ObjectName.'Page'] = $PageCount - 1;
    157157  $CurrentPage = $_SESSION[$ObjectName.'Page'];
    158158
     
    161161
    162162  $Result = '';
    163   if($PageCount > 1)
    164   {
    165     if($CurrentPage > 0)
     163  if ($PageCount > 1)
     164  {
     165    if ($CurrentPage > 0)
    166166    {
    167167      $QueryItems['page'] = 0;
     
    172172    $PagesMax = $PageCount - 1;
    173173    $PagesMin = 0;
    174     if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
    175     if($PagesMin < ($CurrentPage - $Around))
     174    if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     175    if ($PagesMin < ($CurrentPage - $Around))
    176176    {
    177177      $Result.= ' ... ';
    178178      $PagesMin = $CurrentPage - $Around;
    179179    }
    180     for($i = $PagesMin; $i <= $PagesMax; $i++)
    181     {
    182       if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     180    for ($i = $PagesMin; $i <= $PagesMax; $i++)
     181    {
     182      if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
    183183      else {
    184184       $QueryItems['page'] = $i;
     
    186186      }
    187187    }
    188     if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    189     if($CurrentPage < ($PageCount - 1))
     188    if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     189    if ($CurrentPage < ($PageCount - 1))
    190190    {
    191191      $QueryItems['page'] = ($CurrentPage + 1);
     
    196196  }
    197197  $QueryItems['all'] = '1';
    198   if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
     198  if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
    199199
    200200  $Result = '<div style="text-align: center">'.$Result.'</div>';
    201   return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
     201  return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
    202202    'Page' => $CurrentPage,
    203203    'Output' => $Result,
     
    212212  global $OrderDirSQL, $OrderArrowImage, $Config, $System;
    213213
    214   if(array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName))
    215   {
    216     if(array_key_exists('OrderCol', $_GET)) $_SESSION[$ObjectName.'OrderCol'] = $_GET['OrderCol'];
    217     if(array_key_exists('OrderDir', $_GET)) $_SESSION[$ObjectName.'OrderDir'] = $_GET['OrderDir'];
    218   }
    219   if(!array_key_exists($ObjectName.'OrderCol', $_SESSION)) $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn;
    220   if(!array_key_exists($ObjectName.'OrderDir', $_SESSION) ) $_SESSION[$ObjectName.'OrderDir'] = $DefaultOrder;
     214  if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName))
     215  {
     216    if (array_key_exists('OrderCol', $_GET)) $_SESSION[$ObjectName.'OrderCol'] = $_GET['OrderCol'];
     217    if (array_key_exists('OrderDir', $_GET)) $_SESSION[$ObjectName.'OrderDir'] = $_GET['OrderDir'];
     218  }
     219  if (!array_key_exists($ObjectName.'OrderCol', $_SESSION)) $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn;
     220  if (!array_key_exists($ObjectName.'OrderDir', $_SESSION) ) $_SESSION[$ObjectName.'OrderDir'] = $DefaultOrder;
    221221
    222222  // Check OrderCol
    223223  $Found = false;
    224   foreach($Columns as $Column)
    225   {
    226     if($Column['Name'] == $_SESSION[$ObjectName.'OrderCol'])
     224  foreach ($Columns as $Column)
     225  {
     226    if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol'])
    227227    {
    228228      $Found = true;
     
    230230    }
    231231  }
    232   if(($_SESSION[$ObjectName.'OrderCol'] == '') or ($Found == false))
     232  if (($_SESSION[$ObjectName.'OrderCol'] == '') or ($Found == false))
    233233  {
    234234    $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn;
     
    236236  }
    237237  // Check OrderDir
    238   if(($_SESSION[$ObjectName.'OrderDir'] != 0) and ($_SESSION[$ObjectName.'OrderDir'] != 1))
     238  if (($_SESSION[$ObjectName.'OrderDir'] != 0) and ($_SESSION[$ObjectName.'OrderDir'] != 1))
    239239    $_SESSION[$ObjectName.'OrderDir'] = 0;
    240240
    241241  $Result = '';
    242242  $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    243   foreach($Columns as $Index => $Column)
     243  foreach ($Columns as $Index => $Column)
    244244  {
    245245    $QueryItems['ObjectName'] = $ObjectName;
    246246    $QueryItems['OrderCol'] = $Column['Name'];
    247247    $QueryItems['OrderDir'] = 1 - $_SESSION[$ObjectName.'OrderDir'];
    248     if($Column['Name'] == $_SESSION[$ObjectName.'OrderCol'])
     248    if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol'])
    249249      $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.
    250250      $System->Link('/images/'.$OrderArrowImage[$_SESSION[$ObjectName.'OrderDir']]).'" alt="order arrow">';
    251251      else $ArrowImage = '';
    252     if($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';
     252    if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';
    253253      else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>';
    254254  }
    255   return(array(
     255  return (array(
    256256    'SQL' => ' ORDER BY `'.$_SESSION[$ObjectName.'OrderCol'].'` '.$OrderDirSQL[$_SESSION[$ObjectName.'OrderDir']],
    257257    'Output' => '<tr>'.$Result.'</tr>',
     
    263263function GetRemoteAddress()
    264264{
    265   if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
     265  if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
    266266  else $IP = '0.0.0.0';
    267   return($IP);
     267  return ($IP);
    268268}
    269269
     
    274274  $Result = true;
    275275  $RemoteAddr = GetRemoteAddress();
    276   foreach($Config['Web']['IntranetSubnets'] as $Subnet)
    277   {
    278     if(substr($RemoteAddr, 0, strlen($Subnet)) == $Subnet)
     276  foreach ($Config['Web']['IntranetSubnets'] as $Subnet)
     277  {
     278    if (substr($RemoteAddr, 0, strlen($Subnet)) == $Subnet)
    279279    {
    280280      $Result = false;
     
    282282    }
    283283  }
    284   return($Result);
     284  return ($Result);
    285285}
    286286
     
    292292  '(SELECT `Member` FROM `NetworkDevice` WHERE (SELECT `Device` FROM `NetworkInterface` '.
    293293  'WHERE `LocalIP` = "'.$IP.'") = `NetworkDevice`.`Id`) = `Member`.`Id`');
    294   if($DbResult->num_rows > 0)
     294  if ($DbResult->num_rows > 0)
    295295  {
    296296    $DbRow = $DbResult->fetch_assoc();
    297     return($DbRow['Id']);
    298   } else return('');
     297    return ($DbRow['Id']);
     298  } else return ('');
    299299}
    300300
     
    302302{
    303303  $Result = shell_exec('which '.$Command);
    304   return(!empty($Result));
     304  return (!empty($Result));
    305305}
    306306
    307307function RemoveDiacritic($Text)
    308308{
    309   return(str_replace(
     309  return (str_replace(
    310310    array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů',
    311311      'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'),
     
    317317function RouterOSIdent($Name)
    318318{
    319   return(strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-',
     319  return (strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-',
    320320  'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y',
    321321  'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd',
     
    329329function NotBlank($Text)
    330330{
    331   if($Text == '') return('&nbsp');
    332     else return($Text);
     331  if ($Text == '') return ('&nbsp');
     332    else return ($Text);
    333333}
    334334
     
    352352function ProcessURL()
    353353{
    354   if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     354  if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
    355355    $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
    356356    else $PathString = '';
    357   if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
     357  if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
    358358  $PathItems = explode('/', $PathString);
    359   if(array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
     359  if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
    360360    $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
    361361    else $_SERVER['QUERY_STRING'] = '';
    362362  parse_str($_SERVER['QUERY_STRING'], $_GET);
    363   return($PathItems);
     363  return ($PathItems);
    364364}
    365365
    366366function RepeatFunction($Period, $Callback)
    367367{
    368   while(1)
     368  while (1)
    369369  {
    370370    $StartTime = time();
     
    372372    $EndTime = time();
    373373    $Delay = $Period - ($EndTime - $StartTime);
    374     if($Delay < 0) $Delay = 0;
     374    if ($Delay < 0) $Delay = 0;
    375375
    376376    echo('Waiting remaining '.$Delay.' of '.$Period.' seconds period...'."\n");
  • trunk/Common/VCL/Database.php

    r738 r873  
    2828
    2929    $ColumnSQL = array();
    30     foreach($this->Columns as $Column)
     30    foreach ($this->Columns as $Column)
    3131    {
    3232      $ColumnSQL[] = $Column->Name;
     
    3535
    3636    // Get total filtered item count in database
    37     if($this->Filter != '')
     37    if ($this->Filter != '')
    3838    {
    3939      $Query = 'SELECT COUNT(*) FROM (SELECT '.$ColumnSQL.' FROM '.$this->SQL.') AS `TS` '.$this->Filter;
     
    4646    $this->Rows = array();
    4747    $VisibleItemCount = 0;
    48     if(($this->SortOrder != 0) and ($this->SortOrder != 1)) $this->SortOrder = 0;
    49     //if($this->SortColumn)
     48    if (($this->SortOrder != 0) and ($this->SortOrder != 1)) $this->SortOrder = 0;
     49    //if ($this->SortColumn)
    5050    $this->SortColumn = $this->Columns[0]->Name;
    5151    $this->OrderSQL = ' ORDER BY `'.$this->SortColumn.'` '.$this->OrderDirSQL[$this->SortOrder];
     
    5454      $this->Filter.' '.$this->OrderSQL.$SQLLimit;
    5555    $DbResult = $this->Database->query($Query);
    56     while($DbRow = $DbResult->fetch_assoc())
     56    while ($DbRow = $DbResult->fetch_assoc())
    5757    {
    58       if(method_exists($this->OnRowDraw[0], $this->OnRowDraw[1]))
     58      if (method_exists($this->OnRowDraw[0], $this->OnRowDraw[1]))
    5959        $DbRow = call_user_func($this->OnRowDraw, $DbRow);
    6060      $this->Rows[] = $DbRow;
     
    6262    }
    6363    $Row = '<td colspan="'.count($this->Columns).'" style="text-align: right;">Zobrazeno <strong>'.$VisibleItemCount.'</strong>';
    64     if($this->Filter != '') $Row .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>';
     64    if ($this->Filter != '') $Row .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>';
    6565    $Row .= ' z celkem <strong>'.$TotalCount.'</strong>';
    6666    $ListView->Rows[] = $Row;
    6767    $Output = parent::Show();
    68     return($Output);
     68    return ($Output);
    6969  }
    7070}
  • trunk/Common/VCL/General.php

    r693 r873  
    88  //echo($Name.',');
    99  $Result = '';
    10   if($Persistent)
    11     if(array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name];
    12   if(array_key_exists($Name, $_GET))
     10  if ($Persistent)
     11    if (array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name];
     12  if (array_key_exists($Name, $_GET))
    1313  {
    1414    $Result = $_GET[$Name];
    15     if($Persistent) $_SESSION[$Name] = $Result;
    16   }
    17   return($Result);
     15    if ($Persistent) $_SESSION[$Name] = $Result;
     16  }
     17  return ($Result);
    1818}
    1919
     
    3434    $Output = '';
    3535    //$Output .= '#'.$this->Id;
    36     return($Output);
     36    return ($Output);
    3737  }
    3838
     
    4848  function Show()
    4949  {
    50     if($this->Visible)
     50    if ($this->Visible)
    5151    {
    5252      $Output = parent::Show();
    53       foreach($this->Items as $Item)
     53      foreach ($this->Items as $Item)
    5454        $Output .= $Item->Show();
    55       return($Output);
    56     }
    57   }
    58 
    59   function Prepare()
    60   {
    61     foreach($this->Items as $Item)
     55      return ($Output);
     56    }
     57  }
     58
     59  function Prepare()
     60  {
     61    foreach ($this->Items as $Item)
    6262      $Item->Prepare();
    6363  }
     
    7070  function Show()
    7171  {
    72     if($this->Visible)
    73     {
    74       return(parent::Show().'<button>'.$this->Caption.'</button>');
     72    if ($this->Visible)
     73    {
     74      return (parent::Show().'<button>'.$this->Caption.'</button>');
    7575    }
    7676  }
     
    8383  function Show()
    8484  {
    85     return(parent::Show().'<input type="text" name="'.$this->Id.'" value="'.$this->Text.'"/>');
     85    return (parent::Show().'<input type="text" name="'.$this->Id.'" value="'.$this->Text.'"/>');
    8686  }
    8787
     
    108108  function Show()
    109109  {
    110     if(array_key_exists($this->Id.'_Page', $_GET))
     110    if (array_key_exists($this->Id.'_Page', $_GET))
    111111      $this->Position = $_GET[$this->Id.'_Page'];
    112     if($this->Position >= $this->Count) $this->Position = $this->Count / $this->PageSize - 1;
     112    if ($this->Position >= $this->Count) $this->Position = $this->Count / $this->PageSize - 1;
    113113    $Output = '';
    114     for($I = 0; $I < $this->Count / $this->PageSize; $I++)
     114    for ($I = 0; $I < $this->Count / $this->PageSize; $I++)
    115115    {
    116116      $Text = '<a href="?'.$this->Id.'_Page='.$I.'">'.$I.'</a> ';
    117       if($I == $this->Position) $Text = '<strong>'.$Text.'</strong>';
     117      if ($I == $this->Position) $Text = '<strong>'.$Text.'</strong>';
    118118      $Output .= $Text;
    119119    }
    120120    $Output .= '<br/>';
    121     return($Output);
     121    return ($Output);
    122122  }
    123123
     
    134134  function Show()
    135135  {
    136     return($this->Name);
     136    return ($this->Name);
    137137  }
    138138}
     
    155155  {
    156156    $Output = '<table class="WideTable" style="font-size: small;><tr>';
    157     foreach($this->Columns as $Column)
    158     {
    159       if($this->OnColumnDraw != '') $Text = call_user_func($this->OnColumnDraw, $Column);
     157    foreach ($this->Columns as $Column)
     158    {
     159      if ($this->OnColumnDraw != '') $Text = call_user_func($this->OnColumnDraw, $Column);
    160160        else $Text = $Column->Show();
    161161      $Output .= '<th>'.$Text.'</th>';
    162162    }
    163163    $Output .= '</tr>';
    164     foreach($this->Rows as $Row)
     164    foreach ($this->Rows as $Row)
    165165    {
    166166      $Output .= '<tr>';
    167       foreach($Row as $Value)
     167      foreach ($Row as $Value)
    168168        $Output .= '<td>'.$Value.'</td>';
    169169      $Output .= '</tr>';
    170170    }
    171171    $Output .= '</table>';
    172     return($Output);
     172    return ($Output);
    173173  }
    174174}
     
    192192  function ColumnClick($Column)
    193193  {
    194     return('?'.$this->Id.'_SortColumn='.$Column->Id.'&amp;'.$this->Id.'_SortOrder='.(1 - $this->SortOrder));
     194    return ('?'.$this->Id.'_SortColumn='.$Column->Id.'&amp;'.$this->Id.'_SortOrder='.(1 - $this->SortOrder));
    195195  }
    196196
     
    201201    $Output = $Column->Show();
    202202
    203     if($Column->Name == $this->SortColumn)
     203    if ($Column->Name == $this->SortColumn)
    204204    {
    205205      $Output .= '<img style="vertical-align: middle; border: 0px;" src="'.
    206206        $System->Link('/images/'.$this->OrderArrowImage[$this->SortOrder]).'" alt="order arrow">';
    207207    }
    208     if($this->OnColumnClick != '')
     208    if ($this->OnColumnClick != '')
    209209      $Output = '<a href="'.call_user_func($this->OnColumnClick, $Column).'">'.$Output.'</a>';
    210     return($Output);
     210    return ($Output);
    211211  }
    212212
     
    219219    $Output .= parent::Show();
    220220    $Output .= $this->PageSelect->Show();
    221     return($Output);
     221    return ($Output);
    222222  }
    223223
     
    239239  {
    240240    $Output .= '<table>';
    241     foreach($this->Rows as $RowNum => $Row)
     241    foreach ($this->Rows as $RowNum => $Row)
    242242    {
    243243      $Output .= '<tr>';
    244       foreach($Row as $ColNum => $Value)
     244      foreach ($Row as $ColNum => $Value)
    245245      {
    246         if($this->Span[$RowNum][$ColNum] != 1) $Span = ' colspan="'.$this->Span[$RowNum][$ColNum].'"';
     246        if ($this->Span[$RowNum][$ColNum] != 1) $Span = ' colspan="'.$this->Span[$RowNum][$ColNum].'"';
    247247          else $Span = '';
    248248        $Output .= '<td'.$Span.'>'.$Value->Show().'</td>';
     
    251251    }
    252252    $Output .= '</table>';
    253     return($Output);
    254   }
    255 
    256   function Prepare()
    257   {
    258     foreach($this->Rows as $RowNum => $Row)
    259     {
    260       foreach($Row as $ColNum => $Value)
     253    return ($Output);
     254  }
     255
     256  function Prepare()
     257  {
     258    foreach ($this->Rows as $RowNum => $Row)
     259    {
     260      foreach ($Row as $ColNum => $Value)
    261261      {
    262262        $Value->Prepare();
     
    274274  {
    275275    $Output = $this->Caption;
    276     if(method_exists($this->OnExecute[0], $this->OnExecute[1]))
     276    if (method_exists($this->OnExecute[0], $this->OnExecute[1]))
    277277    {
    278278      $Link = 'O='.$this->Id.'&amp;M=Execute';
    279279      $Output = '<a href="?'.$Link.'">'.$Output.'</a>';
    280280    };
    281     return($Output);
     281    return ($Output);
    282282  }
    283283
     
    286286    $Object = ReadSessionVar('O', false);
    287287    $Method = ReadSessionVar('M', false);
    288     if(($Object == $this->Id) and ($Method == 'Execute'))
     288    if (($Object == $this->Id) and ($Method == 'Execute'))
    289289      call_user_func($this->OnExecute, $this);
    290290  }
     
    298298  {
    299299    $Output = '<!DOCTYPE html><html><head></head><body>';
    300     foreach($this->Items as $Item)
     300    foreach ($this->Items as $Item)
    301301      $Output .= $Item->Show();
    302302    $Output .= '</body></html>';
    303     return($Output);
    304   }
    305 
    306   function Prepare()
    307   {
    308     foreach($this->Items as $Item)
     303    return ($Output);
     304  }
     305
     306  function Prepare()
     307  {
     308    foreach ($this->Items as $Item)
    309309      $Item->Prepare();
    310310  }
  • 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}
  • trunk/Packages/Common/AppModule.php

    r858 r873  
    7777  function Install()
    7878  {
    79     if($this->Installed) return;
     79    if ($this->Installed) return;
    8080    $List = array();
    8181    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled));
     
    8989  function Uninstall()
    9090  {
    91     if(!$this->Installed) return;
     91    if (!$this->Installed) return;
    9292    $this->Stop();
    9393    $this->Installed = false;
     
    100100  function Upgrade()
    101101  {
    102     if(!$this->Installed) return;
    103     if($this->InstalledVersion == $this->Version) return;
     102    if (!$this->Installed) return;
     103    if ($this->InstalledVersion == $this->Version) return;
    104104    $List = array();
    105105    $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed));
     
    117117  function Start()
    118118  {
    119     if($this->Running) return;
    120     if(!$this->Installed) return;
     119    if ($this->Running) return;
     120    if (!$this->Installed) return;
    121121    $List = array();
    122122    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotRunning));
     
    128128  function Stop()
    129129  {
    130     if(!$this->Running) return;
     130    if (!$this->Running) return;
    131131    $this->Running = false;
    132132    $List = array();
     
    144144  function Enable()
    145145  {
    146     if($this->Enabled) return;
    147     if(!$this->Installed) return;
     146    if ($this->Enabled) return;
     147    if (!$this->Installed) return;
    148148    $List = array();
    149149    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotEnabled));
     
    154154  function Disable()
    155155  {
    156     if(!$this->Enabled) return;
     156    if (!$this->Enabled) return;
    157157    $this->Stop();
    158158    $this->Enabled = false;
     
    203203  function Perform($List, $Actions, $Conditions = array(ModuleCondition::All))
    204204  {
    205     foreach($List as $Index => $Module)
    206     {
    207       if(in_array(ModuleCondition::All, $Conditions) or
     205    foreach ($List as $Index => $Module)
     206    {
     207      if (in_array(ModuleCondition::All, $Conditions) or
    208208        ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    209209        (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
     
    213213        (!$Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)))
    214214      {
    215         foreach($Actions as $Action)
     215        foreach ($Actions as $Action)
    216216        {
    217           if($Action == ModuleAction::Start) $Module->Start();
    218           if($Action == ModuleAction::Stop) $Module->Stop();
    219           if($Action == ModuleAction::Install) $Module->Install();
    220           if($Action == ModuleAction::Uninstall) $Module->Uninstall();
    221           if($Action == ModuleAction::Enable) $Module->Enable();
    222           if($Action == ModuleAction::Disable) $Module->Disable();
    223           if($Action == ModuleAction::Upgrade) $Module->Upgrade();
     217          if ($Action == ModuleAction::Start) $Module->Start();
     218          if ($Action == ModuleAction::Stop) $Module->Stop();
     219          if ($Action == ModuleAction::Install) $Module->Install();
     220          if ($Action == ModuleAction::Uninstall) $Module->Uninstall();
     221          if ($Action == ModuleAction::Enable) $Module->Enable();
     222          if ($Action == ModuleAction::Disable) $Module->Disable();
     223          if ($Action == ModuleAction::Upgrade) $Module->Upgrade();
    224224        }
    225225      }
     
    229229  function EnumDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
    230230  {
    231     foreach($Module->Dependencies as $Dependency)
    232     {
    233       if(!array_key_exists($Dependency, $this->Modules))
     231    foreach ($Module->Dependencies as $Dependency)
     232    {
     233      if (!array_key_exists($Dependency, $this->Modules))
    234234        throw new Exception(sprintf(T('Module "%s" dependency "%s" not found'), $Module->Name, $Dependency));
    235235      $DepModule = $this->Modules[$Dependency];
    236       if(in_array(ModuleCondition::All, $Conditions) or
     236      if (in_array(ModuleCondition::All, $Conditions) or
    237237        ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    238238        (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
     
    250250  function EnumSuperiorDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
    251251  {
    252     foreach($this->Modules as $RefModule)
    253     {
    254       if(in_array($Module->Name, $RefModule->Dependencies) and
     252    foreach ($this->Modules as $RefModule)
     253    {
     254      if (in_array($Module->Name, $RefModule->Dependencies) and
    255255          (in_array(ModuleCondition::All, $Conditions) or
    256256          ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
     
    270270  {
    271271    $this->LoadModules();
    272     if(file_exists($this->FileName)) $this->LoadState();
     272    if (file_exists($this->FileName)) $this->LoadState();
    273273    $this->StartEnabled();
    274274  }
     
    315315  function ModulePresent($Name)
    316316  {
    317     return(array_key_exists($Name, $this->Modules));
     317    return (array_key_exists($Name, $this->Modules));
    318318  }
    319319
    320320  function ModuleEnabled($Name)
    321321  {
    322     return(array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled);
     322    return (array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled);
    323323  }
    324324
    325325  function ModuleRunning($Name)
    326326  {
    327     return(array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running);
     327    return (array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running);
    328328  }
    329329
     
    331331  function SearchModuleById($Id)
    332332  {
    333     foreach($this->Modules as $Module)
     333    foreach ($this->Modules as $Module)
    334334    {
    335335      //DebugLog($Module->Name.' '.$Module->Id);
    336       if($Module->Id == $Id) return($Module->Name);
    337     }
    338     return('');
     336      if ($Module->Id == $Id) return ($Module->Name);
     337    }
     338    return ('');
    339339  }
    340340
     
    343343    $ConfigModules = array();
    344344    include($this->FileName);
    345     foreach($ConfigModules as $Mod)
    346     {
    347       if(array_key_exists($Mod['Name'], $this->Modules))
     345    foreach ($ConfigModules as $Mod)
     346    {
     347      if (array_key_exists($Mod['Name'], $this->Modules))
    348348      {
    349349        $this->Modules[$Mod['Name']] = $this->Modules[$Mod['Name']];
     
    358358  {
    359359    $Data = array();
    360     foreach($this->Modules as $Module)
     360    foreach ($this->Modules as $Module)
    361361    {
    362362      $Data[] = array('Name' => $Module->Name, 'Enabled' => $Module->Enabled,
     
    381381  {
    382382    $List = scandir($Directory);
    383     foreach($List as $Item)
    384     {
    385       if(is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))
     383    foreach ($List as $Item)
     384    {
     385      if (is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))
    386386      {
    387387        include_once($Directory.'/'.$Item.'/'.$Item.'.php');
     
    394394  function LoadModules()
    395395  {
    396     if(method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
     396    if (method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
    397397      $this->OnLoadModules();
    398398    else $this->LoadModulesFromDir($this->ModulesDir);
  • trunk/Packages/Common/Application.php

    r817 r873  
    1212  function DoOnChange()
    1313  {
    14     foreach($this->OnChange as $Callback)
     14    foreach ($this->OnChange as $Callback)
    1515    {
    1616      call_user_func($Callback);
  • trunk/Packages/Common/Common.php

    r870 r873  
    6565
    6666    $Result = '';
    67     if(array_key_exists('all', $QueryItems))
     67    if (array_key_exists('all', $QueryItems))
    6868    {
    6969      $PageCount = 1;
     
    7676    }
    7777
    78     if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
    79     if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
    80     if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
    81     if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
     78    if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
     79    if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     80    if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
     81    if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
    8282    $CurrentPage = $_SESSION['Page'];
    8383
     
    8585
    8686    $Result = '';
    87     if($PageCount > 1)
     87    if ($PageCount > 1)
    8888    {
    89       if($CurrentPage > 0)
     89      if ($CurrentPage > 0)
    9090      {
    9191        $QueryItems['page'] = 0;
     
    9696      $PagesMax = $PageCount - 1;
    9797      $PagesMin = 0;
    98       if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
    99       if($PagesMin < ($CurrentPage - $Around))
     98      if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     99      if ($PagesMin < ($CurrentPage - $Around))
    100100      {
    101101        $Result.= ' ... ';
    102102        $PagesMin = $CurrentPage - $Around;
    103103      }
    104       for($i = $PagesMin; $i <= $PagesMax; $i++)
     104      for ($i = $PagesMin; $i <= $PagesMax; $i++)
    105105      {
    106         if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     106        if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
    107107        else {
    108108         $QueryItems['page'] = $i;
     
    110110        }
    111111      }
    112       if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    113       if($CurrentPage < ($PageCount - 1))
     112      if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     113      if ($CurrentPage < ($PageCount - 1))
    114114      {
    115115        $QueryItems['page'] = ($CurrentPage + 1);
     
    120120    }
    121121    $QueryItems['all'] = '1';
    122     if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
     122    if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
    123123
    124124    $Result = '<div style="text-align: center">'.$Result.'</div>';
    125125    $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
    126126    $this->Page = $CurrentPage;
    127     return($Result);
     127    return ($Result);
    128128  }
    129129}
  • trunk/Packages/Common/Config.php

    r782 r873  
    1212  function ReadValue($Name)
    1313  {
    14     if(!is_array($Name)) $Name = explode('/', $Name);
     14    if (!is_array($Name)) $Name = explode('/', $Name);
    1515    $Last = array_pop($Name);
    1616    $Data = &$this->Data;
    17     foreach($Name as $Item)
     17    foreach ($Name as $Item)
    1818    {
    1919      $Data = &$Data[$Item];
    2020    }
    21     return($Data[$Last]);
     21    return ($Data[$Last]);
    2222  }
    2323
    2424  function WriteValue($Name, $Value)
    2525  {
    26     if(!is_array($Name)) $Name = explode('/', $Name);
     26    if (!is_array($Name)) $Name = explode('/', $Name);
    2727    $Last = array_pop($Name);
    2828    $Data = &$this->Data;
    29     foreach($Name as $Item)
     29    foreach ($Name as $Item)
    3030    {
    3131      $Data = &$Data[$Item];
     
    3838    $ConfigData = array();
    3939    include $FileName;
    40     foreach($this->Data as $Index => $Item)
     40    foreach ($this->Data as $Index => $Item)
    4141    {
    42       if(array_key_exits($Index, $ConfigData))
     42      if (array_key_exits($Index, $ConfigData))
    4343        $this->Data[$Index] = $ConfigData[$Index];
    4444    }
     
    5252  function GetAsArray()
    5353  {
    54     return($this->Data);
     54    return ($this->Data);
    5555  }
    5656}
  • trunk/Packages/Common/Database.php

    r861 r873  
    1717  function fetch_assoc()
    1818  {
    19     return($this->PDOStatement->fetch(PDO::FETCH_ASSOC));
     19    return ($this->PDOStatement->fetch(PDO::FETCH_ASSOC));
    2020  }
    2121
    2222  function fetch_array()
    2323  {
    24     return($this->PDOStatement->fetch(PDO::FETCH_BOTH));
     24    return ($this->PDOStatement->fetch(PDO::FETCH_BOTH));
    2525  }
    2626
    2727  function fetch_row()
    2828  {
    29     return($this->PDOStatement->fetch(PDO::FETCH_NUM));
     29    return ($this->PDOStatement->fetch(PDO::FETCH_NUM));
    3030  }
    3131}
     
    6161  function Connect($Host, $User, $Password, $Database)
    6262  {
    63     if($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
    64       else if($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;
     63    if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
     64      else if ($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;
    6565      else $ConnectionString = '';
    6666    try {
     
    8181  function Connected()
    8282  {
    83     return(isset($this->PDO));
     83    return (isset($this->PDO));
    8484  }
    8585
     
    9191  function query($Query)
    9292  {
    93     if(!$this->Connected()) throw new Exception(T('Not connected to database'));
    94     if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float();
     93    if (!$this->Connected()) throw new Exception(T('Not connected to database'));
     94    if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float();
    9595    $this->LastQuery = $Query;
    9696    //echo('a'.$this->ShowSQLQuery.'<'.$QueryStartTime.', '.microtime_float());
    97     if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
     97    if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
    9898    {
    9999      $Time = round(microtime_float() - $QueryStartTime, 4);
    100100      $Duration = ' ; '.$Time. ' s';
    101101    }
    102     if(($this->LogSQLQuery == true) and ($Time != 0))
     102    if (($this->LogSQLQuery == true) and ($Time != 0))
    103103      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
    104     if($this->ShowSQLQuery == true)
     104    if ($this->ShowSQLQuery == true)
    105105      echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '.
    106106      'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n");
    107107    $Result = new DatabaseResult();
    108108    $Result->PDOStatement = $this->PDO->query($Query);
    109     if($Result->PDOStatement)
     109    if ($Result->PDOStatement)
    110110    {
    111111      $Result->num_rows = $Result->PDOStatement->rowCount();
     
    115115      $this->Error = $this->PDO->errorInfo();
    116116      $this->Error = $this->Error[2];
    117       if(($this->Error != '') and ($this->ShowSQLError == true))
     117      if (($this->Error != '') and ($this->ShowSQLError == true))
    118118        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
    119119        throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query);
    120120    }
    121     return($Result);
     121    return ($Result);
    122122  }
    123123
    124124  function select($Table, $What = '*', $Condition = 1)
    125125  {
    126     return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));
     126    return ($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));
    127127  }
    128128
     
    142142    $Name = '';
    143143    $Values = '';
    144     foreach($Data as $Key => $Value)
     144    foreach ($Data as $Key => $Value)
    145145    {
    146146      $Name .= ',`'.$Key.'`';
    147       if(!in_array($Value, $this->Functions))
     147      if (!in_array($Value, $this->Functions))
    148148      {
    149         if(is_null($Value)) $Value = 'NULL';
     149        if (is_null($Value)) $Value = 'NULL';
    150150        else $Value = $this->PDO->quote($Value);
    151151      }
     
    154154    $Name = substr($Name, 1);
    155155    $Values = substr($Values, 1);
    156     return('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
     156    return ('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    157157  }
    158158
     
    165165  {
    166166    $Values = '';
    167     foreach($Data as $Key => $Value)
    168     {
    169       if(!in_array($Value, $this->Functions))
     167    foreach ($Data as $Key => $Value)
     168    {
     169      if (!in_array($Value, $this->Functions))
    170170      {
    171         if(is_null($Value)) $Value = 'NULL';
     171        if (is_null($Value)) $Value = 'NULL';
    172172        else $Value = $this->PDO->quote($Value);
    173173      }
     
    175175    }
    176176    $Values = substr($Values, 2);
    177     return('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
     177    return ('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    178178  }
    179179
     
    182182    $Name = '';
    183183    $Values = '';
    184     foreach($Data as $Key => $Value)
    185     {
    186       if(!in_array($Value, $this->Functions))
     184    foreach ($Data as $Key => $Value)
     185    {
     186      if (!in_array($Value, $this->Functions))
    187187      {
    188         if(is_null($Value)) $Value = 'NULL';
     188        if (is_null($Value)) $Value = 'NULL';
    189189        else $Value = $this->PDO->quote($Value);
    190190      }
     
    206206  function real_escape_string($Text)
    207207  {
    208     return(addslashes($Text));
     208    return (addslashes($Text));
    209209  }
    210210
    211211  function quote($Text)
    212212  {
    213     return($this->PDO->quote($Text));
     213    return ($this->PDO->quote($Text));
    214214  }
    215215
     
    239239function TimeToMysqlDateTime($Time)
    240240{
    241   if($Time == NULL) return(NULL);
    242     else return(date('Y-m-d H:i:s', $Time));
     241  if ($Time == NULL) return (NULL);
     242    else return (date('Y-m-d H:i:s', $Time));
    243243}
    244244
    245245function TimeToMysqlDate($Time)
    246246{
    247   if($Time == NULL) return(NULL);
    248     else return(date('Y-m-d', $Time));
     247  if ($Time == NULL) return (NULL);
     248    else return (date('Y-m-d', $Time));
    249249}
    250250
    251251function TimeToMysqlTime($Time)
    252252{
    253   if($Time == NULL) return(NULL);
    254     else return(date('H:i:s', $Time));
     253  if ($Time == NULL) return (NULL);
     254    else return (date('H:i:s', $Time));
    255255}
    256256
    257257function MysqlDateTimeToTime($DateTime)
    258258{
    259   if($DateTime == '') return(NULL);
     259  if ($DateTime == '') return (NULL);
    260260  $Parts = explode(' ', $DateTime);
    261261  $DateParts = explode('-', $Parts[0]);
    262262  $TimeParts = explode(':', $Parts[1]);
    263263  $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
    264   return($Result);
     264  return ($Result);
    265265}
    266266
    267267function MysqlDateToTime($Date)
    268268{
    269   if($Date == '') return(NULL);
    270   return(MysqlDateTimeToTime($Date.' 0:0:0'));
     269  if ($Date == '') return (NULL);
     270  return (MysqlDateTimeToTime($Date.' 0:0:0'));
    271271}
    272272
    273273function MysqlTimeToTime($Time)
    274274{
    275   if($Time == '') return(NULL);
    276   return(MysqlDateTimeToTime('0000-00-00 '.$Time));
    277 }
     275  if ($Time == '') return (NULL);
     276  return (MysqlDateTimeToTime('0000-00-00 '.$Time));
     277}
  • trunk/Packages/Common/Error.php

    r864 r873  
    4545    );
    4646
    47     if(($this->UserErrors & $Number))
     47    if (($this->UserErrors & $Number))
    4848    {
    4949      // Error was suppressed with the @-operator
    50       if(0 === error_reporting())
     50      if (0 === error_reporting())
    5151      {
    5252        return false;
     
    5858      $Backtrace[0]['line'] = $LineNumber;
    5959      $this->Report($Backtrace);
    60       //if((E_ERROR | E_PARSE) & $Number)
     60      //if ((E_ERROR | E_PARSE) & $Number)
    6161      die();
    6262    }
     
    8282      'An internal error occurred!<br/>'.
    8383      'Administrator will be notified and the problem will be investigated and fixed soon.'.'<br/><br/>';
    84     if($this->ShowError == true)
     84    if ($this->ShowError == true)
    8585      $Output .= '<pre>'.$Message.'</pre><br/>';
    8686    $Output .= '</body></html>';
     
    9292    $Date = date('Y-m-d H:i:s');
    9393    $Error = '# '.$Date."\n";
    94     foreach($Backtrace as $Item)
     94    foreach ($Backtrace as $Item)
    9595    {
    96       if(!array_key_exists('line', $Item)) $Item['line'] = '';
    97       if(!array_key_exists('file', $Item)) $Item['file'] = '';
     96      if (!array_key_exists('line', $Item)) $Item['line'] = '';
     97      if (!array_key_exists('file', $Item)) $Item['file'] = '';
    9898
    9999      $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
    100100      $Arguments = '';
    101       if(array_key_exists('args', $Item) and is_array($Item['args']))
    102         foreach($Item['args'] as $Item)
     101      if (array_key_exists('args', $Item) and is_array($Item['args']))
     102        foreach ($Item['args'] as $Item)
    103103        {
    104           if(is_object($Item)) ;
    105           else if(is_array($Item)) $Arguments .= "'".serialize($Item)."',";
     104          if (is_object($Item)) ;
     105          else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',";
    106106          else $Arguments .= "'".$Item."',";
    107107        }
    108         if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
     108        if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
    109109        $Error .= "\n";
    110110    }
    111111    $Error .= "\n";
    112112
    113     foreach($this->OnError as $OnError)
     113    foreach ($this->OnError as $OnError)
    114114      call_user_func($OnError, $Error);
    115115  }
  • trunk/Packages/Common/Image.php

    r746 r873  
    6565  function SaveToFile($FileName)
    6666  {
    67     if($this->Type == IMAGETYPE_JPEG)
     67    if ($this->Type == IMAGETYPE_JPEG)
    6868    {
    6969      imagejpeg($this->Image, $FileName);
    7070    } else
    71     if($this->Type == IMAGETYPE_GIF)
     71    if ($this->Type == IMAGETYPE_GIF)
    7272    {
    73       imagegif($this->Image, $FileName);
     73      imagegif ($this->Image, $FileName);
    7474    } else
    75     if($this->Type == IMAGETYPE_PNG)
     75    if ($this->Type == IMAGETYPE_PNG)
    7676    {
    7777      imagepng($this->Image, $FileName);
     
    8383    $ImageInfo = getimagesize($FileName);
    8484    $this->Type = $ImageInfo[2];
    85     if($this->Type == IMAGETYPE_JPEG)
     85    if ($this->Type == IMAGETYPE_JPEG)
    8686    {
    8787      $this->Image = imagecreatefromjpeg($FileName);
    8888    } else
    89     if($this->Type == IMAGETYPE_GIF)
     89    if ($this->Type == IMAGETYPE_GIF)
    9090    {
    91       $this->Image = imagecreatefromgif($FileName);
     91      $this->Image = imagecreatefromgif ($FileName);
    9292    } else
    93     if( $this->Type == IMAGETYPE_PNG)
     93    if ( $this->Type == IMAGETYPE_PNG)
    9494    {
    9595      $this->Image = imagecreatefrompng($FileName);
     
    112112  function GetWidth()
    113113  {
    114     return(imagesx($this->Image));
     114    return (imagesx($this->Image));
    115115  }
    116116
    117117  function GetHeight()
    118118  {
    119     return(imagesy($this->Image));
     119    return (imagesy($this->Image));
    120120  }
    121121
     
    127127  function ConvertColor($Color)
    128128  {
    129     return(imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff));
     129    return (imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff));
    130130  }
    131131
  • trunk/Packages/Common/Locale.php

    r791 r873  
    2020  function Translate($Text, $Group = '')
    2121  {
    22     if(array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != ''))
    23       return($this->Data[$Group][$Text]);
    24       else return($Text);
     22    if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != ''))
     23      return ($this->Data[$Group][$Text]);
     24      else return ($Text);
    2525  }
    2626
     
    2828  {
    2929    $Key = array_search($Text, $this->Data[$Group]);
    30     if(($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return($Text);
    31       else return($Key);
     30    if (($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return ($Text);
     31      else return ($Key);
    3232  }
    3333}
     
    4747  {
    4848    $FileName = $this->Dir.'/'.$Language.'.php';
    49     if(file_exists($FileName)) {
     49    if (file_exists($FileName)) {
    5050      include_once($FileName);
    5151      $ClassName = 'LocaleText'.$Language;
     
    5959    // Search for php files
    6060    $FileList = scandir($Path);
    61     foreach($FileList as $FileName)
     61    foreach ($FileList as $FileName)
    6262    {
    6363      $FullName = $Path.'/'.$FileName;
    64       if(($FileName == '.') or ($FileName == '..')) ; // Skip virtual items
    65       else if(substr($FileName, 0, 1) == '.') ; // Skip Linux hidden files
    66       else if(is_dir($FullName)) $this->AnalyzeCode($FullName);
    67       else if(file_exists($FullName))
    68       {
    69         if(substr($FullName, -4) == '.php')
     64      if (($FileName == '.') or ($FileName == '..')) ; // Skip virtual items
     65      else if (substr($FileName, 0, 1) == '.') ; // Skip Linux hidden files
     66      else if (is_dir($FullName)) $this->AnalyzeCode($FullName);
     67      else if (file_exists($FullName))
     68      {
     69        if (substr($FullName, -4) == '.php')
    7070        {
    7171          $Content = file_get_contents($FullName);
    7272          // Search occurence of T() function
    73           while(strpos($Content, 'T(') !== false)
     73          while (strpos($Content, 'T(') !== false)
    7474          {
    7575            $Previous = strtolower(substr($Content, strpos($Content, 'T(') - 1, 1));
     
    7777            $Ord = ord($Previous);
    7878            //echo($Ord.',');
    79             if(!(($Ord >= ord('a')) and ($Ord <= ord('z'))))
     79            if (!(($Ord >= ord('a')) and ($Ord <= ord('z'))))
    8080            {
    8181              // Do for non-alpha previous character
    8282              $Original = substr($Content, 0, strpos($Content, ')'));
    8383              $Original2 = '';
    84               if((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'"))
     84              if ((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'"))
    8585                $Original2 = substr($Original, 1, -1);
    86               if((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"'))
     86              if ((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"'))
    8787                $Original2 = substr($Original, 1, -1);
    88               if($Original2 != '')
     88              if ($Original2 != '')
    8989              {
    90                 if(!array_key_exists($Original2, $this->Texts->Data))
     90                if (!array_key_exists($Original2, $this->Texts->Data))
    9191                  $this->Texts->Data[$Original2] = '';
    9292              }
     
    109109    '    $this->Title = \''.$this->Texts->Title.'\';'."\n".
    110110    '    $this->Data = array('."\n";
    111     foreach($this->Texts->Data as $Index => $Item)
     111    foreach ($this->Texts->Data as $Index => $Item)
    112112    {
    113113      $Content .= "      '".$Index."' => '".$Item."',\n";
     
    122122  {
    123123    $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode));
    124     if($DbResult->num_rows > 0)
     124    if ($DbResult->num_rows > 0)
    125125    {
    126126      $Language = $DbResult->fetch_assoc();
    127127      $this->Texts->Data = array();
    128128      $DbResult = $Database->select('Locale', '`Original`, `Translated`', '`Language`='.$Language['Id']);
    129       while($DbRow = $DbResult->fetch_assoc())
     129      while ($DbRow = $DbResult->fetch_assoc())
    130130        $this->Texts->Data[$DbRow['Original']] = $DbRow['Translated'];
    131131    }
     
    135135  {
    136136    $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode));
    137     if($DbResult->num_rows > 0)
     137    if ($DbResult->num_rows > 0)
    138138    {
    139139      $Language = $DbResult->fetch_assoc();
    140140      $Database->delete('Locale', '`Language`='.$Language['Id']);
    141       foreach($this->Texts->Data as $Index => $Item)
     141      foreach ($this->Texts->Data as $Index => $Item)
    142142        $Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '.
    143143        'VALUES('.$Language['Id'].','.$Database->quote($Index).','.$Database->quote($Item).')');
     
    148148  {
    149149    $DbResult = $Database->select('Language', '*', '`Code`='.$Database->quote($LangCode));
    150     if($DbResult->num_rows > 0)
     150    if ($DbResult->num_rows > 0)
    151151    {
    152152      $Language = $DbResult->fetch_assoc();
    153       foreach($this->Texts->Data as $Index => $Item)
     153      foreach ($this->Texts->Data as $Index => $Item)
    154154      {
    155155        $DbResult = $Database->select('Locale', '*', '(`Original` ='.$Database->quote($Index).
    156156          ') AND (`Language`='.($Language['Id']).')');
    157         if($DbResult->num_rows > 0)
     157        if ($DbResult->num_rows > 0)
    158158        $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.
    159159          '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item));
     
    188188    $this->Available = array();
    189189    $FileList = scandir($this->Dir);
    190     foreach($FileList as $FileName)
    191     {
    192       if(substr($FileName, -4) == '.php')
     190    foreach ($FileList as $FileName)
     191    {
     192      if (substr($FileName, -4) == '.php')
    193193      {
    194194        $Code = substr($FileName, 0, -4);
     
    206206    $Locale->AnalyzeCode($Directory);
    207207    $FileList = scandir($this->Dir);
    208     foreach($FileList as $FileName)
    209     {
    210       if(substr($FileName, -4) == '.php')
     208    foreach ($FileList as $FileName)
     209    {
     210      if (substr($FileName, -4) == '.php')
    211211      {
    212212        $FileLocale = new LocaleFile($this->System);
     
    215215
    216216        // Add new
    217         foreach($Locale->Texts->Data as $Index => $Item)
    218           if(!array_key_exists($Index, $FileLocale->Texts->Data))
     217        foreach ($Locale->Texts->Data as $Index => $Item)
     218          if (!array_key_exists($Index, $FileLocale->Texts->Data))
    219219            $FileLocale->Texts->Data[$Index] = $Item;
    220220        // Remove old
    221         foreach($FileLocale->Texts->Data as $Index => $Item)
    222           if(!array_key_exists($Index, $Locale->Texts->Data))
     221        foreach ($FileLocale->Texts->Data as $Index => $Item)
     222          if (!array_key_exists($Index, $Locale->Texts->Data))
    223223            unset($FileLocale->Texts->Data[$Index]);
    224224        $FileLocale->UpdateToDatabase($this->System->Database, $FileLocale->Texts->Code);
     
    232232  function LoadLocale($Code)
    233233  {
    234     if(array_key_exists($Code, $this->Available))
     234    if (array_key_exists($Code, $this->Available))
    235235    {
    236236      $this->CurrentLocale->Dir = $this->Dir;
     
    245245  global $GlobalLocaleManager;
    246246
    247   if(isset($GlobalLocaleManager)) return($GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group));
    248     else return($Text);
    249 }
     247  if (isset($GlobalLocaleManager)) return ($GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group));
     248    else return ($Text);
     249}
  • trunk/Packages/Common/Mail.php

    r791 r873  
    6969  function Organization($org)
    7070  {
    71     if(trim($org != '')) $this->xheaders['Organization'] = $org;
     71    if (trim($org != '')) $this->xheaders['Organization'] = $org;
    7272  }
    7373
    7474  function Priority($Priority)
    7575  {
    76     if(!intval($Priority)) return(false);
    77 
    78     if(!isset($this->priorities[$Priority - 1])) return(false);
     76    if (!intval($Priority)) return (false);
     77
     78    if (!isset($this->priorities[$Priority - 1])) return (false);
    7979
    8080    $this->xheaders['X-Priority'] = $this->priorities[$Priority - 1];
    81     return(true);
     81    return (true);
    8282  }
    8383
     
    9696  function Send()
    9797  {
    98     if(count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));
     98    if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));
    9999
    100100    $Body = $this->BuildAttachment($this->BuildBody());
     
    103103    $this->Headers['CC'] = '';
    104104    $this->Headers['BCC'] = '';
    105     foreach($this->Recipients as $Index => $Recipient)
    106     {
    107       if($Recipient['Type'] == 'SendCombined')
    108       {
    109         if($Index > 0) $To .= ', ';
     105    foreach ($this->Recipients as $Index => $Recipient)
     106    {
     107      if ($Recipient['Type'] == 'SendCombined')
     108      {
     109        if ($Index > 0) $To .= ', ';
    110110        $To .= $Recipient['Address'];
    111111      } else
    112       if($Recipient['Type'] == 'Send')
    113       {
    114         if($Index > 0) $To .= ', ';
     112      if ($Recipient['Type'] == 'Send')
     113      {
     114        if ($Index > 0) $To .= ', ';
    115115        $To .= $Recipient['Name'].' <'.$Recipient['Address'].'>';
    116116      } else
    117       if($Recipient['Type'] == 'Copy')
    118       {
    119         if($Index > 0) $this->Headers['CC'] .= ', ';
     117      if ($Recipient['Type'] == 'Copy')
     118      {
     119        if ($Index > 0) $this->Headers['CC'] .= ', ';
    120120        $this->Headers['CC'] .= $Recipient['Name'].' <'.$To['Address'].'>';
    121121      } else
    122       if($Recipient['Type'] == 'HiddenCopy')
    123       {
    124         if($Index > 0) $this->Headers['BCC'] .= ', ';
     122      if ($Recipient['Type'] == 'HiddenCopy')
     123      {
     124        if ($Index > 0) $this->Headers['BCC'] .= ', ';
    125125        $this->Headers['BCC'] .= $Recipient['Name'].' <'.$To['Address'].'>';
    126126      }
    127127    }
    128     if($To == '') throw new Exception(T('Mail message need at least one recipient address'));
     128    if ($To == '') throw new Exception(T('Mail message need at least one recipient address'));
    129129
    130130    $this->Headers['Mime-Version'] = '1.0';
    131131
    132     if($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;
    133     if($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo;
    134     if($this->From != '') $this->Headers['From'] = $this->From;
     132    if ($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;
     133    if ($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo;
     134    if ($this->From != '') $this->Headers['From'] = $this->From;
    135135
    136136    $Headers = '';
    137     foreach($this->Headers as $Header => $Value)
    138     {
    139       if(($Header != 'Subject') and ($Value != '')) $Headers .= $Header.': '.$Value."\n";
     137    foreach ($this->Headers as $Header => $Value)
     138    {
     139      if (($Header != 'Subject') and ($Value != '')) $Headers .= $Header.': '.$Value."\n";
    140140    }
    141141
    142142    $this->Subject = strtr($this->Subject, "\r\n", '  ');
    143143
    144     if($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
     144    if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
    145145
    146146
    147147    $res = mail($To, $this->Subject, $Body, $Headers);
    148     return($res);
     148    return ($res);
    149149  }
    150150
    151151  function ValidEmail($Address)
    152152  {
    153     if(ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];
    154     if(ereg("^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))
    155       return(true);
    156       else return(false);
     153    if (ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];
     154    if (ereg("^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))
     155      return (true);
     156      else return (false);
    157157  }
    158158
    159159  function CheckAdresses($Addresses)
    160160  {
    161     foreach($Addresses as $Address)
    162     {
    163       if(!$this->ValidEmail($Address))
     161    foreach ($Addresses as $Address)
     162    {
     163      if (!$this->ValidEmail($Address))
    164164  throw new Exception(sprintf(T('Mail message invalid address %s'), $Address));
    165165    }
     
    168168  private function ContentEncoding($Charset)
    169169  {
    170     if($Charset != CHARSET_ASCII) return('8bit');
    171       else return('7bit');
     170    if ($Charset != CHARSET_ASCII) return ('8bit');
     171      else return ('7bit');
    172172  }
    173173
    174174  private function BuildAttachment($Body)
    175175  {
    176     if(count($this->Attachments) > 0)
     176    if (count($this->Attachments) > 0)
    177177    {
    178178      $this->Headers['Content-Type'] = "multipart/mixed;\n boundary=\"PHP-mixed-".$this->Boundary."\"";
     
    181181      $Result .= $Body;
    182182
    183       foreach($this->Attachments as $Attachment)
     183      foreach ($this->Attachments as $Attachment)
    184184      {
    185185        $FileName = $Attachment['FileName'];
     
    187187        $ContentType = $Attachment['FileType'];
    188188        $Disposition = $Attachment['Disposition'];
    189         if($Attachment['Type'] == 'File')
     189        if ($Attachment['Type'] == 'File')
    190190        {
    191           if(!file_exists($FileName))
     191          if (!file_exists($FileName))
    192192            throw new Exception(sprintf(T('Mail message attached file %s can\'t be found'), $FileName));
    193193          $Data = file_get_contents($FileName);
    194194        } else
    195         if($Attachment['Type'] == 'Data') $Data = $Attachment['Data'];
     195        if ($Attachment['Type'] == 'Data') $Data = $Attachment['Data'];
    196196          else $Data = '';
    197197
     
    203203      }
    204204    } else $Result = $Body;
    205     return($Result);
     205    return ($Result);
    206206  }
    207207
     
    209209  {
    210210    $Result = '';
    211     if(count($this->Bodies) > 1)
     211    if (count($this->Bodies) > 1)
    212212    {
    213213      $this->Headers['Content-Type'] = 'multipart/alternative; boundary="PHP-alt-'.$this->Boundary.'"';
     
    221221
    222222
    223     foreach($this->Bodies as $Body)
    224     {
    225       if(count($this->Bodies) > 1) $Result .= "\n\n".'--PHP-alt-'.$this->Boundary."\n";
     223    foreach ($this->Bodies as $Body)
     224    {
     225      if (count($this->Bodies) > 1) $Result .= "\n\n".'--PHP-alt-'.$this->Boundary."\n";
    226226      $Result .= 'Content-Type: '.$Body['Type'].'; charset='.$Body['Charset'].
    227227        "\nContent-Transfer-Encoding: ".$this->ContentEncoding($Body['Charset'])."\n\n".$Body['Content']."\n";
    228228    }
    229     return($Result);
     229    return ($Result);
    230230  }
    231231}
  • trunk/Packages/Common/NetworkAddress.php

    r870 r873  
    1616  function GetNetMask()
    1717  {
    18     return(((1 << IPV4_BIT_WIDTH) - 1) ^ ((1 << (IPV4_BIT_WIDTH - $this->Prefix)) - 1));
     18    return (((1 << IPV4_BIT_WIDTH) - 1) ^ ((1 << (IPV4_BIT_WIDTH - $this->Prefix)) - 1));
    1919  }
    2020
    2121  function AddressToString()
    2222  {
    23     return(implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));
     23    return (implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));
    2424  }
    2525
     
    3939    $To->Address = $From->Address + $HostMask;
    4040    $To->Prefix = IPV4_BIT_WIDTH;
    41     return(array('From' => $From, 'To' => $To));
     41    return (array('From' => $From, 'To' => $To));
    4242  }
    4343
     
    4545  {
    4646    $this->Prefix = $NewPrefix;
    47     if($this->Prefix > IPV4_BIT_WIDTH) $this->Prefix = IPV4_BIT_WIDTH;
    48     if($this->Prefix < 0) $this->Prefix = 0;
     47    if ($this->Prefix > IPV4_BIT_WIDTH) $this->Prefix = IPV4_BIT_WIDTH;
     48    if ($this->Prefix < 0) $this->Prefix = 0;
    4949    $this->Address = $this->Address & $this->GetNetMask();
    5050  }
     
    5353  {
    5454    $UpperNetmask = $this->GetNetMask();
    55     if(($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
     55    if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
    5656      else $Result = false;
    57     return($Result);
     57    return ($Result);
    5858  }
    5959}
     
    7474  function GetNetMask()
    7575  {
    76     return(Int128Xor(Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH)), IntToInt128(1)),
     76    return (Int128Xor(Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH)), IntToInt128(1)),
    7777      Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH - $this->Prefix)), IntToInt128(1))));
    7878  }
     
    8080  function AddressToString()
    8181  {
    82     return(inet_ntop($this->Address));
     82    return (inet_ntop($this->Address));
    8383  }
    8484
     
    9191  {
    9292    $this->Prefix = $NewPrefix;
    93     if($this->Prefix > IPV6_BIT_WIDTH) $this->Prefix = IPV6_BIT_WIDTH;
    94     if($this->Prefix < 0) $this->Prefix = 0;
     93    if ($this->Prefix > IPV6_BIT_WIDTH) $this->Prefix = IPV6_BIT_WIDTH;
     94    if ($this->Prefix < 0) $this->Prefix = 0;
    9595    $this->Address = Int128And($this->Address, $this->GetNetMask());
    9696  }
     
    100100    $Result = array();
    101101    $Data = array_reverse(unpack('C*', $this->Address));
    102     foreach($Data as $Item)
     102    foreach ($Data as $Item)
    103103    {
    104104
     
    106106      $Result[] = dechex(($Item >> 4) & 15);
    107107    }
    108     return($Result);
     108    return ($Result);
    109109  }
    110110
     
    127127  {
    128128    $UpperNetmask = $this->GetNetMask();
    129     if(($this->Prefix < $Address->Prefix) and ((Int128Equal(Int128And($Address->Address, $UpperNetmask), Int128And($this->Address, $UpperNetmask))))) $Result = true;
     129    if (($this->Prefix < $Address->Prefix) and ((Int128Equal(Int128And($Address->Address, $UpperNetmask), Int128And($this->Address, $UpperNetmask))))) $Result = true;
    130130      else $Result = false;
    131     return($Result);
     131    return ($Result);
    132132  }
    133133}
  • trunk/Packages/Common/Page.php

    r796 r873  
    2020  function Show()
    2121  {
    22     return('');
     22    return ('');
    2323  }
    2424
     
    2626  {
    2727    $Output = $this->Show();
    28     return($Output);
     28    return ($Output);
    2929  }
    3030
    3131  function SystemMessage($Title, $Text)
    3232  {
    33     return(call_user_func_array($this->OnSystemMessage, array($Title, $Text)));
     33    return (call_user_func_array($this->OnSystemMessage, array($Title, $Text)));
    3434  }
    3535}
  • trunk/Packages/Common/PrefixMultiplier.php

    r746 r873  
    7474  function TruncateDigits($Value, $Digits = 4)
    7575  {
    76     for($II = 2; $II > -6; $II--)
     76    for ($II = 2; $II > -6; $II--)
    7777    {
    78       if($Value >= pow(10, $II))
     78      if ($Value >= pow(10, $II))
    7979      {
    80         if($Digits < ($II + 1)) $RealDigits = $II + 1;
     80        if ($Digits < ($II + 1)) $RealDigits = $II + 1;
    8181          else $RealDigits = $Digits;
    8282        $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1);
     
    8484      }
    8585    }
    86     return($Value);
     86    return ($Value);
    8787  }
    8888
     
    9393    $Negative = ($Value < 0);
    9494    $Value = abs($Value);
    95     if(($Unit == '') and ($PrefixType != 'Time'))
    96       return($this->TruncateDigits($Value, $Digits));
     95    if (($Unit == '') and ($PrefixType != 'Time'))
     96      return ($this->TruncateDigits($Value, $Digits));
    9797
    9898    $I = $PrefixMultipliers[$PrefixType]['BaseIndex'];
    99     if($Value == 0) return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
     99    if ($Value == 0) return ($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
    100100
    101     if($Value > 1)
     101    if ($Value > 1)
    102102    {
    103       while((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1))
     103      while ((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1))
    104104        $I = $I + 1;
    105105    } else
    106     if($Value < 1)
     106    if ($Value < 1)
    107107    {
    108       while((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1))
     108      while ((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1))
    109109        $I = $I - 1;
    110110    }
     
    113113    // Truncate digits count
    114114    $Value = $this->TruncateDigits($Value, $Digits);
    115     if($Negative) $Value = -$Value;
    116     return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
     115    if ($Negative) $Value = -$Value;
     116    return ($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
    117117  }
    118118}
  • trunk/Packages/Common/Process.php

    r816 r873  
    2020  function Start()
    2121  {
    22     if(!$this->IsRunning())
     22    if (!$this->IsRunning())
    2323    {
    2424      $DescriptorSpec = array(
     
    3838  function Stop()
    3939  {
    40     if($this->IsRunning())
     40    if ($this->IsRunning())
    4141    {
    4242      proc_close($this->Handle);
     
    4747  function IsRunning()
    4848  {
    49     return(is_resource($this->Handle));
     49    return (is_resource($this->Handle));
    5050  }
    5151}
  • trunk/Packages/Common/RSS.php

    r746 r873  
    2828  "    <pubDate>".date('r')."</pubDate>\n".
    2929  "    <ttl>20</ttl>\n";
    30     foreach($this->Items as $Item)
     30    foreach ($this->Items as $Item)
    3131    {
    3232      $Result .= "    <item>\n".
     
    3939    $Result .= "  </channel>\n".
    4040    "</rss>";
    41     return($Result);
     41    return ($Result);
    4242  }
    4343}
  • trunk/Packages/Common/Setup.php

    r841 r873  
    2929      '<input type="submit" name="login" value="'.T('Login').'"/>'.
    3030      '</form>';
    31     return($Output);
     31    return ($Output);
    3232  }
    3333
     
    3737
    3838    $Output .= 'Je připojení k databázi: '.$this->YesNo[$this->UpdateManager->Database->Connected()].'<br/>';
    39     if($this->UpdateManager->Database->Connected())
     39    if ($this->UpdateManager->Database->Connected())
    4040    {
    4141      $Output .= 'Je instalováno: '.$this->YesNo[$this->UpdateManager->IsInstalled()].'<br/>';
    42       if($this->UpdateManager->IsInstalled())
     42      if ($this->UpdateManager->IsInstalled())
    4343        $Output .= 'Je aktuální: '.$this->YesNo[$this->UpdateManager->IsUpToDate()].'<br/>'.
    4444        'Verze databáze: '.$this->UpdateManager->GetDbVersion().'<br/>';
    4545      $Output .= 'Verze databáze kódu: '.$this->UpdateManager->Revision.'<br/>';
    46       if($this->UpdateManager->IsInstalled())
    47       {
    48         if(!$this->UpdateManager->IsUpToDate())
     46      if ($this->UpdateManager->IsInstalled())
     47      {
     48        if (!$this->UpdateManager->IsUpToDate())
    4949          $Output .= '<a href="?action=upgrade">'.T('Upgrade').'</a> ';
    5050        $Output .= '<a href="?action=insert_sample_data">Vložit vzorová data</a> ';
     
    5959    $Output .= '<a href="'.$this->System->Link('/').'">'.T('Go to main page').'</a> ';
    6060    $Output .= '';
    61     return($Output);
     61    return ($Output);
    6262  }
    6363
     
    7373
    7474    $Output = '';
    75     if(isset($this->Config))
    76     {
    77       if(!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';
    78       if(array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];
    79       if(sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword'])
     75    if (isset($this->Config))
     76    {
     77      if (!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';
     78      if (array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];
     79      if (sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword'])
    8080      {
    8181        $Output .= $this->LoginPanel();
    8282      } else
    8383      {
    84         if(array_key_exists('action', $_GET)) $Action = $_GET['action'];
     84        if (array_key_exists('action', $_GET)) $Action = $_GET['action'];
    8585          else $Action = '';
    86         if($Action == 'logout')
     86        if ($Action == 'logout')
    8787        {
    8888          $_SESSION['SystemPassword'] = '';
     
    9090          $Output .= $this->LoginPanel();
    9191        } else
    92         if($Action == 'models')
     92        if ($Action == 'models')
    9393        {
    9494          $this->System->FormManager->UpdateSQLMeta();
    9595        } else
    96         if($Action == 'upgrade')
     96        if ($Action == 'upgrade')
    9797        {
    9898          $Output .= '<h3>Povýšení</h3>';
     
    105105          $Output .= $this->ControlPanel();
    106106        } else
    107         if($Action == 'install')
     107        if ($Action == 'install')
    108108        {
    109109          $Output .= '<h3>Instalace</h3>';
     
    114114          $Output .= $this->ControlPanel();
    115115        } else
    116         if($Action == 'uninstall')
     116        if ($Action == 'uninstall')
    117117        {
    118118          $Output .= '<h3>Odinstalace</h3>';
     
    120120          $Output .= $this->ControlPanel();
    121121        } else
    122         if($Action == 'reload_modules')
     122        if ($Action == 'reload_modules')
    123123        {
    124124          $Output .= '<h3>Znovunačtení seznamu modulů</h3>';
     
    127127          $Output .= $this->ControlPanel();
    128128        } else
    129         if($Action == 'insert_sample_data')
     129        if ($Action == 'insert_sample_data')
    130130        {
    131131          $Output .= '<h3>Vložení vzorových dat</h3>';
     
    133133          $Output .= $this->ControlPanel();
    134134        } else
    135         if($Action == 'modules')
     135        if ($Action == 'modules')
    136136        {
    137137          $Output .= $this->ShowModules();
    138138        } else
    139         if($Action == 'configure_save')
     139        if ($Action == 'configure_save')
    140140        {
    141141           $Output .= $this->ConfigSave($this->Config);
    142142           $Output .= $this->ControlPanel();
    143143        } else
    144         if($Action == 'configure')
     144        if ($Action == 'configure')
    145145        {
    146146          $Output .= $this->PrepareConfig($this->Config);
     
    152152    } else
    153153    {
    154       if(array_key_exists('configure_save', $_POST))
     154      if (array_key_exists('configure_save', $_POST))
    155155      {
    156156        $Output .= $this->ConfigSave(array());
     
    160160      }
    161161    }
    162     return($Output);
     162    return ($Output);
    163163  }
    164164
     
    166166  {
    167167    $Output = '';
    168     if(array_key_exists('op', $_GET)) $Operation = $_GET['op'];
     168    if (array_key_exists('op', $_GET)) $Operation = $_GET['op'];
    169169      else $Operation = '';
    170     if($Operation == 'install')
     170    if ($Operation == 'install')
    171171    {
    172172      $this->System->ModuleManager->Modules[$_GET['name']]->Install();
     
    174174      $Output .= 'Modul '.$_GET['name'].' instalován<br/>';
    175175    } else
    176     if($Operation == 'uninstall')
     176    if ($Operation == 'uninstall')
    177177    {
    178178      $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall();
     
    180180      $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>';
    181181    } else
    182     if($Operation == 'enable')
     182    if ($Operation == 'enable')
    183183    {
    184184      $this->System->ModuleManager->Modules[$_GET['name']]->Enable();
     
    186186      $Output .= 'Modul '.$_GET['name'].' povolen<br/>';
    187187    } else
    188     if($Operation == 'disable')
     188    if ($Operation == 'disable')
    189189    {
    190190      $this->System->ModuleManager->Modules[$_GET['name']]->Disable();
     
    192192      $Output .= 'Modul '.$_GET['name'].' zakázán<br/>';
    193193    } else
    194     if($Operation == 'upgrade')
     194    if ($Operation == 'upgrade')
    195195    {
    196196      $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade();
     
    200200    $Output .= '<h3>Správa modulů</h3>';
    201201    $Output .= $this->ShowList();
    202     return($Output);
     202    return ($Output);
    203203  }
    204204
     
    221221      array('Name' => '', 'Title' => 'Akce'),
    222222    ));
    223     foreach($this->System->ModuleManager->Modules as $Module)
    224     {
    225       if(($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);
     223    foreach ($this->System->ModuleManager->Modules as $Module)
     224    {
     225      if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);
    226226       else $Dependencies = '&nbsp;';
    227227      $Actions = '';
    228       if($Module->Installed == true)
     228      if ($Module->Installed == true)
    229229      {
    230230        $Actions .= ' <a href="?action=modules&amp;op=uninstall&amp;name='.$Module->Name.'">Odinstalovat</a>';
    231         if($Module->Enabled == true) $Actions .= ' <a href="?action=modules&amp;op=disable&amp;name='.$Module->Name.'">Zakázat</a>';
     231        if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&amp;op=disable&amp;name='.$Module->Name.'">Zakázat</a>';
    232232        else $Actions .= ' <a href="?action=modules&amp;op=enable&amp;name='.$Module->Name.'">Povolit</a>';
    233         if($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&amp;op=upgrade&amp;name='.$Module->Name.'">Povýšit</a>';
     233        if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&amp;op=upgrade&amp;name='.$Module->Name.'">Povýšit</a>';
    234234      } else $Actions .= ' <a href="?action=modules&amp;op=install&amp;name='.$Module->Name.'">Instalovat</a>';
    235235
     
    244244    $Output .= $Pageing->Show();
    245245    //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';
    246     return($Output);
     246    return ($Output);
    247247  }
    248248
     
    250250  {
    251251    $Output = '';
    252     if(!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir))
     252    if (!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir))
    253253      $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože složka "'.$this->ConfigDir.'" není povolená pro zápis!';
    254     if(file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php'))
     254    if (file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php'))
    255255      $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor "'.$this->ConfigDir.'/Config.php" není povolen pro zápis!';
    256256    $Output .= '<h3>Nastavení systému</h3>'.
    257257        '<form action="?action=configure_save" method="post">'.
    258258        '<table>';
    259     foreach($this->ConfigDefinition as $Def)
     259    foreach ($this->ConfigDefinition as $Def)
    260260    {
    261261      $PathParts = explode('/', $Def['Name']);
    262262      $TempConfig = &$Config;
    263       foreach($PathParts as $Part)
    264         if(array_key_exists($Part, $TempConfig))
     263      foreach ($PathParts as $Part)
     264        if (array_key_exists($Part, $TempConfig))
    265265        {
    266266          $TempConfig = &$TempConfig[$Part];
    267267        }
    268       if(!is_array($TempConfig)) $Value = $TempConfig;
     268      if (!is_array($TempConfig)) $Value = $TempConfig;
    269269        else $Value = $Def['Default'];
    270270      $Output .= '<tr><td>'.$Def['Title'].'</td><td>';
    271       if($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
    272       if($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
    273       if($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
    274       if($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
    275       if($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
    276       if($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
    277       if($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>';
     271      if ($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
     272      if ($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
     273      if ($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
     274      if ($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
     275      if ($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
     276      if ($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
     277      if ($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>';
    278278    }
    279279    $Output .= '</td></tr>'.
     
    281281        '</table>'.
    282282        '</form>';
    283     return($Output);
     283    return ($Output);
    284284  }
    285285
     
    287287  {
    288288    $Config = $DefaultConfig;
    289     foreach($this->ConfigDefinition as $Def)
     289    foreach ($this->ConfigDefinition as $Def)
    290290    {
    291291      $Value = null;
    292       if($Def['Type'] == 'String') if(array_key_exists($Def['Name'], $_POST))
     292      if ($Def['Type'] == 'String') if (array_key_exists($Def['Name'], $_POST))
    293293        $Value = $_POST[$Def['Name']];
    294       if($Def['Type'] == 'Password') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
     294      if ($Def['Type'] == 'Password') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
    295295        $Value = $_POST[$Def['Name']];
    296       if($Def['Type'] == 'PasswordEncoded') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
     296      if ($Def['Type'] == 'PasswordEncoded') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
    297297        $Value = sha1($_POST[$Def['Name']]);
    298       if($Def['Type'] == 'Integer') if(array_key_exists($Def['Name'], $_POST))
     298      if ($Def['Type'] == 'Integer') if (array_key_exists($Def['Name'], $_POST))
    299299        $Value = $_POST[$Def['Name']];
    300       if($Def['Type'] == 'Float') if(array_key_exists($Def['Name'], $_POST))
     300      if ($Def['Type'] == 'Float') if (array_key_exists($Def['Name'], $_POST))
    301301        $Value = $_POST[$Def['Name']];
    302       if($Def['Type'] == 'Boolean') if(array_key_exists($Def['Name'], $_POST))
     302      if ($Def['Type'] == 'Boolean') if (array_key_exists($Def['Name'], $_POST))
    303303        $Value = $_POST[$Def['Name']];
    304       if($Def['Type'] == 'Array') if(array_key_exists($Def['Name'], $_POST))
     304      if ($Def['Type'] == 'Array') if (array_key_exists($Def['Name'], $_POST))
    305305        $Value = explode(',', $_POST[$Def['Name']]);
    306       if(!is_null($Value))
     306      if (!is_null($Value))
    307307      {
    308308        $PathParts = explode('/', $Def['Name']);
    309309        $TempConfig = &$Config;
    310         foreach($PathParts as $Part)
     310        foreach ($PathParts as $Part)
    311311        {
    312312          $TempConfig = &$TempConfig[$Part];
    313313        }
    314         if(!is_array($TempConfig)) $TempConfig = $Value;
     314        if (!is_array($TempConfig)) $TempConfig = $Value;
    315315        else $Value = $Def['Default'];
    316316      }
     
    319319    file_put_contents($this->ConfigDir.'/Config.php', $ConfigText);
    320320    $Output = 'Konfigurace nastavena<br/>';
    321     return($Output);
     321    return ($Output);
    322322  }
    323323
     
    327327      "\$IsDeveloper = array_key_exists('REMOTE_ADDR', \$_SERVER) and  in_array(\$_SERVER['REMOTE_ADDR'], array('127.0.0.1'));\n\n";
    328328
    329     foreach($this->ConfigDefinition as $Def)
     329    foreach ($this->ConfigDefinition as $Def)
    330330    {
    331331      $PathParts = explode('/', $Def['Name']);
    332332      $Output .= "\$Config";
    333       foreach($PathParts as $Part)
     333      foreach ($PathParts as $Part)
    334334        $Output .= "['".$Part."']";
    335335      $TempConfig = &$Config;
    336336      $Output .= ' = ';
    337       foreach($PathParts as $Part)
    338         if(array_key_exists($Part, $TempConfig))
     337      foreach ($PathParts as $Part)
     338        if (array_key_exists($Part, $TempConfig))
    339339        {
    340340          $TempConfig = &$TempConfig[$Part];
    341341        }
    342       if(!is_array($TempConfig)) $Value = $TempConfig;
     342      if (!is_array($TempConfig)) $Value = $TempConfig;
    343343        else $Value = $Def['Default'];
    344       if($Def['Type'] == 'Array')
     344      if ($Def['Type'] == 'Array')
    345345      {
    346346        $Output .= ' array(';
    347         foreach($Value as $Index => $Item)
     347        foreach ($Value as $Index => $Item)
    348348          $Output .= '\''.$Item.'\', ';
    349349        $Output .= ')';
     
    353353    }
    354354    $Output .= "\n\n";
    355     return($Output);
     355    return ($Output);
    356356  }
    357357}
     
    362362  {
    363363    $Output = '';
    364     if(!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>';
     364    if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>';
    365365    else {
    366       if(!$this->System->Setup->UpdateManager->IsInstalled())
     366      if (!$this->System->Setup->UpdateManager->IsInstalled())
    367367        $Output .= T('System requires database initialization').'<br>';
    368368      else
    369       if(!$this->System->Setup->UpdateManager->IsUpToDate())
     369      if (!$this->System->Setup->UpdateManager->IsUpToDate())
    370370        $Output .= T('System requires database upgrade').'<br>';
    371371    }
    372372    $Output .= sprintf(T('Front page was not configured. Continue to %s'), '<a href="'.$this->System->Link('/setup/').'">'.T('setup').'</a>');
    373     return($Output);
     373    return ($Output);
    374374  }
    375375}
     
    402402  function CheckState()
    403403  {
    404     return($this->Database->Connected() and $this->UpdateManager->IsInstalled() and
     404    return ($this->Database->Connected() and $this->UpdateManager->IsInstalled() and
    405405      $this->UpdateManager->IsUpToDate());
    406406  }
     
    435435  {
    436436    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->UpdateManager->VersionTable.'"');
    437     return($DbResult->num_rows > 0);
     437    return ($DbResult->num_rows > 0);
    438438  }
    439439
     
    443443    $this->UpdateManager->Trace = $Updates->Get();
    444444    $Output = $this->UpdateManager->Upgrade();
    445     return($Output);
     445    return ($Output);
    446446  }
    447447}
  • trunk/Packages/Common/Table.php

    r791 r873  
    77  function Show()
    88  {
    9     return('');
     9    return ('');
    1010  }
    1111}
     
    1515  function GetCell($Y, $X)
    1616  {
    17     return('');
     17    return ('');
    1818  }
    1919
     
    2828  function RowsCount()
    2929  {
    30     return(0);
     30    return (0);
    3131  }
    3232}
     
    3838  function GetCell($Y, $X)
    3939  {
    40     return($this->Cells[$Y][$X]);
     40    return ($this->Cells[$Y][$X]);
    4141  }
    4242
    4343  function RowsCount()
    4444  {
    45     return(count($this->Cells));
     45    return (count($this->Cells));
    4646  }
    4747}
     
    5555  function GetCell($Y, $X)
    5656  {
    57     return($this->Cells[$Y][$X]);
     57    return ($this->Cells[$Y][$X]);
    5858  }
    5959
     
    6262    $this->Cells = array();
    6363    $DbResult = $this->Database->query($this->Query);
    64     while($DbRow = $DbResult->fetch_row())
     64    while ($DbRow = $DbResult->fetch_row())
    6565    {
    6666      $this->Cells[] = $DbRow;
     
    7575  function RowsCount()
    7676  {
    77     return(count($this->Cells));
     77    return (count($this->Cells));
    7878  }
    7979}
     
    114114  {
    115115    $this->Columns = array();
    116     foreach($Columns as $Column)
     116    foreach ($Columns as $Column)
    117117    {
    118118      $NewCol = new TableColumn();
     
    121121      $this->Columns[] = $NewCol;
    122122    }
    123     if(count($this->Columns) > 0)
     123    if (count($this->Columns) > 0)
    124124      $this->DefaultColumn = $this->Columns[0]->Name;
    125125      else $this->DefaultColumn = '';
     
    131131    $Output .= $this->GetOrderHeader();
    132132    $this->Table->BeginRead();
    133     for($Y = 0; $Y < $this->Table->RowsCount(); $Y++)
     133    for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++)
    134134    {
    135135      $Output .= '<tr>';
    136136
    137       for($X = 0; $X < count($this->Columns); $X++)
     137      for ($X = 0; $X < count($this->Columns); $X++)
    138138      {
    139139        $Cell = $this->Table->GetCell($Y, $X);
    140         if($Cell == '') $Output .= '<td>&nbsp;</td>';
     140        if ($Cell == '') $Output .= '<td>&nbsp;</td>';
    141141          else $Output .= '<td>'.$Cell.'</td>';
    142142      }
     
    145145    $this->Table->EndRead();
    146146    $Output .= '</table>';
    147     return($Output);
     147    return ($Output);
    148148  }
    149149
    150150  function GetOrderHeader()
    151151  {
    152     if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
    153     if(array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];
    154     if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;
    155     if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;
     152    if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
     153    if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];
     154    if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;
     155    if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;
    156156
    157157    // Check OrderCol
    158158    $Found = false;
    159     foreach($this->Columns as $Column)
     159    foreach ($this->Columns as $Column)
    160160    {
    161       if($Column->Name == $_SESSION['OrderCol'])
     161      if ($Column->Name == $_SESSION['OrderCol'])
    162162      {
    163163        $Found = true;
     
    165165      }
    166166    }
    167     if($Found == false)
     167    if ($Found == false)
    168168    {
    169169      $_SESSION['OrderCol'] = $this->DefaultColumn;
     
    171171    }
    172172    // Check OrderDir
    173     if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))
     173    if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))
    174174      $_SESSION['OrderDir'] = 0;
    175175
    176176    $Result = '';
    177177    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    178     foreach($this->Columns as $Index => $Column)
     178    foreach ($this->Columns as $Index => $Column)
    179179    {
    180180      $QueryItems['OrderCol'] = $Column->Name;
    181181      $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir'];
    182       if($Column->Name == $_SESSION['OrderCol'])
     182      if ($Column->Name == $_SESSION['OrderCol'])
    183183        $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.$this->OrderArrowImage[$_SESSION['OrderDir']].'" alt="order arrow">';
    184184        else $ArrowImage = '';
    185       if($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';
     185      if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';
    186186        else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>';
    187187    }
     
    190190    $this->OrderDirection = $_SESSION['OrderDir'];
    191191
    192     return('<tr>'.$Result.'</tr>');
     192    return ('<tr>'.$Result.'</tr>');
    193193  }
    194194}
  • trunk/Packages/Common/UTF8.php

    r746 r873  
    529529  {
    530530    $Result = '';
    531     for($I = 0; $I < strlen($String); $I++)
     531    for ($I = 0; $I < strlen($String); $I++)
    532532    {
    533        if(ord($String[$I]) < 128) $Result .= $String[$I];
    534        else if(ord($String[$I]) > 127)
     533       if (ord($String[$I]) < 128) $Result .= $String[$I];
     534       else if (ord($String[$I]) > 127)
    535535       {
    536536         $Result .= $this->CharTable[$Charset][ord($String[$I])];
    537537       }
    538538    }
    539     return($Result);
     539    return ($Result);
    540540  }
    541541
     
    544544    $Result = '';
    545545    $UTFPrefix = '';
    546     for($I = 0; $I < strlen($String); $I++)
     546    for ($I = 0; $I < strlen($String); $I++)
    547547    {
    548       if(ord($String{$I}) & 0x80) // UTF control character
     548      if (ord($String{$I}) & 0x80) // UTF control character
    549549      {
    550         if(ord($String{$I}) & 0x40) // First
     550        if (ord($String{$I}) & 0x40) // First
    551551        {
    552           if($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
     552          if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
    553553          $UTFPrefix = $String{$I};
    554554        }
     
    556556      } else
    557557      {
    558         if($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
     558        if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
    559559        $UTFPrefix = '';
    560560        $Result .= $String{$I};
    561561      }
    562562    }
    563     return($Result);
     563    return ($Result);
    564564  }
    565565}
  • trunk/Packages/Common/Update.php

    r838 r873  
    2323    $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1');
    2424    $Version = $DbResult->fetch_assoc();
    25     return($Version['Revision']);
     25    return ($Version['Revision']);
    2626  }
    2727
     
    2929  {
    3030    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
    31     return($DbResult->num_rows > 0);
     31    return ($DbResult->num_rows > 0);
    3232  }
    3333
    3434  function IsUpToDate()
    3535  {
    36     return($this->Revision <= $this->GetDbVersion());
     36    return ($this->Revision <= $this->GetDbVersion());
    3737  }
    3838
     
    4141    $DbRevision = $this->GetDbVersion();
    4242    $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>';
    43     while($this->Revision > $DbRevision)
     43    while ($this->Revision > $DbRevision)
    4444    {
    45       if(!array_key_exists($DbRevision, $this->Trace))
     45      if (!array_key_exists($DbRevision, $this->Trace))
    4646        die('Missing upgrade trace for revision '.$DbRevision);
    4747      $TraceItem = $this->Trace[$DbRevision];
     
    5656        $TraceItem['Revision'].' WHERE `Id`=1');
    5757    }
    58     return($Output);
     58    return ($Output);
    5959  }
    6060
     
    8181    echo($Query.';<br/>');
    8282    flush();
    83     return($this->Database->query($Query));
     83    return ($this->Database->query($Query));
    8484  }
    8585}
  • trunk/Packages/Common/VarDumper.php

    r746 r873  
    4949                self::$_depth=$depth;
    5050                self::dumpInternal($var,0);
    51                 if($highlight)
     51                if ($highlight)
    5252                {
    5353                        $result=highlight_string("<?php\n".self::$_output,true);
     
    6060        private static function dumpInternal($var,$level)
    6161        {
    62                 switch(gettype($var))
     62                switch (gettype($var))
    6363                {
    6464                        case 'boolean':
     
    8484                                break;
    8585                        case 'array':
    86                                 if(self::$_depth<=$level)
     86                                if (self::$_depth<=$level)
    8787                                        self::$_output.='array(...)';
    88                                 else if(empty($var))
     88                                else if (empty($var))
    8989                                        self::$_output.='array()';
    9090                                else
     
    9393                                        $spaces=str_repeat(' ',$level*4);
    9494                                        self::$_output.="array\n".$spaces.'(';
    95                                         foreach($keys as $key)
     95                                        foreach ($keys as $key)
    9696                                        {
    9797                                                self::$_output.="\n".$spaces."    [$key] => ";
     
    102102                                break;
    103103                        case 'object':
    104                                 if(($id=array_search($var,self::$_objects,true))!==false)
     104                                if (($id=array_search($var,self::$_objects,true))!==false)
    105105                                        self::$_output.=get_class($var).'#'.($id+1).'(...)';
    106                                 else if(self::$_depth<=$level)
     106                                else if (self::$_depth<=$level)
    107107                                        self::$_output.=get_class($var).'(...)';
    108108                                else
     
    114114                                        $spaces=str_repeat(' ',$level*4);
    115115                                        self::$_output.="$className#$id\n".$spaces.'(';
    116                                         foreach($keys as $key)
     116                                        foreach ($keys as $key)
    117117                                        {
    118118                                                $keyDisplay=strtr(trim($key),array("\0"=>':'));
  • trunk/block/index.php

    r659 r873  
    2222
    2323    $DbResult = $this->Database->query('SELECT * FROM NetworkInterface WHERE LocalIP="'.GetRemoteAddress().'"');
    24     if($DbResult->num_rows > 0)
     24    if ($DbResult->num_rows > 0)
    2525    {
    2626      $Interface = $DbResult->fetch_array();
     
    3030      $Member = $DbResult->fetch_array();
    3131
    32       if($Member['Blocked'] == 1)
     32      if ($Member['Blocked'] == 1)
    3333      {
    3434        $Output .= $this->Reasons[1];
     
    3838    $Output .= '<br/><br/>V případě problémů kontaktujte technickou podporu na telefonu 737785792<br/><br/>';
    3939    $Output .= '</body></html>';
    40     return($Output);
     40    return ($Output);
    4141  }
    4242}
  • trunk/cmd.php

    r790 r873  
    33include_once('Application/System.php');
    44
    5 if(isset($_SERVER['REMOTE_ADDR'])) die();
     5if (isset($_SERVER['REMOTE_ADDR'])) die();
    66
    77$System = new Core();
Note: See TracChangeset for help on using the changeset viewer.