本文整理汇总了PHP中System::shutDown方法的典型用法代码示例。如果您正苦于以下问题:PHP System::shutDown方法的具体用法?PHP System::shutDown怎么用?PHP System::shutDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::shutDown方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handler
/**
* Handles an error.
*
* @param integer $errno Number of the error.
* @param string $errstr Error message.
* @param string $errfile Filename where the error occurred.
* @param integer $errline Line of the error.
* @param string $errcontext Context of the error.
*
* @return boolean
*/
public function handler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = null)
{
$this->setupHandler($errno, $errstr, $errfile, $errline, $errcontext);
// Notify all loggers
$this->eventManager->notify($this->event->setArgs(array('trace' => $this->trace, 'type' => $this->type, 'errno' => $this->errno, 'errstr' => $this->errstr, 'errfile' => $this->errfile, 'errline' => $this->errline, 'errcontext' => $this->errcontext)));
if ($this->isPHPError() && System::isDevelopmentMode() && $this->showPHPErrorHandler()) {
// allow PHP to return error
$this->resetHandler();
return false;
}
if (!$this->isDisplayErrorTemplate()) {
// prevent PHP from handling the event after we return
$this->resetHandler();
return true;
}
// obey reporing level
if (abs($this->getType()) > $this->serviceManager['log.display_level']) {
return false;
}
// unless in development mode, exit.
if (!$this->serviceManager['log.display_template']) {
return false;
}
// if we get this far, display template
echo ModUtil::func('Errors', 'user', 'system', array('type' => $this->errno, 'message' => $this->errstr, 'file' => $this->errfile, 'line' => $this->errline));
Zikula_View_Theme::getInstance()->themefooter();
System::shutDown();
}
示例2: onCoreInit
public function onCoreInit(GenericEvent $event)
{
/** @var Request $request */
$request = $this->container->get('request');
// create several booleans to test condition of request regarding install/upgrade
$installed = $this->container->getParameter('installed');
if ($installed) {
VersionUtil::defineCurrentInstalledCoreVersion($this->container);
}
$requiresUpgrade = $installed && version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, \Zikula_Core::VERSION_NUM, '<');
// can't use $request->get('_route') to get any of the following
// all these routes are hard-coded in xml files
$uriContainsInstall = strpos($request->getRequestUri(), '/install') !== false;
$uriContainsUpgrade = strpos($request->getRequestUri(), '/upgrade') !== false;
$uriContainsDoc = strpos($request->getRequestUri(), '/installdoc') !== false;
$uriContainsWdt = strpos($request->getRequestUri(), '/_wdt') !== false;
$uriContainsProfiler = strpos($request->getRequestUri(), '/_profiler') !== false;
$uriContainsRouter = strpos($request->getRequestUri(), '/js/routing?callback=fos.Router.setData') !== false;
$doNotRedirect = $uriContainsProfiler || $uriContainsWdt || $uriContainsRouter || $request->isXmlHttpRequest();
// check if Zikula Core is not installed
if (!$installed && !$uriContainsDoc && !$uriContainsInstall && !$doNotRedirect) {
$this->container->get('router')->getContext()->setBaseUrl($request->getBasePath());
// compensate for sub-directory installs
$url = $this->container->get('router')->generate('install');
$response = new RedirectResponse($url);
$response->send();
\System::shutDown();
}
// check if Zikula Core requires upgrade
if ($requiresUpgrade && !$uriContainsDoc && !$uriContainsUpgrade && !$doNotRedirect) {
$this->container->get('router')->getContext()->setBaseUrl($request->getBasePath());
// compensate for sub-directory installs
$url = $this->container->get('router')->generate('upgrade');
$response = new RedirectResponse($url);
$response->send();
\System::shutDown();
}
if (!$installed || $requiresUpgrade || $this->container->hasParameter('upgrading')) {
\System::setInstalling(true);
}
}
示例3: queryStringDecode
/**
* Decode the path string into a set of variable/value pairs.
*
* This API works in conjunction with the new short urls
* system to extract a path based variable set into the Get, Post
* and request superglobals.
* A sample path is /modname/function/var1:value1.
*
* @return void
*/
public static function queryStringDecode()
{
if (self::isInstalling()) {
return;
}
// get our base parameters to work out if we need to decode the url
$module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
$func = FormUtil::getPassedValue('func', null, 'GETPOST', FILTER_SANITIZE_STRING);
$type = FormUtil::getPassedValue('type', null, 'GETPOST', FILTER_SANITIZE_STRING);
// check if we need to decode the url
if (self::getVar('shorturls') && (empty($module) && empty($type) && empty($func))) {
// user language is not set at this stage
$lang = System::getVar('language_i18n', '');
$customentrypoint = self::getVar('entrypoint');
$expectEntrypoint = !self::getVar('shorturlsstripentrypoint');
$root = empty($customentrypoint) ? 'index.php' : $customentrypoint;
// check if we hit baseurl, e.g. domain.com/ and if we require the language URL
// then we should redirect to the language URL.
if (ZLanguage::isRequiredLangParam() && self::getCurrentUrl() == self::getBaseUrl()) {
$uri = $expectEntrypoint ? "{$root}/{$lang}" : "{$lang}";
self::redirect(self::getBaseUrl() . $uri);
self::shutDown();
}
// check if entry point is part of the URL expectation. If so throw error if it's not present
// since this URL is technically invalid.
if ($expectEntrypoint && strpos(self::getCurrentUrl(), self::getBaseUrl() . $root) !== 0) {
$protocol = System::serverGetVar('SERVER_PROTOCOL');
header("{$protocol} 404 Not Found");
echo __('The requested URL cannot be found');
system::shutDown();
}
if (!$expectEntrypoint && self::getCurrentUrl() == self::getBaseUrl() . $root) {
self::redirect(self::getHomepageUrl());
self::shutDown();
}
if (!$expectEntrypoint && strpos(self::getCurrentUrl(), self::getBaseUrl() . $root) === 0) {
$protocol = System::serverGetVar('SERVER_PROTOCOL');
header("{$protocol} 404 Not Found");
echo __('The requested URL cannot be found');
system::shutDown();
}
// get base path to work out our current url
$parsedURL = parse_url(self::getCurrentUri());
// strip any unwanted content from the provided URL
$tobestripped = array(self::getBaseUri(), "{$root}");
$path = str_replace($tobestripped, '', $parsedURL['path']);
$path = trim($path, '/');
// split the path into a set of argument strings
$args = explode('/', rtrim($path, '/'));
// ensure that each argument is properly decoded
foreach ($args as $k => $v) {
$args[$k] = urldecode($v);
}
$modinfo = null;
$frontController = $expectEntrypoint ? "{$root}/" : '';
// if no arguments present
if (!$args[0] && !isset($_GET['lang']) && !isset($_GET['theme'])) {
// we are in the homepage, checks if language code is forced
if (ZLanguage::getLangUrlRule() && $lang) {
// and redirect then
$response = new RedirectResponse(self::getCurrentUrl() . "/{$lang}");
$respose->send();
System::shutDown();
}
} else {
// check the existing shortURL parameters
// validation of the first parameter as language code
if (ZLanguage::isLangParam($args[0]) && in_array($args[0], ZLanguage::getInstalledLanguages())) {
// checks if the language is not enforced and this url is passing the default lang
if (!ZLanguage::getLangUrlRule() && $lang == $args[0]) {
// redirects the passed arguments without the default site language
array_shift($args);
foreach ($args as $k => $v) {
$args[$k] = urlencode($v);
}
$response = new RedirectResponse(self::getBaseUrl() . $frontController . ($args ? implode('/', $args) : ''));
$respose->send();
System::shutDown();
}
self::queryStringSetVar('lang', $args[0]);
array_shift($args);
} elseif (ZLanguage::getLangUrlRule()) {
// if the lang is forced, redirects the passed arguments plus the lang
foreach ($args as $k => $v) {
$args[$k] = urlencode($v);
}
$langTheme = isset($_GET['theme']) ? "{$lang}/{$_GET['theme']}" : $lang;
$response = new RedirectResponse(self::getBaseUrl() . $frontController . $langTheme . '/' . implode('/', $args));
$response->send();
System::shutDown();
//.........这里部分代码省略.........
示例4: init
/**
* Initialise Zikula.
*
* Carries out a number of initialisation tasks to get Zikula up and
* running.
*
* @param integer $stage Stage to load.
*
* @return boolean True initialisation successful false otherwise.
*/
public function init($stage = self::STAGE_ALL)
{
$coreInitEvent = new Zikula_Event('core.init', $this);
// store the load stages in a global so other API's can check whats loaded
$this->stage = $this->stage | $stage;
if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
ModUtil::flushCache();
System::flushCache();
$this->eventManager->notify(new Zikula_Event('core.preinit', $this));
}
// Initialise and load configuration
if ($stage & self::STAGE_CONFIG) {
if (System::isLegacyMode()) {
require_once 'lib/legacy/Compat.php';
}
// error reporting
if (!System::isInstalling()) {
// this is here because it depends on the config.php loading.
$event = new Zikula_Event('setup.errorreporting', null, array('stage' => $stage));
$this->eventManager->notify($event);
}
// initialise custom event listeners from config.php settings
$coreInitEvent->setArg('stage', self::STAGE_CONFIG);
$this->eventManager->notify($coreInitEvent);
}
// Check that Zikula is installed before continuing
if (System::getVar('installed') == 0 && !System::isInstalling()) {
System::redirect(System::getBaseUrl() . 'install.php?notinstalled');
System::shutDown();
}
if ($stage & self::STAGE_DB) {
try {
$dbEvent = new Zikula_Event('core.init', $this, array('stage' => self::STAGE_DB));
$this->eventManager->notify($dbEvent);
} catch (PDOException $e) {
if (!System::isInstalling()) {
header('HTTP/1.1 503 Service Unavailable');
require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
System::shutDown();
} else {
return false;
}
}
}
if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
ModUtil::dbInfoLoad('Extensions', 'Extensions');
ModUtil::initCoreVars();
ModUtil::dbInfoLoad('Settings', 'Settings');
ModUtil::dbInfoLoad('Theme', 'Theme');
ModUtil::dbInfoLoad('Users', 'Users');
ModUtil::dbInfoLoad('Groups', 'Groups');
ModUtil::dbInfoLoad('Permissions', 'Permissions');
ModUtil::dbInfoLoad('Categories', 'Categories');
if (!System::isInstalling()) {
ModUtil::registerAutoloaders();
}
$coreInitEvent->setArg('stage', self::STAGE_TABLES);
$this->eventManager->notify($coreInitEvent);
}
if ($stage & self::STAGE_SESSIONS) {
SessionUtil::requireSession();
$coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
$this->eventManager->notify($coreInitEvent);
}
// Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
// start block
if ($stage & self::STAGE_LANGS) {
$lang = ZLanguage::getInstance();
}
if ($stage & self::STAGE_DECODEURLS) {
System::queryStringDecode();
$coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
$this->eventManager->notify($coreInitEvent);
}
if ($stage & self::STAGE_LANGS) {
$lang->setup();
$coreInitEvent->setArg('stage', self::STAGE_LANGS);
$this->eventManager->notify($coreInitEvent);
}
// end block
if ($stage & self::STAGE_MODS) {
// Set compression on if desired
if (System::getVar('UseCompression') == 1) {
//ob_start("ob_gzhandler");
}
ModUtil::load('SecurityCenter');
$coreInitEvent->setArg('stage', self::STAGE_MODS);
$this->eventManager->notify($coreInitEvent);
}
//.........这里部分代码省略.........
示例5: processPdf
/**
* Processes a template file using dompdf (LGPL).
*
* @param Zikula_View $view Reference to view object.
* @param string $template Name of template to use.
*
* @return mixed Output.
*/
protected function processPdf(Zikula_View $view, $template)
{
// first the content, to set page vars
$output = $view->fetch($template);
// make local images absolute
$output = str_replace('img src="/', 'img src="' . System::serverGetVar('DOCUMENT_ROOT') . '/', $output);
// see http://codeigniter.com/forums/viewthread/69388/P15/#561214
//$output = utf8_decode($output);
// then the surrounding
$output = $view->fetch('include_pdfheader.tpl') . $output . '</body></html>';
$controllerHelper = new MUVideo_Util_Controller($this->serviceManager);
// create name of the pdf output file
$fileTitle = $controllerHelper->formatPermalink(System::getVar('sitename')) . '-' . $controllerHelper->formatPermalink(PageUtil::getVar('title')) . '-' . date('Ymd') . '.pdf';
// if ($_GET['dbg'] == 1) die($output);
// instantiate pdf object
$pdf = new \DOMPDF();
// define page properties
$pdf->set_paper('A4');
// load html input data
$pdf->load_html($output);
// create the actual pdf file
$pdf->render();
// stream output to browser
$pdf->stream($fileTitle);
// prevent additional output by shutting down the system
System::shutDown();
return true;
}
示例6: executeSQL
/**
* Execute SQL, check for errors and return result. Uses Doctrine's DBAL to generate DB-portable paging code.
*
* @param string $sql The SQL statement to execute.
* @param integer $limitOffset The lower limit bound (optional) (default=-1).
* @param integer $limitNumRows The upper limit bound (optional) (default=-1).
* @param boolean $exitOnError Whether to exit on error (default=true) (optional).
* @param boolean $verbose Whether to be verbose (default=true) (optional).
*
* @return mixed The result set of the successfully executed query or false on error.
* @throws Exception No SQL statment.
*/
public static function executeSQL($sql, $limitOffset = -1, $limitNumRows = -1, $exitOnError = true, $verbose = true)
{
if (!$sql) {
throw new Exception(__('No SQL statement to execute'));
}
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
if (!$connection && System::isInstalling()) {
return false;
}
try {
if ($limitNumRows > 0) {
$tStr = strtoupper(substr(trim($sql), 0, 7));
// Grab first 7 chars to allow syntax like "(SELECT" which may happen with UNION statements
if (strpos($tStr, 'SELECT') === false) {
// TODO D [use normal Select instead of showing an error message if paging is desired for something different than SELECTs] (Guite)
throw new Exception(__('Paging parameters can only be used for SELECT statements'));
}
if ($limitOffset > 0) {
$sql = $connection->modifyLimitQuery($sql, $limitNumRows, $limitOffset);
} else {
$sql = $connection->modifyLimitQuery($sql, $limitNumRows);
}
}
$stmt = $connection->prepare($sql);
//$stmt->setHydrationMode(Doctrine_Core::HYDRATE_RECORD);
if ($stmt->execute()) {
$result = $stmt;
}
if ($result) {
// catch manual SQL which requires cache flushes
$tab = null;
$sql = strtolower(trim(preg_replace("/\\s+/", " ", $sql)));
if (strpos($sql, 'update') === 0) {
list(, $tab, ) = explode(' ', $sql);
}
if (strpos($sql, 'delete') === 0) {
list(, , $tab, ) = explode(' ', $sql);
}
if ($tab && strpos($tab, 'session_info') === false) {
self::flushCache($tab);
}
return $result;
}
} catch (Exception $e) {
echo 'Error in DBUtil::executeSQL: ' . $sql . '<br />' . $e->getMessage() . '<br />';
if (System::isDevelopmentMode() && SecurityUtil::checkPermission('.*', '.*', ACCESS_ADMIN)) {
echo nl2br($e->getTraceAsString());
}
if ($exitOnError) {
System::shutDown();
}
}
return false;
}
示例7: _installer_alreadyinstalled
function _installer_alreadyinstalled(Smarty $smarty)
{
header('HTTP/1.1 500 Internal Server Error');
$smarty->display('installer_alreadyinstalled.tpl');
System::shutDown();
exit;
}
示例8: switch
$httpCode = 500;
$message = $e->getMessage();
$debug = $e->getTrace();
}
}
}
switch (true) {
case $return === true:
// prevent rendering of the theme.
System::shutDown();
break;
case $httpCode == 403:
if (!UserUtil::isLoggedIn()) {
$url = ModUtil::url('Users', 'user', 'login', array('returnpage' => urlencode(System::getCurrentUri())));
LogUtil::registerError(LogUtil::getErrorMsgPermission(), $httpCode, $url);
System::shutDown();
}
// there is no break here deliberately.
// there is no break here deliberately.
case $return === false:
if (!LogUtil::hasErrors()) {
LogUtil::registerError(__f('Could not load the \'%1$s\' module at \'%2$s\'.', array($module, $func)), $httpCode, null);
}
echo ModUtil::func('Errors', 'user', 'main', array('message' => $message, 'exception' => $e));
break;
case $httpCode == 200:
echo $return;
break;
default:
LogUtil::registerError(__f('The \'%1$s\' module returned an error in \'%2$s\'.', array($module, $func)), $httpCode, null);
echo ModUtil::func('Errors', 'user', 'main', array('message' => $message, 'exception' => $e));
示例9: processPdf
/**
* Processes a template file using dompdf (LGPL).
*
* @param Zikula_View $view Reference to view object.
* @param string $template Name of template to use.
*
* @return mixed Output.
*/
protected static function processPdf(Zikula_View $view, $template)
{
// first the content, to set page vars
$output = $view->fetch($template);
// see http://codeigniter.com/forums/viewthread/69388/P15/#561214
//$output = utf8_decode($output);
// then the surrounding
$output = $view->fetch('include_pdfheader.tpl') . $output . '</body></html>';
// create name of the pdf output file
$fileTitle = MUBoard_Util_Controller::formatPermalink(System::getVar('sitename')) . '-' . MUBoard_Util_Controller::formatPermalink(PageUtil::getVar('title')) . '-' . date('Ymd') . '.pdf';
//if ($_GET['dbg'] == 1) die($output);
// instantiate pdf object
$pdf = new DOMPDF();
// define page properties
$pdf->set_paper('A4');
// load html input data
$pdf->load_html($output);
// create the actual pdf file
$pdf->render();
// stream output to browser
$pdf->stream($fileTitle);
// prevent additional output by shutting down the system
System::shutDown();
return true;
}
示例10: onInit
/**
* Initialise Zikula.
*
* Carries out a number of initialisation tasks to get Zikula up and
* running.
*
* @param integer $stage Stage to load.
*
* @return boolean True initialisation successful false otherwise.
*/
public function onInit(GetResponseEvent $event)
{
if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST) {
return;
}
$this->dispatcher = $event->getDispatcher();
$this->stage = $stage = self::STAGE_ALL;
$coreInitEvent = new GenericEvent($this);
$coreInitEvent['request'] = $event->getRequest();
// store the load stages in a global so other API's can check whats loaded
$this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this));
// // Initialise and load configuration
// if ($stage & self::STAGE_CONFIG) {
// // error reporting
// if (!\System::isInstalling()) {
// // this is here because it depends on the config.php loading.
// $event = new GenericEvent(null, array('stage' => $stage));
// $this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event);
// }
//
// // initialise custom event listeners from config.php settings
// $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
// $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
// }
// // Check that Zikula is installed before continuing
// if (\System::getVar('installed') == 0 && !\System::isInstalling()) {
// $response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled');
// $response->send();
// \System::shutdown();
// }
if ($stage & self::STAGE_DB) {
try {
$dbEvent = new GenericEvent();
$this->dispatcher->dispatch('doctrine.init_connection', $dbEvent);
$dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
$this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent);
} catch (\PDOException $e) {
if (!\System::isInstalling()) {
header('HTTP/1.1 503 Service Unavailable');
require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl');
\System::shutDown();
} else {
return false;
}
}
}
if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
\ModUtil::initCoreVars();
\ModUtil::dbInfoLoad('SettingsModule', 'SettingsModule');
\ModUtil::dbInfoLoad('ThemeModule', 'ThemeModule');
\ModUtil::dbInfoLoad('UsersModule', 'UsersModule');
\ModUtil::dbInfoLoad('GroupsModule', 'GroupsModule');
\ModUtil::dbInfoLoad('PermissionsModule', 'PermissionsModule');
\ModUtil::dbInfoLoad('CategoriesModule', 'CategoriesModule');
if (!\System::isInstalling()) {
\ModUtil::registerAutoloaders();
}
$coreInitEvent->setArg('stage', self::STAGE_TABLES);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
if ($stage & self::STAGE_SESSIONS) {
\SessionUtil::requireSession();
$coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
// Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
// start block
if ($stage & self::STAGE_LANGS) {
$lang = \ZLanguage::getInstance();
}
if ($stage & self::STAGE_DECODEURLS) {
\System::queryStringDecode();
$coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
if ($stage & self::STAGE_LANGS) {
$lang->setup();
$coreInitEvent->setArg('stage', self::STAGE_LANGS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
// end block
if ($stage & self::STAGE_MODS) {
// Set compression on if desired
if (\System::getVar('UseCompression') == 1) {
//ob_start("ob_gzhandler");
}
\ModUtil::load('SecurityCenter');
$coreInitEvent->setArg('stage', self::STAGE_MODS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
//.........这里部分代码省略.........
示例11: executeSQL
/**
* Execute SQL, check for errors and return result. Uses Doctrine's DBAL to generate DB-portable paging code.
*
* @param string $sql The SQL statement to execute.
* @param integer $limitOffset The lower limit bound (optional) (default=-1).
* @param integer $limitNumRows The upper limit bound (optional) (default=-1).
* @param boolean $exitOnError Whether to exit on error (default=true) (optional).
* @param boolean $verbose Whether to be verbose (default=true) (optional).
*
* @return mixed The result set of the successfully executed query or false on error.
* @throws Exception No SQL statment.
*/
public static function executeSQL($sql, $limitOffset = -1, $limitNumRows = -1, $exitOnError = true, $verbose = true)
{
if (!$sql) {
throw new Exception(__('No SQL statement to execute'));
}
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
if (!$connection && System::isInstalling()) {
return false;
}
try {
if ($limitNumRows > 0) {
$tStr = strtoupper(substr(trim($sql), 0, 6));
if ($tStr !== 'SELECT') {
// TODO D [use normal Select instead of showing an error message if paging is desired for something different than SELECTs] (Guite)
throw new Exception(__('Paging parameters can only be used for SELECT statements'));
}
if ($limitOffset > 0) {
$sql = $connection->modifyLimitQuery($sql, $limitNumRows, $limitOffset);
} else {
$sql = $connection->modifyLimitQuery($sql, $limitNumRows);
}
}
$stmt = $connection->prepare($sql);
//$stmt->setHydrationMode(Doctrine_Core::HYDRATE_RECORD);
if ($stmt->execute()) {
$result = $stmt;
}
if ($result) {
return $result;
}
} catch (Exception $e) {
echo 'Error in DBUtil::executeSQL: ' . $sql . '<br />' . $e->getMessage() . '<br />';
if (System::isDevelopmentMode() && SecurityUtil::checkPermission('.*', '.*', ACCESS_ADMIN)) {
echo nl2br($e->getTraceAsString());
}
System::shutDown();
}
return false;
}
示例12: init
/**
* Initialise Zikula.
*
* Carries out a number of initialisation tasks to get Zikula up and
* running.
*
* @param integer $stage Stage to load.
* @param Zikula_Request_Http $request
*
* @return boolean True initialisation successful false otherwise.
*/
public function init($stage = self::STAGE_ALL, Request $request)
{
$GLOBALS['__request'] = $request;
// hack for pre 1.5.0 - drak
$coreInitEvent = new GenericEvent($this);
// store the load stages in a global so other API's can check whats loaded
$this->stage = $this->stage | $stage;
if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
ModUtil::flushCache();
System::flushCache();
$args = !System::isInstalling() ? array('lazy' => true) : array();
$this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args));
}
// Initialise and load configuration
if ($stage & self::STAGE_CONFIG) {
// for BC only. remove this code in 2.0.0
if (!System::isInstalling()) {
$this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage)));
}
// initialise custom event listeners from config.php settings
$coreInitEvent->setArgument('stage', self::STAGE_CONFIG);
/***************************************************
* NOTE: this event is monitored by
* \Zikula\Bundle\CoreInstallerBundle\EventListener\InstallUpgradeCheckListener
* to see if install or upgrade is needed
***************************************************/
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
if ($stage & self::STAGE_DB) {
try {
$dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
$this->dispatcher->dispatch('core.init', $dbEvent);
} catch (PDOException $e) {
if (!System::isInstalling()) {
header('HTTP/1.1 503 Service Unavailable');
require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
System::shutDown();
} else {
return false;
}
}
}
if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule');
ModUtil::initCoreVars();
ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule');
ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule');
ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule');
ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule');
ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule');
ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule');
// Add AutoLoading for non-symfony 1.3 modules in /modules
if (!System::isInstalling()) {
ModUtil::registerAutoloaders();
}
$coreInitEvent->setArgument('stage', self::STAGE_TABLES);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
if ($stage & self::STAGE_SESSIONS) {
// SessionUtil::requireSession();
$coreInitEvent->setArgument('stage', self::STAGE_SESSIONS);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
// Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
// start block
if ($stage & self::STAGE_LANGS) {
$lang = ZLanguage::getInstance();
}
if ($stage & self::STAGE_DECODEURLS) {
System::queryStringDecode($request);
$coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
if ($stage & self::STAGE_LANGS) {
$lang->setup($request);
$coreInitEvent->setArgument('stage', self::STAGE_LANGS);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
// end block
if ($stage & self::STAGE_MODS) {
if (!System::isInstalling()) {
ModUtil::load('ZikulaSecurityCenterModule');
}
$coreInitEvent->setArgument('stage', self::STAGE_MODS);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
if ($stage & self::STAGE_THEME) {
// register default page vars
//.........这里部分代码省略.........
示例13: init
/**
* Initialise Zikula.
*
* Carries out a number of initialisation tasks to get Zikula up and
* running.
*
* @param integer $stage Stage to load.
* @param Zikula_Request_Http $request
*
* @return boolean True initialisation successful false otherwise.
*/
public function init($stage = self::STAGE_ALL, Request $request)
{
$GLOBALS['__request'] = $request;
// hack for pre 1.5.0 - drak
$coreInitEvent = new GenericEvent($this);
// store the load stages in a global so other API's can check whats loaded
$this->stage = $this->stage | $stage;
if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
ModUtil::flushCache();
System::flushCache();
$args = !System::isInstalling() ? array('lazy' => true) : array();
$this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args));
}
// Initialise and load configuration
if ($stage & self::STAGE_CONFIG) {
// for BC only. remove this code in 2.0.0
if (!System::isInstalling()) {
$this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage)));
}
// initialise custom event listeners from config.php settings
$coreInitEvent->setArgument('stage', self::STAGE_CONFIG);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
// create several booleans to test condition of request regrading install/upgrade
$installed = $this->getContainer()->getParameter('installed');
if ($installed) {
self::defineCurrentInstalledCoreVersion($this->getContainer());
}
$requiresUpgrade = $installed && version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, self::VERSION_NUM, '<');
// can't use $request->get('_route') to get any of the following
// all these routes are hard-coded in xml files
$uriContainsInstall = strpos($request->getRequestUri(), '/install') !== false;
$uriContainsUpgrade = strpos($request->getRequestUri(), '/upgrade') !== false;
$uriContainsDoc = strpos($request->getRequestUri(), '/installdoc') !== false;
$uriContainsWdt = strpos($request->getRequestUri(), '/_wdt') !== false;
$uriContainsProfiler = strpos($request->getRequestUri(), '/_profiler') !== false;
$uriContainsRouter = strpos($request->getRequestUri(), '/js/routing?callback=fos.Router.setData') !== false;
$doNotRedirect = $uriContainsProfiler || $uriContainsWdt || $uriContainsRouter || $request->isXmlHttpRequest();
// check if Zikula Core is not installed
if (!$installed && !$uriContainsDoc && !$uriContainsInstall && !$doNotRedirect) {
$this->container->get('router')->getContext()->setBaseUrl($request->getBasePath());
// compensate for sub-directory installs
$url = $this->container->get('router')->generate('install');
$response = new RedirectResponse($url);
$response->send();
System::shutDown();
}
// check if Zikula Core requires upgrade
if ($requiresUpgrade && !$uriContainsDoc && !$uriContainsUpgrade && !$doNotRedirect) {
$this->container->get('router')->getContext()->setBaseUrl($request->getBasePath());
// compensate for sub-directory installs
$url = $this->container->get('router')->generate('upgrade');
$response = new RedirectResponse($url);
$response->send();
System::shutDown();
}
if (!$installed || $requiresUpgrade || $this->getContainer()->hasParameter('upgrading')) {
System::setInstalling(true);
}
if ($stage & self::STAGE_DB) {
try {
$dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
$this->dispatcher->dispatch('core.init', $dbEvent);
} catch (PDOException $e) {
if (!System::isInstalling()) {
header('HTTP/1.1 503 Service Unavailable');
require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
System::shutDown();
} else {
return false;
}
}
}
if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule');
ModUtil::initCoreVars();
ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule');
ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule');
ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule');
ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule');
ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule');
ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule');
// Add AutoLoading for non-symfony 1.3 modules in /modules
if (!System::isInstalling()) {
ModUtil::registerAutoloaders();
}
$coreInitEvent->setArgument('stage', self::STAGE_TABLES);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
//.........这里部分代码省略.........
示例14: pnShutDown
/**
* Gracefully shut down the framework (traps all exit and die calls)
*
* @deprecated Deprecated since version 1.3.0.
* @see System::shutDown()
*
* @param $exit_param params to pass to the exit function
* @return none - function halts execution
*
*/
function pnShutDown($exit_param = '')
{
LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'System::shutDown')), E_USER_DEPRECATED);
return System::shutDown($exit_param);
}