本文整理汇总了PHP中QApplication::ServerAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP QApplication::ServerAddress方法的具体用法?PHP QApplication::ServerAddress怎么用?PHP QApplication::ServerAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QApplication
的用法示例。
在下文中一共展示了QApplication::ServerAddress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: InitializeServerAddress
/**
* Called by QApplication::Initialize() to initialize the QApplication::$ServerAddress setting.
* @return void
*/
protected static function InitializeServerAddress()
{
if (array_key_exists('LOCAL_ADDR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['LOCAL_ADDR'];
} else {
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
if (array_key_exists('SERVER_ADDR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['SERVER_ADDR'];
}
}
}
}
示例2: Initialize
/**
* This should be the first call to initialize all the static variables
* The application object also has static methods that are miscellaneous web
* development utilities, etc.
*
* @return void
*/
public static function Initialize()
{
$strCacheProviderClass = 'QCacheProviderNoCache';
if (defined('CACHE_PROVIDER_CLASS')) {
$strCacheProviderClass = CACHE_PROVIDER_CLASS;
}
if ($strCacheProviderClass) {
if (defined('CACHE_PROVIDER_OPTIONS')) {
QApplicationBase::$objCacheProvider = new $strCacheProviderClass(unserialize(CACHE_PROVIDER_OPTIONS));
} else {
QApplicationBase::$objCacheProvider = new $strCacheProviderClass();
}
}
// Are we running as CLI?
if (PHP_SAPI == 'cli') {
QApplication::$CliMode = true;
} else {
QApplication::$CliMode = false;
}
// Setup Server Address
if (array_key_exists('LOCAL_ADDR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['LOCAL_ADDR'];
} else {
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
if (array_key_exists('SERVER_ADDR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['SERVER_ADDR'];
}
}
}
// Setup ScriptFilename and ScriptName
QApplication::$ScriptFilename = $_SERVER['SCRIPT_FILENAME'];
QApplication::$ScriptName = $_SERVER['SCRIPT_NAME'];
// Ensure both are set, or we'll have to abort
if (!QApplication::$ScriptFilename || !QApplication::$ScriptName) {
throw new Exception('Error on QApplication::Initialize() - ScriptFilename or ScriptName was not set');
}
// Setup PathInfo and QueryString (if applicable)
QApplication::$PathInfo = null;
if (array_key_exists('PATH_INFO', $_SERVER)) {
QApplication::$PathInfo = urlencode(trim($_SERVER['PATH_INFO']));
QApplication::$PathInfo = str_ireplace('%2f', '/', QApplication::$PathInfo);
}
QApplication::$QueryString = array_key_exists('QUERY_STRING', $_SERVER) ? $_SERVER['QUERY_STRING'] : null;
// Setup RequestUri
if (defined('__URL_REWRITE__')) {
switch (strtolower(__URL_REWRITE__)) {
case 'apache':
QApplication::$RequestUri = $_SERVER['REQUEST_URI'];
break;
case 'none':
QApplication::$RequestUri = sprintf('%s%s%s', QApplication::$ScriptName, QApplication::$PathInfo, QApplication::$QueryString ? sprintf('?%s', QApplication::$QueryString) : null);
break;
default:
throw new Exception('Invalid URL Rewrite type: ' . __URL_REWRITE__);
}
} else {
QApplication::$RequestUri = sprintf('%s%s%s', QApplication::$ScriptName, QApplication::$PathInfo, QApplication::$QueryString ? sprintf('?%s', QApplication::$QueryString) : null);
}
// Setup DocumentRoot
QApplication::$DocumentRoot = trim(__DOCROOT__);
// Setup Browser Type
if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
$strUserAgent = trim(strtolower($_SERVER['HTTP_USER_AGENT']));
QApplication::$BrowserType = 0;
// INTERNET EXPLORER (supporting versions 6.0, 7.0 and eventually 8.0)
if (strpos($strUserAgent, 'msie') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::InternetExplorer;
if (strpos($strUserAgent, 'msie 6.0') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::InternetExplorer_6_0;
} else {
if (strpos($strUserAgent, 'msie 7.0') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::InternetExplorer_7_0;
} else {
if (strpos($strUserAgent, 'msie 8.0') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::InternetExplorer_8_0;
} else {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Unsupported;
}
}
}
// FIREFOX (supporting versions 1.0, 1.5, 2.0 and eventually 3.0)
} else {
if (strpos($strUserAgent, 'firefox') !== false || strpos($strUserAgent, 'iceweasel') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Firefox;
$strUserAgent = str_replace('iceweasel/', 'firefox/', $strUserAgent);
if (strpos($strUserAgent, 'firefox/1.0') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Firefox_1_0;
} else {
if (strpos($strUserAgent, 'firefox/1.5') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Firefox_1_5;
} else {
//.........这里部分代码省略.........
示例3: Initialize
/**
* This should be the first call to initialize all the static variables
* The application object also has static methods that are miscellaneous web
* development utilities, etc.
*
* @return void
*/
public static function Initialize()
{
// Are we running as CLI?
if (array_key_exists('SERVER_PROTOCOL', $_SERVER)) {
QApplication::$CliMode = false;
} else {
QApplication::$CliMode = true;
}
// Setup Server Address
if (array_key_exists('LOCAL_ADDR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['LOCAL_ADDR'];
} else {
if (array_key_exists('SERVER_ADDR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['SERVER_ADDR'];
}
}
// Setup ScriptFilename and ScriptName
QApplication::$ScriptFilename = $_SERVER['SCRIPT_FILENAME'];
QApplication::$ScriptName = $_SERVER['SCRIPT_NAME'];
// Ensure both are set, or we'll have to abort
if (!QApplication::$ScriptFilename || !QApplication::$ScriptName) {
throw new Exception('Error on QApplication::Initialize() - ScriptFilename or ScriptName was not set');
}
// Setup PathInfo and QueryString (if applicable)
QApplication::$PathInfo = array_key_exists('PATH_INFO', $_SERVER) ? trim($_SERVER['PATH_INFO']) : null;
QApplication::$QueryString = array_key_exists('QUERY_STRING', $_SERVER) ? $_SERVER['QUERY_STRING'] : null;
// Setup RequestUri
QApplication::$RequestUri = sprintf('%s%s%s', QApplication::$ScriptName, QApplication::$PathInfo, QApplication::$QueryString ? sprintf('?%s', QApplication::$QueryString) : null);
// Setup DocumentRoot
QApplication::$DocumentRoot = trim(__DOCROOT__);
// Setup Browser Type
if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
$strUserAgent = trim(strtolower($_SERVER['HTTP_USER_AGENT']));
if (strpos($strUserAgent, 'msie') !== false) {
QApplication::$BrowserType = QBrowserType::InternetExplorer;
} else {
if (strpos($strUserAgent, 'firefox') !== false) {
QApplication::$BrowserType = QBrowserType::Firefox;
} else {
if (strpos($strUserAgent, 'safari') !== false) {
QApplication::$BrowserType = QBrowserType::Safari;
} else {
QApplication::$BrowserType = QBrowserType::Other;
}
}
}
if (strpos($strUserAgent, 'macintosh') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Macintosh;
}
}
// Preload Class Files
foreach (QApplication::$PreloadedClassFile as $strClassFile) {
require $strClassFile;
}
}
示例4: Initialize
/**
* This should be the first call to initialize all the static variables
* The application object also has static methods that are miscellaneous web
* development utilities, etc.
*
* @throws Exception
* @return void
*/
public static function Initialize()
{
self::$EncodingType = defined('__QAPPLICATION_ENCODING_TYPE__') ? __QAPPLICATION_ENCODING_TYPE__ : self::$EncodingType;
// Are we running as CLI?
if (PHP_SAPI == 'cli') {
QApplication::$CliMode = true;
} else {
QApplication::$CliMode = false;
}
// Setup Server Address
if (array_key_exists('LOCAL_ADDR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['LOCAL_ADDR'];
} else {
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
if (array_key_exists('SERVER_ADDR', $_SERVER)) {
QApplication::$ServerAddress = $_SERVER['SERVER_ADDR'];
}
}
}
// Setup ScriptFilename and ScriptName
QApplication::$ScriptFilename = $_SERVER['SCRIPT_FILENAME'];
QApplication::$ScriptName = $_SERVER['SCRIPT_NAME'];
// Ensure both are set, or we'll have to abort
if (!QApplication::$ScriptFilename || !QApplication::$ScriptName) {
throw new Exception('Error on QApplication::Initialize() - ScriptFilename or ScriptName was not set');
}
// Setup PathInfo and QueryString (if applicable)
QApplication::$PathInfo = null;
if (array_key_exists('PATH_INFO', $_SERVER)) {
QApplication::$PathInfo = urlencode(trim($_SERVER['PATH_INFO']));
QApplication::$PathInfo = str_ireplace('%2f', '/', QApplication::$PathInfo);
}
QApplication::$QueryString = array_key_exists('QUERY_STRING', $_SERVER) ? $_SERVER['QUERY_STRING'] : null;
// Setup RequestUri
if (defined('__URL_REWRITE__')) {
switch (strtolower(__URL_REWRITE__)) {
case 'apache':
QApplication::$RequestUri = $_SERVER['REQUEST_URI'];
break;
case 'none':
QApplication::$RequestUri = sprintf('%s%s%s', QApplication::$ScriptName, QApplication::$PathInfo, QApplication::$QueryString ? sprintf('?%s', QApplication::$QueryString) : null);
break;
default:
throw new Exception('Invalid URL Rewrite type: ' . __URL_REWRITE__);
}
} else {
QApplication::$RequestUri = sprintf('%s%s%s', QApplication::$ScriptName, QApplication::$PathInfo, QApplication::$QueryString ? sprintf('?%s', QApplication::$QueryString) : null);
}
// Setup DocumentRoot
QApplication::$DocumentRoot = trim(__DOCROOT__);
// Setup Browser Type
if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
$strUserAgent = trim(strtolower($_SERVER['HTTP_USER_AGENT']));
QApplication::$BrowserType = 0;
// INTERNET EXPLORER (versions 6 through 10)
if (strpos($strUserAgent, 'msie') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::InternetExplorer;
// just major version number. Will not see IE 10.6.
$matches = array();
preg_match('#msie\\s(.\\d)#', $strUserAgent, $matches);
if ($matches) {
QApplication::$BrowserVersion = (int) $matches[1];
}
} else {
if (strpos($strUserAgent, 'trident') !== false) {
// IE 11 significantly changes the user agent, and no longer includes 'MSIE'
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::InternetExplorer;
$matches = array();
preg_match('/rv:(.+)\\)/', $strUserAgent, $matches);
if ($matches) {
QApplication::$BrowserVersion = (double) $matches[1];
}
// FIREFOX
} else {
if (strpos($strUserAgent, 'firefox') !== false || strpos($strUserAgent, 'iceweasel') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Firefox;
$strUserAgent = str_replace('iceweasel/', 'firefox/', $strUserAgent);
$matches = array();
preg_match('#firefox/(.+)#', $strUserAgent, $matches);
if ($matches) {
QApplication::$BrowserVersion = (double) $matches[1];
}
} elseif (strpos($strUserAgent, 'chrome') !== false) {
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Chrome;
// find major version number only
$matches = array();
preg_match('#chrome/(\\d+)#', $strUserAgent, $matches);
if ($matches) {
QApplication::$BrowserVersion = (int) $matches[1];
}
//.........这里部分代码省略.........
示例5: Initialize
/**
* This should be the first call to initialize all the static variables
* The application object also has static methods that are miscellaneous web
* development utilities, etc.
*
* @return void
*/
public static function Initialize() {
// Are we running as CLI?
if (PHP_SAPI == 'cli')
QApplication::$CliMode = true;
else
QApplication::$CliMode = false;
// Setup Server Address
if (array_key_exists('LOCAL_ADDR', $_SERVER))
QApplication::$ServerAddress = $_SERVER['LOCAL_ADDR'];
else if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER))
QApplication::$ServerAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if (array_key_exists('SERVER_ADDR', $_SERVER))
QApplication::$ServerAddress = $_SERVER['SERVER_ADDR'];
// Setup ScriptFilename and ScriptName
QApplication::$ScriptFilename = $_SERVER['SCRIPT_FILENAME'];
QApplication::$ScriptName = $_SERVER['SCRIPT_NAME'];
// Ensure both are set, or we'll have to abort
if ((!QApplication::$ScriptFilename) || (!QApplication::$ScriptName)) {
throw new Exception('Error on QApplication::Initialize() - ScriptFilename or ScriptName was not set');
}
// Setup PathInfo and QueryString (if applicable)
QApplication::$PathInfo = array_key_exists('PATH_INFO', $_SERVER) ? trim($_SERVER['PATH_INFO']) : null;
QApplication::$QueryString = array_key_exists('QUERY_STRING', $_SERVER) ? $_SERVER['QUERY_STRING'] : null;
// Setup RequestUri
if (defined('__URL_REWRITE__')) {
switch (strtolower(__URL_REWRITE__)) {
case 'apache':
QApplication::$RequestUri = $_SERVER['REQUEST_URI'];
break;
case 'none':
QApplication::$RequestUri = sprintf('%s%s%s',
QApplication::$ScriptName, QApplication::$PathInfo,
(QApplication::$QueryString) ? sprintf('?%s', QApplication::$QueryString) : null);
break;
default:
throw new Exception('Invalid URL Rewrite type: ' . __URL_REWRITE__);
}
} else {
QApplication::$RequestUri = sprintf('%s%s%s',
QApplication::$ScriptName, QApplication::$PathInfo,
(QApplication::$QueryString) ? sprintf('?%s', QApplication::$QueryString) : null);
}
// Setup DocumentRoot
QApplication::$DocumentRoot = trim(__DOCROOT__);
// Setup Browser Type
if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
$strUserAgent = trim(strtolower($_SERVER['HTTP_USER_AGENT']));
// INTERNET EXPLORER (supporting versions 6.0 and 7.0)
if (strpos($strUserAgent, 'msie') !== false) {
QApplication::$BrowserType = QBrowserType::InternetExplorer;
if (strpos($strUserAgent, 'msie 6.0') !== false)
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::InternetExplorer_6_0;
else if (strpos($strUserAgent, 'msie 7.0') !== false)
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::InternetExplorer_7_0;
else
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Unsupported;
// FIREFOX (supporting versions 1.0, 1.5 and 2.0)
} else if ((strpos($strUserAgent, 'firefox') !== false) || (strpos($strUserAgent, 'iceweasel') !== false)) {
QApplication::$BrowserType = QBrowserType::Firefox;
$strUserAgent = str_replace('iceweasel/', 'firefox/', $strUserAgent);
if (strpos($strUserAgent, 'firefox/1.0') !== false)
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Firefox_1_0;
else if (strpos($strUserAgent, 'firefox/1.5') !== false)
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Firefox_1_5;
else if (strpos($strUserAgent, 'firefox/2.0') !== false)
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Firefox_2_0;
else
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Unsupported;
// SAFARI (supporting version 2.0 and eventually 3.0)
} else if (strpos($strUserAgent, 'safari') !== false) {
QApplication::$BrowserType = QBrowserType::Safari;
if (strpos($strUserAgent, 'safari/41') !== false)
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Safari_2_0;
else if (strpos($strUserAgent, 'safari/52') !== false)
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Safari_3_0;
else
QApplication::$BrowserType = QApplication::$BrowserType | QBrowserType::Unsupported;
//.........这里部分代码省略.........