_arrayMergeRecursive($config, $localConfig); } if (!defined('PATH_SEPARATOR')) { $config[$section]['PATH_SEPARATOR'] = (getenv('COMSPEC')) ? ';' : ':'; } if (null === $config['define']['DEBUG']) { $config['define']['DEBUG'] = ( self::isReservedIp($_SERVER['REMOTE_ADDR']) || in_array($_SERVER['REMOTE_ADDR'], $config['debug']['ips']) ) && isset($_COOKIE[$config['debug']['cookie']]); } $this->_initBaseurlWebpath($config[$section]); $config[$section]['BASE_PATH'] = realpath($config[$section]['WWW_PATH'] . '/' . $config[$section]['BASE_PATH']); foreach($config[$section] as $var => $value) { define(strtoupper($var), $value); } } public static function isReservedIp($ip) { $long = ip2long($ip); // check for 10.0.0.0 - 10.255.255.255 if (10 == $long >> 24) { return true; } // TODO check for 172.16.0.0 - 172.31.255.255 // TODO check for 192.168.0.0 - 192.168.255.255 return false; } protected function _initBaseurlWebpath(&$config) { $host = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']; //$config['WWW_PATH'] = dirname($_SERVER['SCRIPT_FILENAME']); $config['WWW_PATH'] = realpath('.'); //$config['BASE_URL'] = $host . str_replace(realpath($_SERVER['DOCUMENT_ROOT']), '', $config['WWW_PATH']); $config['BASE_URL'] = $host . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $config['BASE_URL'] = substr($config['BASE_URL'], 0, -1); while (!is_file($config['WWW_PATH'] . '/_lib/_sys/Frwd_ConfigLite.php')) { $config['WWW_PATH'] = dirname($config['WWW_PATH']); $config['BASE_URL'] = dirname($config['BASE_URL']); if ('/' == $config['WWW_PATH']) { die('INCORECT SCRIPT LOCATION'); } } $config['BASE_URL_HTTP'] = str_replace('https://', 'http://', $config['BASE_URL']); $config['BASE_URL_HTTPS'] = str_replace('http://', 'https://', $config['BASE_URL']); $config['WEB_PATH'] = str_replace($host, '', $config['BASE_URL']); return true; } protected function _arrayMergeRecursive($array1, $array2) { if (is_array($array1) && is_array($array2)) { foreach ($array2 as $key => $value) { if (isset($array1[$key])) { $array1[$key] = $this->_arrayMergeRecursive($array1[$key], $value); } else { $array1[$key] = $value; } } } else { $array1 = $array2; } return $array1; } }