Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/Global.php

    r879 r880  
    22
    33include_once(dirname(__FILE__).'/../Packages/Common/Common.php');
    4 if(file_exists(dirname(__FILE__).'/../Config/Config.php'))
     4if (file_exists(dirname(__FILE__).'/../Config/Config.php'))
    55  include_once(dirname(__FILE__).'/../Config/Config.php');
    66include_once(dirname(__FILE__).'/../Application/Core.php');
     
    1313
    1414// Back compatibility, will be removed
    15 if(isset($InitSystem) and $InitSystem)
     15if (isset($InitSystem) and $InitSystem)
    1616{
    1717  $System = new Core();
     
    2525  {
    2626    global $TempPageContent;
    27     return($TempPageContent);
     27    return $TempPageContent;
    2828  }
    2929}
     
    5454{
    5555  list($Usec, $Sec) = explode(' ', microtime());
    56   return ((float)$Usec + (float)$Sec);
     56  return (float)$Usec + (float)$Sec;
    5757}
    5858
     
    6464
    6565  $UnitIndex = 0;
    66   while($Value > 1024)
     66  while ($Value > 1024)
    6767  {
    6868    $Value = round($Value / 1024, 3);
    6969    $UnitIndex++;
    7070  }
    71   return($Value.' '.$UnitNames[$UnitIndex]);
     71  return $Value.' '.$UnitNames[$UnitIndex];
    7272}
    7373
     
    7676  $Result = array();
    7777  $Parts = explode('&', $QueryString);
    78   foreach($Parts as $Part)
    79   {
    80     if($Part != '')
    81     {
    82       if(!strpos($Part, '=')) $Part .= '=';
     78  foreach ($Parts as $Part)
     79  {
     80    if ($Part != '')
     81    {
     82      if (!strpos($Part, '=')) $Part .= '=';
    8383      $Item = explode('=', $Part);
    8484      $Result[$Item[0]] = $Item[1];
    8585    }
    8686  }
    87   return($Result);
     87  return $Result;
    8888}
    8989
     
    9191{
    9292  $Parts = array();
    93   foreach($QueryStringArray as $Index => $Item)
     93  foreach ($QueryStringArray as $Index => $Item)
    9494  {
    9595    $Parts[] = $Index.'='.$Item;
    9696  }
    97   return(implode('&', $Parts));
     97  return implode('&', $Parts);
    9898}
    9999
     
    107107  //$return = Str_Replace(Array("(",")",".","!",",","\"","'"), "", $return); //odstraní ().!,"'
    108108  //$return = StrToLower($return); // velká písmena nahradí malými.
    109   return($return);
     109  return $return;
    110110}
    111111
     
    116116  $Days = floor($Days - $month * 30);
    117117  $month = $month - $year * 12;
    118   return($year.'r '.$month.'m '.$Days.'d');
     118  return $year.'r '.$month.'m '.$Days.'d';
    119119}
    120120
     
    137137
    138138  error_reporting(E_ALL ^ E_WARNING);
    139   if (($handle = @fopen($url, "r")) === FALSE) return(false);
     139  if (($handle = @fopen($url, "r")) === FALSE) return false;
    140140
    141141  $data = stream_get_contents($handle);
     
    164164  $data = strip_tags($data);
    165165
    166   return($data);
     166  return $data;
    167167}
    168168
     
    178178  $PageCount = floor($TotalCount / $ItemPerPage) + 1;
    179179
    180   if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
    181   if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
    182   if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
    183   if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
     180  if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
     181  if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     182  if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
     183  if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
    184184  $CurrentPage = $_SESSION['Page'];
    185185
     
    188188
    189189  $Result = '';
    190   if($PageCount > 1)
    191   {
    192     if($CurrentPage > 0)
     190  if ($PageCount > 1)
     191  {
     192    if ($CurrentPage > 0)
    193193    {
    194194      $QueryItems['page'] = 0;
     
    199199    $PagesMax = $PageCount - 1;
    200200    $PagesMin = 0;
    201     if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
    202     if($PagesMin < ($CurrentPage - $Around))
     201    if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     202    if ($PagesMin < ($CurrentPage - $Around))
    203203    {
    204204      $Result.= ' ... ';
    205205      $PagesMin = $CurrentPage - $Around;
    206206    }
    207     for($i = $PagesMin; $i <= $PagesMax; $i++)
    208     {
    209       if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     207    for ($i = $PagesMin; $i <= $PagesMax; $i++)
     208    {
     209      if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
    210210      else {
    211211       $QueryItems['page'] = $i;
     
    213213      }
    214214    }
    215     if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    216     if($CurrentPage < ($PageCount - 1))
     215    if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     216    if ($CurrentPage < ($PageCount - 1))
    217217    {
    218218      $QueryItems['page'] = ($CurrentPage + 1);
     
    223223  }
    224224  $Result = '<div style="text-align: center">'.$Result.'</div>';
    225   return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
     225  return array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
    226226    'Page' => $CurrentPage,
    227227    'Output' => $Result,
    228   ));
     228  );
    229229}
    230230
     
    236236  global $OrderDirSQL, $OrderArrowImage, $Config, $System;
    237237
    238   if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
    239   if(array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))
     238  if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
     239  if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))
    240240    $_SESSION['OrderDir'] = $_GET['OrderDir'];
    241   if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;
    242   if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;
     241  if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;
     242  if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;
    243243
    244244  // Check OrderCol
    245245  $Found = false;
    246   foreach($Columns as $Column)
    247   {
    248     if($Column['Name'] == $_SESSION['OrderCol'])
     246  foreach ($Columns as $Column)
     247  {
     248    if ($Column['Name'] == $_SESSION['OrderCol'])
    249249    {
    250250      $Found = true;
     
    252252    }
    253253  }
    254   if($Found == false)
     254  if ($Found == false)
    255255  {
    256256    $_SESSION['OrderCol'] = $DefaultColumn;
     
    258258  }
    259259  // Check OrderDir
    260   if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;
     260  if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;
    261261
    262262  $Result = '';
    263263  $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    264   foreach($Columns as $Index => $Column)
     264  foreach ($Columns as $Index => $Column)
    265265  {
    266266    $QueryItems['OrderCol'] = $Column['Name'];
    267267    $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir'];
    268     if($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.
     268    if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.
    269269      $System->Link('/images/'.$OrderArrowImage[$_SESSION['OrderDir']]).'" alt="order arrow"/>';
    270270      else $ArrowImage = '';
    271     if($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';
     271    if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';
    272272      else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>';
    273273  }
    274   return(array(
     274  return array(
    275275    'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']],
    276276    'Output' => '<tr>'.$Result.'</tr>',
    277277    'Column' => $_SESSION['OrderCol'],
    278278    'Direction' => $_SESSION['OrderDir'],
    279   ));
     279  );
    280280}
    281281
     
    287287  $DbResult = $System->Database->select('ClientVersion', '`Id`, `Version`', '`Imported` = 1');
    288288  $Output .= '<option value=""';
    289   if($Selected == '')
     289  if ($Selected == '')
    290290    $Output .= ' selected="selected"';
    291291  $Output .= '>'.T('None').'</option>';
    292   while($ClientVersion = $DbResult->fetch_assoc())
     292  while ($ClientVersion = $DbResult->fetch_assoc())
    293293  {
    294294    $Output .= '<option value="'.$ClientVersion['Id'].'"';
    295     if($Selected == $ClientVersion['Id'])
     295    if ($Selected == $ClientVersion['Id'])
    296296      $Output .= ' selected="selected"';
    297297    $Output .= '>'.$ClientVersion['Version'].'</option>';
    298298  }
    299299  $Output .= '</select>';
    300   return($Output);
     300  return $Output;
    301301}
    302302
     
    307307  $Result = array();
    308308  $DbResult = $System->Database->query('SELECT * FROM `Language` WHERE `Enabled` = 1');
    309   while($DbRow = $DbResult->fetch_assoc())
     309  while ($DbRow = $DbResult->fetch_assoc())
    310310    $Result[$DbRow['Id']] = $DbRow;
    311   return($Result);
     311  return $Result;
    312312}
    313313
     
    316316function HumanDate($SQLDateTime)
    317317{
    318   if($SQLDateTime == '') return('&nbsp;');
     318  if ($SQLDateTime == '') return '&nbsp;';
    319319  $DateTimeParts = explode(' ', $SQLDateTime);
    320   if($DateTimeParts[0] != '0000-00-00')
     320  if ($DateTimeParts[0] != '0000-00-00')
    321321  {
    322322    $DateParts = explode('-', $DateTimeParts[0]);
    323     return(($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1));
    324   } else return('&nbsp;');
     323    return ($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1);
     324  } else return '&nbsp;';
    325325}
    326326
    327327function HumanDateTime($SQLDateTime)
    328328{
    329   if($SQLDateTime == '') return('&nbsp;');
     329  if ($SQLDateTime == '') return '&nbsp;';
    330330  $DateTimeParts = explode(' ', $SQLDateTime);
    331   if($DateTimeParts[0] != '0000-00-00' and $SQLDateTime <> '')
     331  if ($DateTimeParts[0] != '0000-00-00' and $SQLDateTime <> '')
    332332  {
    333333    $DateParts = explode('-', $DateTimeParts[0]);
    334334    $Output = ($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1);
    335335  } else $Output = '&nbsp;';
    336   if(count($DateTimeParts) > 1)
    337   if($DateTimeParts[1] != '00:00:00')
     336  if (count($DateTimeParts) > 1)
     337  if ($DateTimeParts[1] != '00:00:00')
    338338  {
    339339    $TimeParts = explode(':', $DateTimeParts[1]);
    340340    $Output .= ' '.($TimeParts[0] * 1).':'.($TimeParts[1] * 1).':'.($TimeParts[2] * 1);
    341341  };
    342   return($Output);
     342  return $Output;
    343343}
    344344
     
    347347  global $System, $Config;
    348348
    349   if($Prev)
     349  if ($Prev)
    350350    $sql = 'SELECT `ID` FROM `'.$Table.'` AS `item` WHERE '.
    351351      '(`Language` = '.$Config['OriginalLanguage'].') AND NOT EXISTS(SELECT `entry` '.
     
    359359  $DbResult = $System->Database->query($sql);
    360360  $Next = $DbResult->fetch_assoc();
    361   if($Next)
    362   {
    363     if($Prev) $Output = '<a href="form.php?group='.$GroupId.'&amp;ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> ';
     361  if ($Next)
     362  {
     363    if ($Prev) $Output = '<a href="form.php?group='.$GroupId.'&amp;ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> ';
    364364    else $Output = '<a href="form.php?group='.$GroupId.'&amp;ID='.$Next['ID'].'">Následující '.$Next['ID'].'</a> ';
    365       return('form.php?group='.$GroupId.'&amp;ID='.$Next['ID']);
     365      return 'form.php?group='.$GroupId.'&amp;ID='.$Next['ID'];
    366366  }
    367367}
     
    371371  global $System, $BuildNumbers;
    372372
    373   if(isset($BuildNumbers[$Version]) == false)
     373  if (isset($BuildNumbers[$Version]) == false)
    374374  {
    375375    $sql = 'SELECT `BuildNumber` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"';
     
    378378    $BuildNumbers[$Version] = $DbRow['BuildNumber'];
    379379  }
    380   return($BuildNumbers[$Version]);
     380  return $BuildNumbers[$Version];
    381381}
    382382
     
    386386  global $System, $VersionsWOW;
    387387
    388   if(isset($VersionsWOW[$BuildNumber]) == false)
     388  if (isset($VersionsWOW[$BuildNumber]) == false)
    389389  {
    390390    $sql = 'SELECT `Version` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"';
     
    393393    $VersionsWOW[$BuildNumber] = $Version['Version'];
    394394  }
    395   return($VersionsWOW[$BuildNumber]);
     395  return $VersionsWOW[$BuildNumber];
    396396}
    397397
     
    401401  global $System, $VersionsWOWId;
    402402
    403   if(isset($VersionsWOWId[$BuildNumber]) == false)
     403  if (isset($VersionsWOWId[$BuildNumber]) == false)
    404404  {
    405405    $sql = 'SELECT `Id` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"';
     
    408408    $VersionsWOWId[$BuildNumber] = $Version['Id'];
    409409  }
    410   return($VersionsWOWId[$BuildNumber]);
     410  return $VersionsWOWId[$BuildNumber];
    411411}
    412412
     
    416416  $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree();
    417417
    418   if(array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1;
     418  if (array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1;
    419419    else $GroupId = 1;
    420420
    421   if(isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.');
    422   return($GroupId);
     421  if (isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.');
     422  return $GroupId;
    423423}
    424424
    425425function LoadCommandLineParameters()
    426426{
    427   if(!array_key_exists('REMOTE_ADDR', $_SERVER))
    428   {
    429     foreach($_SERVER['argv'] as $Parameter)
    430     {
    431       if(strpos($Parameter, '=') !== false)
     427  if (!array_key_exists('REMOTE_ADDR', $_SERVER))
     428  {
     429    foreach ($_SERVER['argv'] as $Parameter)
     430    {
     431      if (strpos($Parameter, '=') !== false)
    432432      {
    433433        $Index = substr($Parameter, 0, strpos($Parameter, '='));
     
    444444  $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    445445
    446   if(array_key_exists('Tab', $_GET)) $_SESSION['Tab'] = $_GET['Tab'];
    447   if(!array_key_exists('Tab', $_SESSION)) $_SESSION['Tab'] = 0;
    448   if(($_SESSION['Tab'] < 0) or ($_SESSION['Tab'] > (count($Tabs) - 1))) $_SESSION['Tab'] = 0;
     446  if (array_key_exists('Tab', $_GET)) $_SESSION['Tab'] = $_GET['Tab'];
     447  if (!array_key_exists('Tab', $_SESSION)) $_SESSION['Tab'] = 0;
     448  if (($_SESSION['Tab'] < 0) or ($_SESSION['Tab'] > (count($Tabs) - 1))) $_SESSION['Tab'] = 0;
    449449  $Output = '<div id="header">'.
    450450    '<ul>';
    451   foreach($Tabs as $Index => $Tab)
     451  foreach ($Tabs as $Index => $Tab)
    452452  {
    453453    $QueryItems['Tab'] = $Index;
    454     if($Index == $_SESSION['Tab']) $Selected = ' id="selected"';
     454    if ($Index == $_SESSION['Tab']) $Selected = ' id="selected"';
    455455      else $Selected = '';
    456456    $Output .= '<li'.$Selected.'><a href="?'.SetQueryStringArray($QueryItems).'">'.$Tab.'</a></li>';
    457457  }
    458458  $Output .= '</ul></div>';
    459   return($Output);
     459  return $Output;
    460460}
    461461
    462462function CheckBox($Name, $Checked = false, $Id = '', $Class = '', $Disabled = false)
    463463{
    464   if($Id) $Id = ' id="'.$Id.'"'; else $Id = '';
    465   if($Class) $Class = ' class="'.$Class.'"'; else $Class = '';
    466   if($Checked) $Checked = ' checked="checked"'; else $Checked = '';
    467   if($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = '';
    468   return('<input type="checkbox" value="checked" name="'.$Name.'"'.$Checked.$Disabled.$Id.$Class.' />');
     464  if ($Id) $Id = ' id="'.$Id.'"'; else $Id = '';
     465  if ($Class) $Class = ' class="'.$Class.'"'; else $Class = '';
     466  if ($Checked) $Checked = ' checked="checked"'; else $Checked = '';
     467  if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = '';
     468  return '<input type="checkbox" value="checked" name="'.$Name.'"'.$Checked.$Disabled.$Id.$Class.' />';
    469469}
    470470
    471471function RadioButton($Name, $Value, $Checked = false, $OnClick = '', $Disabled = false)
    472472{
    473   if($Checked) $Checked = ' checked="checked"'; else $Checked = '';
    474   if($OnClick != '') $OnClick = ' onclick="'.$OnClick.'"'; else $OnClick = '';
    475   if($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = '';
    476   return('<input type="radio" name="'.$Name.'" value="'.$Value.'"'.$Checked.$Disabled.$OnClick.'/>');
     473  if ($Checked) $Checked = ' checked="checked"'; else $Checked = '';
     474  if ($OnClick != '') $OnClick = ' onclick="'.$OnClick.'"'; else $OnClick = '';
     475  if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = '';
     476  return '<input type="radio" name="'.$Name.'" value="'.$Value.'"'.$Checked.$Disabled.$OnClick.'/>';
    477477}
    478478
    479479function SelectOption($Name, $Text, $Selected = false)
    480480{
    481   if($Selected) $Selected = ' selected="selected"'; else $Selected = '';
    482   return('<option value="'.$Name.'"'.$Selected.'>'.$Text.'</option>');
     481  if ($Selected) $Selected = ' selected="selected"'; else $Selected = '';
     482  return '<option value="'.$Name.'"'.$Selected.'>'.$Text.'</option>';
    483483}
    484484
    485485function DeleteDirectory($dirname)
    486486{
    487   if(is_dir($dirname))
     487  if (is_dir($dirname))
    488488  {
    489489    $dir_handle = opendir($dirname);
    490     if(!$dir_handle) return(false);
    491     while($file = readdir($dir_handle))
    492     {
    493       if(($file != '.') and ($file != '..'))
     490    if (!$dir_handle) return false;
     491    while ($file = readdir($dir_handle))
     492    {
     493      if (($file != '.') and ($file != '..'))
    494494      {
    495         if(!is_dir($dirname.'/'.$file)) unlink($dirname.'/'.$file);
     495        if (!is_dir($dirname.'/'.$file)) unlink($dirname.'/'.$file);
    496496          else DeleteDirectory($dirname.'/'.$file);
    497497      }
     
    500500    rmdir($dirname);
    501501  }
    502   return(true);
     502  return true;
    503503}
    504504
     
    515515  $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree();
    516516
    517   foreach($TranslationTree as $TableID => $Value)
    518   {
    519     if($Value['TablePrefix'] == $Table) return $TableID;
     517  foreach ($TranslationTree as $TableID => $Value)
     518  {
     519    if ($Value['TablePrefix'] == $Table) return $TableID;
    520520  }
    521521}
     
    540540    'Dictionary' => 'Text',
    541541  );
    542   return($TablesColumn);
     542  return $TablesColumn;
    543543}
    544544
     
    578578  $sqlall = '';
    579579
    580   foreach($TablesColumn as $Table => $Column)
     580  foreach ($TablesColumn as $Table => $Column)
    581581  {
    582582    $orderinby = ' ORDER BY ID DESC ';
     
    588588
    589589    $where = '(`Language` = '.$Config['OriginalLanguage'].') ';
    590     if ($mode == 1) 
     590    if ($mode == 1)
    591591    {
    592592      $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table.
     
    594594      ') AND (`Sub`.`Entry` = `O`.`Entry`))';
    595595    }
    596     if ($mode == 2) 
     596    if ($mode == 2)
    597597    {
    598598      $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.
     
    601601    }
    602602    $where .= ' AND (';
    603     if (array_search('the', $ArrStr)) 
     603    if (array_search('the', $ArrStr))
    604604    {
    605605      $where .= '(`O`.`'.$Column.'` LIKE "The %") OR ';
     
    607607
    608608    $SqlOK = false;
    609     if (count($ArrStr) > 0) 
     609    if (count($ArrStr) > 0)
    610610    {
    611611      for ($i = 0; $i < count($ArrStr); $i++)
     
    614614        if ((strlen($ArrStr[$i]) > 3) or ( ((count($ArrStr) < 6) or ($i == 0)) and (strlen($ArrStr[$i]) > 0) ) )  //length
    615615          if ((!$FirstBig) or (ctype_upper(substr($ArrStr[$i], 0, 1))) or (count($ArrStr) < 6) )  //first big
    616             if (array_search($ArrStr[$i], $ArrStr) == $i) 
     616            if (array_search($ArrStr[$i], $ArrStr) == $i)
    617617            {  // first in array
    618618              $where .= '(`O`.`'.$Column.'` LIKE "'.addslashes($ArrStr[$i]).'%") OR ';
     
    623623      $where .= ')';
    624624    }
    625     if ($SqlOK) 
     625    if ($SqlOK)
    626626    {
    627627        //$sql.$where.$groupby.$orderby
    628628//          $buff[] = array($Line['ID'], GetIDbyName($Table), $Line['Orig'], $Line['Tran']);
    629       if ($sqlall <> '') 
    630       { 
    631         $sqlall .= ' UNION ALL ( '.$sql.$where.$groupby.' )';     
     629      if ($sqlall <> '')
     630      {
     631        $sqlall .= ' UNION ALL ( '.$sql.$where.$groupby.' )';
    632632      } else {
    633         $sqlall .= ' ( '.$sql.$where.$groupby.' )';             
     633        $sqlall .= ' ( '.$sql.$where.$groupby.' )';
    634634      }
    635635    }
    636636  }
    637   if ($SqlOK) 
     637  if ($SqlOK)
    638638  {
    639639    $orderby = ' ORDER BY LENGTH(Orig) DESC ';
     
    641641    $DbResult = $System->Database->query($sqlall.$orderby);
    642642    //  echo ($sql.'|'.$where.'|'.$groupby);
    643     while($Line = $DbResult->fetch_assoc())
     643    while ($Line = $DbResult->fetch_assoc())
    644644    {
    645645      $buff[] = array($Line['ID'], $Line['GroupId'], $Line['Orig'], $Line['Tran']);
     
    652652{
    653653  $Pixels = $Width * ($Percent / 100);
    654   if($Pixels > $Width) $Pixels = $Width;
    655   if($Text == '') $Text = $Percent;
    656 
    657   return('<div class="progressbar" style="width: '.$Width.'px">'.
     654  if ($Pixels > $Width) $Pixels = $Width;
     655  if ($Text == '') $Text = $Percent;
     656
     657  return '<div class="progressbar" style="width: '.$Width.'px">'.
    658658    '<div class="bar" style="width: '.$Pixels.'px;"></div>'.
    659659    '<div class="text" style="width: '.$Width.'px">'.$Text.'</div>'.
    660     '</div>');
     660    '</div>';
    661661}
    662662
     
    665665  $IndexLevel = 100;
    666666
    667   if($XP > 0) $Level = floor(sqrt($XP / $IndexLevel));
     667  if ($XP > 0) $Level = floor(sqrt($XP / $IndexLevel));
    668668    else $Level = 0;
    669669  $MinXP = $Level * $Level * $IndexLevel;
     
    671671  $MaxXP = $MaxXP - $MinXP;
    672672  $XP = $XP - $MinXP;
    673   return(array('Level' => $Level, 'XP' => $XP, 'MaxXP' => $MaxXP));
     673  return array('Level' => $Level, 'XP' => $XP, 'MaxXP' => $MaxXP);
    674674}
    675675
     
    677677{
    678678  $Result = $Default;
    679   if(array_key_exists($Name, $_GET)) $Result = $_GET[$Name];
    680   else if(array_key_exists($Name, $_POST)) $Result = $_POST[$Name];
    681   else if($Session and array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name];
    682   if($Numeric and !is_numeric($Result)) $Result = $Default;
    683   if($Session) $_SESSION[$Name] = $Result;
    684   return($Result);
     679  if (array_key_exists($Name, $_GET)) $Result = $_GET[$Name];
     680  else if (array_key_exists($Name, $_POST)) $Result = $_POST[$Name];
     681  else if ($Session and array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name];
     682  if ($Numeric and !is_numeric($Result)) $Result = $Default;
     683  if ($Session) $_SESSION[$Name] = $Result;
     684  return $Result;
    685685}
    686686
     
    693693  $Result = '';
    694694  $I = 0;
    695   while((strpos($Content, 'http://') !== false) or (strpos($Content, 'https://') !== false))
    696   {
    697     if(strpos($Content, 'http://') !== false) $I = strpos($Content, 'http://');
    698     if(strpos($Content, 'https://') !== false) $I = strpos($Content, 'https://');
     695  while ((strpos($Content, 'http://') !== false) or (strpos($Content, 'https://') !== false))
     696  {
     697    if (strpos($Content, 'http://') !== false) $I = strpos($Content, 'http://');
     698    if (strpos($Content, 'https://') !== false) $I = strpos($Content, 'https://');
    699699    $Result .= substr($Content, 0, $I);
    700700    $Content = substr($Content, $I);
    701701    $SpacePos = strpos($Content, ' ');
    702     if($SpacePos !== false) $URL = substr($Content, 0, strpos($Content, ' '));
     702    if ($SpacePos !== false) $URL = substr($Content, 0, strpos($Content, ' '));
    703703      else $URL = substr($Content, 0);
    704704
     
    707707  }
    708708  $Result .= $Content;
    709   return($Result);
     709  return $Result;
    710710}
    711711
     
    729729  );
    730730
    731   return('<div class="message" style="background-color: '.$BackgroundColor[$Type].
     731  return '<div class="message" style="background-color: '.$BackgroundColor[$Type].
    732732    ';"><table><tr><td class="icon"><img src="'.
    733733    $System->Link('/images/message/'.$IconName[$Type].'.png').'" alt="'.
    734     $IconName[$Type].'"><td>'.$Text.'</td></tr></table></div>');
     734    $IconName[$Type].'"><td>'.$Text.'</td></tr></table></div>';
    735735}
    736736
    737737function ProcessURL()
    738738{
    739   if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     739  if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
    740740    $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
    741741  else $PathString = '';
    742   if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
     742  if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
    743743  $PathItems = explode('/', $PathString);
    744   if(strpos(GetRequestURI(), '?') !== false)
     744  if (strpos(GetRequestURI(), '?') !== false)
    745745    $_SERVER['QUERY_STRING'] = substr(GetRequestURI(), strpos(GetRequestURI(), '?') + 1);
    746746  else $_SERVER['QUERY_STRING'] = '';
    747747  parse_str($_SERVER['QUERY_STRING'], $_GET);
    748748  // SQL injection hack protection
    749   foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);
    750   return($PathItems);
     749  foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);
     750  return $PathItems;
    751751}
    752752
     
    757757  $Output = '<select name="Language">';
    758758  $DbResult = $System->Database->select('Language', '`Id`, `Name`', '`Enabled` = 1');
    759   while($Language = $DbResult->fetch_assoc())
     759  while ($Language = $DbResult->fetch_assoc())
    760760  {
    761761    $Output .= '<option value="'.$Language['Id'].'"';
    762     if($Selected == $Language['Id'])
     762    if ($Selected == $Language['Id'])
    763763      $Output .= ' selected="selected"';
    764764    $Output .= '>'.T($Language['Name']).'</option>';
    765765  }
    766766  $Output .= '</select>';
    767   return($Output);
     767  return $Output;
    768768}
    769769
    770770function GetClientProxyAddresses()
    771771{
    772   if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
     772  if (array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
    773773    else $IP = array();
    774774}
     
    776776function GetRemoteAddress()
    777777{
    778   if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
     778  if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
    779779    else $IP = '';
    780   return($IP);
     780  return $IP;
    781781}
    782782
    783783function GetRequestURI()
    784784{
    785   if(array_key_exists('REQUEST_URI', $_SERVER)) return($_SERVER['REQUEST_URI']);
    786     else return($_SERVER['PHP_SELF']);
    787 }
     785  if (array_key_exists('REQUEST_URI', $_SERVER)) return $_SERVER['REQUEST_URI'];
     786    else return $_SERVER['PHP_SELF'];
     787}
Note: See TracChangeset for help on using the changeset viewer.