Changeset 92


Ignore:
Timestamp:
Apr 7, 2020, 11:53:58 AM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
Location:
trunk
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    r84 r92  
    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__).'/../Global.php');
     
    2424    $this->ShowPage = true;
    2525    $this->BaseURL = $_SERVER['SCRIPT_NAME'];
    26     if(substr($this->BaseURL, -10, 10) == '/index.php')
     26    if (substr($this->BaseURL, -10, 10) == '/index.php')
    2727      $this->BaseURL = substr($this->BaseURL, 0, -10);
    2828  }
     
    3232    global $Config, $DatabaseRevision, $WithoutSessionStart;
    3333
    34     if($this->UseSession) session_start();
     34    if ($this->UseSession) session_start();
    3535
    3636    $ErrorHandler = new ErrorHandler();
     
    5050
    5151    // SQL injection hack protection
    52     foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
    53     foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
     52    foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
     53    foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
    5454
    5555    $this->Config = &$Config;
     
    5858    $this->Setup = new Setup($this);
    5959    $this->Setup->Start();
    60     if($this->Setup->CheckState())
     60    if ($this->Setup->CheckState())
    6161    {
    6262      $this->ModuleManager->Start();
     
    6767  {
    6868    $this->RunCommon();
    69     if($this->ShowPage)
     69    if ($this->ShowPage)
    7070    {
    7171      $this->PathItems = ProcessURL();
     
    8080    /* @var $Page Page */
    8181    $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
    82     if($ClassName != '')
     82    if ($ClassName != '')
    8383    {
    8484      $Page = new $ClassName($this);
     
    9191  function RegisterPage($Path, $Handler)
    9292  {
    93     if(is_array($Path))
     93    if (is_array($Path))
    9494    {
    9595      $Page = &$this->Pages;
    9696      $LastKey = array_pop($Path);
    97       foreach($Path as $PathItem)
     97      foreach ($Path as $PathItem)
    9898      {
    9999        $Page = &$Page[$PathItem];
    100100      }
    101       if(!is_array($Page)) $Page = array('' => $Page);
     101      if (!is_array($Page)) $Page = array('' => $Page);
    102102      $Page[$LastKey] = $Handler;
    103103    } else $this->Pages[$Path] = $Handler;
     
    111111  function SearchPage($PathItems, $Pages)
    112112  {
    113     if(count($PathItems) > 0) $PathItem = $PathItems[0];
     113    if (count($PathItems) > 0) $PathItem = $PathItems[0];
    114114      else $PathItem = '';
    115     if(array_key_exists($PathItem, $Pages))
     115    if (array_key_exists($PathItem, $Pages))
    116116    {
    117       if(is_array($Pages[$PathItem]))
     117      if (is_array($Pages[$PathItem]))
    118118      {
    119119        array_shift($PathItems);
    120         return($this->SearchPage($PathItems, $Pages[$PathItem]));
    121       } else return($Pages[$PathItem]);
    122     } else return('');
     120        return $this->SearchPage($PathItems, $Pages[$PathItem]);
     121      } else return $Pages[$PathItem];
     122    } else return '';
    123123  }
    124124
    125125  function Link($Target)
    126126  {
    127     return($this->BaseURL.$Target);
     127    return $this->BaseURL.$Target;
    128128  }
    129129}
     
    141141  {
    142142    Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
    143     return('<h3 align="center">'.T('Required page not found'));
     143    return '<h3 align="center">'.T('Required page not found');
    144144  }
    145145}
  • trunk/Application/DefaultConfig.php

    r78 r92  
    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'),
     
    5353        array('Name' => 'MainRouter/ConnectTimeout', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Vypršení času'),
    5454        array('Name' => 'MainRouter/MangleRuleSubgroupMinPrefix', 'Type' => 'Integer', 'Default' => '28', 'Title' => 'Nejmenší prefix podsítě pro mangle pravidla'),
    55     ));
     55    );
    5656  }
    5757}
  • trunk/Application/UpdateTrace.php

    r81 r92  
    4444  'REFERENCES `Measure`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
    4545  $DbResult = $Manager->Execute('SELECT `Id`, `PermissionAdd` FROM `Measure`');
    46   while($DbRow = $DbResult->fetch_assoc())
     46  while ($DbRow = $DbResult->fetch_assoc())
    4747  {
    4848    $Manager->Execute('INSERT INTO `Permission` (`Measure`, `Operation`) VALUES ('.
     
    5050        }
    5151  $DbResult = $Manager->Execute('SELECT `Id`, `PermissionView` FROM `Measure`');
    52   while($DbRow = $DbResult->fetch_assoc())
     52  while ($DbRow = $DbResult->fetch_assoc())
    5353  {
    5454          $Manager->Execute('INSERT INTO `Permission` (`Measure`, `Operation`) VALUES ('.
     
    6161{
    6262  $DbResult = $Manager->Execute('SELECT `DataTable`,`DataType` FROM `Measure`;');
    63   while($Measure = $DbResult->fetch_assoc())
     63  while ($Measure = $DbResult->fetch_assoc())
    6464  {
    6565    $Table = $Measure['DataTable'];
     
    8080  function Get()
    8181  {
    82     return(array(
     82    return array(
    8383      65 => array('Revision' => 67, 'Function' => 'UpdateTo67'),
    8484      67 => array('Revision' => 79, 'Function' => 'UpdateTo79'),
    85     ));
     85    );
    8686  }
    8787}
  • trunk/Application/Version.php

    r90 r92  
    66// and system will need database update.
    77
    8 $Revision = 88;
     8$Revision = 92;
    99$DatabaseRevision = 79;
    10 $ReleaseTime = strtotime('2019-10-04');
     10$ReleaseTime = strtotime('2020-04-07');
  • trunk/Application/View.php

    r90 r92  
    2828  {
    2929    $Output = $this->ShowPage($Page->Show());
    30     return($Output);
     30    return $Output;
    3131  }
    3232}
  • trunk/Global.php

    r77 r92  
    77function HumanDate($Time)
    88{
    9   return(date('j.n.Y', $Time));
     9  return date('j.n.Y', $Time);
    1010}
    1111
     
    1313{
    1414  list($Usec, $Sec) = explode(" ", microtime());
    15   return ((float)$Usec + (float)$Sec);
     15  return (float)$Usec + (float)$Sec;
    1616}
    1717
    1818function MakeLink($Target, $Title)
    1919{
    20   return('<a href="'.$Target.'">'.$Title.'</a>');
     20  return '<a href="'.$Target.'">'.$Title.'</a>';
    2121}
    2222
     
    2525  $Result = '<table cellspacing="0" class="BasicTable">';
    2626  $Result .= '<tr>';
    27   foreach($Table['Header'] as $Item)
     27  foreach ($Table['Header'] as $Item)
    2828    $Result .= '<th>'.$Item.'</th>';
    2929  $Result .= '</tr>';
    30   foreach($Table['Rows'] as $Row)
     30  foreach ($Table['Rows'] as $Row)
    3131  {
    3232    $Result .= '<tr>';
    33     foreach($Row as $Item)
     33    foreach ($Row as $Item)
    3434      $Result .= '<td>'.$Item.'</td>';
    3535    $Result .= '</tr>';
    3636  }
    3737  $Result .= '</table>';
    38   return($Result);
     38  return $Result;
    3939}
    4040
     
    4848  );
    4949
    50   foreach($Class as $Index => $Item)
     50  foreach ($Class as $Index => $Item)
    5151  {
    52     if(!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];
    53     switch($Item['Type'])
     52    if (!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];
     53    switch ($Item['Type'])
    5454    {
    5555      case 'Boolean':
    56         if($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"';
     56        if ($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"';
    5757        $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>';
    5858        break;
     
    6969  }
    7070  $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).MakeLink('?Operation=Add2', 'Přidat');
    71   return($Output);
     71  return $Output;
    7272}
    7373
    7474function ProcessURL()
    7575{
    76   if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     76  if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
    7777    $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
    7878    else $PathString = '';
    79   if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
     79  if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
    8080  $PathItems = explode('/', $PathString);
    81   if(array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
     81  if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
    8282    $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
    8383    else $_SERVER['QUERY_STRING'] = '';
    8484  parse_str($_SERVER['QUERY_STRING'], $_GET);
    85   return($PathItems);
     85  return $PathItems;
    8686}
    8787
     
    9090  $Result = array();
    9191  $Parts = explode('&', $QueryString);
    92   foreach($Parts as $Part)
     92  foreach ($Parts as $Part)
    9393  {
    94     if($Part != '')
     94    if ($Part != '')
    9595    {
    96       if(!strpos($Part, '=')) $Part .= '=';
     96      if (!strpos($Part, '=')) $Part .= '=';
    9797      $Item = explode('=', $Part);
    9898      $Result[$Item[0]] = $Item[1];
    9999    }
    100100  }
    101   return($Result);
     101  return $Result;
    102102}
    103103
     
    105105{
    106106  $Parts = array();
    107   foreach($QueryStringArray as $Index => $Item)
     107  foreach ($QueryStringArray as $Index => $Item)
    108108  {
    109109    $Parts[] = $Index.'='.$Item;
    110110  }
    111   return(implode('&amp;', $Parts));
     111  return implode('&amp;', $Parts);
    112112}
  • trunk/Graph.php

    r85 r92  
    2626    global $Config;
    2727
    28     if(!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku');
     28    if (!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku');
    2929    $StartTime = addslashes($_GET['From']);
    30     if(!array_key_exists('To',$_GET)) die('Musíte zadat čas konce');
     30    if (!array_key_exists('To',$_GET)) die('Musíte zadat čas konce');
    3131    $EndTime = addslashes($_GET['To']);
    32     if($EndTime < $StartTime) $EndTime = $StartTime + 60;
     32    if ($EndTime < $StartTime) $EndTime = $StartTime + 60;
    3333    $TimeDifference = $EndTime - $StartTime;
    34     if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
     34    if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
    3535    $MeasureId = addslashes($_GET['Measure']);
    36     if(!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
     36    if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
    3737    else $Width = addslashes($_GET['Width']);
    38     if(!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
     38    if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
    3939    else $Height = addslashes($_GET['Height']);
    40     if(!array_key_exists('Differential', $_GET)) $Differential = $Config['DefaultVariables']['Differential'];
     40    if (!array_key_exists('Differential', $_GET)) $Differential = $Config['DefaultVariables']['Differential'];
    4141    else $Differential = addslashes($_GET['Differential']);
    4242    $VerticalLinesCount = round($Height / ($this->FontSize + 4));
     
    5454
    5555    $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1;
    56     if($Level < 0) $Level = 0;
    57     if($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;
     56    if ($Level < 0) $Level = 0;
     57    if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;
    5858
    5959    $Points = $Measure->GetValues($StartTime, $EndTime, $Level);
     
    6363    $AvgValue = 0;
    6464    $MinValue = 1000000000000000000;
    65     foreach($Points as $Index => $Item)
     65    foreach ($Points as $Index => $Item)
    6666    {
    6767      //$Points[$Index]['Min'] =  $Points[$Index]['Min'] / $Measure['Divider'];
    6868      //$Points[$Index]['Avg'] =  $Points[$Index]['Avg'] / $Measure['Divider'];
    6969      //$Points[$Index]['Max'] =  $Points[$Index]['Max'] / $Measure['Divider'];
    70       if($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];
    71       if($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];
    72       if($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];
    73       if($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];
     70      if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];
     71      if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];
     72      if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];
     73      if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];
    7474      $AvgValue = $AvgValue + $Points[$Index]['Avg'];
    7575    }
     
    8282    $PointsAvg = array(0, $Height - 1);
    8383    $PointsMax = array(0, $Height - 1);
    84     if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
    85     {
    86       foreach($Points as $Index => $Item)
     84    if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
     85    {
     86      foreach ($Points as $Index => $Item)
    8787      {
    8888        $PointsMin[] = $Index * $Width / $Measure->DivisionCount;
     
    138138    $TimeRange = $EndTime - $StartTime;
    139139    $TimeMarksIndex = 0;
    140     while((($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) and ($TimeMarksIndex < (count($TimeMarks) - 1)))
     140    while ((($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) and ($TimeMarksIndex < (count($TimeMarks) - 1)))
    141141      $TimeMarksIndex += 1;
    142     if($TimeMarksIndex < 2) $TimeMarksIndex = 2;
     142    if ($TimeMarksIndex < 2) $TimeMarksIndex = 2;
    143143    $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1];
    144144    $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2];
     
    149149    // Zobraz měřítko Y
    150150    $VerticalLinesDistance = $Height / $VerticalLinesCount;
    151     for($I = 1; $I <= $VerticalLinesCount; $I++)
     151    for ($I = 1; $I <= $VerticalLinesCount; $I++)
    152152    {
    153153      $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    154       for($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
     154      for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
    155155      //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    156156    }
     
    160160    // Zobraz měřítko X
    161161    $LastTextEnd = 0;
    162     for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
     162    for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
    163163    {
    164164      $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
    165165      //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    166       if(($MajorTimeMarks > 60*60*24)) $Text = date('j.n.Y', $Time + $TimeShift);
     166      if (($MajorTimeMarks > 60*60*24)) $Text = date('j.n.Y', $Time + $TimeShift);
    167167        else $Text = date('j.n.Y G:i', $Time + $TimeShift);
    168168      $BoundBox = imagettfbbox($this->FontSize, 0, $this->FontFileName, $Text);
    169       if($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
     169      if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
    170170      {
    171         for($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
     171        for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
    172172        imagettftext($Image, $this->FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,  $Height - 2, $Black, $this->FontFileName, $Text);
    173173        $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2;
    174174      }
    175       else for($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
     175      else for ($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
    176176    }
    177177
    178178    // Popisky osy Y
    179     for($I = 1; $I <= $VerticalLinesCount; $I++)
     179    for ($I = 1; $I <= $VerticalLinesCount; $I++)
    180180    {
    181181      $Y = $Height - 1 - ($VerticalLinesDistance * $I);
     
    185185          $Measure->Data['Unit'], 3);
    186186      $BoundBox = imagettfbbox($this->FontSize, 0, $this->FontFileName, $Text);
    187       if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     187      if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
    188188        imagettftext($Image, $this->FontSize, 0, 2,  $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $this->FontFileName, $Text);
    189189    }
  • trunk/Modules/Admin/Admin.php

    r78 r92  
    4141  function Show()
    4242  {
    43     if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = '';
    44     switch($Operation)
     43    if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = '';
     44    switch ($Operation)
    4545    {
    4646      case 'Add':
     
    5959        $Output = $this->ShowNone();
    6060    }
    61     return($Output);
     61    return $Output;
    6262  }
    6363
     
    7070
    7171    $Result = $this->Database->select('Measure', '*', '1 ORDER BY Description');
    72     while($Measure = $Result->fetch_array())
     72    while ($Measure = $Result->fetch_array())
    7373    {
    7474      array_push($Table['Rows'], array($Measure['Description'], MakeLink('?Operation=Edit&amp;MeasureId='.$Measure['Id'], 'Editovat').' '.MakeLink('?Operation=Delete&amp;MeasureId='.$Measure['Id'], 'Odstranit').' '.MakeLink('?Operation=RebuildCache&amp;MeasureId='.$Measure['Id'], 'Přestavět cache')));
    7575    }
    7676    $Output = '<h3>Seznam měření</h3>'.Table($Table).MakeLink('?Operation=Add', 'Přidat');
    77     return($Output);
     77    return $Output;
    7878  }
    7979
     
    8383    $Values = array();
    8484    $Values = $DbResult->fetch_array();
    85     return(ShowEditTable('Measure', $Values));
     85    return ShowEditTable('Measure', $Values);
    8686  }
    8787
     
    8989  {
    9090    $Values = array();
    91     return(ShowEditTable('Measure', $Values));
     91    return ShowEditTable('Measure', $Values);
    9292  }
    9393
  • trunk/Modules/Measure/Measure.php

    r91 r92  
    8383  function TimeSegment($Level)
    8484  {
    85     return(pow($this->LevelReducing, $Level) * 60);
     85    return pow($this->LevelReducing, $Level) * 60;
    8686  }
    8787
    8888  function GetDataTable()
    8989  {
    90     return('data_'.$this->Data['Name']);
     90    return 'data_'.$this->Data['Name'];
    9191  }
    9292
    9393  function AlignTime($Time, $TimeSegment)
    9494  {
    95     return(round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment +
    96       $this->ReferenceTime);
     95    return round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment +
     96      $this->ReferenceTime;
    9797  }
    9898
     
    100100  {
    101101    $Result = $this->Database->select('Measure', '*', '`Id`='.$Id);
    102     if($Result->num_rows > 0)
     102    if ($Result->num_rows > 0)
    103103    {
    104104      $this->Data = $Result->fetch_array();
    105       if($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
     105      if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
    106106        else $this->Data['ContinuityEnabled'] = 2;    // continuous graph
    107107    } else die('Měřená veličina '.$Id.' nenalezena.');
     
    112112    $Result = $this->Database->select($this->Data['DataTable'], '*', '(`Measure`='.$this->Data['Id'].') AND '.
    113113      '(`Level`=0) ORDER BY `Time` DESC LIMIT 2');
    114     if($Result->num_rows == 0) {
     114    if ($Result->num_rows == 0) {
    115115      // No measure value found. Simply insert new first value.
    116116      $this->Database->insert($this->Data['DataTable'],
     
    118118        'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time),
    119119        'Continuity' => 0));
    120     } else if($Result->num_rows == 1) {
     120    } else if ($Result->num_rows == 1) {
    121121      // One value exists. Add second value.
    122122      $this->Database->insert($this->Data['DataTable'],
     
    128128      $LastValue = $Result->fetch_array();
    129129      $NextToLastValue = $Result->fetch_array();
    130       if(($Time - MysqlDateTimeToTime($LastValue['Time'])) < (1 - $this->PeriodTolerance) * $this->Data['Period'])
     130      if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < (1 - $this->PeriodTolerance) * $this->Data['Period'])
    131131      {
    132132        // New value added too quickly. Need to wait for next measure period.
     
    135135      {
    136136        // We are near defined period and can add new value.
    137         if(($Time - MysqlDateTimeToTime($LastValue['Time'])) < (1 + $this->PeriodTolerance) * $this->Data['Period']) {
     137        if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < (1 + $this->PeriodTolerance) * $this->Data['Period']) {
    138138          // New value added near defined measure period inside tolerance. Keep continuity.
    139139          $Continuity = 1;
     
    143143          $Continuity = 0;
    144144        }
    145         if(($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value) and
     145        if (($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value) and
    146146          ($LastValue['Continuity'] == 1) and ($Continuity == 1))
    147147        {
     
    165165  function UpdateHigherLevels($Time)
    166166  {
    167     for($Level = 1; $Level <= $this->MaxLevel; $Level++)
     167    for ($Level = 1; $Level <= $this->MaxLevel; $Level++)
    168168    {
    169169      $TimeSegment = $this->TimeSegment($Level);
    170170      $EndTime = $this->AlignTime($Time, $TimeSegment);
    171       //if($EndTime < $Time) $EndTime = $EndTime + $TimeSegment;
     171      //if ($EndTime < $Time) $EndTime = $EndTime + $TimeSegment;
    172172      $StartTime = $EndTime - $TimeSegment;
    173173
     
    178178        '(`Time` < "'.TimeToMysqlDateTime($EndTime).'") AND '.
    179179        '(`Measure`='.$this->Data['Id'].') AND (`Level`='.($Level - 1).') ORDER BY `Time`');
    180       while($Row = $Result->fetch_array())
     180      while ($Row = $Result->fetch_array())
    181181      {
    182182        $Row['Time'] = MysqlDateTimeToTime($Row['Time']);
     
    211211
    212212    // Trim outside parts
    213     foreach($this->ValueTypes as $ValueType)
     213    foreach ($this->ValueTypes as $ValueType)
    214214    {
    215215      $Values[0][$ValueType] = Interpolation(
     
    218218    }
    219219    $Values[0]['Time'] = $LeftTime;
    220     foreach($this->ValueTypes as $ValueType)
     220    foreach ($this->ValueTypes as $ValueType)
    221221    {
    222222      $Values[count($Values) - 1][$ValueType] = Interpolation(
     
    228228
    229229    // Perform computation
    230     foreach($this->ValueTypes as $ValueType)
     230    foreach ($this->ValueTypes as $ValueType)
    231231    {
    232232      // Compute new value
    233       for($I = 0; $I < (count($Values) - 1); $I++)
    234       {
    235         if($ValueType == 'Avg')
     233      for ($I = 0; $I < (count($Values) - 1); $I++)
     234      {
     235        if ($ValueType == 'Avg')
    236236        {
    237237          if ($this->Data['Cumulative'])
     
    240240          } else
    241241          {
    242             if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']);
    243             else if($this->Differential == 0)
     242            if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']);
     243            else if ($this->Differential == 0)
    244244            {
    245245              $NewValue[$ValueType] = $NewValue[$ValueType] + ($Values[$I + 1]['Time'] - $Values[$I]['Time']) *
     
    251251          }
    252252        }
    253         else if($ValueType == 'Max')
    254         {
    255           if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
     253        else if ($ValueType == 'Max')
     254        {
     255          if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
    256256          {
    257             if(0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
     257            if (0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
    258258          }
    259259          else
    260260          {
    261             if($this->Differential == 0)
     261            if ($this->Differential == 0)
    262262            {
    263               if($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];
     263              if ($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];
    264264            } else {
    265265              $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType];
    266               if($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
     266              if ($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
    267267            }
    268268          }
    269269        }
    270         else if($ValueType == 'Min')
    271         {
    272           if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
     270        else if ($ValueType == 'Min')
     271        {
     272          if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
    273273          {
    274             if(0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
     274            if (0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
    275275          } else {
    276             if($this->Differential == 0)
     276            if ($this->Differential == 0)
    277277            {
    278               if($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];
     278              if ($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];
    279279            } else {
    280280              $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType];
    281               if($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
     281              if ($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
    282282            }
    283283          }
     
    286286      $NewValue[$ValueType] = $NewValue[$ValueType];
    287287    }
    288     //if(($RightTime - $LeftTime) > 0)
    289     if($this->Data['Cumulative'] == 0)
     288    //if (($RightTime - $LeftTime) > 0)
     289    if ($this->Data['Cumulative'] == 0)
    290290    {
    291291      $NewValue['Avg'] = $NewValue['Avg'] / ($RightTime - $LeftTime);
    292292    }
    293     return($NewValue);
     293    return $NewValue;
    294294  }
    295295
     
    299299    $Result = $this->Database->select($this->Data['DataTable'], '*', '(`Measure`='.$this->Data['Id'].') AND '.
    300300      '(`Level`='.$Level.') ORDER BY `Time` LIMIT 1');
    301     if($Result->num_rows > 0)
     301    if ($Result->num_rows > 0)
    302302    {
    303303      $Row = $Result->fetch_array();
     
    307307    $Result = $this->Database->select($this->Data['DataTable'], '*', '(`Measure`='.$this->Data['Id'].') AND '.
    308308      '(`Level`='.$Level.') ORDER BY `Time` DESC LIMIT 1');
    309     if($Result->num_rows > 0)
     309    if ($Result->num_rows > 0)
    310310    {
    311311      $Row = $Result->fetch_array();
     
    313313    } else $AbsoluteRightTime = 0;
    314314
    315     return(array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime));
     315    return array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime);
    316316  }
    317317
     
    323323      '(`Time` > "'.TimeToMysqlDateTime($Time).'") AND (`Measure`='.
    324324      $this->Data['Id'].') AND (`Level`='.$Level.') ORDER BY `Time` ASC LIMIT 1');
    325     if($DbResult->num_rows > 0)
     325    if ($DbResult->num_rows > 0)
    326326    {
    327327      // Found one value, simply return it
    328328      $Row = $DbResult->fetch_array();
    329329      $Row['Time'] = MysqlDateTimeToTime($Row['Time']);
    330       return(array($Row));
     330      return array($Row);
    331331    } else
    332332    {
     
    339339        '(`Time` < "'.TimeToMysqlDateTime($Time).'") AND (`Measure`='.$this->Data['Id'].') '.
    340340        'AND (`Level`='.$Level.') ORDER BY `Time` DESC LIMIT 1');
    341       if($DbResult->num_rows > 0)
     341      if ($DbResult->num_rows > 0)
    342342      {
    343343        $Row = $DbResult->fetch_array();
     
    345345          'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));
    346346      }
    347       return($Result);
     347      return $Result;
    348348    }
    349349  }
     
    356356      '(`Time` < "'.TimeToMysqlDateTime($Time).'") AND (`Measure`='.$this->Data['Id'].') '.
    357357      'AND (`Level`='.$Level.') ORDER BY `Time` DESC LIMIT 1');
    358     if($DbResult->num_rows > 0)
     358    if ($DbResult->num_rows > 0)
    359359    {
    360360      // Found one value, simply return it
    361361      $Row = $DbResult->fetch_array();
    362362      $Row['Time'] = MysqlDateTimeToTime($Row['Time']);
    363       return(array($Row));
     363      return array($Row);
    364364    } else {
    365365      // Not found any value. Calculate it
     
    372372        '(`Time` > "'.TimeToMysqlDateTime($Time).'") AND (`Measure`='.$this->Data['Id'].') '.
    373373        'AND (`Level`='.$Level.') ORDER BY `Time` ASC LIMIT 1');
    374       if($DbResult->num_rows > 0)
     374      if ($DbResult->num_rows > 0)
    375375      {
    376376        $Row = $DbResult->fetch_array();
     
    378378          'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));
    379379      }
    380       return($Result);
     380      return $Result;
    381381    }
    382382  }
     
    386386  //$AbsoluteTime = GetTimeRange($this->DataId);
    387387
    388 //  if(($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and
     388//  if (($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and
    389389//    ($TimeTo > $AbsoluteLeftTime) and ($TimeTo < $AbsoluteRightTime))
    390390//  {
     
    397397      '(`Measure`='.$this->Data['Id'].') AND (`Level`='.$Level.') ORDER BY `Time`');
    398398    $Values = array();
    399     while($Row = $Result->fetch_array())
     399    while ($Row = $Result->fetch_array())
    400400    {
    401401      $Values[] = array('Time' => MysqlDateTimeToTime($Row['Time']),
     
    406406
    407407    $Points = array();
    408     if(count($Values) > 0)
     408    if (count($Values) > 0)
    409409    {
    410410      $Values = array_merge(
     
    415415      $StartIndex = 0;
    416416      $Points = array();
    417       for($I = 0; $I < $this->DivisionCount; $I++)
     417      for ($I = 0; $I < $this->DivisionCount; $I++)
    418418      {
    419419        $TimeStart = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * $I;
     
    421421
    422422        $EndIndex = $StartIndex;
    423         while($Values[$EndIndex]['Time'] < $TimeEnd) $EndIndex = $EndIndex + 1;
     423        while ($Values[$EndIndex]['Time'] < $TimeEnd) $EndIndex = $EndIndex + 1;
    424424        $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    425425        $Points[] = $this->ComputeOneValue($TimeStart, $TimeEnd, $SubValues, $Level);
     
    427427      }
    428428    } else $Points[] = array('Min' => 0, 'Avg' => 0, 'Max' => 0);
    429     return($Points);
     429    return $Points;
    430430  }
    431431
     
    433433  {
    434434    echo('Velicina '.$this->Data['Name']."<br>\n");
    435     if($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
     435    if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
    436436      else $this->Data['ContinuityEnabled'] = 2;    // continuous graph
    437437
     
    443443    echo("<br>\n");
    444444
    445     for($Level = 1; $Level <= $this->MaxLevel; $Level++)
     445    for ($Level = 1; $Level <= $this->MaxLevel; $Level++)
    446446    {
    447447      echo('Uroven '.$Level."<br>\n");
     
    453453      $Count = round(($EndTime - $StartTime) / $TimeSegment / $BurstCount);
    454454      echo('For 0 to '.$Count."<br>\n");
    455       for($I = 0; $I <= $Count; $I++)
     455      for ($I = 0; $I <= $Count; $I++)
    456456      {
    457457        echo($I.' ');
     
    463463          TimeToMysqlDateTime($EndTime2).'") AND (`Measure`='.$this->Data['Id'].
    464464          ') AND (`Level`='.($Level - 1).') ORDER BY `Time`');
    465         while($Row = $DbResult->fetch_array())
     465        while ($Row = $DbResult->fetch_array())
    466466        {
    467467          $Row['Time'] = MysqlDateTimeToTime($Row['Time']);
     
    469469        }
    470470
    471         if(count($Values) > 0)
     471        if (count($Values) > 0)
    472472        {
    473473          $Values = array_merge(
     
    477477
    478478          $StartIndex = 0;
    479           for($B = 0; $B < $BurstCount; $B++)
     479          for ($B = 0; $B < $BurstCount; $B++)
    480480          {
    481481            echo('.');
     
    484484
    485485            $EndIndex = $StartIndex;
    486             while($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;
     486            while ($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;
    487487            $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    488             if(count($SubValues) > 2)
     488            if (count($SubValues) > 2)
    489489            {
    490490              $Point = $this->ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Level);
     
    511511  {
    512512    $Result = $this->Database->select('Measure', 'Id');
    513     while($Row = $Result->fetch_array())
     513    while ($Row = $Result->fetch_array())
    514514    {
    515515      $Measure = new Measure();
  • trunk/Modules/Measure/Page.php

    r86 r92  
    6868    // Day selection
    6969    $Output .= '<select name="Day">';
    70     for($I = 1; $I < 32; $I++)
    71     {
    72       if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
     70    for ($I = 1; $I < 32; $I++)
     71    {
     72      if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
    7373      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    7474    }
     
    7777    // Month selection
    7878    $Output .= '<select name="Month">';
    79     foreach($this->Months as $Index => $Month)
    80     {
    81       if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
    82       if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
     79    foreach ($this->Months as $Index => $Month)
     80    {
     81      if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
     82      if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
    8383    }
    8484    $Output .= '</select>. ';
     
    8686    // Year selection
    8787    $Output .= '<select name="Year">';
    88     for($I = 2000; $I <= date("Y"); $I++)
    89     {
    90       if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
     88    for ($I = 2000; $I <= date("Y"); $I++)
     89    {
     90      if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
    9191      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    9292    }
     
    9595    // Hour selection
    9696    $Output .= '<select name="Hour">';
    97     for($I = 0; $I < 24; $I++)
    98     {
    99       if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
     97    for ($I = 0; $I < 24; $I++)
     98    {
     99      if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
    100100      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    101101    }
     
    104104    // Minute selection
    105105    $Output .= '<select name="Minute">';
    106     for($I = 0; $I < 60; $I++)
    107     {
    108       if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
     106    for ($I = 0; $I < 60; $I++)
     107    {
     108      if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
    109109      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    110110    }
     
    117117    $Output .= '</form>';
    118118
    119     return($Output);
     119    return $Output;
    120120  }
    121121 
     
    123123  {
    124124    $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` ASC LIMIT 1');
    125     if($Result2->num_rows > 0)
     125    if ($Result2->num_rows > 0)
    126126    {
    127127      $Row = $Result2->fetch_array();
     
    132132      $LastMeasureValue = 0;
    133133    }
    134     return(array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue));
     134    return array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue);
    135135  }
    136136
     
    138138  {
    139139    $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` DESC LIMIT 1');
    140     if($Result2->num_rows > 0)
     140    if ($Result2->num_rows > 0)
    141141    {
    142142      $Row = $Result2->fetch_array();
     
    147147      $LastMeasureValue = 0;
    148148    }
    149     return(array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue));
     149    return array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue);
    150150  }
    151151 
     
    164164    $Output = '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small; margin: 0px auto;">';
    165165    $Output .= '<tr><th>Měřená veličina</th><th>Poslední hodnota</th><th>Čas posledního měření</th><th>Interpolace</th><th>Poznámky</th>';
    166     if(array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>';
     166    if (array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>';
    167167    $Output .= '</tr>';
    168168    $Result = $this->Database->select('Measure', '*', '( `Enabled`=1) AND ((`PermissionView`="all") OR (`PermissionView`="'.
    169169      gethostbyaddr($_SERVER['REMOTE_ADDR']).'")) ORDER BY `Description`');
    170     while($Measure = $Result->fetch_array())
     170    while ($Measure = $Result->fetch_array())
    171171    {
    172172      $StopWatchStart = GetMicrotime();
    173       if(array_key_exists('Debug', $_GET))
     173      if (array_key_exists('Debug', $_GET))
    174174      {
    175175        $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', '`Measure`='.$Measure['Id']);
     
    179179      $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.
    180180        $Measure['Id'].') AND (`Level`=0) ORDER BY `Time` DESC LIMIT 1');
    181       if($Result2->num_rows > 0)
     181      if ($Result2->num_rows > 0)
    182182      {
    183183        $Row = $Result2->fetch_array();
     
    188188        $LastMeasureValue = '&nbsp;';
    189189      }
    190       if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';
    191       if($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
     190      if ($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';
     191      if ($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
    192192      $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    193193      $Output .= '<tr><td style="text-align: left"><a href="?Measure='.$Measure['Id'].
     
    195195        $LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.
    196196        $Interpolate.'</td><td>'.$Measure['Info'].'</td>';
    197       if(array_key_exists('Debug', $_GET))
     197      if (array_key_exists('Debug', $_GET))
    198198        $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
    199199      $Output .= '</tr>';
    200200    }
    201201    $Output .= '</table>';
    202     return($Output);
     202    return $Output;
    203203  }
    204204
     
    214214      '&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].
    215215      '">Odkaz na vybraný graf</a><br/>';
    216     return($Output);
     216    return $Output;
    217217  }
    218218
     
    221221    $Output = '';
    222222
    223     if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
    224     switch($_GET['Operation'])
     223    if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     224    switch ($_GET['Operation'])
    225225    {
    226226      case 'SetTime':
    227         if(array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and
     227        if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and
    228228        array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST))
    229229        {
    230           if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     230          if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
    231231          {
    232232            $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'],
     
    236236        break;
    237237      case 'SetTimeNow':
    238         if(array_key_exists('Time', $_GET))
     238        if (array_key_exists('Time', $_GET))
    239239        {
    240           if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     240          if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
    241241          {
    242242            $_SESSION[$_GET['Time']] = $this->Time;
     
    249249
    250250    // Show graph time range menu
    251     if($_SESSION['TimeSpecify'] == 0)
     251    if ($_SESSION['TimeSpecify'] == 0)
    252252    {
    253253      $Output .= 'Délka úseku: ';
    254       foreach($this->GraphTimeRanges as $Index => $Item)
     254      foreach ($this->GraphTimeRanges as $Index => $Item)
    255255        $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a>&nbsp;';
    256256      $Output .= '<br>';
     
    266266      '<a href="?Move=Right">&gt;</a> <a href="?Move=RightEnd">&gt;|</a> <a href="?Move=Now">Nyní</a><br>';
    267267    $Output .= '<br/>';
    268     return($Output);
     268    return $Output;
    269269
    270270  }
     
    277277    {
    278278      if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
    279       //if(array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
    280       //if(array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
     279      //if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];
     280      //if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];
    281281      //$$Index = $_SESSION[$Index];
    282282    }
     
    370370      '((`PermissionView`="all") OR (`PermissionView`="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'")) '.
    371371      'AND (`Id`='.($_SESSION['Measure'] * 1).')');
    372     if($Result->num_rows == 0)
     372    if ($Result->num_rows == 0)
    373373      $_SESSION['Measure'] = $Config['DefaultVariables']['Measure'];
    374374
     
    378378    $Output .= $this->ShowMeasureTable();
    379379    $Output .= '</div>';
    380     return($Output);
     380    return $Output;
    381381  }
    382382}
  • trunk/Packages/Common/AppModule.php

    r69 r92  
    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

    r90 r92  
    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

    r90 r92  
    6262
    6363    $Result = '';
    64     if(array_key_exists('all', $QueryItems))
     64    if (array_key_exists('all', $QueryItems))
    6565    {
    6666      $PageCount = 1;
     
    7373    }
    7474
    75     if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
    76     if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
    77     if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
    78     if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
     75    if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
     76    if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     77    if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
     78    if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
    7979    $CurrentPage = $_SESSION['Page'];
    8080
     
    8282
    8383    $Result = '';
    84     if($PageCount > 1)
     84    if ($PageCount > 1)
    8585    {
    86       if($CurrentPage > 0)
     86      if ($CurrentPage > 0)
    8787      {
    8888        $QueryItems['page'] = 0;
     
    9393      $PagesMax = $PageCount - 1;
    9494      $PagesMin = 0;
    95       if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
    96       if($PagesMin < ($CurrentPage - $Around))
     95      if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     96      if ($PagesMin < ($CurrentPage - $Around))
    9797      {
    9898        $Result.= ' ... ';
    9999        $PagesMin = $CurrentPage - $Around;
    100100      }
    101       for($i = $PagesMin; $i <= $PagesMax; $i++)
     101      for ($i = $PagesMin; $i <= $PagesMax; $i++)
    102102      {
    103         if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     103        if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
    104104        else {
    105105         $QueryItems['page'] = $i;
     
    107107        }
    108108      }
    109       if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    110       if($CurrentPage < ($PageCount - 1))
     109      if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     110      if ($CurrentPage < ($PageCount - 1))
    111111      {
    112112        $QueryItems['page'] = ($CurrentPage + 1);
     
    117117    }
    118118    $QueryItems['all'] = '1';
    119     if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
     119    if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
    120120
    121121    $Result = '<div style="text-align: center">'.$Result.'</div>';
    122122    $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
    123123    $this->Page = $CurrentPage;
    124     return($Result);
     124    return $Result;
    125125  }
    126126}
  • trunk/Packages/Common/Config.php

    r69 r92  
    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

    r90 r92  
    77{
    88  list($usec, $sec) = explode(" ", microtime());
    9   return ((float)$usec + (float)$sec);
     9  return (float)$usec + (float)$sec;
    1010}
    1111
     
    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      $Duration = ' ; '.round(microtime_float() - $QueryStartTime, 4). ' s';
    99     if($this->LogSQLQuery == true)
     99    if ($this->LogSQLQuery == true)
    100100      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
    101     if($this->ShowSQLQuery == true)
     101    if ($this->ShowSQLQuery == true)
    102102      echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '.
    103103      'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n");
    104104    $Result = new DatabaseResult();
    105105    $Result->PDOStatement = $this->PDO->query($Query);
    106     if($Result->PDOStatement)
     106    if ($Result->PDOStatement)
    107107    {
    108108      $Result->num_rows = $Result->PDOStatement->rowCount();
     
    112112      $this->Error = $this->PDO->errorInfo();
    113113      $this->Error = $this->Error[2];
    114       if(($this->Error != '') and ($this->ShowSQLError == true))
     114      if (($this->Error != '') and ($this->ShowSQLError == true))
    115115        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
    116116        throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query);
    117117    }
    118     return($Result);
     118    return $Result;
    119119  }
    120120
    121121  function select($Table, $What = '*', $Condition = 1)
    122122  {
    123     return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));
     123    return $this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
    124124  }
    125125
     
    139139    $Name = '';
    140140    $Values = '';
    141     foreach($Data as $Key => $Value)
     141    foreach ($Data as $Key => $Value)
    142142    {
    143143      $Name .= ',`'.$Key.'`';
    144       if(!in_array($Value, $this->Functions))
    145       {
    146         if(is_null($Value)) $Value = 'NULL';
     144      if (!in_array($Value, $this->Functions))
     145      {
     146        if (is_null($Value)) $Value = 'NULL';
    147147        else $Value = $this->PDO->quote($Value);
    148148      }
     
    151151    $Name = substr($Name, 1);
    152152    $Values = substr($Values, 1);
    153     return('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
     153    return 'INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')';
    154154  }
    155155
     
    162162  {
    163163    $Values = '';
    164     foreach($Data as $Key => $Value)
    165     {
    166       if(!in_array($Value, $this->Functions))
    167       {
    168         if(is_null($Value)) $Value = 'NULL';
     164    foreach ($Data as $Key => $Value)
     165    {
     166      if (!in_array($Value, $this->Functions))
     167      {
     168        if (is_null($Value)) $Value = 'NULL';
    169169        else $Value = $this->PDO->quote($Value);
    170170      }
     
    172172    }
    173173    $Values = substr($Values, 2);
    174     return('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
     174    return 'UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')';
    175175  }
    176176
     
    179179    $Name = '';
    180180    $Values = '';
    181     foreach($Data as $Key => $Value)
    182     {
    183       if(!in_array($Value, $this->Functions))
    184       {
    185         if(is_null($Value)) $Value = 'NULL';
     181    foreach ($Data as $Key => $Value)
     182    {
     183      if (!in_array($Value, $this->Functions))
     184      {
     185        if (is_null($Value)) $Value = 'NULL';
    186186        else $Value = $this->PDO->quote($Value);
    187187      }
     
    203203  function real_escape_string($Text)
    204204  {
    205     return(addslashes($Text));
     205    return addslashes($Text);
    206206  }
    207207
    208208  function quote($Text)
    209209  {
    210     return($this->PDO->quote($Text));
     210    return $this->PDO->quote($Text);
    211211  }
    212212
     
    234234function TimeToMysqlDateTime($Time)
    235235{
    236   if($Time == NULL) return(NULL);
    237     else return(date('Y-m-d H:i:s', $Time));
     236  if ($Time == NULL) return NULL;
     237    else return date('Y-m-d H:i:s', $Time);
    238238}
    239239
    240240function TimeToMysqlDate($Time)
    241241{
    242   if($Time == NULL) return(NULL);
    243     else return(date('Y-m-d', $Time));
     242  if ($Time == NULL) return NULL;
     243    else return date('Y-m-d', $Time);
    244244}
    245245
    246246function TimeToMysqlTime($Time)
    247247{
    248   if($Time == NULL) return(NULL);
    249     else return(date('H:i:s', $Time));
     248  if ($Time == NULL) return NULL;
     249    else return date('H:i:s', $Time);
    250250}
    251251
    252252function MysqlDateTimeToTime($DateTime)
    253253{
    254   if($DateTime == '') return(NULL);
     254  if ($DateTime == '') return NULL;
    255255  $Parts = explode(' ', $DateTime);
    256256  $DateParts = explode('-', $Parts[0]);
    257257  $TimeParts = explode(':', $Parts[1]);
    258258  $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
    259   return($Result);
     259  return $Result;
    260260}
    261261
    262262function MysqlDateToTime($Date)
    263263{
    264   if($Date == '') return(NULL);
    265   return(MysqlDateTimeToTime($Date.' 0:0:0'));
     264  if ($Date == '') return NULL;
     265  return MysqlDateTimeToTime($Date.' 0:0:0');
    266266}
    267267
    268268function MysqlTimeToTime($Time)
    269269{
    270   if($Time == '') return(NULL);
    271   return(MysqlDateTimeToTime('0000-00-00 '.$Time));
    272 }
     270  if ($Time == '') return NULL;
     271  return MysqlDateTimeToTime('0000-00-00 '.$Time);
     272}
  • trunk/Packages/Common/Error.php

    r77 r92  
    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>';
     
    9393    $Date = date('Y-m-d H:i:s');
    9494    $Error = '# '.$Date."\n";
    95     foreach($Backtrace as $Item)
     95    foreach ($Backtrace as $Item)
    9696    {
    97       if(!array_key_exists('line', $Item)) $Item['line'] = '';
    98       if(!array_key_exists('file', $Item)) $Item['file'] = '';
     97      if (!array_key_exists('line', $Item)) $Item['line'] = '';
     98      if (!array_key_exists('file', $Item)) $Item['file'] = '';
    9999
    100100      $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
    101101      $Arguments = '';
    102       if(array_key_exists('args', $Item) and is_array($Item['args']))
    103         foreach($Item['args'] as $Item)
     102      if (array_key_exists('args', $Item) and is_array($Item['args']))
     103        foreach ($Item['args'] as $Item)
    104104        {
    105           if(is_object($Item)) ;
    106           else if(is_array($Item)) $Arguments .= "'".serialize($Item)."',";
     105          if (is_object($Item)) ;
     106          else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',";
    107107          else $Arguments .= "'".$Item."',";
    108108        }
    109         if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
     109        if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
    110110        $Error .= "\n";
    111111    }
    112112    $Error .= "\n";
    113113
    114     foreach($this->OnError as $OnError)
     114    foreach ($this->OnError as $OnError)
    115115      call_user_func($OnError, $Error);
    116116  }
  • trunk/Packages/Common/Image.php

    r69 r92  
    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    {
    9191      $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

    r69 r92  
    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

    r69 r92  
    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

    r77 r92  
    1414  function GetNetMask()
    1515  {
    16     return(0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1));
     16    return 0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1);
    1717  }
    1818
    1919  function AddressToString()
    2020  {
    21     return(implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));
     21    return implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255)));
    2222  }
    2323
     
    3737    $To->Address = $From->Address + $HostMask;
    3838    $To->Prefix = 32;
    39     return(array('From' => $From, 'To' => $To));
     39    return array('From' => $From, 'To' => $To);
    4040  }
    4141
     
    4343  {
    4444    $this->Prefix = $NewPrefix;
    45     if($this->Prefix > 32) $this->Prefix = 32;
    46     if($this->Prefix < 0) $this->Prefix = 0;
     45    if ($this->Prefix > 32) $this->Prefix = 32;
     46    if ($this->Prefix < 0) $this->Prefix = 0;
    4747    $this->Address = $this->Address & $this->GetNetMask();
    4848  }
     
    5151  {
    5252    $UpperNetmask = $this->GetNetMask();
    53     if(($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
     53    if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
    5454      else $Result = false;
    5555    //echo($Address->AddressToString().'/'.$Address->Prefix.' in '.$this->AddressToString().'/'.$this->Prefix.' '.$Result."\n");
    56     return($Result);
     56    return $Result;
    5757  }
    5858}
     
    7171  function AddressToString()
    7272  {
    73     return(inet_ntop($this->Address));
     73    return inet_ntop($this->Address);
    7474  }
    7575
     
    8383    $Result = array();
    8484    $Data = array_reverse(unpack('C*', $this->Address));
    85     foreach($Data as $Item)
     85    foreach ($Data as $Item)
    8686    {
    8787
     
    8989      $Result[] = dechex(($Item >> 4) & 15);
    9090    }
    91     return($Result);
     91    return $Result;
    9292  }
    9393
  • trunk/Packages/Common/Page.php

    r69 r92  
    1717  function Show()
    1818  {
    19     return('');
     19    return '';
    2020  }
    2121
     
    2323  {
    2424    $Output = $this->Show();
    25     return($Output);
     25    return $Output;
    2626  }
    2727
    2828  function SystemMessage($Title, $Text)
    2929  {
    30     return(call_user_func_array($this->OnSystemMessage, array($Title, $Text)));
     30    return call_user_func_array($this->OnSystemMessage, array($Title, $Text));
    3131  }
    3232}
  • trunk/Packages/Common/PrefixMultiplier.php

    r52 r92  
    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/RSS.php

    r77 r92  
    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

    r70 r92  
    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
    405       $this->UpdateManager->IsUpToDate());
     404    $this->Database->Connected() and $this->UpdateManager->IsInstalled() and
     405      $this->UpdateManager->IsUpToDate();
    406406  }
    407407
     
    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

    r90 r92  
    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

    r69 r92  
    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

    r90 r92  
    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

    r55 r92  
    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/Point.php

    r63 r92  
    1616{
    1717  $Point = new Point($X, $Y);
    18   return($Point);
     18  return $Point;
    1919}
    2020
     
    2323{
    2424  $Y = ($P2->Y - $P1->Y) / ($P2->X - $P1->X) * ($X - $P1->X) + $P1->Y;
    25   return($Y);
     25  return $Y;
    2626}
  • trunk/add.php

    r87 r92  
    1212// Try to load single value
    1313$Time = time();
    14 if(array_key_exists('MeasureId', $_GET) and array_key_exists('Value', $_GET))
     14if (array_key_exists('MeasureId', $_GET) and array_key_exists('Value', $_GET))
    1515{
    1616  if (array_key_exists('Time', $_GET)) $Time = $_GET['Time'] * 1;
     
    3939  $Measure->Load($MeasureId);
    4040  $HostName = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    41   if(($HostName == $Measure->Data['PermissionAdd']) or ($_SERVER['REMOTE_ADDR'] == gethostbyname($Measure->Data['PermissionAdd'])))
     41  if (($HostName == $Measure->Data['PermissionAdd']) or ($_SERVER['REMOTE_ADDR'] == gethostbyname($Measure->Data['PermissionAdd'])))
    4242  {
    4343    $Measure->AddValue($Value, $Time);
Note: See TracChangeset for help on using the changeset viewer.