src.dualinventive.com/mtinfo/dist/webroot/main/include/status.php

213 lines
11 KiB
PHP

<?php
/** \file include\status.php
* \brief DI status menu
* \author Rob Schalken, Core|Vision
* \version 1.0
* \date 17-10-2008
*
* This file displays the status message
*/
/************************************/
/* XMLHTTP requirements */
/************************************/
require_once("core_xml.php");
if (db_ver_right_user($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "login")) {
if ((isset($_SESSION[$_PAGE_INFO['id']]['sts'])) && (is_array($_SESSION[$_PAGE_INFO['id']]['sts']))) {
// Define number of columns
$items = sizeof($_SESSION[$_PAGE_INFO['id']]['sts']['data']);
if ($items) {
$columns = ceil($items / 20);
$width = (100/$columns) . "%";
}
// Initial value
$col_counter = 0;
// Store timeout value
$_SESSION[$_PAGE_INFO['id']]['sts']['timeout'] = (int)$_POST['timeout'];
if (is_array($_SESSION[$_PAGE_INFO['id']]['sts']['data'])) {
echo "<table width=100%>";
foreach($_SESSION[$_PAGE_INFO['id']]['sts']['data'] as $item) {
// Start of row
if (!$col_counter) {
echo "<tr>";
}
echo "<td width=" . $width . ">";
echo "<div style=\"color:white;margin:1px;font-size:12px;\">";
switch($item['status']) {
// Busy => error?
case 0:
if ((!(int)$_POST['timeout']) || ($_SESSION[$_PAGE_INFO['id']]['sts']['finished'])) {
echo "<!--[if lte IE 6]>";
echo "<span style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . "error.png');\">";
echo "<![endif]-->";
echo "<img id=\"img_sts\" src=\"" . IMAGE_DIR . "error.png\" alt=\"\" style=\"vertical-align:middle;height:18px\">";
echo "<!--[if lte IE 6]>";
echo "</span>";
echo "<![endif]-->";
}
else {
echo "<img src=\"" . IMAGE_DIR . "busy.gif\" alt=\"\" style=\"vertical-align:middle;height:18px\">";
}
break;
// Busy => undefined
case -1:
if ((!(int)$_POST['timeout']) || ($_SESSION[$_PAGE_INFO['id']]['sts']['finished'])) {
echo "<!--[if lte IE 6]>";
echo "<span style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . "empty_18x18.png');\">";
echo "<![endif]-->";
echo "<img id=\"img_sts\" src=\"" . IMAGE_DIR . "empty_18x18.png\" alt=\"\" style=\"vertical-align:middle;height:18px\">";
echo "<!--[if lte IE 6]>";
echo "</span>";
echo "<![endif]-->";
}
else {
echo "<img src=\"" . IMAGE_DIR . "busy.gif\" alt=\"\" style=\"vertical-align:middle;height:18px\">";
}
break;
// Ok
case 1:
echo "<!--[if lte IE 6]>";
echo "<span style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . "ok.png');\">";
echo "<![endif]-->";
echo "<img id=\"img_sts\" src=\"" . IMAGE_DIR . "ok.png\" alt=\"\" style=\"vertical-align:middle;height:18px\">";
echo "<!--[if lte IE 6]>";
echo "</span>";
echo "<![endif]-->";
break;
// Error
case 2:
echo "<!--[if lte IE 6]>";
echo "<span style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . "error.png');\">";
echo "<![endif]-->";
echo "<img id=\"img_sts\" src=\"" . IMAGE_DIR . "error.png\" alt=\"\" style=\"vertical-align:middle;height:18px\">";
echo "<!--[if lte IE 6]>";
echo "</span>";
echo "<![endif]-->";
break;
// Ok with info
case 3:
echo "<!--[if lte IE 6]>";
echo "<span style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . "info.png');\">";
echo "<![endif]-->";
echo "<img id=\"img_sts\" src=\"" . IMAGE_DIR . "info.png\" alt=\"\" style=\"vertical-align:middle;height:18px\">";
echo "<!--[if lte IE 6]>";
echo "</span>";
echo "<![endif]-->";
break;
// Undefined
default:
echo "<!--[if lte IE 6]>";
echo "<span style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . "empty_18x18.png');\">";
echo "<![endif]-->";
echo "<img id=\"img_sts\" src=\"" . IMAGE_DIR . "empty_18x18.png\" alt=\"\" style=\"vertical-align:middle;height:18px\">";
echo "<!--[if lte IE 6]>";
echo "</span>";
echo "<![endif]-->";
break;
}
echo "&nbsp&nbsp " . _($item['text']);
echo "</div>";
echo "</td>";
// Increment column counter
$col_counter = (($col_counter + 1) == $columns) ? 0 : $col_counter + 1;
// End of row
if (!$col_counter) {
echo "</tr>";
}
}
// End of row
if ($col_counter) {
echo "</tr>";
}
echo "</table>";
}
// Hide cancel button?
if (isset($_SESSION[$_PAGE_INFO['id']]['sts']['cancel_hide'])) {
// Remove setting
unset($_SESSION[$_PAGE_INFO['id']]['sts']['cancel_hide']);
// Hide cancel button (when visible)
echo "<script type=\"text/javascript\">\n";
echo "getElement(\"ibox_cancel_button\").style.visibility=\"hidden\";\n";
echo "</script>\n";
}
// Display button or timeout?
if (($_SESSION[$_PAGE_INFO['id']]['sts']['finished']) || (!(int)($_POST['timeout']))) {
// Finish 2 => interrupted! => Hide
if ($_SESSION[$_PAGE_INFO['id']]['sts']['finished'] == 2) {
echo "<script type=\"text/javascript\">\n";
echo "iBox.hide();\n";
echo "</script>\n";
}
else {
if (($_POST['timeout'] == -1) && (!isset($_SESSION[$_PAGE_INFO['id']]['sts']['button']))) {
// Increase status box => needed for buttons
echo "<script type=\"text/javascript\">\n";
echo "getElement('ibox_wrapper').style.height = parseInt(getElement('ibox_wrapper').style.height) + 60 + 'px'\n";
echo "getElement('ibox_content').style.height = parseInt(getElement('ibox_content').style.height) + 60 + 'px'\n";
echo "</script>\n";
// Buttons handled
$_SESSION[$_PAGE_INFO['id']]['sts']['button'] = TRUE;
}
// Display buttons
echo "<div style=\"padding-right:10px;\"><center>";
// Alert after button click?
if (isset($_SESSION[$_PAGE_INFO['id']]['sts']['alert']['text'])) {
$_SESSION[$_PAGE_INFO['id']]['errormsg']['type'] = "alert";
$_SESSION[$_PAGE_INFO['id']]['errormsg']['text'] = $_SESSION[$_PAGE_INFO['id']]['sts']['alert']['text'];
unset($_SESSION[$_PAGE_INFO['id']]['sts']['alert']['text']);
}
if (strlen($_SESSION[$_PAGE_INFO['id']]['sts']['redirect'])) {
echo "<input id=\"button\" type=\"button\" value=\"" . _("Ok") . "\" onClick=\"" . $_SESSION[$_PAGE_INFO['id']]['sts']['redirect'] . "\">";
}
else {
$extra_event = "";
if (isset($_SESSION[$_PAGE_INFO['id']]['errormsg']['text'])) {
$extra_event = "onSubmit('after_status', '', 1);";
}
echo "<input id=\"button\" type=\"button\" value=\"" . _("Ok") . "\" onClick=\"try {showClass('select_element');} catch(err) {};javascript:iBox.hide();" . $extra_event . "\">";
}
echo "</center></div>";
}
// Hide cancel button (when visible)
echo "<script type=\"text/javascript\">\n";
echo "getElement(\"ibox_cancel_button\").style.visibility=\"hidden\";\n";
echo "</script>\n";
// IE6 workaround => 10 => finished
$_SESSION[$_PAGE_INFO['id']]['sts']['finished'] = 10;
}
else {
echo "<tr>";
if ($_POST['timeout'] != -1) {
echo "<br><br><div style=\"color:white;margin:5px;font-size:12px;\">Timeout : " . (int)$_POST['timeout'] . " [s]</div>";
}
}
// Status initialized
$_SESSION[$_PAGE_INFO['id']]['sts']['init'] = TRUE;
}
}
else {
// Display logout message
$_SESSION[$_PAGE_INFO['id']]['login_info']['errormsg'] = _("No valid rights");
// Redirect page back to login page
echo "<script type=\"text/javascript\">\n";
echo "location.href='/?id=" . $_PAGE_INFO['id'] . "&href=" . PAGE_LOGIN. "'\n";
echo "</script>\n";
}
?>