function initialize() { $ini = eZINI::instance( 'xmlinstaller.ini' ); $extensionDirectoryList = array_unique( $ini->variable( 'XMLInstallerSettings', 'ExtensionDirectories' ) ); $handlerList = array_unique( $ini->variable( 'XMLInstallerSettings', 'XMLInstallerHandler' ) ); foreach( $extensionDirectoryList as $extensionDirectory ) { $handler = reset( $handlerList ); do { $fileName = eZExtension::baseDirectory() . '/' . $extensionDirectory . '/xmlinstallerhandler/' . $handler . '.php'; if ( file_exists( $fileName ) ) { include_once( $fileName ); $className = $handler; $info = call_user_func(array($className, 'handlerInfo')); if ( array_key_exists( 'XMLName', $info ) && array_key_exists( 'Info', $info ) ) { $this->HandlerList[$info['XMLName']] = array( 'Info' => $info['Info'], 'File' => $fileName, 'Class' => $className ); } unset($handlerList[key($handlerList)]); $handler = current( $handlerList ); } else { $handler = next( $handlerList ); } } while ( $handler ); } }
/** * Returns an ajaxuploader handler instance from the ezjscore function * arguments. * * @param array $args the arguments of the ezjscore ajax function * @return ezpAjaxUploaderHandlerInterface * * @throws InvalidArgumentException if the handler cannot be instanciated */ private static function getHandler( array $args ) { if ( !isset( $args[0] ) ) { throw new InvalidArgumentException( ezpI18n::tr( 'extension/ezjscore/ajaxuploader', 'Unable to find the identifier of ajax upload handler' ) ); } $http = eZHTTPTool::instance(); $handlerData = $http->postVariable( 'AjaxUploadHandlerData', array() ); $handlerOptions = new ezpExtensionOptions(); $handlerOptions->iniFile = 'ezjscore.ini'; $handlerOptions->iniSection = 'AjaxUploader'; $handlerOptions->iniVariable = 'AjaxUploadHandler'; $handlerOptions->handlerIndex = $args[0]; $handlerOptions->handlerParams = $handlerData; $handler = eZExtension::getHandlerClass( $handlerOptions ); if ( !$handler instanceof ezpAjaxUploaderHandlerInterface ) { throw new InvalidArgumentException( ezpI18n::tr( 'extension/ezjscore/ajaxuploader', 'Unable to load the ajax upload handler' ) ); } return $handler; }
public function runPreRoutingFilters( ezcMvcRequest $request ) { $prefixFilterOptions = new ezpExtensionOptions(); $prefixFilterOptions->iniFile = 'rest.ini'; $prefixFilterOptions->iniSection = 'System'; $prefixFilterOptions->iniVariable = 'PrefixFilterClass'; $prefixFilterOptions->handlerParams = array( $request, $this->apiPrefix ); $prefixFilter = eZExtension::getHandlerClass( $prefixFilterOptions ); $prefixFilter->filter(); // We call this method here, so that implementors won't have to remember // adding this call to their own filter() implementation. $prefixFilter->filterRequestUri(); try { $this->runCustomFilters( self::FILTER_TYPE_PREROUTING, array( 'request' => $request ) ); } catch ( Exception $e ) { $request->variables['exception'] = $e; $request->uri = $this->apiPrefix . '/fatal'; return new ezcMvcInternalRedirect( $request ); } }
/** * Constructor. * * $filePath File path. If specified, file metadata is fetched in the constructor. */ function __construct( $filePath = false ) { $filePath = eZDBFileHandler::cleanPath( $filePath ); eZDebugSetting::writeDebug( 'kernel-clustering', "db::ctor( '$filePath' )" ); if ( self::$dbbackend === null ) { $optionArray = array( 'iniFile' => 'file.ini', 'iniSection' => 'ClusteringSettings', 'iniVariable' => 'DBBackend' ); $options = new ezpExtensionOptions( $optionArray ); self::$dbbackend = eZExtension::getHandlerClass( $options ); self::$dbbackend->_connect( false ); // connection failed if( self::$dbbackend->db === false ) throw new eZClusterHandlerDBNoConnectionException( self::$dbbackend->dbparams['host'], self::$dbbackend->dbparams['user'], self::$dbbackend->dbparams['pass'] ); } $this->filePath = $filePath; if ( !isset( $GLOBALS['eZDBFileHandler_Settings'] ) ) { $fileINI = eZINI::instance( 'file.ini' ); $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling'] = $fileINI->variable( "ClusteringSettings", "NonExistantStaleCacheHandling" ); unset( $fileINI ); } $this->nonExistantStaleCacheHandling = $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling']; $this->filePermissionMask = octdec( eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' ) ); }
/** * Constructor * * If provided with $filePath, will use this file for further operations. * If not given, the file* methods must be used instead * * @param string $filePath Path of the file to handle * * @throws eZDBNoConnectionException DB connection failed */ function __construct( $filePath = false ) { if ( self::$nonExistantStaleCacheHandling === null ) { $fileINI = eZINI::instance( 'file.ini' ); self::$nonExistantStaleCacheHandling = $fileINI->variable( "ClusteringSettings", "NonExistantStaleCacheHandling" ); unset( $fileINI ); } // DB Backend init if ( self::$dbbackend === null ) { self::$dbbackend = eZExtension::getHandlerClass( new ezpExtensionOptions( array( 'iniFile' => 'file.ini', 'iniSection' => 'eZDFSClusteringSettings', 'iniVariable' => 'DBBackend' ) ) ); self::$dbbackend->_connect( false ); } if ( $filePath !== false ) { $filePath = eZDBFileHandler::cleanPath( $filePath ); eZDebugSetting::writeDebug( 'kernel-clustering', "dfs::ctor( '$filePath' )" ); } else { eZDebugSetting::writeDebug( 'kernel-clustering', "dfs::ctor()" ); } $this->filePath = $filePath; }
public function testComplexReordering() { self::setExtensions( array( 'ezfind', 'ezflow', 'ezgmaplocation', 'ezjscore', 'ezmultiupload', 'ezoe', 'ezwebin', 'ezwt' ) ); $this->assertSame( array( 'ezfind', 'ezflow', 'ezgmaplocation', 'ezjscore', 'ezmultiupload', 'ezoe', 'ezwebin', 'ezwt' ), eZExtension::activeExtensions() ); }
static function gather() { $contentTypes = array('Objects (including users)' => array('table' => 'ezcontentobject'), 'Users' => array('table' => 'ezuser'), 'Nodes' => array('table' => 'ezcontentobject_tree'), 'Content Classes' => array('table' => 'ezcontentclass'), 'Information Collections' => array('table' => 'ezinfocollection'), 'Pending notification events' => array('table' => 'eznotificationevent', 'wherecondition' => 'status = 0'), 'Objects pending indexation' => array('table' => 'ezpending_actions', 'wherecondition' => "action = 'index_object'"), 'Binary files (content)' => array('table' => 'ezbinaryfile'), 'Image files (content)' => array('table' => 'ezimagefile'), 'Media files (content)' => array('table' => 'ezmedia'), 'Maximum children per node' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_tree GROUP BY parent_node_id ) nodes'), 'Maximum nodes per object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_tree GROUP BY contentobject_id ) nodes'), 'Maximum incoming relations to an object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_link GROUP BY to_contentobject_id ) links', 'nvl' => 0), 'Maximum outgoing relations from an object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_link GROUP BY from_contentobject_id ) links', 'nvl' => 0)); $db = eZDB::instance(); $contentList = array(); foreach ($contentTypes as $key => $desc) { if (isset($desc['table'])) { $sql = 'SELECT COUNT(*) AS NUM FROM ' . $desc['table']; if (@$desc['wherecondition']) { $sql .= ' WHERE ' . $desc['wherecondition']; } } else { $sql = $desc['sql']; } $count = $db->arrayQuery($sql); $contentList[$key] = $count[0]['NUM'] === null ? $desc['nvl'] : $count[0]['NUM']; } if (in_array('ezfind', eZExtension::activeExtensions())) { $ini = eZINI::instance('solr.ini'); $ezfindpingurl = $ini->variable('SolrBase', 'SearchServerURI') . "/admin/stats.jsp"; $data = eZHTTPTool::getDataByURL($ezfindpingurl, false); //var_dump( $data ); if (preg_match('#<stat +name="numDocs" ?>([^<]+)</stat>#', $data, $matches)) { $contentList['Documents in SOLR'] = trim($matches[1]); } else { $contentList['Documents in SOLR'] = 'Unknown'; } } return $contentList; }
/** * Returns a shared instance of the eZShopAccountHandler class * as defined in shopaccount.ini[HandlerSettings]Repositories * and ExtensionRepositories. * * @return eZDefaultShopAccountHandler Or similar clases. */ static function instance() { $accountHandler = null; if ( eZExtension::findExtensionType( array( 'ini-name' => 'shopaccount.ini', 'repository-group' => 'HandlerSettings', 'repository-variable' => 'Repositories', 'extension-group' => 'HandlerSettings', 'extension-variable' => 'ExtensionRepositories', 'type-group' => 'AccountSettings', 'type-variable' => 'Handler', 'alias-group' => 'AccountSettings', 'alias-variable' => 'Alias', 'subdir' => 'shopaccounthandlers', 'type-directory' => false, 'extension-subdir' => 'shopaccounthandlers', 'suffix-name' => 'shopaccounthandler.php' ), $out ) ) { $filePath = $out['found-file-path']; include_once( $filePath ); $class = $out['type'] . 'ShopAccountHandler'; $accountHandler = new $class( ); } else { $accountHandler = new eZDefaultShopAccountHandler(); } return $accountHandler; }
/** * Register ezote/Autoloader::autoload as autoloader */ public static function register($extensionDir = false) { if (!static::$registered) { static::$extensionDir = $extensionDir ?: \eZExtension::baseDirectory(); static::$registered = spl_autoload_register(array(new self(), 'autoload')); } }
static function loadHandler($directories, $handlerString) { $foundHandler = false; $includeFile = ''; $baseDirectory = eZExtension::baseDirectory(); $notificationINI = eZINI::instance('notification.ini'); $repositoryDirectories = $notificationINI->variable('NotificationEventHandlerSettings', 'RepositoryDirectories'); $extensionDirectories = $notificationINI->variable('NotificationEventHandlerSettings', 'ExtensionDirectories'); foreach ($extensionDirectories as $extensionDirectory) { $extensionPath = "{$baseDirectory}/{$extensionDirectory}/notification/handler/"; if (file_exists($extensionPath)) { $repositoryDirectories[] = $extensionPath; } } foreach ($repositoryDirectories as $repositoryDirectory) { $repositoryDirectory = trim($repositoryDirectory, '/'); $includeFile = "{$repositoryDirectory}/{$handlerString}/{$handlerString}handler.php"; if (file_exists($includeFile)) { $foundHandler = true; break; } } if (!$foundHandler) { eZDebug::writeError("Notification handler does not exist: {$handlerString}", __METHOD__); return false; } include_once $includeFile; $className = $handlerString . "handler"; return new $className(); }
/** * Returns a new instance of the eZUser class pr $protocol. * * @param string $protocol If not set to 'standard' (default), then the code will look * for handler first in kernel/classes/datatypes/ezuser/, then according to * site.ini[UserSettings]ExtensionDirectory settings * @return eZUser */ static function instance($protocol = "standard") { $triedFiles = array(); if ($protocol == "standard") { $impl = new eZUser(0); return $impl; } else { $ezuserFile = 'kernel/classes/datatypes/ezuser/ez' . strtolower($protocol) . 'user.php'; $triedFiles[] = $ezuserFile; if (file_exists($ezuserFile)) { include_once $ezuserFile; $className = 'eZ' . $protocol . 'User'; $impl = new $className(); return $impl; } else { $ini = eZINI::instance(); $extensionDirectories = $ini->variable('UserSettings', 'ExtensionDirectory'); $directoryList = eZExtension::expandedPathList($extensionDirectories, 'login_handler'); foreach ($directoryList as $directory) { $userFile = $directory . '/ez' . strtolower($protocol) . 'user.php'; $triedFiles[] = $userFile; if (file_exists($userFile)) { include_once $userFile; $className = 'eZ' . $protocol . 'User'; $impl = new $className(); return $impl; } } } } // if no one appropriate instance was found eZDebug::writeWarning("Unable to find user login handler '{$protocol}', searched for these files: " . implode(', ', $triedFiles), __METHOD__); $impl = null; return $impl; }
function checkRecurrenceCondition($newsletter) { if (!$newsletter->attribute('recurrence_condition')) { return true; } if (0 < count($this->conditionExtensions)) { foreach ($this->conditionExtensions as $conditionExtension) { // TODO: Extend to ask multiple condition extensions to allow more complex checks $siteINI = eZINI::instance(); $siteINI->loadCache(); $extensionDirectory = $siteINI->variable('ExtensionSettings', 'ExtensionDirectory'); $extensionDirectories = eZDir::findSubItems($extensionDirectory); $directoryList = eZExtension::expandedPathList($extensionDirectories, 'condition_handler'); foreach ($directoryList as $directory) { $handlerFile = $directory . '/' . strtolower($conditionExtension) . 'handler.php'; // we only check one extension for now if ($conditionExtension === $newsletter->attribute('recurrence_condition') && file_exists($handlerFile)) { include_once $handlerFile; $className = $conditionExtension . 'Handler'; if (class_exists($className)) { $impl = new $className(); // Ask if condition is fullfilled return $impl->checkCondition($newsletter); } else { eZDebug::writeError("Class {$className} not found. Unable to verify recurrence condition. Blocked recurrence."); return false; } } } } } // If we have a condition but no match we prevent the sendout eZDebug::writeError("Newsletter recurrence condition '" . $newsletter->attribute('recurrence_condition') . "' extension not found "); return false; }
function get($oid) { $oidroot = $this->oidRoot(); $oidroot = $oidroot[0]; switch (preg_replace('/\\.0$/', '', $oid)) { case $oidroot . '1.1': if (in_array('ezfind', eZExtension::activeExtensions())) { $ini = eZINI::instance('solr.ini'); $data = eZHTTPTool::getDataByURL($ini->variable('SolrBase', 'SearchServerURI') . "/admin/ping", false); if (stripos($data, '<str name="status">OK</str>') !== false) { $status = 1; } else { $status = 0; } } else { $status = -1; } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $status); case $oidroot . '1.2': if (in_array('ezfind', eZExtension::activeExtensions())) { $ini = eZINI::instance('solr.ini'); $data = eZHTTPTool::getDataByURL($ini->variable('SolrBase', 'SearchServerURI') . "/admin/stats.jsp", false); if (preg_match('#<stat +name="numDocs" +>[ \\t\\r\\n]*(\\d+)[ \\t\\r\\n]*</stat>#', $data, $status)) { $status = $status[1]; } else { $status = -2; } } else { $status = -1; } return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $status); } return self::NO_SUCH_OID; }
/** * Constructor * * If provided with $filePath, will use this file for further operations. * If not given, the file* methods must be used instead * * @param string $filePath Path of the file to handle * * @throws eZDBNoConnectionException DB connection failed */ function __construct($filePath = false) { if (self::$nonExistantStaleCacheHandling === null) { $fileINI = eZINI::instance('file.ini'); self::$nonExistantStaleCacheHandling = $fileINI->variable("ClusteringSettings", "NonExistantStaleCacheHandling"); unset($fileINI); } // DB Backend init if (self::$dbbackend === null) { self::$dbbackend = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'eZDFSClusteringSettings', 'iniVariable' => 'DBBackend'))); self::$dbbackend->_connect(false); $fileINI = eZINI::instance('file.ini'); if ($fileINI->variable('ClusterEventsSettings', 'ClusterEvents') === 'enabled' && self::$dbbackend instanceof eZClusterEventNotifier) { $listener = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'ClusterEventsSettings', 'iniVariable' => 'Listener', 'handlerParams' => array(new eZClusterEventLoggerEzdebug())))); if ($listener instanceof eZClusterEventListener) { self::$dbbackend->registerListener($listener); $listener->initialize(); } } } if ($filePath !== false) { $filePath = self::cleanPath($filePath); eZDebugSetting::writeDebug('kernel-clustering', "dfs::ctor( '{$filePath}' )"); } else { eZDebugSetting::writeDebug('kernel-clustering', "dfs::ctor()"); } $this->filePath = $filePath; }
/** * Gets an instance of the StaticCacheHandler and ask it for the user hash. * * @return string */ static function getUserHash() { $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler'); $options = new ezpExtensionOptions($optionArray); $staticCacheHandler = eZExtension::getHandlerClass($options); return $staticCacheHandler->getUserHash(); }
/** * Update block pool for block with given $blockID * * @static * @param string $blockID * @param integer $publishedBeforeOrAt * @return integer */ public static function updateBlockPoolByBlockID($block, $publishedBeforeOrAt = false) { $db = eZDB::instance(); $blockINI = eZINI::instance('block.ini'); if (!$publishedBeforeOrAt) { $publishedBeforeOrAt = time(); } if (!$blockINI->hasVariable($block['block_type'], 'FetchClass')) { // Pure manual block, nothing is going to be fetched, but we need to update last_update as it is used for rotations if ($block['rotation_type'] != self::ROTATION_NONE) { $db->query("UPDATE ezm_block SET last_update={$publishedBeforeOrAt} WHERE id='" . $block['id'] . "'"); } return 0; } $fetchClassOptions = new ezpExtensionOptions(); $fetchClassOptions->iniFile = 'block.ini'; $fetchClassOptions->iniSection = $block['block_type']; $fetchClassOptions->iniVariable = 'FetchClass'; $fetchInstance = eZExtension::getHandlerClass($fetchClassOptions); if (!$fetchInstance instanceof eZFlowFetchInterface) { eZDebug::writeWarning("Can't create an instance of the {$fetchClass} class", "eZFlowOperations::updateBlockPoolByBlockID('" . $block['id'] . "')"); return false; } $fetchFixedParameters = array(); if ($blockINI->hasVariable($block['block_type'], 'FetchFixedParameters')) { $fetchFixedParameters = $blockINI->variable($block['block_type'], 'FetchFixedParameters'); } $fetchParameters = unserialize($block['fetch_params']); if (!is_array($fetchParameters)) { // take care of blocks existing in db where ini definition changed eZDebug::writeWarning("Found existing block which has no necessary parameters serialized in the db (block needs updating)", "eZFlowOperations::updateBlockPoolByBlockID('" . $block['id'] . "')"); $fetchParameters = array(); } $parameters = array_merge($fetchFixedParameters, $fetchParameters); $newItems = array(); foreach ($fetchInstance->fetch($parameters, $block['last_update'], $publishedBeforeOrAt) as $item) { $newItems[] = array('blockID' => $block['id'], 'objectID' => $item['object_id'], 'nodeID' => $item['node_id'], 'priority' => 0, 'timestamp' => $item['ts_publication']); } $itemsToRemove = 0; if (isset($parameters['Limit'])) { $count = $db->arrayQuery("SELECT count(*) as count FROM ezm_pool WHERE block_id='" . $block['id'] . "'"); $itemsToRemove = (int) $count[0]['count'] + count($newItems) - (int) $parameters['Limit']; } if (!empty($newItems) || $itemsToRemove > 0) { $db->begin(); if ($itemsToRemove > 0) { $db->query("DELETE FROM ezm_pool WHERE block_id='" . $block['id'] . "' ORDER BY ts_publication ASC LIMIT " . $itemsToRemove); } if (!empty($newItems)) { eZFlowPool::insertItems($newItems); } $db->query("UPDATE ezm_block SET last_update={$publishedBeforeOrAt} WHERE id='" . $block['id'] . "'"); $db->commit(); } return count($newItems); }
/** Executes the needed operator(s). Checks operator names, and calls the appropriate functions. */ function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters) { switch ($operatorName) { case 'eZDebug': $operatorValue = $this->eZdebug($operatorValue, $namedParameters['debuglvl'], $namedParameters['label']); break; case 'objDebug': $operatorValue = $this->objdebug($operatorValue, $namedParameters['show_values'] == 'show', $namedParameters['level']); break; case 'objInspect': require_once 'kernel/common/template.php'; $tpl = templateInit(); $tpl->setVariable('counter', self::$inspectcounter); $exts = eZExtension::activeExtensions(); $wstransport = ''; if (in_array('ezjscore', $exts)) { $wstransport = 'ezjscore'; } else { if (in_array('ggwebservices', $exts)) { $wstransport = 'ggwebservices'; } } $tpl->setVariable('transport', $wstransport); if (class_exists('ezPOInspector')) { $tpl->setVariable('value', json_encode(ezPOInspector::objInspect($operatorValue))); $tpl->setVariable('error', false); } else { $tpl->setVariable('value', null); $tpl->setVariable('error', "Cannot inspect value: extension ezpersistentobject_inspector most likely missing"); } $tpl->setVariable('sort_attributes', $namedParameters['sort_attributes']); $tpl->setVariable('send_to_debug', $namedParameters['send_to_debug']); $operatorValue = $tpl->fetch('design:ezdebug/objinspect.tpl'); if ($namedParameters['send_to_debug']) { // send div to debug output via a debug msg $tpl = templateInit(); $tpl->setVariable('counter', self::$inspectcounter); eZDebug::writeDebug($tpl->fetch('design:ezdebug/objinspectdebugoutput.tpl'), 'objInspect ' . self::$inspectcounter); } self::$inspectcounter++; break; case 'addTimingPoint': eZDebug::addTimingPoint($namedParameters['label']); $operatorValue = ''; break; case 'numQueries': $operatorValue = $this->numqueries($namedParameters['cluster']); break; case 'getDefinedVars': $operatorValue = $this->getDefinedVars($tpl, $namedParameters['namespace'], $rootNamespace, $currentNamespace); break; } }
static function create( $handlerName = false ) { $shopINI = eZINI::instance( 'shop.ini' ); if ( $handlerName === false) { if ( $shopINI->hasVariable( 'ExchangeRatesSettings', 'ExchangeRatesUpdateHandler' ) ) $handlerName = $shopINI->variable( 'ExchangeRatesSettings', 'ExchangeRatesUpdateHandler' ); } $handlerName = strtolower( $handlerName ); $dirList = array(); $repositoryDirectories = $shopINI->variable( 'ExchangeRatesSettings', 'RepositoryDirectories' ); $extensionDirectories = $shopINI->variable( 'ExchangeRatesSettings', 'ExtensionDirectories' ); $baseDirectory = eZExtension::baseDirectory(); foreach ( $extensionDirectories as $extensionDirectory ) { if ( !empty( $extensionDirectory ) ) $dirList[] = $baseDirectory . '/' . $extensionDirectory . '/exchangeratehandlers'; } foreach ( $repositoryDirectories as $repositoryDirectory ) { if ( !empty( $repositoryDirectory ) ) $dirList[] = $repositoryDirectory; } $foundHandler = false; foreach ( $dirList as $dir ) { $includeFile = "$dir/$handlerName/{$handlerName}handler.php"; if ( file_exists( $includeFile ) ) { $foundHandler = true; break; } } if ( !$foundHandler ) { eZDebug::writeError( "Exchange rates update handler '$handlerName' not found, " . "searched in these directories: " . implode( ', ', $dirList ), 'eZExchangeRatesUpdateHandler::create' ); return false; } require_once( $includeFile ); $className = $handlerName . 'handler'; return new $className; }
/** * Returns the currently configured class for handling Route security. * * @static * @throws ezpRestRouteSecurityFilterNotFoundException * @return ezpRestRouteFilterInterface */ public static function getRouteFilter() { $opt = new ezpExtensionOptions(); $opt->iniFile = 'rest.ini'; $opt->iniSection = 'RouteSettings'; $opt->iniVariable = 'RouteSettingImpl'; $routeSecurityFilterInstance = eZExtension::getHandlerClass($opt); if (!$routeSecurityFilterInstance instanceof self) { throw new ezpRestRouteSecurityFilterNotFoundException(); } return $routeSecurityFilterInstance; }
/** * Unloads an extension by removing it from ActiveExtensions setting, * clearing extensions cache and remove ini dir (not extension siteaccess) * * @param string $extension Extension name to unload * @return bool True on success, false if not loaded */ public static function unload($extension) { $ini = eZINI::instance(); $activeExtensions = $ini->variable('ExtensionSettings', 'ActiveExtensions'); if (!in_array($extension, $activeExtensions, true)) { return false; } $ini->setVariable('ExtensionSettings', 'ActiveExtensions', array_diff($activeExtensions, array($extension))); $ini->removeOverrideDir('extension:' . $extension); eZExtension::clearActiveExtensionsMemoryCache(); return true; }
static function send(eZMail $mail) { $ini = eZINI::instance(); $transportType = trim($ini->variable('MailSettings', 'Transport')); $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'MailSettings', 'iniVariable' => 'TransportAlias', 'handlerIndex' => strtolower($transportType)); $options = new ezpExtensionOptions($optionArray); $transportClass = eZExtension::getHandlerClass($options); if (!is_object($transportClass)) { eZDebug::writeError("No class available for mail transport type '{$transportType}', cannot send mail", __METHOD__); } return $transportClass->sendMail($mail); }
/** * @param string $provider * @return ezpRestProviderInterface */ protected static function createProvider($provider) { $providerOptions = new ezpExtensionOptions(); $providerOptions->iniFile = 'rest.ini'; $providerOptions->iniSection = 'ApiProvider'; $providerOptions->iniVariable = 'ProviderClass'; $providerOptions->handlerIndex = $provider; $providerInstance = eZExtension::getHandlerClass($providerOptions); if (!$providerInstance instanceof ezpRestProviderInterface) { throw new ezpRestProviderNotFoundException($provider); } return $providerInstance; }
function sPdf2png() { $ini = eZINI::instance('spdf2png.ini'); $this->cacheEnabled = $ini->variable('CacheSettings', 'Cache') == 'enabled'; $this->debugEnabled = $ini->variable('DebugSettings', 'DebugPDF') == 'enabled'; $this->javaExec = $ini->variable('BinarySettings', 'JavaExecutable'); $this->cacheTTL = $ini->variable('CacheSettings', 'TTL'); $fileSep = eZSys::fileSeparator(); $this->fileSep = $fileSep; $this->extensionDir = eZSys::rootDir() . $fileSep . eZExtension::baseDirectory() . $fileSep . 'pdf2png'; //$this->paradoxPDFExec = $this->pdf2pngExtensionDir.$fileSep.'bin'.$fileSep.'paradoxpdf.jar'; $this->tmpDir = eZSys::rootDir() . $fileSep . 'var' . $fileSep . 'cache' . $fileSep . 'public' . $fileSep . 'pdf2png'; }
public function runPreRoutingFilters(ezcMvcRequest $request) { $prefixFilterOptions = new ezpExtensionOptions(); $prefixFilterOptions->iniFile = 'rest.ini'; $prefixFilterOptions->iniSection = 'System'; $prefixFilterOptions->iniVariable = 'PrefixFilterClass'; $prefixFilterOptions->handlerParams = array($request, $this->apiPrefix); $prefixFilter = eZExtension::getHandlerClass($prefixFilterOptions); $prefixFilter->filter(); // We call this method here, so that implementors won't have to remember // adding this call to their own filter() implementation. $prefixFilter->filterRequestUri(); }
/** * Searches for the output formatter handler class for a given format * * @static * @param string $format * @return ezpAttributeOperatorFormatterInterface */ protected static function createFormatter($format) { $formatterOptions = new ezpExtensionOptions(); $formatterOptions->iniFile = 'template.ini'; $formatterOptions->iniSection = 'AttributeOperator'; $formatterOptions->iniVariable = 'OutputFormatter'; $formatterOptions->handlerIndex = $format; $formatterInstance = eZExtension::getHandlerClass($formatterOptions); if (!$formatterInstance instanceof ezpAttributeOperatorFormatterInterface) { eZDebug::writeError("Undefined output formatter for '{$format}'", __METHOD__); } return $formatterInstance; }
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'); }
function changeSiteAccessSetting(&$siteaccess, $optionData) { $cli = eZCLI::instance(); if (file_exists('settings/siteaccess/' . $optionData)) { $siteaccess = $optionData; return "Using siteaccess {$siteaccess} for cronjob"; } elseif (isExtensionSiteaccess($optionData)) { $siteaccess = $optionData; eZExtension::prependExtensionSiteAccesses($siteaccess); return "Using extension siteaccess {$siteaccess} for cronjob"; } else { return "Siteaccess {$optionData} does not exist, using default siteaccess"; } }
/** * Returns ezpRestContentProviderInterface object for requested renderer * * @param string $renderer * @param ezpContent $content * @return ezpRestContentProviderInterface */ protected static function createRenderer($renderer, ezpContent $content, ezpRestMvcController $controller) { $rendererOptions = new ezpExtensionOptions(); $rendererOptions->iniFile = 'rest.ini'; $rendererOptions->iniSection = 'OutputSettings'; $rendererOptions->iniVariable = 'RendererClass'; $rendererOptions->handlerIndex = $renderer; $rendererOptions->handlerParams = array($content, $controller); $rendererInstance = eZExtension::getHandlerClass($rendererOptions); if (!$rendererInstance instanceof ezpRestContentRendererInterface) { throw new ezpRestContentRendererNotFoundException($renderer); } return $rendererInstance; }
public function filter() { if ( eZINI::instance( 'rest.ini' )->variable( 'Authentication', 'RequireHTTPS') === 'enabled' && $this->req->isEncrypted === false ) { // When an unencrypted connection is identified, we have to alter the // flag to avoid infinite loop, when the request is rerouted to the error controller. // This should be improved in the future. $this->req->isEncrypted = true; throw new ezpRestHTTPSRequiredException(); } // 0. Check if the given route needs authentication. if ( !$this->shallAuthenticate() ) { $this->filter = new ezpRestNoAuthStyle(); } else if ( $this->filter === null ) { $opt = new ezpExtensionOptions(); $opt->iniFile = 'rest.ini'; $opt->iniSection = 'Authentication'; $opt->iniVariable = 'AuthenticationStyle'; $authFilter = eZExtension::getHandlerClass( $opt ); if ( !$authFilter instanceof ezpRestAuthenticationStyle ) { throw new ezpRestAuthStyleNotFoundException(); } $this->filter = $authFilter; } // 1. Initialize the context needed for authenticating the user. $auth = $this->filter->setup( $this->req ); if ( $auth instanceof ezcMvcInternalRedirect ) return $auth; // 2.Perform the authentication // Result of authentication filter can be a valid ezp user (auth succeeded) or an internal redirect (ezcMvcInternalRedirect) $user = $this->filter->authenticate( $auth, $this->req ); if ( $user instanceof eZUser ) { eZUser::setCurrentlyLoggedInUser( $user, $user->attribute( 'contentobject_id' ) ); $this->filter->setUser( $user ); } else if ( $user instanceof ezcMvcInternalRedirect ) { return $user; } }
function changeSiteAccessSetting(&$siteaccess, $optionData) { global $cronPart; $cli = eZCLI::instance(); if (file_exists('settings/siteaccess/' . $optionData)) { $siteaccess = $optionData; $cli->output("Using siteaccess {$siteaccess} for cronjob"); } elseif (isExtensionSiteaccess($optionData)) { $siteaccess = $optionData; $cli->output("Using extension siteaccess {$siteaccess} for cronjob"); eZExtension::prependExtensionSiteAccesses($siteaccess); } else { $cli->notice("Siteaccess {$optionData} does not exist, using default siteaccess"); } }