Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/System.php

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