/** * @static * @return mixed|\Zend_Db_Adapter_Abstract */ public static function get() { try { if (\Zend_Registry::isRegistered("Pimcore_Resource_Mysql")) { $connection = \Zend_Registry::get("Pimcore_Resource_Mysql"); if ($connection instanceof Wrapper) { return $connection; } } } catch (\Exception $e) { \Logger::error($e); } // get new connection try { $db = self::getConnection(); self::set($db); return $db; } catch (\Exception $e) { $errorMessage = "Unable to establish the database connection with the given configuration in /website/var/config/system.xml, for details see the debug.log. \nReason: " . $e->getMessage(); \Logger::emergency($errorMessage); \Logger::emergency($e); \Pimcore\Tool::exitWithError($errorMessage); } }
/** * @param bool $forceReload * @return mixed|null|\Zend_Config * @throws \Zend_Exception */ public static function getSystemConfig($forceReload = false) { $config = null; if (\Zend_Registry::isRegistered("pimcore_config_system") && !$forceReload) { $config = \Zend_Registry::get("pimcore_config_system"); } else { try { $file = self::locateConfigFile("system.php"); if (file_exists($file)) { $config = new \Zend_Config(include $file); } else { throw new \Exception($file . " doesn't exist"); } self::setSystemConfig($config); } catch (\Exception $e) { $file = self::locateConfigFile("system.php"); \Logger::emergency("Cannot find system configuration, should be located at: " . $file); if (is_file($file)) { $m = "Your system.php located at " . $file . " is invalid, please check and correct it manually!"; Tool::exitWithError($m); } } } return $config; }
/** * @static * @return \Zend_Config */ public static function getConfig() { $config = null; if (\Zend_Registry::isRegistered("coreshop_config")) { $config = \Zend_Registry::get("coreshop_config"); } else { try { $config = new \Zend_Config_Xml(CORESHOP_CONFIGURATION); self::setConfig($config); } catch (\Exception $e) { \Logger::emergency("Cannot find system configuration, should be located at: " . PIMCORE_CONFIGURATION_SYSTEM); if (is_file(CORESHOP_CONFIGURATION)) { $m = "Your coreshop-config.xml located at " . CORESHOP_CONFIGURATION . " is invalid, please check and correct it manually!"; \Pimcore\Tool::exitWithError($m); } } } return $config; }
/** * @param bool $forceReload * @return mixed|null|\Zend_Config_Xml * @throws \Zend_Exception */ public static function getSystemConfig($forceReload = false) { $config = null; if (\Zend_Registry::isRegistered("pimcore_config_system") && !$forceReload) { $config = \Zend_Registry::get("pimcore_config_system"); } else { try { $config = new \Zend_Config_Xml(PIMCORE_CONFIGURATION_SYSTEM); self::setSystemConfig($config); } catch (\Exception $e) { \Logger::emergency("Cannot find system configuration, should be located at: " . PIMCORE_CONFIGURATION_SYSTEM); if (is_file(PIMCORE_CONFIGURATION_SYSTEM)) { $m = "Your system.xml located at " . PIMCORE_CONFIGURATION_SYSTEM . " is invalid, please check and correct it manually!"; Tool::exitWithError($m); } } } return $config; }
/** * @static * @return \Zend_Config */ public static function getConfig() { $config = NULL; if (\Zend_Registry::isRegistered('toolbox_config')) { $config = \Zend_Registry::get('toolbox_config'); } else { $configFile = TOOLBOX_CONFIGURATION_FILE; try { $config = new \Zend_Config(include $configFile); self::setConfig($config, 'toolbox_config'); } catch (\Exception $e) { \Logger::emergency("Cannot find system configuration, should be located at: " . $configFile); if (is_file($configFile)) { Tool::exitWithError("Your toolbox_configuration.php located at " . $configFile . " is invalid, please check and correct it manually!"); } } } return $config; }
/** * @throws \Zend_Controller_Response_Exception */ public function checkForErrors() { if ($error = $this->getParam('error_handler')) { if ($error->exception) { if ($error->exception instanceof \Zend_Controller_Router_Exception || $error->exception instanceof \Zend_Controller_Action_Exception) { header('HTTP/1.1 404 Not Found'); //$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found'); $this->getResponse()->setHttpResponseCode(404); // check if the resource that wasn't found is a common static file // for them we don't show the error page, as generating this is very heavy in terms of performance if (preg_match("/\\.(js|css|png|jpe?g|gif|eot|ttf|woff|svg|ico|map|swf|txt)\$/", $this->getRequest()->getPathInfo())) { echo "HTTP/1.1 404 Not Found\nFiltered by error handler (static file exception)"; exit; } } else { header('HTTP/1.1 503 Service Temporarily Unavailable'); //$this->getResponse()->setRawHeader('HTTP/1.1 503 Service Temporarily Unavailable'); $this->getResponse()->setHttpResponseCode(503); } \Logger::error("Unable to find URL: " . $_SERVER["REQUEST_URI"]); \Logger::error($error->exception); \Pimcore::getEventManager()->trigger("frontend.error", $this, ["exception" => $error->exception]); try { // check if we have the error page already in the cache // the cache is written in Pimcore\Controller\Plugin\HttpErrorLog::dispatchLoopShutdown() $cacheKey = "error_page_response_" . \Pimcore\Tool\Frontend::getSiteKey(); if ($responseBody = \Pimcore\Cache::load($cacheKey)) { $this->getResponse()->setBody($responseBody); $this->getResponse()->sendResponse(); // write to http_error log $errorLogPlugin = \Zend_Controller_Front::getInstance()->getPlugin("Pimcore\\Controller\\Plugin\\HttpErrorLog"); if ($errorLogPlugin) { $errorLogPlugin->writeLog(); } exit; } else { $document = \Zend_Registry::get("pimcore_error_document"); $this->setDocument($document); $this->setParam("document", $document); $this->disableLayout(); // http_error log writing is done in Pimcore_Controller_Plugin_HttpErrorLog in this case } } catch (\Exception $e) { $m = "Unable to load error document"; Tool::exitWithError($m); } } } }
/** * @static * */ public static function setSystemRequirements() { // try to set system-internal variables $maxExecutionTime = 240; if (php_sapi_name() == "cli") { $maxExecutionTime = 0; } error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); //@ini_set("memory_limit", "1024M"); @ini_set("max_execution_time", $maxExecutionTime); @set_time_limit($maxExecutionTime); mb_internal_encoding("UTF-8"); // this is for simple_dom_html ini_set('pcre.recursion-limit', 100000); // set dummy timezone if no tz is specified / required for example by the logger, ... $defaultTimezone = @date_default_timezone_get(); if (!$defaultTimezone) { date_default_timezone_set("UTC"); // UTC -> default timezone } // check some system variables if (version_compare(PHP_VERSION, '5.4', "<")) { $m = "pimcore requires at least PHP version 5.4.0 your PHP version is: " . PHP_VERSION; Tool::exitWithError($m); } }
/** * @static * @return mixed|\Zend_Config */ public static function getPerspectivesConfig() { if (\Zend_Registry::isRegistered("pimcore_config_perspectives")) { $config = \Zend_Registry::get("pimcore_config_perspectives"); } else { try { $file = self::locateConfigFile("perspectives.php"); if (file_exists($file)) { $config = new \Zend_Config(include $file); } else { throw new \Exception($file . " doesn't exist"); } self::setPerspectivesConfig($config); } catch (\Exception $e) { Logger::info("Cannot find perspectives configuration, should be located at: " . $file); if (is_file($file)) { $m = "Your perspectives.php located at " . $file . " is invalid, please check and correct it manually!"; Tool::exitWithError($m); } $config = new \Zend_Config(self::getStandardPerspective()); self::setPerspectivesConfig($config); } } return $config; }
/** * @return mixed|null|\Zend_Config_Xml * @throws \Zend_Exception */ public static function getPluginConfig() { $config = NULL; if (\Zend_Registry::isRegistered('lucenesearch_plugin_config')) { $config = \Zend_Registry::get('lucenesearch_plugin_config'); } else { try { $config = new \Zend_Config_Xml(LUCENESEARCH__PLUGIN_CONFIG); self::setPluginConfig($config); } catch (\Exception $e) { if (is_file(LUCENESEARCH__PLUGIN_CONFIG)) { $m = 'Your plugin_xml.xml located at ' . LUCENESEARCH__PLUGIN_CONFIG . ' is invalid, please check and correct it manually!'; Tool::exitWithError($m); } } } return $config; }