Changeset 55 for trunk/index.php


Ignore:
Timestamp:
Apr 7, 2020, 12:55:39 AM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r54 r55  
    1616require_once('Modules/Event/EventPage.php');
    1717
    18 if(isset($_SERVER['REMOTE_ADDR'])) session_start();
     18if (isset($_SERVER['REMOTE_ADDR'])) session_start();
    1919
    2020class ApplicationTanec extends Application
     
    4040  function IsAdmin()
    4141  {
    42     return (array_key_exists('IsAdmin', $_SESSION) and ($_SESSION['IsAdmin'] == 1));
     42    return array_key_exists('IsAdmin', $_SESSION) and ($_SESSION['IsAdmin'] == 1);
    4343  }
    4444
    4545  function Link($URL)
    4646  {
    47     return($this->Config['BaseURL'].$URL);
     47    return $this->Config['BaseURL'].$URL;
    4848  }
    4949
    5050  function AbsoluteLink($URL)
    5151  {
    52     return($this->Config['HostName'].$this->Config['BaseURL'].$URL);
     52    return $this->Config['HostName'].$this->Config['BaseURL'].$URL;
    5353  }
    5454
     
    5656  {
    5757    $Output = '<div>';
    58     foreach($this->MainMenu as $MenuItem)
     58    foreach ($this->MainMenu as $MenuItem)
    5959    {
    6060      $Output .= '<a href="'.$this->Link($MenuItem['Link']).'">'.$MenuItem['Title'].'</a> ';
    6161    }
    6262    $Output .= '</div>';
    63     return($Output);
     63    return $Output;
    6464  }
    6565
    6666  function ProcessURL()
    6767  {
    68     if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     68    if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
    6969      $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
    7070    else $PathString = '';
    71     if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
     71    if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
    7272    $PathItems = explode('/', $PathString);
    73     if(array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
     73    if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
    7474      $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
    7575    else $_SERVER['QUERY_STRING'] = '';
    7676    parse_str($_SERVER['QUERY_STRING'], $_GET);
    77     return($PathItems);
     77    return $PathItems;
    7878  }
    7979
    8080  function RegisterPage($Path, $Handler)
    8181  {
    82     if(is_array($Path))
     82    if (is_array($Path))
    8383    {
    8484      $Page = &$this->Pages;
    8585      $LastKey = array_pop($Path);
    86       foreach($Path as $PathItem)
     86      foreach ($Path as $PathItem)
    8787      {
    8888        $Page = &$Page[$PathItem];
    8989      }
    90       if(!is_array($Page)) $Page = array('' => $Page);
     90      if (!is_array($Page)) $Page = array('' => $Page);
    9191      $Page[$LastKey] = $Handler;
    9292    } else $this->Pages[$Path] = $Handler;
     
    115115  function SearchPage($PathItems, $Pages)
    116116  {
    117     if(count($PathItems) > 0) $PathItem = $PathItems[0];
     117    if (count($PathItems) > 0) $PathItem = $PathItems[0];
    118118      else $PathItem = '';
    119     if(array_key_exists($PathItem, $Pages))
    120     {
    121       if(is_array($Pages[$PathItem]))
     119    if (array_key_exists($PathItem, $Pages))
     120    {
     121      if (is_array($Pages[$PathItem]))
    122122      {
    123123        array_shift($PathItems);
    124         return($this->SearchPage($PathItems, $Pages[$PathItem]));
    125       } else return($Pages[$PathItem]);
    126     } else return('');
     124        return $this->SearchPage($PathItems, $Pages[$PathItem]);
     125      } else return $Pages[$PathItem];
     126    } else return '';
    127127  }
    128128
    129129  function PageNotFound()
    130130  {
    131     return('Page '.implode('/', $this->PathItems).' not found.');
     131    return 'Page '.implode('/', $this->PathItems).' not found.';
    132132  }
    133133
     
    138138    /* @var $Page Page */
    139139    $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
    140     if($ClassName != '')
     140    if ($ClassName != '')
    141141    {
    142142      $Page = new $ClassName($this);
     
    150150  {
    151151    $this->RunCommon();
    152     if($this->ShowPage)
     152    if ($this->ShowPage)
    153153    {
    154154      $this->PathItems = ProcessURL();
     
    191191  {
    192192    Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
    193     return('<h3 align="center">Požadovaná stránka neexistuje.</h3>');
     193    return '<h3 align="center">Požadovaná stránka neexistuje.</h3>';
    194194  }
    195195}
     
    208208      'Disallow: /*?'."\n".
    209209      'Sitemap: '.$this->System->AbsoluteLink('/sitemap.xml');
    210     return($Result);
     210    return $Result;
    211211  }
    212212}
     
    259259
    260260    $Result .= '</urlset>';
    261     return($Result);
     261    return $Result;
    262262  }
    263263}
Note: See TracChangeset for help on using the changeset viewer.