/** Display the error code and error message to the user if a database error occurred. * The error must be read by the child method. This method will call a backtrace so * you see the script and specific line in which the error occurred. * @param $code The database error code that will be displayed. * @param $message The database error message that will be displayed. * @return Will exit the script and returns a html output with the error informations. */ public function db_error($code = 0, $message = '') { global $g_root_path, $gMessage, $gPreferences, $gCurrentOrganization, $gDebug, $gL10n; $htmlOutput = ''; $backtrace = $this->getBacktrace(); // Rollback on open transaction if ($this->transactions > 0) { $this->rollback(); } if (!headers_sent() && isset($gPreferences) && defined('THEME_SERVER_PATH')) { // create html page object $page = new HtmlPage($gL10n->get('SYS_DATABASE_ERROR')); } // transform the database error to html $error_string = '<div style="font-family: monospace;"> <p><b>S Q L - E R R O R</b></p> <p><b>CODE:</b> ' . $code . '</p> ' . $message . '<br /><br /> <b>B A C K T R A C E</b><br /> ' . $backtrace . ' </div>'; $htmlOutput = $error_string; // in debug mode show error in log file if ($gDebug === 1) { error_log($code . ': ' . $message); } // display database error to user if (!headers_sent() && isset($gPreferences) && defined('THEME_SERVER_PATH')) { $page->addHtml($htmlOutput); $page->show(); } else { echo $htmlOutput; } exit; }
require_once '../../installation/db_scripts/preferences.php'; // set some specific preferences whose values came from user input of the installation wizard $orga_preferences['email_administrator'] = $_POST['orgaEmail']; $orga_preferences['system_language'] = $gPreferences['system_language']; // create all necessary data for this organization $newOrganization->setPreferences($orga_preferences, false); $newOrganization->createBasicData($gCurrentUser->getValue('usr_id')); // if installation of second organization than show organization select at login if ($gCurrentOrganization->countAllRecords() === 2) { $sql = 'UPDATE ' . TBL_PREFERENCES . ' SET prf_value = 1 WHERE prf_name = \'system_organization_select\' '; $gDb->query($sql); } $gDb->endTransaction(); // create html page object $page = new HtmlPage($gL10n->get('INS_SETUP_WAS_SUCCESSFUL')); $page->addHtml('<p class="lead">' . $gL10n->get('ORG_ORGANIZATION_SUCCESSFULL_ADDED', $_POST['orgaLongName']) . '</p>'); // show form $form = new HtmlForm('add_new_organization_form', $g_root_path . '/adm_program/modules/preferences/preferences.php', $page); $form->addSubmitButton('btn_foward', $gL10n->get('SYS_NEXT'), array('icon' => THEME_PATH . '/icons/forward.png')); // add form to html page and show page $page->addHtml($form->show(false)); $page->show(); // clean up unset($_SESSION['add_organization_request']); break; case 4: // show php info page echo phpinfo(); break; }
/** * Create a html page if necessary and show the message with the configured buttons. * @param string $content The message text that should be shown. The content could have html. * @param string $headline Optional a headline for the message. Default will be SYS_NOTE. */ public function show($content, $headline = '') { // noetig, da dies bei den includes benoetigt wird global $gDb, $gL10n, $page; $html = ''; // first perform a rollback in database if there is an open transaction $gDb->rollback(); // Ueberschrift setzen, falls diese vorher nicht explizit gesetzt wurde if ($headline === '') { $headline = $gL10n->get('SYS_NOTE'); } // Variablen angeben if (!$this->inline) { // nur pruefen, wenn vorher nicht schon auf true gesetzt wurde $this->inline = headers_sent(); } if (!$this->inline) { // create html page object $page = new HtmlPage($headline); $page->hideMenu(); if (!$this->includeThemeBody) { // don't show custom html of the current theme $page->hideThemeHtml(); } // forward to next page after x seconds if ($this->timer > 0) { $page->addJavascript('window.setTimeout("window.location.href=\'' . $this->forwardUrl . '\'", ' . $this->timer . ');'); } } elseif (!$this->modalWindowMode) { header('Content-type: text/html; charset=utf-8'); $html .= '<h1>' . $headline . '</h1>'; } // create html for buttons $htmlButtons = ''; if ($this->showButtons) { if ($this->forwardUrl !== '') { if ($this->showYesNoButtons) { $htmlButtons .= ' <button id="admButtonYes" class="btn" type="button" onclick="self.location.href=\'' . $this->forwardUrl . '\'"> <img src="' . THEME_PATH . '/icons/ok.png" alt="' . $gL10n->get('SYS_YES') . '" /> ' . $gL10n->get('SYS_YES') . ' </button> <button id="admButtonNo" class="btn" type="button" onclick="history.back()"> <img src="' . THEME_PATH . '/icons/error.png" alt="' . $gL10n->get('SYS_NO') . '" /> ' . $gL10n->get('SYS_NO') . ' </button>'; } else { // Wenn weitergeleitet wird, dann auch immer einen Weiter-Button anzeigen $htmlButtons .= ' <a class="btn" href="' . $this->forwardUrl . '">' . $gL10n->get('SYS_NEXT') . ' <img src="' . THEME_PATH . '/icons/forward.png" alt="' . $gL10n->get('SYS_NEXT') . '" title="' . $gL10n->get('SYS_NEXT') . '" /> </a>'; } } else { // Wenn nicht weitergeleitet wird, dann immer einen Zurueck-Button anzeigen // bzw. ggf. einen Fenster-Schließen-Button if (!$this->modalWindowMode) { $htmlButtons .= ' <a class="btn" href="javascript:history.back()"> <img src="' . THEME_PATH . '/icons/back.png" alt="' . $gL10n->get('SYS_BACK') . '" title="' . $gL10n->get('SYS_BACK') . '" />' . $gL10n->get('SYS_BACK') . '</a>'; } } } if ($this->modalWindowMode) { $html .= ' <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title">' . $headline . '</h4> </div> <div class="modal-body">' . $content . '</div> <div class="modal-footer">' . $htmlButtons . '</div>'; } else { $html .= ' <div class="message"> <p class="lead">' . $content . '</p> ' . $htmlButtons . ' </div>'; } if ($this->showTextOnly) { // show the pure message text without any html echo strip_tags($content); } elseif ($this->showHtmlTextOnly) { // show the pure message text with their html echo $content; } elseif ($this->inline) { // show the message in html but without the theme specific header and body echo $html; } else { // show a Admidio html page with complete theme header and body $page->addHtml($html); $page->show(); } exit; }