本文整理汇总了PHP中apache_getenv函数的典型用法代码示例。如果您正苦于以下问题:PHP apache_getenv函数的具体用法?PHP apache_getenv怎么用?PHP apache_getenv使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apache_getenv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
/**
* 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;
}
示例2: get_count
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;
}
示例3: check
/**
* {@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;
}
示例4: get_count
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;
}
示例5: envParam
/**
* 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 '';
}
}
示例6: index
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);
}
示例7: __construct
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) {
}
}
示例8: nv_getenv
/**
* 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 '';
}
示例9: let
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);
}
示例10: PMA_getenv
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 '';
}
示例11: getenv
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 '';
}
示例12: fullPath
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();
}
}
示例13: BAD_REFERER_get_env
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 '';
}
示例14: nv_getenv
/**
* 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 '';
}
示例15: check
/**
* {@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;
}