src.dualinventive.com/mtinfo/dist/webroot/rc-4.05/include/errormsg.php

110 lines
5.6 KiB
PHP

<?php
/** \file include\errormsg.php
* \brief DI webinterface error message
* \author Rob Schalken, Core|Vision
* \version $Revision: 26247 $
* \date $Date: 2016-02-29 10:40:22 +0100 (Mon, 29 Feb 2016) $
*
* This file displays the error message
*/
/************************************/
/* XMLHTTP requirements */
/************************************/
if (isset($_POST['xml'])) {
require_once("core_xml.php");
}
echo "<script type=\"text/javascript\">\n";
if ((isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['type'])) && (!empty($_SESSION[$_PAGE_INFO['id']]['errormsg']))) {
// Activate alternate stylesheet
echo "setActiveStyleSheet('ibox_normal');\n";
if ($_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] == "alert") {
$body = "<html><head></head><body>";
$body .= "<form>";
// Add CSRF (cross-site request forgery) token
$body .= "<input type=\\\"hidden\\\" name=\\\"__csrf_token__\\\" value=\\\"" . csrf_create_token("ibox") . "\\\">";
$body .= "<p>";
$body .= specialchars(str_replace('\\r\\n', '</p><p>',_($_SESSION[$_PAGE_INFO['id']]['errormsg']['text'])));
$body .= "</p>";
$body .= "<input id=\\\"button\\\" type=\\\"submit\\\" onClick=\\\"iBox.hide(); return false;\\\" value=\\\"Ok\\\">";
$body .= "</form></body></html>";
$ibox_title = (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['title'])) ? $_SESSION[$_PAGE_INFO['id']]['errormsg']['title'] : "Warning";
echo "iBox.show(\"" . $body . "\", \"" . _($ibox_title) . "\");\n";
}
else if (($_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] == "confirm") || ($_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] == "confirm_xml")) {
$body = "<html><head></head><body>";
$body .= "<form>";
// Add CSRF (cross-site request forgery) token
$body .= "<input type=\\\"hidden\\\" name=\\\"__csrf_token__\\\" value=\\\"" . csrf_create_token("ibox") . "\\\">";
$body .= "<p>";
$body .= specialchars(str_replace('\r\n', '</p><p>',(_($_SESSION[$_PAGE_INFO['id']]['errormsg']['text']))));
$body .= "</p>";
// xml recall?
$xml_recall = ($_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] == "confirm") ? 0 : 1;
// Yes button
if (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['recall'])) {
$error_action = (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['force_hide'])) ? "iBox.hide();" : "";
if (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['action'])) {
$error_action .= $_SESSION[$_PAGE_INFO['id']]['errormsg']['action'];
}
$body .= "<input id=\\\"button\\\" type=\\\"submit\\\" onClick=\\\"onSubmit('" . $_SESSION[$_PAGE_INFO['id']]['errormsg']['recall'] . "', ''," . $xml_recall . "); " . $error_action . " return false;\\\" value=\\\"" . _("Yes") . "\\\">";
}
else if (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['redirect'])) {
$body .= "<input id=\\\"button\\\" type=\\\"submit\\\" onClick=\\\"location.href='" . $_SESSION[$_PAGE_INFO['id']]['errormsg']['redirect'] . "'; return false;\\\" value=\\\"" . _("Yes") . "\\\">";
}
else {
$body .= "<input id=\\\"button\\\" type=\\\"submit\\\" onClick=\\\"iBox.hide(); return false;\\\" value=\\\"" . _("Yes") . "\\\">";
}
// No button
if (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['recall_no'])) {
$error_action = (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['force_hide'])) ? "iBox.hide();" : "";
if (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['action_no'])) {
$error_action .= $_SESSION[$_PAGE_INFO['id']]['errormsg']['action_no'];
}
$body .= "<input id=\\\"button\\\" type=\\\"submit\\\" onClick=\\\"onSubmit('" . $_SESSION[$_PAGE_INFO['id']]['errormsg']['recall_no'] . "', ''," . $xml_recall . "); " . $error_action . " return false;\\\" value=\\\"" . _("No") . "\\\">";
}
else if (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['redirect_no'])) {
$body .= "<input id=\\\"button\\\" type=\\\"submit\\\" onClick=\\\"location.href='" . $_SESSION[$_PAGE_INFO['id']]['errormsg']['redirect_no'] . "'; return false;\\\" value=\\\"" . _("No") . "\\\">";
}
else {
$body .= "<input id=\\\"button\\\" type=\\\"submit\\\" onClick=\\\"iBox.hide(); return false;\\\" value=\\\"" . _("No") . "\\\">";
}
$body .= "</form></body></html>";
echo "iBox.show(\"" . $body . "\", \"" . _("Confirm") . "\");\n";
}
else if ($_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] == "choose_language") {
$body = "<html><head></head><body>";
$body .= "<form>";
// Add CSRF (cross-site request forgery) token
$body .= "<input type=\\\"hidden\\\" name=\\\"__csrf_token__\\\" value=\\\"" . csrf_create_token("ibox") . "\\\">";
$body .= "<center>";
// Create buttons for every languae
$i18n_languages = db_fetch_system_lang();
$keys = array_keys($i18n_languages);
for ($i = 0; $i < sizeof($i18n_languages); $i++) {
$body .= "<input type=\\\"submit\\\" style=\\\"width:200px\\\" onClick=\\\"" . $_SESSION[$_PAGE_INFO['id']]['errormsg'][$keys[$i]] . "iBox.hide(); return false;\\\" value=\\\"" . _("" . $i18n_languages[$keys[$i]] . "") . "\\\"><br>";
}
$body .= "<br><input style=\\\"width:200px\\\" type=\\\"submit\\\" onClick=\\\"iBox.hide(); return false;\\\" value=\\\"" . _("Cancel") . "\\\">";
$body .= "</form></center></body></html>";
echo "iBox.show(\"" . $body . "\", \"" . _("Choose language") . "\"); \n";
}
// Hide cancel button (when visible)
echo "getElement(\"ibox_cancel_button\").style.visibility=\"hidden\";\n";
// Clear all info
$_SESSION[$_PAGE_INFO['id']]['errormsg'] = array();
}
echo "</script>\n";
?>