/** * Gets the value from the environment variables * * @param $ref * @param null $default returned when the value is empty * @param bool $required * @throws Exception in case a required value was requested but found empty */ public static function read($ref, $default = null, $required = false) { // Start with $value as null $value = null; // Try $_ENV first if (isset($_ENV[$ref])) { $value = $_ENV[$ref]; } // Fallback to using getenv if (empty($value) && function_exists('getenv')) { $value = getenv($ref); } // Fallback to using apache_getenv if (empty($value) && function_exists('apache_getenv')) { $value = apache_getenv($ref); } // Fallback to $_SERVER if (empty($value) && isset($_SERVER[$ref])) { $value = $_SERVER[$ref]; } // Handle the case when the env var is empty if (empty($value)) { if ($required) { throw new \Exception("Environment variable {$ref} needs to be non-empty. Adjust app configuration and re-build."); } // All configuration directives are expected to be non-empty, but since this one is not required, we settle with writing // a warning to the error_log if (defined('SEND_WARNINGS_ABOUT_EMPTY_CONFIG_TO_ERROR_LOG') && SEND_WARNINGS_ABOUT_EMPTY_CONFIG_TO_ERROR_LOG) { error_log("[php-app-config] {$ref} empty, defaulting to {$default}"); } $value = $default; } return $value; }
function get_count() { $host = 'api.b.st-hatena.com'; $scheme = apache_getenv('HTTPS') ? 'https://' : 'http://'; $url = $scheme . getenv('HTTP_HOST') . getenv('REQUEST_URI'); if (!($fp = fsockopen($host, 80))) { return 0; } $out = sprintf("GET /entry.count?url=%s HTTP/1.1\r\n", urlencode($url)); $out .= sprintf("Host: %s\r\n", $host); $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); $b = $num = false; while (!feof($fp)) { $line = trim(fgets($fp, 128)); if (empty($line)) { $b = true; continue; } if ($b !== true) { continue; } $num = $line; } fclose($fp); return (int) $num; }
/** * {@inheritDoc} */ public static function check($options = array()) { $key = 'HTTP_USER_AGENT'; $agent = ''; if (isset($_SERVER[$key])) { $agent = $_SERVER[$key]; } elseif (isset($_ENV[$key])) { $agent = $_ENV[$key]; } elseif (getenv($key)) { $agent = getenv($key); } elseif (function_exists('apache_getenv')) { $agent = apache_getenv($key, true); } // No HTTP_USER_AGENT detected, return false upon DoS check, // otherwise null. if (empty($agent) || '-' == $agent) { return empty($options['dos']) ? null : false; } // Check bad bots if (!empty($options['bot'])) { $pattern = is_array($options['bot']) ? implode('|', $options['bot']) : $options['bot']; $status = preg_match('/' . $pattern . '/i', $agent) ? false : null; return $status; } return null; }
function get_count() { $host = 'num.bookmarks.yahoo.co.jp'; $scheme = apache_getenv('HTTPS') ? 'https://' : 'http://'; $url = $scheme . getenv('HTTP_HOST') . getenv('REQUEST_URI'); $url = 'http://google.co.jp/'; if (!($fp = fsockopen($host, 80))) { return 0; } $out = sprintf("GET /yjnostb.php?urls=%s HTTP/1.1\r\n", $url); $out .= sprintf("Host: %s\r\n", $host); $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); $b = $num = false; $lines = ''; while (!feof($fp)) { $line = trim(fgets($fp, 128)); if (empty($line)) { $b = true; continue; } if ($b !== true) { continue; } $lines .= $line; } if (preg_match('/ct="([0-9]+)"/i', $lines, $matches)) { $num = $matches[1]; } fclose($fp); return (int) $num; }
/** * Env Param that comes from server virtual host, * currently support only apache * @param $param * @return string */ public static function envParam($param) { if (function_exists('apache_getenv')) { return apache_getenv($param); } else { return ''; } }
function index($pending = false) { if (apache_getenv('USE_EID')) { $this->view(apache_getenv('USE_EID')); return true; } $type = $pending ? 'pending' : 'upcoming'; $this->_runList($type, $pending); }
function __construct() { try { if (function_exists('apache_getenv') && strlen(apache_getenv('GIROCHECKOUT_SERVER'))) { $url = parse_url($this->requestURL); $this->requestURL = apache_getenv('GIROCHECKOUT_SERVER') . $url['path']; } } catch (Exception $e) { } }
/** * ips::nv_getenv() * * @param mixed $key * @return * */ private function nv_getenv($key) { if (isset($_SERVER[$key])) { return $_SERVER[$key]; } elseif (isset($_ENV[$key])) { return $_ENV[$key]; } elseif (@getenv($key)) { return @getenv($key); } elseif (function_exists('apache_getenv') && apache_getenv($key, true)) { return apache_getenv($key, true); } return ''; }
function let() { $this->_text = apply_filters('page_title', get_bloginfo('name')); $scheme = apache_getenv('HTTPS') ? 'https://' : 'http://'; $params = array('url=' . urlencode($scheme . getenv('HTTP_HOST') . getenv('REQUEST_URI'))); if (!empty($this->_via)) { $params[] = 'via=' . urlencode($this->_via); } if (!empty($this->_text)) { $params[] = 'text=' . urlencode($this->_text); } return sprintf('<a href="%s" title="%s"><img src="%s" alt="%s"/></a>', sprintf($this->_bookmarkUrl, implode('&', $params)), sprintf(__('Post to %s', 'media_hooker'), $this->_name), $this->_iconUrl, $this->_name); }
function PMA_getenv($var_name) { if (isset($_SERVER[$var_name])) { return $_SERVER[$var_name]; } elseif (isset($_ENV[$var_name])) { return $_ENV[$var_name]; } elseif (getenv($var_name)) { return getenv($var_name); } elseif (function_exists('apache_getenv') && apache_getenv($var_name, true)) { return apache_getenv($var_name, true); } return ''; }
public function getenv($strName) { $r = NULL; if (isset($_SERVER[$strName])) { return $_SERVER[$strName]; } elseif (isset($_ENV[$strName])) { return $_ENV[$strName]; } elseif ($r = getenv($strName)) { return $r; } elseif (function_exists('apache_getenv') && ($r = apache_getenv($strName, true))) { return $r; } return ''; }
public function fullPath() { if ($this->isServerSecure()) { $http_protocol = 'https://'; } else { $http_protocol = 'http://'; } if (stristr($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) { $request_url = apache_getenv("HTTP_HOST"); $this->setRootPath($http_protocol . $request_url . DIRECTORY_SEPARATOR); } else { $this->longCreationFromServer(); } }
function BAD_REFERER_get_env($st_var) { global $HTTP_SERVER_VARS; if (isset($_SERVER[$st_var])) { return strip_tags($_SERVER[$st_var]); } elseif (isset($_ENV[$st_var])) { return strip_tags($_ENV[$st_var]); } elseif (isset($HTTP_SERVER_VARS[$st_var])) { return strip_tags($HTTP_SERVER_VARS[$st_var]); } elseif (getenv($st_var)) { return strip_tags(getenv($st_var)); } elseif (function_exists('apache_getenv') && apache_getenv($st_var, true)) { return strip_tags(apache_getenv($st_var, true)); } return ''; }
/** * nv_getenv() * * @param mixed $a * @return */ function nv_getenv($a) { if (!is_array($a)) { $a = array($a); } foreach ($a as $b) { if (isset($_SERVER[$b])) { return $_SERVER[$b]; } elseif (isset($_ENV[$b])) { return $_ENV[$b]; } elseif (@getenv($b)) { return @getenv($b); } elseif (function_exists('apache_getenv') && apache_getenv($b, true)) { return apache_getenv($b, true); } } return ''; }
/** * {@inheritDoc} */ public static function check($options = array()) { $key = 'HTTP_USER_AGENT'; $agent = ''; if (isset($_SERVER[$key])) { $agent = $_SERVER[$key]; } elseif (isset($_ENV[$key])) { $agent = $_ENV[$key]; } elseif (getenv($key)) { $agent = getenv($key); } elseif (function_exists('apache_getenv')) { $agent = apache_getenv($key, true); } if (empty($agent) || '-' == $agent) { return false; } return null; }
/** * Környezeti információkat kérdezhetünk le. * * @example \library\Enviroment::GetEnv("DOCUMENT_ROOT"); * @access public * @param string $pin_EnvKey Környezeti változó neve. * @return string */ public static function GetEnv(string $pin_EnvKey) : string { // get HTTPS if ($pin_EnvKey == "HTTPS") { if (isset($_SERVER) && !empty($_SERVER)) { return isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"; } else { return strpos(self::GetEnv("SCRIPT_URI"), "https://") === 0; } } if (isset($_SERVER[$pin_EnvKey])) { return $_SERVER[$pin_EnvKey]; } elseif (isset($_ENV[$pin_EnvKey])) { return $_ENV[$pin_EnvKey]; } elseif (getenv($pin_EnvKey) !== false) { return getenv($pin_EnvKey); } elseif (function_exists("apache_getenv")) { // IIS Server nem támogatja az apache_getenv függvényt. if (apache_getenv($pin_EnvKey) !== false) { return apache_getenv($pin_EnvKey); } } // get SCRIPT_FILENAME if ($pin_EnvKey == "SCRIPT_FILENAME" && defined("SERVER_IIS") && SERVER_IIS === true) { return str_replace("\\\\", "\\", self::GetEnv("PATH_TRANSLATED")); } // get DOCUMENT_ROOT if ($pin_EnvKey == "DOCUMENT_ROOT") { (int) ($loc_Offset = 0); if (!strpos(self::GetEnv("SCRIPT_NAME"), ".php")) { $loc_Offset = 4; } return substr(self::GetEnv("SCRIPT_FILENAME"), 0, strlen(self::GetEnv("SCRIPT_FILENAME")) - (strlen(self::GetEnv("SCRIPT_NAME")) + $loc_Offset)); } // get PHP_SELF if ($pin_EnvKey == "PHP_SELF") { return str_replace(self::GetEnv("DOCUMENT_ROOT"), "", self::GetEnv("SCRIPT_FILENAME")); } return ""; }
/** * {@inheritDoc} */ public static function check($options = array()) { if (!$options) { return null; } $key = 'HTTP_USER_AGENT'; $agent = ''; if (isset($_SERVER[$key])) { $agent = $_SERVER[$key]; } elseif (isset($_ENV[$key])) { $agent = $_ENV[$key]; } elseif (getenv($key)) { $agent = getenv($key); } elseif (function_exists('apache_getenv')) { $agent = apache_getenv($key, true); } if (empty($agent) || '-' == $agent) { return null; } // Check bad bots $pattern = implode('|', $options); $status = preg_match('/' . $pattern . '/i', $agent) ? false : null; return $status; }
/** * Get the IP address of the web server Rogo is running on. * * @return string The IP address of the webserver. */ static function get_server_address() { if (!empty($_SERVER['SERVER_ADDR'])) { // This should work on Apache and most other server. return $_SERVER['SERVER_ADDR']; } elseif (!empty($_SERVER['LOCAL_ADDR'])) { // This will work on IIS when PHP is running as a CGI module. return $_SERVER['LOCAL_ADDR']; } elseif (function_exists('apache_getenv')) { // Fall back on an apache method if $_SERVER does not exsist. return apache_getenv('SERVER_ADDR'); } elseif (function_exists('gethostname')) { // A possibly expensive emergency fall back, it will return the IP address of the systems name, // which maynot be the same as the web server IP, especially if localhost or 127.0.0.1 is being used. return gethostbyname(gethostname()); } else { return '0.0.0.0'; } }
private function _getEnv($data) { $out = false; switch (true) { case isset($_SERVER[$data]): $out = $_SERVER[$data]; break; case isset($_ENV[$data]): $out = $_ENV[$data]; break; case $tmp = getenv($data): $out = $tmp; break; case function_exists('apache_getenv') && ($tmp = apache_getenv($data, true)): $out = $tmp; break; default: $out = false; } unset($tmp); return $out; }
/** * Request::get_Env() * * @param mixed $key * @return */ private function get_Env($key) { if (!is_array($key)) { $key = array($key); } foreach ($key as $k) { if (isset($_SERVER[$k])) { return $_SERVER[$k]; } elseif (isset($_ENV[$k])) { return $_ENV[$k]; } elseif (@getenv($k)) { return @getenv($k); } elseif (function_exists('apache_getenv') && apache_getenv($k, true)) { return apache_getenv($k, true); } } return ''; }
function let() { $scheme = apache_getenv('HTTPS') ? 'https://' : 'http://'; return sprintf('<a href="%s%s%s%s" title="%s"><img src="%s" alt="%s"/></a>', $this->_bookmarkUrl, $scheme, getenv('HTTP_HOST'), getenv('REQUEST_URI'), sprintf(__('Post to %s', 'media_hooker'), $this->_name), $this->_iconUrl, $this->_name); }
| | Example: | $template['default']['regions'] = array( | 'header' => array( | 'content' => array('<h1>Welcome</h1>','<p>Hello World</p>'), | 'name' => 'Page Header', | 'wrapper' => '<div>', | 'attributes' => array('id' => 'header', 'class' => 'clearfix') | ) | ); | */ /* |-------------------------------------------------------------------------- | Default Template Configuration (adjust this or create your own) |-------------------------------------------------------------------------- */ $default_template = 'template2'; if ($key = strtolower(apache_getenv('USE_KEY'))) { $path = APPPATH . 'views/custom_templates/' . $key . '/_template_' . $key . '.php'; if (is_file($path)) { $default_template = 'custom_templates/' . $key . '/_template_' . $key . '.php'; } } $template['default']['template'] = $default_template; $template['default']['regions'] = array('header', 'content', 'footer', 'logged', 'feedurl', 'sidebar2', 'sidebar3', 'info_block'); $template['default']['parser'] = 'parser'; $template['default']['parser_method'] = 'parse'; $template['default']['parse_template'] = FALSE; /* End of file template.php */ /* Location: ./system/application/config/template.php */
/** * Check to see if they have a custom template for the style (based on the * custom directory path in the config) * * @param string $view View passed into the functions above * @return string Returns path to either the same view or the found custom view */ public function has_custom_view($view) { $cpath = $this->CI->config->item('custom_template_dir'); if ($key = apache_getenv('USE_KEY')) { $cpath = $this->CI->config->item('custom_template_dir') . '/' . $key . '/' . $view; if (is_file(APPPATH . '/views/' . $cpath . '.php')) { return $cpath; } else { return $view; } } else { return $view; } }
/* |-------------------------------------------------------------------------- | Base Site URL |-------------------------------------------------------------------------- | | URL to your CodeIgniter root. Typically this will be your base URL, | WITH a trailing slash: | | http://example.com/ | | If this is not set then CodeIgniter will guess the protocol, domain and | path to your installation. | */ $config['base_url'] = ''; switch (apache_getenv('APPLICATION_ENV')) { case 'local': $config['base_url'] = 'http://local.comune-grezzana/'; break; } /* |-------------------------------------------------------------------------- | Index File |-------------------------------------------------------------------------- | | Typically this will be your index.php file, unless you've renamed it to | something else. If you are using mod_rewrite to remove the page set this | variable so that it is blank. | */ $config['index_page'] = '';
/** * 获取apache子进程的环境变量 * <code>Apache::getenv('SERVER_ADDR');</code> * @param string $key key值 * @param bool $walk_to_top key 是否递归到顶部,默认false * @return string apache的子进程的环境变量 */ public static function get_env($key, $walk_to_top = false) { return apache_getenv($key, $walk_to_top); }
function plugin_dav_myurl0() { // $_SERVER['HTTPS'] - https かどうかの判定用 // get_script_absuri(); // rc - http://jo1upk.blogdns.net:80 $url = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://'; $url .= $_SERVER['HTTP_HOST']; $port = apache_getenv('SERVER_PORT'); if (isset($port) && $port != 443 && $_SERVER['HTTPS'] == 'on') { $url .= ':' . $port; } else { if (isset($port) && $port != 80 && $_SERVER['HTTPS'] != 'on') { $url .= ':' . $port; } } return $url; }
function ech0($LK) { $v = true; $e = 1; if (substr($LK, 0, 3) != B('SVND')) { $v = false; } $data = spr1ntf($LK); if ($data !== false) { $data['version'] = ($data['vn'] & 0xf0) >> 4; $data['nfr'] = $data['vn'] & 0xf; $GLOBALS['LKN'] = $data['nfr']; unset($data['vn']); /* //Q2hlY2sgZm9yIGludmFsaWQga2V5IHZlcnNpb25z switch ($data['version']) { case 1: $v = false; break; } */ if (@$data['expires']) { if (preg_match('#^(\\d{4})(\\d\\d)(\\d\\d)$#', $data['expires'], $matches)) { $ex = mktime(0, 0, 0, $matches[2], $matches[3], $matches[1]); if ($ex < time()) { $GLOBALS['LE'] = "HExp"; $GLOBALS['EI'] = isc_date("jS F Y", $ex); $v = false; } } } if (!mysql_user_row($data['edition'])) { $GLOBALS['LE'] = "HInv"; $v = false; } else { $e = $data['edition']; } } else { $GLOBALS['LE'] = "HInv"; $v = false; } $host = ''; if (function_exists('apache_getenv')) { $host = @apache_getenv('HTTP_HOST'); } if (!$host) { $host = @$_SERVER['HTTP_HOST']; } if ($colon = strpos($host, ':')) { $host = substr($host, 0, $colon); } if ($host != B('421aa90e079fa326b6494f812ad13e79') && $host != B('MTI3LjAuMC4x')) { $hashes = array(md5($host)); if (strtolower(substr($host, 0, 4)) == 'www.') { $hashes[] = md5(substr($host, 4)); } else { $hashes[] = md5('www.' . $host); } /*if (!in_array(@$data['hash'], $hashes)) { $GLOBALS['LE'] = "HSer"; $GLOBALS['EI'] = $host; $v = false; }*/ } $GLOBALS[B("QXBwRWRpdGlvbg==")] = GetLang(B("RWRpdGlvbg==") . $e); return $v; }
/** * Получение реального ip текущего пользователя * * @param string $out IP адрес который будет отдан функцией, если больше ничего не обнаружено * @return string IP пользователя * * @see http://stackoverflow.com/questions/5036443/php-how-to-block-proxies-from-my-site */ function get_user_ip($out = '127.0.0.1') { $_getEnv = function ($data) { $out = false; switch (true) { case isset($_SERVER[$data]): $out = $_SERVER[$data]; break; case isset($_ENV[$data]): $out = $_ENV[$data]; break; case $tmp = getenv($data): $out = $tmp; break; case function_exists('apache_getenv') && ($tmp = apache_getenv($data, true)): $out = $tmp; break; default: $out = false; } unset($tmp); return $out; }; //Порядок условий зависит от приоритетов switch (true) { case $tmp = $_getEnv('HTTP_COMING_FROM'): $out = $tmp; break; case $tmp = $_getEnv('HTTP_X_COMING_FROM'): $out = $tmp; break; case $tmp = $_getEnv('HTTP_VIA'): $out = $tmp; break; case $tmp = $_getEnv('HTTP_FORWARDED'): $out = $tmp; break; case $tmp = $_getEnv('HTTP_FORWARDED_FOR'): $out = $tmp; break; case $tmp = $_getEnv('HTTP_X_FORWARDED'): $out = $tmp; break; case $tmp = $_getEnv('HTTP_X_FORWARDED_FOR'): $out = $tmp; break; case !empty($_SERVER['REMOTE_ADDR']): $out = $_SERVER['REMOTE_ADDR']; break; default: $out = false; } unset($tmp); return false !== $out && preg_match('|^(?:[0-9]{1,3}\\.){3,3}[0-9]{1,3}$|', $out, $matches) ? $out : false; }
/** * Set an environment variable. * * This is done using: * - putenv, * - $_ENV, * - $_SERVER. * * The environment variable value is stripped of single and double quotes. * * @param string $name * @param string|null $value * * @return void */ public function setEnvironmentVariable($name, $value = null) { list($name, $value) = $this->normaliseEnvironmentVariable($name, $value); // Don't overwrite existing environment variables if we're immutable // Ruby's dotenv does this with `ENV[key] ||= value`. if ($this->immutable && $this->getEnvironmentVariable($name) !== null) { return; } // If PHP is running as an Apache module and an existing // Apache environment variable exists, overwrite it if (function_exists('apache_getenv') && function_exists('apache_setenv') && apache_getenv($name)) { apache_setenv($name, $value); } putenv("{$name}={$value}"); $_ENV[$name] = $value; $_SERVER[$name] = $value; }
function let() { $scheme = apache_getenv('HTTPS') ? 'https://' : 'http://'; return sprintf('<a href="%s" title="%s"><img src="%s" alt="%s"/></a>', sprintf($this->_bookmarkUrl, apply_filters('page_title', get_bloginfo('name')), $scheme . getenv('HTTP_HOST') . getenv('REQUEST_URI')), sprintf(__('Post to %s', 'media_hooker'), $this->_name), $this->_iconUrl, $this->_name); }