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; }
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; }
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() ); }
/** 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; } }
/** * Startup and run script. */ public function run() { $this->Script->startup(); $this->Options = $this->Script->getOptions("[db-host:][db-user:][db-password:][db-database:][db-type:|db-driver:][sql][clean][clean-all][conc:][php-exec:][commit-within:][class-identifiers:]", "", array('db-host' => "Database host", 'db-user' => "Database user", 'db-password' => "Database password", 'db-database' => "Database name", 'db-driver' => "Database driver", 'db-type' => "Database driver, alias for --db-driver", 'sql' => "Display sql queries", 'clean' => "Remove all search data of the current installation id before beginning indexing", 'clean-all' => "Remove all search data for all installations", 'conc' => 'Parallelization, number of concurent processes to use', 'php-exec' => 'Full path to PHP executable', 'commit-within' => 'Commit to Solr within this time in seconds (default ' . self::DEFAULT_COMMIT_WITHIN . ' seconds)', 'class-identifiers' => 'Index objects belonging to this class/content type only, can be a comma separated list of identifiers or numerical values (no spaces) ')); $this->Script->initialize(); // check if ezfind is enabled and exit if not if (!in_array('ezfind', eZExtension::activeExtensions())) { $this->CLI->error('eZ Find extension is not enabled and because of that index process will fail. Please enable it and run this script again.'); $this->Script->shutdown(0); } // Fix siteaccess $siteAccess = $this->Options['siteaccess'] ? $this->Options['siteaccess'] : false; $this->classIdentifiers = array(); if (isset($this->Options['class-identifiers'])) { $this->classIdentifiers = preg_split('/,/', $this->Options['class-identifiers']); } if ($siteAccess) { $this->changeSiteAccessSetting($siteAccess); } else { $this->CLI->warning('You did not specify a siteaccess. The admin siteaccess is a required option in most cases.'); $input = readline('Are you sure the default siteaccess has all available languages defined? ([y] or [q] to quit )'); if ($input === 'q') { $this->Script->shutdown(0); } } // Check that Solr server is up and running if (!$this->checkSolrRunning()) { $this->Script->shutdown(1); exit; } $this->initializeDB(); // call clean up routines which will deal with the CLI arguments themselves $this->cleanUp(); $this->cleanUpAll(); if (isset($this->Options['commit-within']) && is_numeric($this->Options['commit-within'])) { $this->commitWithin = (int) $this->Options['commit-within']; } $this->CLI->output('Starting object re-indexing'); // Get PHP executable from user. $this->getPHPExecutable(); $this->runMain(); }
/** * Returns path to site access * * @param string $siteAccess * @return string|false Return path to siteacces or false if invalid */ static function findPathToSiteAccess($siteAccess) { $ini = eZINI::instance(); $siteAccessList = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'); if (!in_array($siteAccess, $siteAccessList)) { return false; } $currentPath = 'settings/siteaccess/' . $siteAccess; if (file_exists($currentPath)) { return $currentPath; } $activeExtensions = eZExtension::activeExtensions(); $baseDir = eZExtension::baseDirectory(); foreach ($activeExtensions as $extension) { $currentPath = $baseDir . '/' . $extension . '/settings/siteaccess/' . $siteAccess; if (file_exists($currentPath)) { return $currentPath; } } return 'settings/siteaccess/' . $siteAccess; }
/** * Tries to load an ini value, including the settings from this extension even when it is not active. * Note: when not active, the settings of this extensions are loaded with lower precedence compared to same settings * from other extensions. * * @param string $fileName * @param string $blockName * @param string $varName * @param int $type * @return array|mixed|null */ static function getIniValue($fileName, $blockName, $varName, $type = self::TYPE_SCALAR) { if ($type == self::TYPE_SCALAR) { $value = null; } else { $value = array(); } $ini = eZINI::instance($fileName); if (in_array('ggsysinfo', eZExtension::activeExtensions())) { return $ini->hasVariable($blockName, $varName) ? $ini->variable($blockName, $varName) : $value; } else { // load still what possible values are added from other extensions $value = $ini->hasVariable($blockName, $varName) ? $ini->variable($blockName, $varName) : $value; $ini = eZINI::fetchFromFile(__DIR__ . '/../settings/sysinfo.ini'); if ($type == self::TYPE_SCALAR) { return array_merge($value, $ini->variable($blockName, $varName)); } else { if ($value !== null) { return $value; } return $ini->variable($blockName, $varName); } } }
$script->initialize(); $dataTypeName = $options['datatype']; if ($dataTypeName === null) { $cli->output("Error: The option --datatype is required. Add --help for more information."); } $allowedDatatypes = eZDataType::allowedTypes(); if ($dataTypeName !== null and in_array($dataTypeName, $allowedDatatypes)) { // Inserting data from the dba-data files of the datatypes eZDataType::loadAndRegisterAllTypes(); $registeredDataTypes = eZDataType::registeredDataTypes(); if (isset($registeredDataTypes[$dataTypeName])) { $dataType = $registeredDataTypes[$dataTypeName]; if ($dataType->importDBDataFromDBAFile()) { $cli->output("The database is updated for the datatype: " . $cli->style('emphasize') . $dataType->DataTypeString . $cli->style('emphasize-end') . "\n" . 'dba-data is imported from the file: ' . $cli->style('emphasize') . $dataType->getDBAFilePath() . $cli->style('emphasize-end')); } else { $activeExtensions = eZExtension::activeExtensions(); $errorString = "Failed importing datatype related data into database: \n" . ' datatype - ' . $dataType->DataTypeString . ", \n" . ' checked dba-data file - ' . $dataType->getDBAFilePath(false); foreach ($activeExtensions as $activeExtension) { $fileName = eZExtension::baseDirectory() . '/' . $activeExtension . '/datatypes/' . $dataType->DataTypeString . '/' . $dataType->getDBAFileName(); $errorString .= "\n" . str_repeat(' ', 23) . ' - ' . $fileName; if (file_exists($fileName)) { $errorString .= " (found, but not successfully imported)"; } } $cli->error($errorString); } } else { $cli->error("Error: The datatype " . $dataTypeName . " does not exist."); } } else { $cli->error("Error: The datatype " . $dataTypeName . " is not registered.");
/** * Returns the list of active module repositories, as defined in module.ini * * @param boolean $useExtensions * If true, module.ini files in extensions will be scanned as well. * If false, only the module.ini overrides in settings will be. * * @return array a path list of currently active modules */ static function activeModuleRepositories($useExtensions = true) { $moduleINI = eZINI::instance('module.ini'); $moduleRepositories = $moduleINI->variable('ModuleSettings', 'ModuleRepositories'); if ($useExtensions) { $extensionRepositories = $moduleINI->variable('ModuleSettings', 'ExtensionRepositories'); $extensionDirectory = eZExtension::baseDirectory(); $activeExtensions = eZExtension::activeExtensions(); $globalExtensionRepositories = array(); foreach ($extensionRepositories as $extensionRepository) { $extPath = $extensionDirectory . '/' . $extensionRepository; $modulePath = $extPath . '/modules'; if (!in_array($extensionRepository, $activeExtensions)) { eZDebug::writeWarning("Extension '{$extensionRepository}' was reported to have modules but has not yet been activated.\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions\n" . "or make sure it is activated in the setting ExtensionSettings/ActiveExtensions in site.ini."); } else { if (file_exists($modulePath)) { $globalExtensionRepositories[] = $modulePath; } else { if (!file_exists($extPath)) { eZDebug::writeWarning("Extension '{$extensionRepository}' was reported to have modules but the extension itself does not exist.\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions.\n" . "You should probably remove this extension from the list."); } else { eZDebug::writeWarning("Extension '{$extensionRepository}' does not have the subdirectory 'modules' allthough it reported it had modules.\n" . "Looked for directory '" . $modulePath . "'\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extension."); } } } } $moduleRepositories = array_merge($moduleRepositories, $globalExtensionRepositories); } return $moduleRepositories; }
function findHandler(&$result, $mimeInfo) { // Check for specific mime handler plugin $uploadINI = eZINI::instance('upload.ini'); $uploadSettings = $uploadINI->variable('CreateSettings', 'MimeUploadHandlerMap'); $mime = $mimeInfo['name']; $elements = explode('/', $mime); $mimeGroup = $elements[0]; $handlerName = false; // Check first for MIME-Type group, this allows a handler to work // with an entire group, e.g. image if (isset($uploadSettings[$mimeGroup])) { $handlerName = $uploadSettings[$mimeGroup]; } else { if (isset($uploadSettings[$mime])) { $handlerName = $uploadSettings[$mime]; } } if ($handlerName !== false) { $baseDirectory = eZExtension::baseDirectory(); $extensionDirectories = eZExtension::activeExtensions(); // Check all extension directories for an upload handler for this mimetype foreach ($extensionDirectories as $extensionDirectory) { $handlerPath = $baseDirectory . '/' . $extensionDirectory . '/uploadhandlers/' . $handlerName . ".php"; if (!file_exists($handlerPath)) { continue; } include_once $handlerPath; $handlerClass = $handlerName; $handler = new $handlerClass(); if (!$handler instanceof eZContentUploadHandler) { eZDebug::writeError("Content upload handler '{$handlerName}' is not inherited from eZContentUploadHandler. All upload handlers must do this.", __METHOD__); return false; } return $handler; } $result['errors'][] = array('description' => ezpI18n::tr('kernel/content/upload', "Could not find content upload handler '%handler_name'", null, array('%handler_name' => $handlerName))); return false; } return true; }
public function testCycleInvolvesNoReordering2() { self::setExtensions(array('cycle2', 'cycle1')); $this->assertSame(array('cycle2', 'cycle1'), eZExtension::activeExtensions()); }
static function ezgeshiAvailable() { if (in_array('ezsh', eZExtension::activeExtensions())) { $info = eZExtension::extensionInfo('ezsh'); // since ezp 4.4, we have a lowercase version info return version_compare(@$info['Version'], '1.3') >= 0 || version_compare(@$info['version'], '1.3') >= 0; } return false; }
/** * * Handles casese where the token is reset during a request. * * @param bool $restore * * @return bool * */ public static function handleEZXFormToken($restore = false) { $activeExtensions = \eZExtension::activeExtensions(); if (in_array('ezformtoken', $activeExtensions)) { if ($restore) { if (isset(self::$ezxFormToken) && !empty(self::$ezxFormToken)) { \eZSession::set(\ezxFormToken::SESSION_KEY, self::$ezxFormToken); } } else { self::$ezxFormToken = \eZSession::get(\ezxFormToken::SESSION_KEY); } return self::$ezxFormToken; } return false; }
function checkSiteaccess($siteAccess, $bailOutOnError = false) { $extensionBaseDir = eZExtension::baseDirectory(); $extensionNameArray = eZExtension::activeExtensions(); $siteAccessSettingsDir = '/settings/siteaccess/'; $siteAccessExists = false; if (file_exists('settings/siteaccess/' . $siteAccess)) { $siteAccessExists = true; } else { // Not found, check if it exists in extensions foreach ($extensionNameArray as $extensionName) { $extensionSiteaccessPath = $extensionBaseDir . '/' . $extensionName . $siteAccessSettingsDir . $siteAccess; if (file_exists($extensionSiteaccessPath)) { $siteAccessExists = true; break; } } } if (!$siteAccessExists && $bailOutOnError) { showError("Siteaccess '" . $siteAccess . "' does not exist. Exiting..."); } return $siteAccessExists; }
/** * Prepend extension siteaccesses * * @param string|false $accessName Optional access name, will use global if false * @param eZINI|false|null $ini * @param true $globalDir * @param string|false|null See {@link eZExtension::prependSiteAccess()} * @param bool $order Prepend extensions in reverse order by setting this to false */ static function prependExtensionSiteAccesses( $accessName = false, $ini = false, $globalDir = true, $identifier = null, $order = true ) { $extensionList = eZExtension::activeExtensions( 'default' ); if ( !$order ) { $extensionList = array_reverse( $extensionList ); } foreach( $extensionList as $extension ) { self::prependSiteAccess( $extension, $accessName, $ini, $globalDir, $identifier ); } }
} else { $phpAcceleratorInfo = array(); } } else { $systemInfo = array('cpu_type' => '', 'cpu_speed' => '', 'cpu_count' => '', 'memory_size' => ''); $phpAcceleratorInfo = array(); } $webserverInfo = false; if (function_exists('apache_get_version')) { $webserverInfo = array('name' => 'Apache', 'modules' => false, 'version' => apache_get_version()); if (function_exists('apache_get_modules')) { $webserverInfo['modules'] = apache_get_modules(); } } $tpl->setVariable('ezpublish_version', eZPublishSDK::version() . " (" . eZPublishSDK::alias() . ")"); $tpl->setVariable('ezpublish_extensions', eZExtension::activeExtensions()); $tpl->setVariable('php_version', phpversion()); $tpl->setVariable('php_accelerator', $phpAcceleratorInfo); $tpl->setVariable('webserver_info', $webserverInfo); $tpl->setVariable('database_info', $db->databaseName()); $tpl->setVariable('database_charset', $db->charset()); $tpl->setVariable('database_object', $db); $tpl->setVariable('php_loaded_extensions', get_loaded_extensions()); $tpl->setVariable('autoload_functions', spl_autoload_functions()); // Workaround until ezcTemplate // The new system info class uses properties instead of attributes, so the // values are not immediately available in the old template engine. $tpl->setVariable('system_info', $systemInfo); $phpINI = array(); foreach (array('safe_mode', 'register_globals', 'file_uploads') as $iniName) { $phpINI[$iniName] = ini_get($iniName) != 0;
if (isset($options['admin-user'])) { $adminUser = $options['admin-user']; } else { $adminUser = '******'; } $user = eZUser::fetchByName($adminUser); if ($user) { eZUser::setCurrentlyLoggedInUser($user, $user->attribute('id')); } else { $cli->error('Could not fetch admin user object'); $script->shutdown(1); return; } // Take care of script monitoring $scheduledScript = false; if (isset($options['scriptid']) and in_array('ezscriptmonitor', eZExtension::activeExtensions()) and class_exists('eZScheduledScript')) { $scriptID = $options['scriptid']; $scheduledScript = eZScheduledScript::fetch($scriptID); } // Do the update if (isset($options['classid'])) { updateClass($options['classid']); } else { $cli->notice('The classid parameter was not given, will check all classes.'); $classes = eZContentClass::fetchAllClasses(false); foreach ($classes as $class) { $cli->notice('Checking class ' . $class['id'] . ': ' . $class['name']); updateClass($class['id']); } } $script->shutdown();
<?php /** * Tests status of eZ Publish install in more detail than ezinfo/isalive * For every test, 1 = OK, 0 = KO and X = NA. ? = test not yet implemented * NB: some tests are enabled/disabled depending upon config in sysinfo.ini * * @author G. Giunta * @copyright (C) G. Giunta 2008-2016 * @license Licensed under GNU General Public License v2.0. See file license.txt */ // backwards compatibility if (!isset($Params['viewmode'])) { if (isset($Params['output_format'])) { $Params['viewmode'] = $Params['output_format']; } } $testsList = sysInfoTools::runTests(); $ezsnmpd_available = false; if (in_array('ezsnmpd', eZExtension::activeExtensions())) { $ezsnmpd_available = true; } if ($Params['viewmode'] == 'plaintext' || $Params['viewmode'] == 'json') { $response_type = $Params['viewmode']; $response_data = $testsList; return; } $tpl->setVariable('testslist', $testsList); $tpl->setVariable('ezsnmpd_available', $ezsnmpd_available);
/** * Register extensions "the YMC way". * * * @return void * @access public * @author ymc-dabe * @see eZExtension::activateExtensions() * @link http://issues.ez.no/IssueView.php?Id=2709 */ public function registerExtensions($virtual_siteaccess = false) { if (!$this->attribute('is_enabled')) { eZDebug::writeError("The ymcExtensionLoader is disabled, but " . __METHOD__ . " has just been called (which really shouldn't be done)!", __METHOD__); } $siteaccess = self::getCurrentSiteaccess(); $isBasicLoad = true; $is_virtual_load = false; $cache_hit = false; $defaultActiveExtensions = self::$alwaysEnabledExtensions; if (!in_array('ymcextensionloader', $defaultActiveExtensions)) { $defaultActiveExtensions[] = 'ymcextensionloader'; } if ($this->standardLoadingCompleted === true and $virtual_siteaccess !== false and $siteaccess !== $virtual_siteaccess) { if ($this->virtualLoadingCompleted === true) { eZDebug::writeError("Unnecessary call to 'ymcExtensionLoader::registerExtensions('.{$virtual_siteaccess}.')'!", __METHOD__); return; } $siteaccess = $virtual_siteaccess; self::setInternalSiteaccess($siteaccess); eZDebug::accumulatorStart('OpenVolanoExtensionLoader_VirtualSiteaccess', 'OpenVolano: Enhanced Extension Loader', "After virtual siteaccess '{$siteaccess}' initialised "); $isBasicLoad = false; $is_virtual_load = true; $this->rebuildIniOverrideArray($siteaccess, $isBasicLoad); } else { if (null !== $siteaccess) { if ($this->standardLoadingCompleted === true) { eZDebug::writeError("Unnecessary call to " . __METHOD__ . "!", __METHOD__); return; } $isBasicLoad = false; eZDebug::accumulatorStart('OpenVolanoExtensionLoader_Siteaccess', 'OpenVolano: Enhanced Extension Loader', "After siteaccess '{$siteaccess}' initialised "); } else { if (self::$earlyLoadingCompleted === true) { eZDebug::writeWarning("Force registering additional extensions - please keep in mind, that it is not possible to unload extensions", __METHOD__); } eZDebug::accumulatorStart('OpenVolanoExtensionLoader_Basic', 'OpenVolano: Enhanced Extension Loader', 'Pre siteaccess initialised'); } } $ini = eZINI::instance(); $allExtensionsRegistered = false; if ($isBasicLoad) { self::$globalCacheDirectory = eZSys::cacheDirectory(); $cacheFileName = 'basic'; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionBasicLoadInformation'; } else { if ($is_virtual_load) { $cacheFileName = 'siteaccess-' . $this->attribute('non_virtual_siteaccess') . '-virtualsiteaccess-' . $siteaccess; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionVirtualSiteaccessLoadInformation'; } else { $cacheFileName = 'siteaccess-' . $siteaccess; $cache_var_name = 'ymcExtensionLoaderRegisterExtensionSiteaccessLoadInformation'; } } $write_cache = false; $can_write_cache = true; $cacheDir = eZSys::cacheDirectory() . '/openvolano/extensions'; if (!is_writable($cacheDir)) { if (!eZDir::mkdir($cacheDir, 0777, true)) { $can_write_cache = false; eZDebug::writeError("Couldn't create cache directory '{$cacheDir}', perhaps wrong permissions", __METHOD__); } } $cacheFilePath = $cacheDir . '/' . $cacheFileName; if (!file_exists($cacheFilePath)) { $write_cache = $can_write_cache; if ($isBasicLoad) { eZDebug::writeNotice("No cache found for loading basic set of extensions", __METHOD__); } else { eZDebug::writeNotice("No cache found for loading per siteaccess set of extensions for siteaccess '{$siteaccess}'", __METHOD__); } } else { include $cacheFilePath; if (!isset(${$cache_var_name})) { eZDebug::writeWarning("Cache '{$cache_var_name}' in file '{$cacheFilePath}' not found. Trying to force rewrite of this cache file...", __METHOD__); $write_cache = $can_write_cache; } else { eZDebug::writeNotice("Cache hit: {$cacheFilePath}", __METHOD__); $defaultActiveExtensions = ${$cache_var_name}; $cache_hit = true; unset($cache_var_name); } } $additional_lookups = 0; //Loop registering of extensions until all are loaded while (!$allExtensionsRegistered) { //First we asume we do not need to check for new extensions $allExtensionsRegistered = true; //these extensions are always active $activeExtensions = $defaultActiveExtensions; //Get all active extension $activeExtensions = array_unique(array_merge($activeExtensions, eZExtension::activeExtensions())); foreach ($activeExtensions as $activeExtension) { //only activate an extension if it has not been registered, yet if (!in_array($activeExtension, $this->registeredExtensions)) { $this->registeredExtensions[] = $activeExtension; $fullExtensionPath = eZExtension::baseDirectory() . '/' . $activeExtension; if (!file_exists($fullExtensionPath)) { eZDebug::writeWarning("Extension '{$activeExtension}' does not exist, looked for directory '{$fullExtensionPath}'", __METHOD__); } else { $fullExtensionAutoloadPath = $fullExtensionPath . '/autoload'; if ($activeExtension !== 'ymcextensionloader' and !in_array($activeExtension, self::$noAutoloadExtensions) and file_exists($fullExtensionAutoloadPath)) { //add the new extension's autoload-dir to the eZ compontents autoload system (if needed) ezcBase::addClassRepository($fullExtensionPath, $fullExtensionAutoloadPath); } //We are about to activate a new extension which might need to load one ore more other extension (if we do not have a cached info about this) $allExtensionsRegistered = $cache_hit; } } } $this->rebuildIniOverrideArray($siteaccess, $isBasicLoad); if (!$allExtensionsRegistered) { $additional_lookups++; } } if (!$cache_hit) { if ($isBasicLoad) { eZDebug::writeNotice("Loaded all basic extensions in {$additional_lookups} additional lookups...", __METHOD__); } else { if ($is_virtual_load) { eZDebug::writeNotice("Loaded all virtual siteaccess extensions in {$additional_lookups} additional lookups...", __METHOD__); } else { eZDebug::writeNotice("Loaded all siteaccess extensions in {$additional_lookups} additional lookups...", __METHOD__); } } } if ($write_cache) { if ($isBasicLoad) { eZDebug::writeNotice("Storing basic extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } else { if ($is_virtual_load) { eZDebug::writeNotice("Storing virtual siteaccess extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } else { eZDebug::writeNotice("Storing siteaccess extension load information into cache file '{$cacheFilePath}'...", __METHOD__); } } $php = new eZPHPCreator($cacheDir, $cacheFileName); $php->addRawVariable($cache_var_name, $this->registeredExtensions); $php->store(); } if ($is_virtual_load) { $this->virtualLoadingCompleted = true; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_VirtualSiteaccess'); } else { if (!$isBasicLoad) { $this->standardLoadingCompleted = true; $this->non_virtual_siteaccess_name = $siteaccess; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_Siteaccess'); } else { self::$earlyLoadingCompleted = true; eZDebug::accumulatorStop('OpenVolanoExtensionLoader_Basic'); } } //Use the following line to take a look into the ini-hierarchy... //ymc_pr($GLOBALS["eZINIOverrideDirList"], $siteaccess.'|'.self::getCurrentSiteaccess()); if (!$is_virtual_load and !$isBasicLoad and $ini->hasVariable('SiteAccessSettings', 'VirtualSiteaccessSystem') and $ini->variable('SiteAccessSettings', 'VirtualSiteaccessSystem') !== 'disabled') { $allowLoadingOfPreviouslyKnownSiteaccesses = false; if ($ini->hasVariable('SiteAccessSettings', 'VirtualSiteaccessSystem') and $ini->variable('VirtualSiteaccessSettings', 'AllowLoadingOfPerviouslyKnowSiteaccesses') === 'enabled') { $allowLoadingOfPreviouslyKnownSiteaccesses = true; } if (isset($GLOBALS['eZURIRequestInstance']) and is_object($GLOBALS['eZURIRequestInstance'])) { $uri = eZURI::instance(); $elements = $uri->elements(false); if (count($elements) > 0 and $elements[0] != '') { $goInVirtualSiteaccessMode = true; if ($ini->hasVariable('VirtualSiteaccessSettings', 'SkipLoadingForUri') and is_array($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri')) and count($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri')) > 0) { $uri_string = $uri->elements(true); foreach ($ini->variable('VirtualSiteaccessSettings', 'SkipLoadingForUri') as $ignoreUriForVirtualSiteaccess) { if (strpos($uri_string, $ignoreUriForVirtualSiteaccess) === 0) { $goInVirtualSiteaccessMode = false; break; } } unset($uri_string); } } else { $goInVirtualSiteaccessMode = false; } if ($goInVirtualSiteaccessMode) { $matchIndex = 1; $name = $elements[0]; //by ymc-dabe //Code taken from /access.php line 241-249 of eZ publish v4.1.3 //KEEP IT IN SYNC! //start $name = preg_replace(array('/[^a-zA-Z0-9]+/', '/_+/', '/^_/', '/_$/'), array('_', '_', '', ''), $name); //by ymc-dabe //Code taken from /access.php line 241-249 of eZ publush v4.1.3 //KEEP IT IN SYNC! //end if ($allowLoadingOfPreviouslyKnownSiteaccesses or !in_array($name, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { eZSys::addAccessPath($name); $uri->increase($matchIndex); $uri->dropBase(); $this->registerExtensions($name); //die if virtual siteaccess is not found if (!in_array($name, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { header($_SERVER['SERVER_PROTOCOL'] . " 400 Bad Request"); header("Status: 400 Bad Request"); eZExecution::cleanExit(); } } unset($name); } } else { if (isset($GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess']) and $GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess'] != '') { $virtualSiteaccessName = $GLOBALS['ymcEnhancedExtensionLoaderVirtualSiteaccess']; if ($allowLoadingOfPreviouslyKnownSiteaccesses or !in_array($virtualSiteaccessName, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { eZSys::addAccessPath($virtualSiteaccessName); $this->registerExtensions($virtualSiteaccessName); if (!in_array($virtualSiteaccessName, $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'))) { fputs(STDERR, "\n----------\nError: Invalid siteaccess '{$virtualSiteaccessName}'!\n----------\n\n"); eZExecution::cleanExit(); } } unset($virtualSiteaccessName); } } } else { if ($this->standardLoadingCompleted === true) { $this->virtualLoadingCompleted = true; } } if ($this->standardLoadingCompleted === true) { $this->loadingCompleted = true; if ($this->originalNonVirtualSiteaccessName === false) { $this->originalNonVirtualSiteaccessName = $this->attribute('non_virtual_siteaccess'); if ($this->originalVirtualSiteaccessName === false and $siteaccess != $this->attribute('non_virtual_siteaccess')) { $this->originalVirtualSiteaccessName = $siteaccess; } } } }
$ver = eZPublishSDK::majorVersion(); $restv2 = $ver >= 2012 & eZPublishSDK::minorVersion() >= 9 || $ver >= 5 && $ver < 2011; $method = '/'; } else { $uri = "webservices/execute/{$protocol}"; } } } eZURI::transformURI($uri, false, 'full'); if ($protocol == 'rest v2' || $protocol == 'rest v1') { // for now, manually remove siteaccess name if found in url $sa = $GLOBALS['eZCurrentAccess']['name']; $uri = str_replace("/{$sa}/", "/", $uri); } /// @todo disable link if ezjscore not active, enable rest v1 and rest v2 ... if ($protocol == 'ezjscore' && in_array('ezjscore', eZExtension::activeExtensions()) || $protocol != 'ezjscore' && $protocol != 'rest v1' && $protocol != 'rest v2' && $wsINI->variable('GeneralSettings', 'Enable' . strtoupper($protocol)) == 'true' || $protocol == 'rest v1' && $restv1 || $protocol == 'rest v2' && $restv2) { $url = parse_url($uri); $params = '?wsaction='; $params .= '&host=' . $url['host']; $params .= '&port=' . (isset($url['port']) ? $url['port'] : ''); $params .= '&path=' . (isset($url['path']) ? $url['path'] : '/'); if ($url['scheme'] == 'https') { $params .= '&protocol=2'; } if ($i > 4) { $i = 4; } $params .= "&wstype={$i}"; /// @todo filter out all cookies except the one for current session ? $ccookies = array(); foreach ($_COOKIE as $cn => $cv) {
function loadAndRegisterExtensionGateways() { $gatewaysINI = eZINI::instance('paymentgateways.ini'); $siteINI = eZINI::instance('site.ini'); $extensionDirectory = $siteINI->variable('ExtensionSettings', 'ExtensionDirectory'); $activeExtensions = eZExtension::activeExtensions(); foreach ($activeExtensions as $extension) { $gatewayPath = "{$extensionDirectory}/{$extension}/classes/" . $extension . 'gateway.php'; if (file_exists($gatewayPath)) { include_once $gatewayPath; } } }
/** * EVENT EZ FLOW -> Reverse smart view cache * Called from Listener factory * @param array $nodeList * @return array */ public static function addReverseRelatedNodesIfNeeded( $nodeList ) { $activeExtensions = eZExtension::activeExtensions(); if ( in_array( 'ezflow', $activeExtensions ) ) $nodeList = array_unique( self::addReverseRelatedNodes( $nodeList ) ); return $nodeList; }
/** * @todo set up soap and webdav tests */ public static function runTests() { $status_tests = array('db' => '0', 'cluster db' => '0', 'ldap server' => '0', 'web access' => '0', 'ezfind' => '0', 'mail' => '0'); $db = eZDB::instance(); if ($db->isConnected() === true) { $status_tests['db'] = '1'; } $clusterDBHandler = ezSysinfoClusterManager::clusterDBHandler(); if ($clusterDBHandler instanceof eZDBFileHandler) { // warning - we dig into the private parts of the cluster file handler, // as no real API are provided for it (yet) if (is_resource($clusterDBHandler->backend->db)) { $status_tests['cluster db'] = '1'; } } else { if (is_object($clusterDBHandler)) { // This is even worse: we have no right to know if db connection is ok. // So we replicate some code here... try { $clusterDBHandler->_connect(); $status_tests['cluster db'] = '1'; } catch (exception $e) { } } else { $status_tests['cluster db'] = 'X'; } } if (in_array('ezfind', eZExtension::activeExtensions())) { $ini = eZINI::instance('solr.ini'); $ezfinpingurl = $ini->variable('SolrBase', 'SearchServerURI') . "/admin/ping"; $data = eZHTTPTool::getDataByURL($ezfinpingurl, false); $pos2 = stripos($data, '<str name="status">OK</str>'); if ($pos2 !== false) { $status_tests['ezfind'] = '1'; } else { $status_tests['ezfind'] = '0'; } } else { $status_tests['ezfind'] = 'X'; } $ini = eZINI::instance('ldap.ini'); if ($ini->variable('LDAPSettings', 'LDAPEnabled') == 'true' && $ini->variable('LDAPSettings', 'LDAPServer') != '') { if (function_exists('ldap_connect')) { // code copied over ezldapuser class... $LDAPVersion = $ini->variable('LDAPSettings', 'LDAPVersion'); $LDAPServer = $ini->variable('LDAPSettings', 'LDAPServer'); $LDAPPort = $ini->variable('LDAPSettings', 'LDAPPort'); $LDAPBindUser = $ini->variable('LDAPSettings', 'LDAPBindUser'); $LDAPBindPassword = $ini->variable('LDAPSettings', 'LDAPBindPassword'); $ds = ldap_connect($LDAPServer, $LDAPPort); if ($ds) { ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $LDAPVersion); if ($LDAPBindUser == '') { $r = ldap_bind($ds); } else { $r = ldap_bind($ds, $LDAPBindUser, $LDAPBindPassword); } if ($r) { $status_tests['ldap server'] = '1'; } } } } else { $status_tests['ldap server'] = 'X'; } $ini = eZINI::instance('sysinfo.ini'); $websites = $ini->variable('SystemStatus', 'WebBeacons'); if (is_string($websites)) { $websites = array($websites); } foreach ($websites as $key => $site) { if (trim($site) == '') { unset($websites[$key]); } } if (count($websites)) { foreach ($websites as $site) { // current eZ code is broken if no curl is installed, as it does not check for 404 or such. // besides, it does not even support proxies... if (extension_loaded('curl')) { if (eZHTTPTool::getDataByURL($site, true)) { $status_tests['web access'] = '1'; break; } } else { $data = eZHTTPTool::getDataByURL($site, false); if ($data !== false && sysInfoTools::isHTTP200($data)) { $status_tests['web access'] = '1'; break; } } } } else { $status_tests['web access'] = 'X'; } $ini = eZINI::instance('sysinfo.ini'); $recipient = $ini->variable('SystemStatus', 'MailReceiver'); $mail = new eZMail(); if (trim($recipient) != '' && $mail->validate($recipient)) { $mail->setReceiver($recipient); $ini = eZINI::instance(); $sender = $ini->variable('MailSettings', 'EmailSender'); $mail->setSender($sender); $mail->setSubject("Test email"); $mail->setBody("This email was automatically sent while testing eZ Publish connectivity to the mail server. Please do not reply."); $mailResult = eZMailTransport::send($mail); if ($mailResult) { $status_tests['mail'] = '1'; } } else { $status_tests['mail'] = 'X'; } /* $ini = eZINI::instance( 'soap.ini' ); if ( $ini->variable( 'GeneralSettings', 'EnableSOAP' ) == 'true' ) { /// @todo... } else { $status_tests['ez soap'] = 'X'; } $ini = eZINI::instance( 'webdav.ini' ); if ( $ini->variable( 'GeneralSettings', 'EnableWebDAV' ) == 'true' ) { /// @todo... } else { $status_tests['ez webdav'] = 'X'; } */ return $status_tests; }
} if (count($checkResult) == 0) { $tpl->setVariable('md5_result', 'ok'); } else { $tpl->setVariable('md5_result', $checkResult); } } } if ($Module->isCurrentAction('DBCheck')) { $db = eZDB::instance(); $dbSchema = eZDbSchema::instance(); // read original schema from dba file $originalSchema = eZDbSchema::read('share/db_schema.dba'); // merge schemas from all active extensions that declare some db schema $extensionsdir = eZExtension::baseDirectory(); foreach (eZExtension::activeExtensions() as $activeextension) { if (file_exists($extensionsdir . '/' . $activeextension . '/share/db_schema.dba')) { if ($extensionschema = eZDbSchema::read($extensionsdir . '/' . $activeextension . '/share/db_schema.dba')) { $originalSchema = eZDbSchema::merge($originalSchema, $extensionschema); } } } // transform schema to 'localized' version for current db // (we might as well convert $dbSchema to generic format and diff in generic format, // but eZDbSchemaChecker::diff does not know how to re-localize the generated sql $dbSchema->transformSchema($originalSchema, true); $differences = eZDbSchemaChecker::diff($dbSchema->schema(array('format' => 'local', 'force_autoincrement_rebuild' => true)), $originalSchema); $sqlDiff = $dbSchema->generateUpgradeFile($differences); if (strlen($sqlDiff) == 0) { $tpl->setVariable('upgrade_sql', 'ok'); } else {
function getDBAExtensionFilePath() { $activeExtensions = eZExtension::activeExtensions(); $dataTypeString = $this->DataTypeString; $dbaFileName = $this->getDBAFileName(); $fileName = false; foreach ($activeExtensions as $activeExtension) { $extesionFileName = eZExtension::baseDirectory() . '/' . $activeExtension . '/datatypes/' . $dataTypeString . '/' . $dbaFileName; if (file_exists($extesionFileName)) { $fileName = $extesionFileName; break; } } return $fileName; }
/** * @desc The view : generation * @author David LE RICHE <*****@*****.**> * @param array $params => view parameter array * @return array * @copyright 2012 * @version 1.1 */ public static function generateTranslation($Params) { $tpl = eZTemplate::factory(); if (isset($_POST['todo']) && $_POST['todo'] == 'chooseExtension') { try { $tabFileDir = array(); $tfGene = new OWTranslateTranslationFileGenerator(); foreach ($_POST['extension'] as $extension) { $tabFileDir = array_merge($tabFileDir, $tfGene->scanDirectory(eZExtension::baseDirectory() . '/' . $extension)); $tfGene->tabFile = array_merge($tfGene->tabFile, $tabFileDir); } $tfGene->analyseFiles(); $isGenerate = $tfGene->generateXML(); $tpl->setVariable('generation', $isGenerate ? true : false); } catch (Exception $e) { eZLog::write($e, 'owtranslate.log'); } } else { $tpl->setVariable('extensionList', eZExtension::activeExtensions()); } // return the view $Result = self::getView('generation', $tpl); return $Result; }