132 lines
4.2 KiB
PHP
132 lines
4.2 KiB
PHP
<?php
|
|
/** \file include\fetch_info.php
|
|
* \brief DI webinterface fetch info php => javascript
|
|
* \author Rob Schalken, Core|Vision
|
|
* \version 1.0
|
|
* \date 17-10-2008
|
|
*
|
|
*/
|
|
|
|
|
|
// Check rights
|
|
if (isset($_POST['check_rights'])) {
|
|
// Non-read only => This to be sure that the session info is stored periodic
|
|
unset($_PAGE_INFO['session_read_only']);
|
|
|
|
// Required pages
|
|
require_once("utilities.php");
|
|
require_once("session.php");
|
|
|
|
// Initial values
|
|
$logout = 0;
|
|
|
|
// Session logged out?
|
|
if (!isset($_SESSION[$_GET['id']]['logged_on'])) {
|
|
// Set flag
|
|
$logout = 1;
|
|
|
|
// Debug info
|
|
DBG("LOGOUT: Login flag not set (session id: " . $_GET['id'] . ", menu: " . $_SESSION[$_GET['id']]['MTinfo_menu'] . ", Last access: " . (abs(time() - $_SESSION[$_GET['id']]['last_access'])) . ")");
|
|
DBG($_SESSION[$_GET['id']]);
|
|
}
|
|
|
|
// No project => Select login rights & date/time
|
|
if ((!$logout) && (!db_ver_right_user($_GET['user'], "login"))) {
|
|
// Set flags
|
|
$logout = 1;
|
|
|
|
// Debug info
|
|
DBG("LOGOUT: Invalid rights (user: " . $_GET['user'] . ")");
|
|
}
|
|
|
|
// Project selected?
|
|
if ((!$logout) && (isset($_GET['project']))) {
|
|
// Get project info
|
|
$row_project = db_fetch_project($_GET['project'], "", 1);
|
|
|
|
// Check for non-closed projects
|
|
// normal project => planning status must be finished
|
|
// rc project => planning and design status must be validated and the project must be released
|
|
if (is_array($row_project)) {
|
|
if (($row_project['status'] == "afgesloten") ||
|
|
((($row_project['type'] == "normaal") && ($row_project['pstatus'] != "gereed")) ||
|
|
(($row_project['type'] == "rc") && (($row_project['pstatus'] != "gevalideerd") || ($row_project['ostatus'] != "gevalideerd") || ($row_project['sstatus'] != "vrijgegeven"))))) {
|
|
// Set flag
|
|
$logout = 1;
|
|
|
|
// Debug info
|
|
DBG("LOGOUT: Invalid project (project id: " . $_GET['project'] . ", type: " . $row_project['type'] . ", status: " . ((strlen($row_project['status'])) ? $row_project['status'] : "-") . ", sstatus: " . $row_project['sstatus'] . ", ostatus: " . $row_project['ostatus'] . ", pstatus: " . $row_project['pstatus'] . ")");
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($logout) {
|
|
// Redirect page back to login page
|
|
echo "<script type=\"text/javascript\">\n";
|
|
echo "location.href='?id=" . $_GET['id'] . "&href=" . PAGE_LOGIN. "'\n";
|
|
echo "</script>\n";
|
|
}
|
|
else {
|
|
// Everything ok => Green heartbeat led
|
|
echo "green";
|
|
}
|
|
}
|
|
else {
|
|
// Read only => Lock as less as possible
|
|
$_PAGE_INFO['session_read_only'] = TRUE;
|
|
|
|
// Initial values
|
|
$result = "";
|
|
|
|
// Required pages
|
|
require_once("utilities.php");
|
|
require_once("session.php");
|
|
|
|
if (db_ver_right_user($_SESSION[$_PAGE_INFO['id']]['login']['user']['id'], "login")) {
|
|
// Session info
|
|
if (isset($_POST['session_info'])) {
|
|
// Return specific part of session
|
|
$req = split(",", $_POST['session_info']);
|
|
|
|
if (is_array($req)) {
|
|
switch(sizeof($req))
|
|
{
|
|
case 1:
|
|
$result = $_SESSION[$_PAGE_INFO['id']][$req[0]];
|
|
break;
|
|
case 2:
|
|
$result = $_SESSION[$_PAGE_INFO['id']][$req[0]][$req[1]];
|
|
break;
|
|
case 3:
|
|
$result = $_SESSION[$_PAGE_INFO['id']][$req[0]][$req[1]][$req[2]];
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Return result
|
|
echo $result;
|
|
}
|
|
|
|
// Get datetime
|
|
if (isset($_POST['get_datetime'])) {
|
|
echo date('Y-m-d H:i:s');
|
|
}
|
|
|
|
// File exists
|
|
if (isset($_POST['file_exits'])) {
|
|
echo (file_exists($_POST['file']))? "1" : "0";
|
|
}
|
|
}
|
|
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";
|
|
}
|
|
}
|
|
?>
|