Changeset 805 for trunk/includes


Ignore:
Timestamp:
May 24, 2014, 11:35:47 PM (10 years ago)
Author:
chronos
Message:
  • Fixed: Do not log client proxy IP address as remote address because it can be faked and also there can be multiple client proxy addresses.
  • Modified: Do not use directly $_SERVER variables REMOTE_ADDR and REQUEST_URI as they are not initialized if script is executed from command line.
  • Fixed: Default configuration was not complete.
Location:
trunk/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/Update.php

    r553 r805  
    5454        $InstallMethod = $this->InstallMethod;
    5555        $InstallMethod($this);
     56        $this->Update();
    5657  }
    5758 
  • trunk/includes/Version.php

    r804 r805  
    66// and system will need database update.
    77
    8 $Revision = 804; // Subversion revision
     8$Revision = 805; // Subversion revision
    99$DatabaseRevision = 803; // Database structure revision
    10 $ReleaseTime = '2014-04-14';
     10$ReleaseTime = '2014-05-24';
  • trunk/includes/global.php

    r800 r805  
    754754        if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
    755755        $PathItems = explode('/', $PathString);
    756         if(strpos($_SERVER['REQUEST_URI'], '?') !== false)
    757                 $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
     756        if(strpos(GetRequestURI(), '?') !== false)
     757                $_SERVER['QUERY_STRING'] = substr(GetRequestURI(), strpos(GetRequestURI(), '?') + 1);
    758758        else $_SERVER['QUERY_STRING'] = '';
    759759        parse_str($_SERVER['QUERY_STRING'], $_GET);
     
    780780}
    781781
     782function GetClientProxyAddresses()
     783{
     784  if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
     785    else $IP = array();
     786}
     787
    782788function GetRemoteAddress()
    783789{
    784   if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
    785   else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
    786   else $IP = '0.0.0.0';
     790  if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
     791    else $IP = '';
    787792  return($IP);
    788793}
     794
     795function GetRequestURI()
     796{
     797  if(array_key_exists('REQUEST_URI', $_SERVER)) return($_SERVER['REQUEST_URI']);
     798    else return($_SERVER['PHP_SELF']);
     799}
  • trunk/includes/system.php

    r800 r805  
    110110    $ScriptStartTime = GetMicrotime();
    111111
    112     if(isset($_SERVER['REMOTE_ADDR'])) session_start();
     112    if(GetRemoteAddress() != '') session_start();
    113113
    114114    if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.');
     
    433433                $ScriptGenerateDuration.' s / '.ini_get('max_execution_time').' s &nbsp;&nbsp; '.T('Used memory').': '.
    434434                HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B &nbsp;&nbsp; <a href="http://validator.w3.org/check?uri='.
    435                 htmlentities('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?'.$_SERVER['QUERY_STRING']).'">HTML validator</a></td></tr>';
     435                htmlentities('http://'.$_SERVER['HTTP_HOST'].GetRequestURI().'?'.$_SERVER['QUERY_STRING']).'">HTML validator</a></td></tr>';
    436436                $Output .= '</table>'.
    437437      '</body>'.
Note: See TracChangeset for help on using the changeset viewer.