public function build() { $this->doc = new \DOMDocument('1.0', 'UTF-8'); $dom_root = $this->doc->createElement('document'); $dom_root->setAttribute('debug', $this->getConfigValue('site.debug')); $dom_root->setAttribute('url', (string) E()->getRequest()->getURI()); $this->doc->appendChild($dom_root); $dom_documentProperties = $this->doc->createElement('properties'); $dom_root->appendChild($dom_documentProperties); $prop = $this->doc->createElement('property', E()->getSiteManager()->getCurrentSite()->base); $prop->setAttribute('name', 'base'); $prop->setAttribute('folder', E()->getSiteManager()->getCurrentSite()->folder); $dom_documentProperties->appendChild($prop); $prop = $this->doc->createElement('property', $langID = E()->getLanguage()->getCurrent()); $prop->setAttribute('name', 'lang'); $prop->setAttribute('abbr', E()->getRequest()->getLangSegment()); $prop->setAttribute('real_abbr', E()->getLanguage()->getAbbrByID($langID)); $dom_documentProperties->appendChild($prop); unset($prop); $result = $this->doc->createElement('errors'); $result->setAttribute('xml:id', 'result'); $dom_root->appendChild($result); $vm = E()->getController()->getViewMode(); if ($vm == DocumentController::TRANSFORM_JSON) { $errors = [['message' => $this->e->getMessage()]]; $data = ['result' => false, 'errors' => $errors]; $result->appendChild(new \DOMText(json_encode($data))); } else { $error = $this->doc->createElement('error'); $result->appendChild($error); $error->appendChild($this->doc->createElement('message', $this->e->getMessage())); $error->setAttribute('file', $this->e->getFile()); $error->setAttribute('line', $this->e->getLine()); $bktrace = $this->doc->createElement('backtrace'); $dbgObj = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT, 5); array_walk($dbgObj, function ($callable) use($bktrace) { $bktrace->appendChild($call = $this->doc->createElement('call')); array_walk($callable, function ($value, $key) use($call) { if (is_scalar($value)) { $call->appendChild($this->doc->createElement($key, $value)); } elseif (is_array($value)) { foreach ($value as $k1 => $v1) { if (!is_scalar($v1)) { $v1 = '[...]'; } $call->appendChild($this->doc->createElement($key, $v1)); } } }); }); $result->appendChild($bktrace); if ($vm == DocumentController::TRANSFORM_HTML) { E()->getController()->getTransformer()->setFileName('error_page.xslt'); } } }
/** * Displays a system exception in the paackageinstallation exception template. * * @param SystemException $e */ protected function showPackageInstallationException(SystemException $e) { $dbException = false; $sqlError = ''; $sqlErrorNumber = 0; $sqlVersion = ''; if ($e instanceof DatabaseException) { $dbException = true; $sqlError = $e->getErrorDesc(); $sqlErrorNumber = $e->getErrorNumber(); $sqlVersion = $e->getSQLVersion(); } WCF::getTPL()->assign(array('dbException' => $dbException, 'sqlError' => $sqlError, 'sqlErrorNumber' => $sqlErrorNumber, 'sqlVersion' => $sqlVersion, 'errorMessage' => $e->getMessage(), 'errorDescription' => $e->getDescription(), 'phpVersion' => phpversion(), 'wcfVersion' => WCF_VERSION, 'file' => $e->getFile() . ' (' . $e->getLine() . ')', 'errorCode' => $e->getCode(), 'date' => gmdate('m/d/Y h:ia'), 'requestUri' => isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 'httpReferer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', 'stackTrace' => $e->getTraceAsString())); WCF::getTPL()->append(array('packageName' => '')); WCF::getTPL()->display('packageInstallationException'); exit; }