本文整理汇总了PHP中eZSys::hostname方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSys::hostname方法的具体用法?PHP eZSys::hostname怎么用?PHP eZSys::hostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSys
的用法示例。
在下文中一共展示了eZSys::hostname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extension_path
/**
* Loose extension path function for include use originally from ezextension.php
*
* @deprecated Since 4.3
*/
function extension_path($extension, $withWWWDir = false, $withHost = false, $withProtocol = false)
{
$base = eZExtension::baseDirectory();
$path = '';
if ($withProtocol) {
if (is_string($withProtocol)) {
$path .= $withProtocol;
} else {
$path .= eZSys::serverProtocol();
}
$path .= ':';
}
if ($withHost) {
$path .= '//';
if (is_string($withHost)) {
$path .= $withHost;
} else {
$path .= eZSys::hostname();
}
}
if ($withWWWDir) {
$path .= eZSys::wwwDir();
}
if ($withWWWDir) {
$path .= '/' . $base . '/' . $extension;
} else {
$path .= $base . '/' . $extension;
}
return $path;
}
示例2: reCAPTCHAValidate
static function reCAPTCHAValidate($http)
{
// check if the current user is able to bypass filling in the captcha and
// return true without checking if so
$currentUser = eZUser::currentUser();
$accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
if ($accessAllowed["accessWord"] == 'yes') {
return true;
}
$ini = eZINI::instance('recaptcha.ini');
// If PrivateKey is an array try and find a match for the current host
$privatekey = $ini->variable('Keys', 'PrivateKey');
if (is_array($privatekey)) {
$hostname = eZSys::hostname();
if (isset($privatekey[$hostname])) {
$privatekey = $privatekey[$hostname];
} else {
// try our luck with the first entry
$privatekey = array_shift($privatekey);
}
}
$recaptcha_challenge_field = $http->postVariable('recaptcha_challenge_field');
$recaptcha_response_field = $http->postVariable('recaptcha_response_field');
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
return $resp->is_valid;
}
示例3: modify
function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
switch ($operatorName) {
case 'recaptcha_get_html':
include_once 'extension/recaptcha/classes/recaptchalib.php';
// Retrieve the reCAPTCHA public key from the ini file
$ini = eZINI::instance('recaptcha.ini');
$key = $ini->variable('Keys', 'PublicKey');
if (is_array($key)) {
$hostname = eZSys::hostname();
if (isset($key[$hostname])) {
$key = $key[$hostname];
} else {
// try our luck with the first entry
$key = array_shift($key);
}
}
// check if the current user is able to bypass filling in the captcha and
// return nothing so that no captcha is displayed
$currentUser = eZUser::currentUser();
$accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
if ($accessAllowed["accessWord"] == 'yes') {
$operatorValue = 'User bypasses CAPTCHA';
} else {
// Run the HTML generation code from the reCAPTCHA PHP library
$operatorValue = recaptcha_get_html($key);
}
break;
}
}
示例4: sendConfirmation
function sendConfirmation()
{
if ($this->attribute('status') != eZSubscription::StatusPending) {
return;
}
$res = eZTemplateDesignResource::instance();
$ini = eZINI::instance();
$hostname = eZSys::hostname();
$template = 'design:eznewsletter/sendout/registration.tpl';
$tpl = eZNewsletterTemplateWrapper::templateInit();
$tpl->setVariable('userData', eZUserSubscriptionData::fetch($this->attribute('email')));
$tpl->setVariable('hostname', $hostname);
$tpl->setVariable('subscription', $this);
$tpl->setVariable('subscriptionList', $this->attribute('subscription_list'));
$templateResult = $tpl->fetch($template);
if ($tpl->hasVariable('subject')) {
$subject = $tpl->variable('subject');
}
$mail = new eZMail();
$mail->setSender($ini->variable('MailSettings', 'EmailSender'), $ini->variable('SiteSettings', 'SiteName'));
$mail->setReceiver($this->attribute('email'));
$mail->setBody($templateResult);
$mail->setSubject($subject);
eZMailTransport::send($mail);
}
示例5: __construct
public function __construct(array $settings = array())
{
$this->settings = $settings + array('use-cache-headers' => true, 'max-age' => 86400, 'siteaccess' => null, 'use-exceptions' => false);
unset($settings);
require_once __DIR__ . '/treemenu_functions.php';
$this->setUseExceptions($this->settings['use-exceptions']);
header('X-Powered-By: ' . eZPublishSDK::EDITION . ' (index_treemenu)');
if ($this->settings['use-cache-headers'] === true) {
define('MAX_AGE', $this->settings['max-age']);
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + MAX_AGE) . ' GMT');
header('Cache-Control: max-age=' . MAX_AGE);
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) . ' GMT');
header('Pragma: ');
exit;
}
}
// Tweaks ini filetime checks if not defined!
// This makes ini system not check modified time so
// that index_treemenu.php can assume that index.php does
// this regular enough, set in config.php to override.
if (!defined('EZP_INI_FILEMTIME_CHECK')) {
define('EZP_INI_FILEMTIME_CHECK', false);
}
eZExecution::addFatalErrorHandler(function () {
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
});
eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
// Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs):
$_SERVER['SCRIPT_FILENAME'] = str_replace('/index_treemenu.php', '/index.php', $_SERVER['SCRIPT_FILENAME']);
$_SERVER['PHP_SELF'] = str_replace('/index_treemenu.php', '/index.php', $_SERVER['PHP_SELF']);
$ini = eZINI::instance();
$timezone = $ini->variable('TimeZoneSettings', 'TimeZone');
if ($timezone) {
putenv("TZ={$timezone}");
}
// init uri code
$GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
$this->uri = eZURI::instance(eZSys::requestURI());
$GLOBALS['eZRequestedURI'] = $this->uri;
// Check for extension
eZExtension::activateExtensions('default');
// load siteaccess
// Use injected siteaccess if available or match it internally.
$this->access = isset($this->settings['siteaccess']) ? $this->settings['siteaccess'] : eZSiteAccess::match($this->uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
eZSiteAccess::change($this->access);
// Check for new extension loaded by siteaccess
eZExtension::activateExtensions('access');
}
示例6: getReCapturePrivateKey
/**
* Returns the PrivateKey associated with the current host.
*
* @access public
* @return string
*/
static function getReCapturePrivateKey()
{
$privatekey = '';
$ini = eZINI::instance('recaptcha.ini');
// If PrivateKey is an array try and find a match for the current host
$privateKeyIni = $ini->variable('Keys', 'PrivateKey');
if (is_array($privateKeyIni)) {
$hostname = eZSys::hostname();
if (isset($privateKeyIni[$hostname])) {
$privatekey = $privateKeyIni[$hostname];
} else {
// try our luck with the first entry
$privatekey = array_shift($privateKeyIni);
}
} else {
$privatekey = $privateKeyIni;
}
return $privatekey;
}
示例7: execute
function execute($process, $event)
{
$parameterList = $process->attribute('parameter_list');
$nodeID = $parameterList['node_id'];
$userID = $parameterList['user_id'];
$languageCode = $parameterList['language_code'];
$ini = eZINI::instance('ocoperatorscollection.ini');
foreach ($ini->variable('Redirect', 'ExcludeReferers') as $exclude) {
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $exclude) !== false) {
return eZWorkflowType::STATUS_ACCEPTED;
}
}
$node = eZContentObjectTreeNode::fetch($nodeID);
if (!$node) {
return eZWorkflowType::STATUS_ACCEPTED;
}
$http = eZHTTPTool::instance();
$http->setSessionVariable("RedirectAfterLogin", 'content/view/full/' . $nodeID);
$identifiers = $ini->hasVariable('Subsite', 'Classes') ? $ini->variable('Subsite', 'Classes') : array();
if (in_array($node->attribute('class_identifier'), $identifiers)) {
$dataMap = $node->attribute('data_map');
if (isset($dataMap['link']) && $dataMap['link']->hasContent()) {
if ($dataMap['link']->Content() !== "http://" . eZSys::hostname() . '/') {
header('Location: ' . $dataMap['link']->Content());
}
}
}
$path = $node->attribute('path');
foreach ($path as $item) {
if (in_array($item->attribute('class_identifier'), $identifiers)) {
$dataMap = $item->attribute('data_map');
if (isset($dataMap['link']) && $dataMap['link']->hasContent()) {
if ($dataMap['link']->Content() !== "http://" . eZSys::hostname() . '/') {
header('Location: ' . $dataMap['link']->Content() . 'content/view/full/' . $nodeID);
}
}
}
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例8: putenv
putenv("TZ={$timezone}");
}
// init uri code
$GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
$uri = eZURI::instance(eZSys::requestURI());
$GLOBALS['eZRequestedURI'] = $uri;
// Check for extension
eZExtension::activateExtensions('default');
// load siteaccess
if (method_exists('eZSiteAccess', 'match') && method_exists('eZSiteAccess', 'change')) {
$access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
$access = eZSiteAccess::change($access);
} else {
include_once 'access.php';
$access = accessType($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
$access = changeAccess($access);
}
$GLOBALS['eZCurrentAccess'] = $access;
// Check for new extension loaded by siteaccess
eZExtension::activateExtensions('access');
$db = eZDB::instance();
if ($db->isConnected()) {
eZSession::start();
} else {
exitWithInternalError();
return;
}
$moduleINI = eZINI::instance('module.ini');
$globalModuleRepositories = $moduleINI->variable('ModuleSettings', 'ModuleRepositories');
$globalModuleRepositories[] = 'extension/eztags/modules';
示例9: getOutput
/**
* Generate text html of a output for preview and sending email
*
* @see classes/cjwnewslettermail.php getAllOutputFormatTextByContentObjectVersion()
* @see modules/newsletter/preview.php
* @param unknown_type $editionContentObjectId
* @param unknown_type $versionId
* @param unknown_type $outputFormat
* @param string $siteAccess
* @param string $skinName
* @param int $forceImageIncludeSettings -1 - use default settings
* 1 - force do not render all img to file://settings from newsletterContentArray['html_mail_image_include'] will be used
* 0 - force renders all img to file://
* @return array
*/
static function getOutput($editionContentObjectId, $versionId, $outputFormat, $siteAccess, $skinName = 'default', $forceSettingImageIncludeTo = -1)
{
if ($skinName == '') {
$skinName = 'default';
}
$cjwNewsletterIni = eZINI::instance('cjw_newsletter.ini');
$phpCli = $cjwNewsletterIni->variable('NewsletterSettings', 'PhpCli');
$currentHostName = eZSys::hostname();
$wwwDir = eZSys::wwwDir();
//$wwwDir = 'tmp';
$wwwDirString = '';
if ($wwwDir != '') {
$wwwDirString = "--www_dir={$wwwDir} ";
}
$cmd = "\"{$phpCli}\" extension/cjw_newsletter/bin/php/createoutput.php --object_id={$editionContentObjectId} --object_version={$versionId} --output_format_id={$outputFormat} {$wwwDirString}--current_hostname={$currentHostName} --skin_name={$skinName} -s {$siteAccess}";
$fileSep = eZSys::fileSeparator();
$cmd = str_replace('/', $fileSep, $cmd);
eZDebug::writeDebug("shell_exec( {$cmd} )", 'newsletter/preview');
// echo "<hr>$cmd<hr>";
$returnValue = shell_exec(escapeshellcmd($cmd));
$newsletterContentArray = unserialize(trim($returnValue));
if (CjwNewsletterEdition::imageIncludeIsEnabled()) {
$htmlMailImageInclude = 1;
}
// forpreview
$imageInclude = false;
// render file:// if we want to force it
// or use setting from $newsletterContentArray['html_mail_image_include']
if ($forceSettingImageIncludeTo === -1 && $newsletterContentArray['html_mail_image_include'] === 1) {
$imageInclude = true;
} elseif ($forceSettingImageIncludeTo === 1) {
$imageInclude = true;
} elseif ($forceSettingImageIncludeTo === 0) {
// $imageInclude = false;
}
if ($imageInclude === true) {
$newsletterContentArray = CjwNewsletterEdition::prepareImageInclude($newsletterContentArray);
}
return $newsletterContentArray;
}
示例10: redirectTo
/**
* Sets the module to redirect at the end of the execution
*
* @param string $uri the URI to redirect to
*
* @see setRedirectURI(), setExitStatus()
*
* @return void
*/
function redirectTo($uri)
{
$originalURI = $uri;
$uri = preg_replace("#(^.*)(/+)\$#", "\$1", $uri);
if (strlen($originalURI) != 0 and strlen($uri) == 0) {
$uri = '/';
}
$urlComponents = parse_url($uri);
// eZSys::hostname() can contain port if present.
// So parsing it with parse_url() as well to only get host.
$currentHostname = eZSys::hostname();
$currentHostnameParsed = parse_url($currentHostname, PHP_URL_HOST);
$currentHostname = $currentHostnameParsed ? $currentHostnameParsed : $currentHostname;
if (isset($urlComponents['host']) && $urlComponents['host'] !== $currentHostname) {
$allowedHosts = $this->getAllowedRedirectHosts();
if (!isset($allowedHosts[$urlComponents['host']])) {
// Non-authorized host, return only the URI (without host) + query string and fragment if present.
eZDebug::writeError("Redirection requested on non-authorized host '{$urlComponents['host']}'");
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
echo "Redirection requested on non-authorized host";
eZDB::checkTransactionCounter();
eZExecution::cleanExit();
}
}
$this->RedirectURI = $uri;
$this->setExitStatus(self::STATUS_REDIRECT);
}
示例11: createSiteaccessUrls
function createSiteaccessUrls( $params )
{
$urlList = array();
$siteaccessList = $params['siteaccess_list'];
$accessType = $params['access_type'];
$accessTypeValue = $params['access_type_value'];
$excludePortList = isset( $params['exclude_port_list'] ) ? $params['exclude_port_list'] : array();
$hostname = false;
if ( isset( $params['host'] ) && $params['host'] !== '' )
$hostname = $this->extractHostname( $params['host'] );
if ( !$hostname )
$hostname = eZSys::hostname();
$indexFile = eZSys::wwwDir() . eZSys::indexFileName();
switch( $accessType )
{
case 'port':
{
$port = $accessTypeValue;
// build urls
foreach( $siteaccessList as $siteaccess )
{
// skip ports which are already in use
while( in_array( $port, $excludePortList ) )
++$port;
$urlList[$siteaccess]['url'] = "$hostname:$port" . $indexFile;
$urlList[$siteaccess]['port'] = $port;
++$port;
}
}
break;
case 'host':
case 'hostname':
{
$prependSiteAccess = isset( $params['host_prepend_siteaccess'] ) && is_bool( $params['host_prepend_siteaccess'] ) ? $params['host_prepend_siteaccess'] : true;
$hostname = $this->extractHostname( $accessTypeValue );
if ( !$hostname )
$hostname = $accessTypeValue;
foreach( $siteaccessList as $siteaccess )
{
if ( $prependSiteAccess )
{
// replace undescores with dashes( '_' -> '-' );
$hostPrefix = preg_replace( '/(_)/', '-', $siteaccess);
// create url and host
$urlList[$siteaccess]['url'] = $hostPrefix . '.' . $hostname . $indexFile;
$urlList[$siteaccess]['host'] = $hostPrefix . '.' . $hostname;
}
else
{
// create url and host
$urlList[$siteaccess]['url'] = $hostname . $indexFile;
$urlList[$siteaccess]['host'] = $hostname;
}
}
}
break;
case 'url':
case 'uri':
{
foreach( $siteaccessList as $siteaccess )
{
$urlList[$siteaccess]['url'] = $hostname . $indexFile . '/' . $siteaccess;
}
}
break;
default:
break;
}
return $urlList;
}
示例12: createRedirectUrl
static function createRedirectUrl( $path, $parameters = array() )
{
$parameters = array_merge( array( 'host' => false,
'protocol' => false,
'port' => false,
'username' => false,
'password' => false,
'override_host' => false,
'override_protocol' => false,
'override_port' => false,
'override_username' => false,
'override_password' => false,
'pre_url' => true ),
$parameters );
$host = $parameters['host'];
$protocol = $parameters['protocol'];
$port = $parameters['port'];
$username = $parameters['username'];
$password = $parameters['password'];
if ( preg_match( '#^([a-zA-Z0-9]+):(.+)$#', $path, $matches ) )
{
if ( $matches[1] )
$protocol = $matches[1];
$path = $matches[2];
}
if ( preg_match( '#^//((([a-zA-Z0-9_.]+)(:([a-zA-Z0-9_.]+))?)@)?([^./:]+(\.[^./:]+)*)(:([0-9]+))?(.*)$#', $path, $matches ) )
{
if ( $matches[6] )
{
$host = $matches[6];
}
if ( $matches[3] )
$username = $matches[3];
if ( $matches[5] )
$password = $matches[5];
if ( $matches[9] )
$port = $matches[9];
$path = $matches[10];
}
if ( $parameters['pre_url'] )
{
if ( strlen( $path ) > 0 and
$path[0] != '/' )
{
$preURL = eZSys::serverVariable( 'SCRIPT_URL' );
if ( strlen( $preURL ) > 0 and
$preURL[strlen($preURL) - 1] != '/' )
$preURL .= '/';
$path = $preURL . $path;
}
}
if ( $parameters['override_host'] )
$host = $parameters['override_host'];
if ( $parameters['override_port'] )
$port = $parameters['override_port'];
if ( !is_string( $host ) )
$host = eZSys::hostname();
if ( !is_string( $protocol ) )
{
$protocol = eZSys::serverProtocol();
// Default to https if SSL is enabled
if ( eZSys::isSSLNow() )
{
$port = false;
}
}
if ( $parameters['override_protocol'] )
$protocol = $parameters['override_protocol'];
$uri = $protocol . '://';
if ( $parameters['override_username'] )
$username = $parameters['override_username'];
if ( $parameters['override_password'] )
$password = $parameters['override_password'];
if ( $username )
{
$uri .= $username;
if ( $password )
$uri .= ':' . $password;
$uri .= '@';
}
$uri .= $host;
if ( $port )
$uri .= ':' . $port;
$uri .= $path;
return $uri;
}
示例13: getServerURL
public static function getServerURL()
{
if ( self::$serverURL === null )
{
$oeini = eZINI::instance( 'ezoe.ini' );
if ( $oeini->hasVariable( 'SystemSettings', 'RelativeURL' ) &&
$oeini->variable( 'SystemSettings', 'RelativeURL' ) === 'enabled' )
{
self::$serverURL = eZSys::wwwDir();
if ( self::$serverURL === '/' )
self::$serverURL = '';
}
else
{
$domain = eZSys::hostname();
$protocol = 'http';
// Default to https if SSL is enabled
// Check if SSL port is defined in site.ini
$sslPort = 443;
$ini = eZINI::instance();
if ( $ini->hasVariable( 'SiteSettings', 'SSLPort' ) )
$sslPort = $ini->variable( 'SiteSettings', 'SSLPort' );
if ( eZSys::serverPort() == $sslPort )
$protocol = 'https';
self::$serverURL = $protocol . '://' . $domain . eZSys::wwwDir();
}
}
return self::$serverURL;
}
示例14: __construct
/**
* Constructs an ezpKernel instance
*/
public function __construct(array $settings = array())
{
if (isset($settings['injected-settings'])) {
$injectedSettings = array();
foreach ($settings['injected-settings'] as $keySetting => $injectedSetting) {
list($file, $section, $setting) = explode('/', $keySetting);
$injectedSettings[$file][$section][$setting] = $injectedSetting;
}
// Those settings override anything else in local .ini files and their overrides
eZINI::injectSettings($injectedSettings);
}
if (isset($settings['injected-merge-settings'])) {
$injectedSettings = array();
foreach ($settings['injected-merge-settings'] as $keySetting => $injectedSetting) {
list($file, $section, $setting) = explode('/', $keySetting);
$injectedSettings[$file][$section][$setting] = $injectedSetting;
}
// Those settings override anything else in local .ini files and their overrides
eZINI::injectMergeSettings($injectedSettings);
}
$this->settings = $settings + array('siteaccess' => null, 'use-exceptions' => false, 'session' => null, 'service-container' => null);
unset($settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting);
require_once __DIR__ . '/global_functions.php';
$this->setUseExceptions($this->settings['use-exceptions']);
$GLOBALS['eZSiteBasics'] = array('external-css' => true, 'show-page-layout' => true, 'module-run-required' => true, 'policy-check-required' => true, 'policy-check-omit-list' => array(), 'url-translator-allowed' => true, 'validity-check-required' => false, 'user-object-required' => true, 'session-required' => true, 'db-required' => false, 'no-cache-adviced' => false, 'site-design-override' => false, 'module-repositories' => array());
$this->siteBasics =& $GLOBALS['eZSiteBasics'];
// Reads settings from i18n.ini and passes them to eZTextCodec.
list($i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension']) = eZINI::instance('i18n.ini')->variableMulti('CharacterSettings', array('Charset', 'HTTPCharset', 'MBStringExtension'), array(false, false, 'enabled'));
eZTextCodec::updateSettings($i18nSettings);
// @todo Change so code only supports utf-8 in 5.0?
// Initialize debug settings.
eZUpdateDebugSettings();
// Set the different permissions/settings.
$ini = eZINI::instance();
// Set correct site timezone
$timezone = $ini->variable("TimeZoneSettings", "TimeZone");
if ($timezone) {
date_default_timezone_set($timezone);
}
list($iniFilePermission, $iniDirPermission) = $ini->variableMulti('FileSettings', array('StorageFilePermissions', 'StorageDirPermissions'));
// OPTIMIZATION:
// Sets permission array as global variable, this avoids the eZCodePage include
$GLOBALS['EZCODEPAGEPERMISSIONS'] = array('file_permission' => octdec($iniFilePermission), 'dir_permission' => octdec($iniDirPermission), 'var_directory' => eZSys::cacheDirectory());
unset($i18nSettings, $timezone, $iniFilePermission, $iniDirPermission);
eZExecution::addCleanupHandler(function () {
if (class_exists('eZDB', false) && eZDB::hasInstance()) {
eZDB::instance()->setIsSQLOutputEnabled(false);
}
});
// Sets up the FatalErrorHandler
$this->setupFatalErrorHandler();
// Enable this line to get eZINI debug output
// eZINI::setIsDebugEnabled( true );
// Enable this line to turn off ini caching
// eZINI::setIsCacheEnabled( false);
if ($ini->variable('RegionalSettings', 'Debug') === 'enabled') {
eZLocale::setIsDebugEnabled(true);
}
eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
$GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
// Initialize basic settings, such as vhless dirs and separators
if ($this->hasServiceContainer() && $this->getServiceContainer()->has('request')) {
eZSys::init(basename($this->getServiceContainer()->get('request')->server->get('SCRIPT_FILENAME')), $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
} else {
eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
}
// Check for extension
eZExtension::activateExtensions('default');
// Extension check end
// Use injected siteaccess if available or match it internally.
$this->access = isset($this->settings['siteaccess']) ? $this->settings['siteaccess'] : eZSiteAccess::match(eZURI::instance(eZSys::requestURI()), eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
eZSiteAccess::change($this->access);
eZDebugSetting::writeDebug('kernel-siteaccess', $this->access, 'current siteaccess');
// Check for siteaccess extension
eZExtension::activateExtensions('access');
// Siteaccess extension check end
// Now that all extensions are activated and siteaccess has been changed, reset
// all eZINI instances as they may not take into account siteaccess specific settings.
eZINI::resetAllInstances(false);
ezpEvent::getInstance()->registerEventListeners();
$this->mobileDeviceDetect = new ezpMobileDeviceDetect(ezpMobileDeviceDetectFilter::getFilter());
// eZSession::setSessionArray( $mainRequest->session );
}
示例15: __construct
/**
* @param array $settings
* @param null $responseWriterClass Name of the ezpRestHttpResponseWriter implementation to use during request
*/
public function __construct(array $settings = array(), $responseWriterClass = null)
{
$this->responseWriterClass = $responseWriterClass;
if (isset($settings['injected-settings'])) {
$injectedSettings = array();
foreach ($settings['injected-settings'] as $keySetting => $injectedSetting) {
list($file, $section, $setting) = explode('/', $keySetting);
$injectedSettings[$file][$section][$setting] = $injectedSetting;
}
// Those settings override anything else in local .ini files and their overrides
eZINI::injectSettings($injectedSettings);
}
if (isset($settings['injected-merge-settings'])) {
$injectedSettings = array();
foreach ($settings['injected-merge-settings'] as $keySetting => $injectedSetting) {
list($file, $section, $setting) = explode('/', $keySetting);
$injectedSettings[$file][$section][$setting] = $injectedSetting;
}
// Those settings override anything else in local .ini files and their overrides
eZINI::injectMergeSettings($injectedSettings);
}
$this->settings = $settings + array('use-cache-headers' => true, 'max-age' => 86400, 'siteaccess' => null, 'use-exceptions' => false);
unset($settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting);
// lazy loaded database driver
include __DIR__ . '/lazy.php';
$this->setUseExceptions($this->settings['use-exceptions']);
// Tweaks ini filetime checks if not defined!
// This makes ini system not check modified time so
// that index_treemenu.php can assume that index.php does
// this regular enough, set in config.php to override.
if (!defined('EZP_INI_FILEMTIME_CHECK')) {
define('EZP_INI_FILEMTIME_CHECK', false);
}
eZExecution::addFatalErrorHandler(function () {
if (!headers_sent()) {
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
}
});
eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
// Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs):
$_SERVER['SCRIPT_FILENAME'] = str_replace('/index_rest.php', '/index.php', $_SERVER['SCRIPT_FILENAME']);
$_SERVER['PHP_SELF'] = str_replace('/index_rest.php', '/index.php', $_SERVER['PHP_SELF']);
$ini = eZINI::instance();
$timezone = $ini->variable('TimeZoneSettings', 'TimeZone');
if ($timezone) {
putenv("TZ={$timezone}");
}
eZDebug::setHandleType(eZDebug::HANDLE_NONE);
$GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
$ini = eZINI::instance();
eZSys::init('index_rest.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') == 'true');
$uri = eZURI::instance(eZSys::requestURI());
$GLOBALS['eZRequestedURI'] = $uri;
// load extensions
eZExtension::activateExtensions('default');
require_once __DIR__ . '/restkernel_functions.php';
// set siteaccess from X-Siteaccess header if given and exists
if (isset($_SERVER['HTTP_X_SITEACCESS']) && eZSiteAccess::exists($_SERVER['HTTP_X_SITEACCESS'])) {
$access = array('name' => $_SERVER['HTTP_X_SITEACCESS'], 'type' => eZSiteAccess::TYPE_STATIC);
} else {
$access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
}
eZSiteAccess::change($access);
// load siteaccess extensions
eZExtension::activateExtensions('access');
// Now that all extensions are activated and siteaccess has been changed, reset
// all eZINI instances as they may not take into account siteaccess specific settings.
eZINI::resetAllInstances(false);
if (ezpRestDebug::isDebugEnabled()) {
$debug = ezpRestDebug::getInstance();
$debug->updateDebugSettings();
}
}