/** * 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; }
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; }
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; } }
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); }
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'); }
/** * 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; }
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; }
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';
/** * 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; }
/** * 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); }
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; }
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; }
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; }
/** * 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 ); }
/** * @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(); } }
function fetchImageURL() { $imageNode = $this->attribute( 'image_node' ); if ( !$imageNode ) return false; $imageObject = $imageNode->attribute( 'object' ); if ( !$imageObject ) return false; $dataMap = $imageObject->attribute( 'data_map' ); if ( !$dataMap ) return false; $imageAttribute = $dataMap['image']; if ( !$imageAttribute ) return false; $imageHandler = $imageAttribute->attribute( 'content' ); if ( !$imageHandler ) return false; $imageAlias = $imageHandler->imageAlias( 'rss' ); if( !$imageAlias ) return false; $url = eZSys::hostname() . eZSys::wwwDir() .'/'. $imageAlias['url']; $url = preg_replace( "#^(//)#", "/", $url ); return 'http://'.$url; }
$_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'); $uri = eZURI::instance(eZSys::requestURI()); $GLOBALS['eZRequestedURI'] = $uri; // Check for extension eZExtension::activateExtensions('default'); // load siteaccess $access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile()); $access = eZSiteAccess::change($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'); eZModule::setGlobalPathList($globalModuleRepositories); $module = eZModule::exists('content');
/** * This function is only a helpfunction * * @param $mailTemplate * @return unknown_type */ function sendSubcriptionMail($mailTemplate) { $tplResource = eZTemplateDesignResource::instance(); $ini = eZINI::instance('site.ini'); $cjwNewsletterIni = eZINI::instance('cjw_newsletter.ini'); $hostName = eZSys::hostname(); // $template = 'design:newsletter/mail/subscription_confirmation.tpl'; $template = $mailTemplate; $newsletterUser = $this; include_once 'kernel/common/template.php'; $tpl = templateInit(); $tpl->setVariable('newsletter_user', $newsletterUser); $tpl->setVariable('hostname', $hostName); $templateResult = $tpl->fetch($template); // get subject from template var definition if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } $emailSender = $cjwNewsletterIni->variable('NewsletterMailSettings', 'EmailSender'); $emailSenderName = $cjwNewsletterIni->variable('NewsletterMailSettings', 'EmailSenderName'); $emailReceiver = $newsletterUser->attribute('email'); $emailReplyTo = $cjwNewsletterIni->variable('NewsletterMailSettings', 'EmailReplyTo'); $emailReturnPath = $cjwNewsletterIni->variable('NewsletterMailSettings', 'EmailReturnPath'); // TODO Namen extrahieren $emailReceiverName = ''; $emailSubject = $subject; $emailBody['text'] = $templateResult; $cjwMail = new CjwNewsletterMail(); // x header set for current user $cjwMail->setExtraMailHeadersByNewsletterUser($this); $cjwMail->setTransportMethodDirectlyFromIni(); // trigger_error("test error", E_USER_ERROR); $sendResult = $cjwMail->sendEmail($emailSender, $emailSenderName, $emailReceiver, $emailReceiverName, $emailSubject, $emailBody, false, 'utf-8', $emailReplyTo, $emailReturnPath); return $sendResult; }
/** * 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 ); if ( isset( $urlComponents['host'] ) && $urlComponents['host'] !== eZSys::hostname() ) { $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( eZModule::STATUS_REDIRECT ); }
function sendConfirmation($email, $subscription, $subscribe) { //send mail $res = eZTemplateDesignResource::instance(); $ini = eZINI::instance(); $hostname = eZSys::hostname(); if ($subscribe) { $template = 'design:eznewsletter/sendout/subscription.tpl'; } else { $template = 'design:eznewsletter/sendout/unsubscription.tpl'; } $tpl = eZNewsletterTemplateWrapper::templateInit(); $tpl->setVariable('userData', eZUserSubscriptionData::fetch($email)); $tpl->setVariable('hostname', $hostname); $tpl->setVariable('subscription', $subscription); $subscriptionList = eZSubscriptionList::fetch($subscription->attribute('subscriptionlist_id'), eZSubscriptionList::StatusPublished, true, true); $tpl->setVariable('subscriptionList', $subscriptionList); $templateResult = $tpl->fetch($template); if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } $mail = new eZMail(); $mail->setSender($ini->variable('MailSettings', 'EmailSender')); $mail->setReceiver($email); $mail->setBody($templateResult); $mail->setSubject($subject); eZMailTransport::send($mail); }
/** * Processes user activation * * @param eZUser $user * @param string $password */ public static function processUserActivation($user, $password) { $ini = eZINI::instance(); $tpl = eZTemplate::factory(); $tpl->setVariable('user', $user); $tpl->setVariable('object', $user->contentObject()); $tpl->setVariable('hostname', eZSys::hostname()); $tpl->setVariable('password', $password); // Check whether account activation is required. $verifyUserType = $ini->variable('UserSettings', 'VerifyUserType'); $sendUserMail = !!$verifyUserType; // For compatibility with old setting if ($verifyUserType === 'email' && $ini->hasVariable('UserSettings', 'VerifyUserEmail') && $ini->variable('UserSettings', 'VerifyUserEmail') !== 'enabled') { $verifyUserType = false; } if ($verifyUserType === 'email') { // Disable user account and send verification mail to the user $userID = $user->attribute('contentobject_id'); // Create enable account hash and send it to the newly registered user $hash = md5(mt_rand() . time() . $userID); if (eZOperationHandler::operationIsAvailable('user_activation')) { eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => false)); } else { eZUserOperationCollection::activation($userID, $hash, false); } // Log out current user eZUser::logoutCurrent(); $tpl->setVariable('hash', $hash); $sendUserMail = true; } else { if ($verifyUserType) { $verifyUserTypeClass = false; // load custom verify user settings if ($ini->hasGroup('VerifyUserType_' . $verifyUserType)) { if ($ini->hasVariable('VerifyUserType_' . $verifyUserType, 'File')) { include_once $ini->variable('VerifyUserType_' . $verifyUserType, 'File'); } $verifyUserTypeClass = $ini->variable('VerifyUserType_' . $verifyUserType, 'Class'); } // try to call the verify user class with function verifyUser if ($verifyUserTypeClass && method_exists($verifyUserTypeClass, 'verifyUser')) { $sendUserMail = call_user_func(array($verifyUserTypeClass, 'verifyUser'), $user, $tpl); } else { eZDebug::writeWarning("Unknown VerifyUserType '{$verifyUserType}'", 'ngconnect/profile'); } } } // send verification mail to user if email type or custom verify user type returned true if ($sendUserMail) { $mail = new eZMail(); $templateResult = $tpl->fetch('design:user/registrationinfo.tpl'); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $emailSender = $ini->variable('MailSettings', 'EmailSender'); if ($tpl->hasVariable('email_sender')) { $emailSender = $tpl->variable('email_sender'); } else { if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } $mail->setSender($emailSender); if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } else { $subject = ezpI18n::tr('kernel/user/register', 'Registration info'); } $mail->setSubject($subject); $mail->setReceiver($user->attribute('email')); $mail->setBody($templateResult); eZMailTransport::send($mail); } }
return $Module->handleError(3, 'kernel'); } $sub = $NewsletterItem->userData(); $subscription = eZSubscription::fetch($NewsletterItem->attribute('subscription_id')); $tpl->setVariable('NewsletterItem', $NewsletterItem); $tpl->setVariable('UserHash', $Params['UserHash']); $tpl->setVariable('subscriptions', $subscription); if ($http->hasPostVariable('OKButton')) { $subscription->unsubscribe(); $siteini = eZINI::instance(); $sender = $siteini->variable('MailSettings', 'EmailSender'); $mail = new eZMail(); $mail->setReceiver($sub['email']); $mail->setSender($sender); $mail->setSubject(ezpI18n::tr('newsletteraddons', "Your subscription removal")); $hostName = eZSys::hostname(); $mailtpl = eZTemplate::instance(); $mailtpl->setVariable('hostname', $hostName); $mailtpl->setVariable('siteaccess', $GLOBALS['eZCurrentAccess']['name']); $mailtpl->setVariable('NewsletterItem', $NewsletterItem); $mailtext = $mailtpl->fetch('design:eznewsletter/unregister_subscription_email.tpl'); $mail->setBody($mailtext); eZMailTransport::send($mail); $Result = array(); $Result['content'] = $tpl->fetch("design:eznewsletter/unregister_subscription_success.tpl"); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('eznewsletter', 'Remove subscription'))); return; } if ($http->hasPostVariable('CancelButton')) { $ini = eZINI::instance(); return $Module->redirectTo($ini->variable('SiteSettings', 'DefaultPage'));
eZExecution::cleanExit(); } else { // Print the list of ID nodes.. //Structure : name, type, ID $nodes = eZFunctionHandler::execute('content', 'list', array('parent_node_id' => $parentNodeID)); $array = array(); foreach ($nodes as $node) { $tpl->setVariable('node', $node); $nodeID = $node->attribute('node_id'); $name = $node->attribute('name'); $className = $node->attribute('class_name'); $object =& $node->object(); $contentClass = $object->contentClass(); $isContainer = $contentClass->attribute('is_container'); preg_match('/\\/+[a-z0-9\\-\\._]+\\/?[a-z0-9_\\.\\-\\?\\+\\/~=&#;,]*[a-z0-9\\/]{1}/si', $tpl->fetch('design:ezodf/icon.tpl'), $matches); $iconPath = 'http://' . eZSys::hostname() . ':' . eZSys::serverPort() . $matches[0]; $array[] = array($nodeID, $name, $className, $isContainer, $iconPath); } //Test if not empty if (empty($array)) { print 'problem:No Items'; eZExecution::cleanExit(); } //Convert the array into a string and display it $display = ''; foreach ($array as $line) { foreach ($line as $element) { $display .= $element . ';'; } $display .= chr(13); }
static function serverPort() { if (empty($GLOBALS['eZSysServerPort'])) { $hostname = eZSys::hostname(); if (preg_match("/.*:([0-9]+)/", $hostname, $regs)) { $port = $regs[1]; } else { $port = eZSys::serverVariable('SERVER_PORT'); } $GLOBALS['eZSysServerPort'] = $port; } return $GLOBALS['eZSysServerPort']; }
function checkContentActions($module, $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage) { if ($module->isCurrentAction('Cancel')) { $http = eZHTTPTool::instance(); if ($http->hasPostVariable('RedirectIfDiscarded')) { eZRedirectManager::redirectTo($module, $http->postVariable('RedirectIfDiscarded')); } else { eZRedirectManager::redirectTo($module, '/'); } $version->removeThis(); $http = eZHTTPTool::instance(); $http->removeSessionVariable("RegisterUserID"); $http->removeSessionVariable('StartedRegistration'); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ($module->isCurrentAction('Publish')) { $userID = $object->attribute('id'); $operationResult = eZOperationHandler::execute('user', 'register', array('user_id' => $userID)); // send feedback $ini = eZINI::instance(); $tpl = eZTemplate::factory(); $hostname = eZSys::hostname(); $user = eZUser::fetch($userID); $feedbackTypes = $ini->variableArray('UserSettings', 'RegistrationFeedback'); foreach ($feedbackTypes as $feedbackType) { switch ($feedbackType) { case 'email': // send feedback with the default email type $mail = new eZMail(); $tpl->resetVariables(); $tpl->setVariable('user', $user); $tpl->setVariable('object', $object); $tpl->setVariable('hostname', $hostname); $templateResult = $tpl->fetch('design:user/registrationfeedback.tpl'); if ($tpl->hasVariable('content_type')) { $mail->setContentType($tpl->variable('content_type')); } $emailSender = $ini->variable('MailSettings', 'EmailSender'); if ($tpl->hasVariable('email_sender')) { $emailSender = $tpl->variable('email_sender'); } else { if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } $feedbackReceiver = $ini->variable('UserSettings', 'RegistrationEmail'); if ($tpl->hasVariable('email_receiver')) { $feedbackReceiver = $tpl->variable('email_receiver'); } else { if (!$feedbackReceiver) { $feedbackReceiver = $ini->variable('MailSettings', 'AdminEmail'); } } if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } else { $subject = ezpI18n::tr('kernel/user/register', 'New user registered'); } $mail->setSender($emailSender); $mail->setReceiver($feedbackReceiver); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); break; default: $registrationFeedbackClass = false; // load custom registration feedback settings if ($ini->hasGroup('RegistrationFeedback_' . $feedbackType)) { if ($ini->hasVariable('RegistrationFeedback_' . $feedbackType, 'File')) { include_once $ini->variable('RegistrationFeedback_' . $feedbackType, 'File'); } $registrationFeedbackClass = $ini->variable('RegistrationFeedback_' . $feedbackType, 'Class'); } // try to call the registration feedback class with function registrationFeedback if ($registrationFeedbackClass && method_exists($registrationFeedbackClass, 'registrationFeedback')) { call_user_func(array($registrationFeedbackClass, 'registrationFeedback'), $user, $tpl, $object, $hostname); } else { eZDebug::writeWarning("Unknown feedback type '{$feedbackType}'", 'user/register'); } } } $http = eZHTTPTool::instance(); $http->removeSessionVariable("GeneratedPassword"); $http->removeSessionVariable("RegisterUserID"); $http->removeSessionVariable('StartedRegistration'); // if everything is passed, login the user if ($operationResult['status'] === eZModuleOperationInfo::STATUS_CONTINUE) { $user->loginCurrent(); } // check for redirectionvariable if ($operationResult['status'] === eZModuleOperationInfo::STATUS_CONTINUE || $operationResult['status'] === eZModuleOperationInfo::STATUS_HALTED) { if ($http->hasSessionVariable('RedirectAfterUserRegister')) { $module->redirectTo($http->sessionVariable('RedirectAfterUserRegister')); $http->removeSessionVariable('RedirectAfterUserRegister'); } else { if ($http->hasPostVariable('RedirectAfterUserRegister')) { $module->redirectTo($http->postVariable('RedirectAfterUserRegister')); } else { $module->redirectTo('/user/success/'); } } } else { eZDebug::writeError('Unexpected operation status: ' . $operationResult['status'], 'user/register'); // @todo: finish the failure code $module->redirectTo('/user/register/5'); } } }
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 = eZSys::serverProtocol(); self::$serverURL = $protocol . '://' . $domain . eZSys::wwwDir(); } } return self::$serverURL; }
/** * Send activativation to the user * * If the user is enabled, igore */ public static function sendActivationEmail($userID) { eZDebugSetting::writeNotice('kernel-user', 'Sending activation email.', 'user register'); $ini = eZINI::instance(); $tpl = eZTemplate::factory(); $user = eZUser::fetch($userID); $tpl->setVariable('user', $user); $object = eZContentObject::fetch($userID); $tpl->setVariable('object', $object); $hostname = eZSys::hostname(); $tpl->setVariable('hostname', $hostname); // Check whether account activation is required. $verifyUserType = $ini->variable('UserSettings', 'VerifyUserType'); $sendUserMail = !!$verifyUserType; if ($verifyUserType === 'email') { // Disable user account and send verification mail to the user // Create enable account hash and send it to the newly registered user $hash = md5(mt_rand() . time() . $userID); if (eZOperationHandler::operationIsAvailable('user_activation')) { $operationResult = eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => false)); } else { eZUserOperationCollection::activation($userID, $hash, false); } $tpl->setVariable('hash', $hash); $sendUserMail = true; } else { if ($verifyUserType) { $verifyUserTypeClass = false; // load custom verify user settings if ($ini->hasGroup('VerifyUserType_' . $verifyUserType)) { if ($ini->hasVariable('VerifyUserType_' . $verifyUserType, 'File')) { include_once $ini->variable('VerifyUserType_' . $verifyUserType, 'File'); } $verifyUserTypeClass = $ini->variable('VerifyUserType_' . $verifyUserType, 'Class'); } // try to call the verify user class with function verifyUser $user = eZContentObject::fetch($userID); if ($verifyUserTypeClass && method_exists($verifyUserTypeClass, 'verifyUser')) { $sendUserMail = call_user_func(array($verifyUserTypeClass, 'verifyUser'), $user, $tpl); } else { eZDebug::writeWarning("Unknown VerifyUserType '{$verifyUserType}'", 'user/register'); } } } // send verification mail to user if email type or custum verify user type returned true if ($sendUserMail) { $templateResult = $tpl->fetch('design:user/registrationinfo.tpl'); if ($tpl->hasVariable('content_type')) { $contentType = $tpl->variable('content_type'); } else { $contentType = $ini->variable('MailSettings', 'ContentType'); } $emailSender = $ini->variable('MailSettings', 'EmailSender'); if ($tpl->hasVariable('email_sender')) { $emailSender = $tpl->variable('email_sender'); } else { if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } } if ($tpl->hasVariable('subject')) { $subject = $tpl->variable('subject'); } else { $subject = ezpI18n::tr('kernel/user/register', 'Registration info'); } $mail = new eZMail(); $mail->setSender($emailSender); $mail->setContentType($contentType); $user = eZUser::fetch($userID); $receiver = $user->attribute('email'); $mail->setReceiver($receiver); $mail->setSubject($subject); $mail->setBody($templateResult); $mailResult = eZMailTransport::send($mail); } return array('status' => eZModuleOperationInfo::STATUS_CONTINUE); }
/** * Constructs an ezpKernel instance */ public function __construct(array $settings = array()) { $this->settings = $settings + array('siteaccess' => null, 'use-exceptions' => false, 'session' => null); unset($settings); 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); } }); eZExecution::addFatalErrorHandler(function () { header("HTTP/1.1 500 Internal Server Error"); echo "<b>Fatal error</b>: The web server did not finish its request<br/>"; if (ini_get('display_errors') == 1) { if (eZDebug::isDebugEnabled()) { echo "<p>The execution of eZ Publish was abruptly ended, the debug output is present below.</p>"; } else { echo "<p>Debug information can be found in the log files normally placed in var/log/* or by enabling 'DebugOutput' in site.ini</p>"; } } else { echo "<p>Contact website owner with current url and info on what you did, and owner will be able to debug the issue further (by enabling 'display_errors' in php.ini).</p>"; } eZDisplayResult(null); }); eZExecution::setCleanExit(); // 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 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()); if ($this->mobileDeviceDetect->isEnabled()) { $this->mobileDeviceDetect->process(); if ($this->mobileDeviceDetect->isMobileDevice()) { $this->mobileDeviceDetect->redirect(); } } // eZSession::setSessionArray( $mainRequest->session ); /** * Check for activating Debug by user ID (Final checking. The first was in eZDebug::updateSettings()) * @uses eZUser::instance() So needs to be executed after eZSession::start()|lazyStart() */ eZDebug::checkDebugByUser(); }
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 $access = eZSiteAccess::match( $uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile() ); $access = eZSiteAccess::change( $access ); $GLOBALS['eZCurrentAccess'] = $access; // Check for new extension loaded by siteaccess eZExtension::activateExtensions( 'access' ); $db = eZDB::instance(); if ( $db->isConnected() ) { eZSession::start(); } else {
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 = 'http'; // Default to https if SSL is enabled // Check if SSL port is defined in site.ini $ini = eZINI::instance(); $sslPort = 443; if ($ini->hasVariable('SiteSettings', 'SSLPort')) { $sslPort = $ini->variable('SiteSettings', 'SSLPort'); } if (eZSys::serverPort() == $sslPort) { $protocol = 'https'; $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; }