public function safemode($lastError = array()) { $this->tryToRepairPiwik(); if (empty($lastError)) { $lastError = array('message' => Common::getRequestVar('error_message', null, 'string'), 'file' => Common::getRequestVar('error_file', null, 'string'), 'line' => Common::getRequestVar('error_line', null, 'integer')); } $outputFormat = Common::getRequestVar('format', 'html', 'string'); $outputFormat = strtolower($outputFormat); if (!empty($outputFormat) && 'html' !== $outputFormat) { $errorMessage = $lastError['message']; if (Piwik::isUserIsAnonymous()) { $errorMessage = 'A fatal error occurred.'; } $response = new \Piwik\API\ResponseBuilder($outputFormat); $message = $response->getResponseException(new Exception($errorMessage)); return $message; } if (Common::isPhpCliMode()) { // TODO: I can't find how this will ever get called / safeMode is never set for Console throw new Exception("Error: " . var_export($lastError, true)); } $view = new View('@CorePluginsAdmin/safemode'); $view->lastError = $lastError; $view->isSuperUser = Piwik::hasUserSuperUserAccess(); $view->isAnonymousUser = Piwik::isUserIsAnonymous(); $view->plugins = Plugin\Manager::getInstance()->loadAllPluginsAndGetTheirInfo(); $view->deactivateNonce = Nonce::getNonce(static::DEACTIVATE_NONCE); $view->uninstallNonce = Nonce::getNonce(static::UNINSTALL_NONCE); $view->emailSuperUser = implode(',', Piwik::getAllSuperUserAccessEmailAddresses()); $view->piwikVersion = Version::VERSION; $view->showVersion = !Common::getRequestVar('tests_hide_piwik_version', 0); $view->pluginCausesIssue = ''; if (!empty($lastError['file'])) { preg_match('/piwik\\/plugins\\/(.*)\\//', $lastError['file'], $matches); if (!empty($matches[1])) { $view->pluginCausesIssue = $matches[1]; } } return $view->render(); }
public function safemode($lastError = array()) { if (empty($lastError)) { $lastError = array('message' => Common::getRequestVar('error_message', null, 'string'), 'file' => Common::getRequestVar('error_file', null, 'string'), 'line' => Common::getRequestVar('error_line', null, 'integer')); } $outputFormat = Common::getRequestVar('format', 'html', 'string'); $outputFormat = strtolower($outputFormat); if (!empty($outputFormat) && 'html' !== $outputFormat) { $errorMessage = $lastError['message']; if (Piwik::isUserIsAnonymous()) { $errorMessage = 'A fatal error occurred.'; } $response = new \Piwik\API\ResponseBuilder($outputFormat); $message = $response->getResponseException(new Exception($errorMessage)); return $message; } $view = new View('@CorePluginsAdmin/safemode'); $view->lastError = $lastError; $view->isSuperUser = Piwik::isUserIsSuperUser(); $view->isAnonymousUser = Piwik::isUserIsAnonymous(); $view->plugins = Plugin\Manager::getInstance()->returnLoadedPluginsInfo(); $view->deactivateNonce = Nonce::getNonce(static::DEACTIVATE_NONCE); $view->uninstallNonce = Nonce::getNonce(static::UNINSTALL_NONCE); $view->emailSuperUser = Piwik::getSuperUserEmail(); $view->piwikVersion = Version::VERSION; $view->showVersion = !Common::getRequestVar('tests_hide_piwik_version', 0); $view->pluginCausesIssue = ''; if (!empty($lastError['file'])) { preg_match('/piwik\\/plugins\\/(.*)\\//', $lastError['file'], $matches); if (!empty($matches[1])) { $view->pluginCausesIssue = $matches[1]; } } return $view->render(); }