/**
  * Our singleton INIT function
  *
  * @access	protected
  * @return	@e void
  */
 protected static function init()
 {
     if (self::$initiated !== TRUE) {
         //-----------------------------------------
         // IP Address
         //-----------------------------------------
         if (ipsRegistry::$settings['xforward_matching']) {
             foreach (array_reverse(explode(',', my_getenv('HTTP_X_FORWARDED_FOR'))) as $x_f) {
                 $addrs[] = trim($x_f);
             }
             $addrs[] = my_getenv('HTTP_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_X_CLUSTER_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_PROXY_USER');
         }
         $addrs[] = my_getenv('REMOTE_ADDR');
         //-----------------------------------------
         // Do we have one yet?
         //-----------------------------------------
         foreach ($addrs as $ip) {
             //-----------------------------------------
             // IP v4
             //-----------------------------------------
             if (IPSLib::validateIPv4($ip)) {
                 self::instance()->ip_address = $ip;
                 break;
             } else {
                 if (IPSLib::validateIPv6($ip)) {
                     self::instance()->ip_address = $ip;
                     break;
                 }
             }
         }
         //-----------------------------------------
         // Make sure we take a valid IP address
         //-----------------------------------------
         if (!self::instance()->ip_address and !isset($_SERVER['SHELL']) and $_SERVER['SESSIONNAME'] != 'Console') {
             print "Could not determine your IP address";
             exit;
         }
         if (IPS_IS_UPGRADER) {
             require_once IPS_ROOT_PATH . "setup/sources/classes/session/sessions.php";
             /*noLibHook*/
             self::$session_class = new sessions();
         } else {
             self::setMember(0);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Singleton init method
  *
  * @return	@e void
  */
 protected static function init()
 {
     if (self::$initiated !== TRUE) {
         //-----------------------------------------
         // IP Address
         //-----------------------------------------
         if (ipsRegistry::$settings['xforward_matching']) {
             //foreach( array_reverse( explode( ',', my_getenv('HTTP_X_FORWARDED_FOR') ) ) as $x_f ) // See http://community.invisionpower.com/resources/bugs.html/_/ip-board/multiple-ips-in-x-forwarded-for-r37844
             foreach (explode(',', my_getenv('HTTP_X_FORWARDED_FOR')) as $x_f) {
                 $addrs[] = trim($x_f);
             }
             $addrs[] = my_getenv('HTTP_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_X_CLUSTER_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_PROXY_USER');
         }
         $addrs[] = my_getenv('REMOTE_ADDR');
         //-----------------------------------------
         // Do we have one yet?
         //-----------------------------------------
         foreach ($addrs as $ip) {
             //-----------------------------------------
             // IP v4
             //-----------------------------------------
             if (IPSLib::validateIPv4($ip)) {
                 self::instance()->ip_address = $ip;
                 break;
             } else {
                 if (IPSLib::validateIPv6($ip)) {
                     self::instance()->ip_address = $ip;
                     break;
                 }
             }
         }
         //-----------------------------------------
         // Make sure we take a valid IP address
         //-----------------------------------------
         if (!self::instance()->ip_address and !isset($_SERVER['SHELL']) and $_SERVER['SESSIONNAME'] != 'Console') {
             if (!defined('IPS_IS_SHELL') or !IPS_IS_SHELL) {
                 print "Could not determine your IP address";
                 exit;
             }
         }
         //-----------------------------------------
         // Get user-agent, browser and OS
         //-----------------------------------------
         self::instance()->user_agent = IPSText::parseCleanValue(my_getenv('HTTP_USER_AGENT'));
         self::instance()->operating_system = self::_fetch_os();
         if (IPS_AREA == 'admin') {
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/session/adminSessions.php', 'adminSessions');
             /**
              * Support for extending the session class
              */
             if (is_file(IPS_ROOT_PATH . "sources/classes/session/ssoAdminSessions.php")) {
                 $classToLoadA = IPSLib::loadLibrary(IPS_ROOT_PATH . "sources/classes/session/ssoAdminSessions.php", 'ssoAdminSessions');
                 /**
                  * Does the ssoAdminSessions class exist?
                  */
                 if (class_exists($classToLoadA)) {
                     $parent = get_parent_class($classToLoadA);
                     /**
                      * Is it a child of adminSessions
                      */
                     if ($parent == $classToLoad) {
                         self::$session_class = new $classToLoadA();
                     } else {
                         self::$session_class = new $classToLoad();
                     }
                 }
             } else {
                 self::$session_class = new $classToLoad();
             }
         } else {
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/session/publicSessions.php', 'publicSessions');
             /**
              * Support for extending the session class
              */
             if (is_file(IPS_ROOT_PATH . "sources/classes/session/ssoPublicSessions.php")) {
                 $classToLoadA = IPSLib::loadLibrary(IPS_ROOT_PATH . "sources/classes/session/ssoPublicSessions.php", 'ssoPublicSessions');
                 /**
                  * Does the ssoPublicSessions class exist?
                  */
                 if (class_exists($classToLoadA)) {
                     $parent = get_parent_class($classToLoadA);
                     /**
                      * Is it a child of publicSessions
                      */
                     if ($parent == $classToLoad) {
                         self::$session_class = new $classToLoadA();
                     } else {
                         self::$session_class = new $classToLoad();
                     }
                 }
             } else {
                 self::$session_class = new $classToLoad();
             }
             //-----------------------------------------
             // Set other
             //-----------------------------------------
             self::$data_store['publicSessionID'] = self::$session_class->session_data['id'];
         }
         //-----------------------------------------
         // Set user agent
         //-----------------------------------------
         $_cookie = IPSCookie::get("uagent_bypass");
         self::$data_store['userAgentKey'] = isset(self::$session_class->session_data['uagent_key']) ? self::$session_class->session_data['uagent_key'] : '';
         self::$data_store['userAgentType'] = isset(self::$data_store['uagent_type']) ? self::$data_store['uagent_type'] : self::$session_class->session_data['uagent_type'];
         self::$data_store['userAgentVersion'] = isset(self::$session_class->session_data['uagent_version']) ? self::$session_class->session_data['uagent_version'] : '';
         self::$data_store['userAgentBypass'] = $_cookie ? true : (isset(self::$session_class->session_data['uagent_bypass']) ? self::$session_class->session_data['uagent_bypass'] : '');
         self::$data_store['forumsModeratorData'] = array();
         /* Some mobile app set up */
         if (self::$data_store['userAgentType'] == 'mobileApp') {
             /* This converts non UTF-8 POST/GET data in __construct */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/base/ipsMobileApp.php', 'ipsMobileApp');
             ipsRegistry::setClass('isMobileApp', new $classToLoad());
         }
     }
 }
 /**
  * Our singleton INIT function
  *
  * @access	protected
  * @return	void
  */
 protected static function init()
 {
     if (self::$initiated !== TRUE) {
         //-----------------------------------------
         // IP Address
         //-----------------------------------------
         if (ipsRegistry::$settings['xforward_matching']) {
             foreach (array_reverse(explode(',', my_getenv('HTTP_X_FORWARDED_FOR'))) as $x_f) {
                 $x_f = trim($x_f);
                 if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $x_f)) {
                     $addrs[] = $x_f;
                 }
             }
             $addrs[] = my_getenv('HTTP_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_X_CLUSTER_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_PROXY_USER');
         }
         $addrs[] = my_getenv('REMOTE_ADDR');
         //-----------------------------------------
         // Do we have one yet?
         //-----------------------------------------
         foreach ($addrs as $ip) {
             if ($ip) {
                 preg_match("/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\$/", $ip, $match);
                 self::instance()->ip_address = $match[1] . '.' . $match[2] . '.' . $match[3] . '.' . $match[4];
                 if (self::instance()->ip_address and self::instance()->ip_address != '...') {
                     break;
                 }
             }
         }
         //-----------------------------------------
         // Make sure we take a valid IP address
         //-----------------------------------------
         if ((!self::instance()->ip_address or self::instance()->ip_address == '...') and !isset($_SERVER['SHELL']) and $_SERVER['SESSIONNAME'] != 'Console') {
             print "Could not determine your IP address";
             exit;
         }
         if (IPS_IS_UPGRADER) {
             require_once IPS_ROOT_PATH . "setup/sources/classes/session/sessions.php";
             self::$session_class = new sessions();
         } else {
             self::setMember(0);
         }
     }
 }