61 lines
2.2 KiB
PHP
61 lines
2.2 KiB
PHP
<?php
|
|
/** \file html\index.php
|
|
* \brief ZKL webinterface main parser file
|
|
* \author Rob Schalken, Core|Vision
|
|
* \version 1.0
|
|
* \date 17-10-2008
|
|
*
|
|
* This file checks whether a background process must be started or a "normal" webpage must be displayed
|
|
*/
|
|
|
|
/*
|
|
* Required page(s)
|
|
*/
|
|
require_once("include/definitions.php");
|
|
require_once("include/utilities.php");
|
|
require_once("include/db.php");
|
|
|
|
|
|
/*
|
|
* Check if background is needed and allowed
|
|
*/
|
|
if ((isset($_POST['background_id'])) && (stristr($_POST['background_id'], $_GET['id']) !== FALSE)) {
|
|
// Check if valid id
|
|
// Session_id _ unique number
|
|
$id_check = explode('_', $_POST['background_id']);
|
|
if ((is_array($id_check)) && (sizeof($id_check) == 2) &&
|
|
($id_check[0] == $_GET['id']) &&
|
|
(is_numeric($id_check[1])) && (abs(($id_check[1]/1000) - (microtime(TRUE))) < (15 * 60))) {
|
|
// Check if process already exist?
|
|
$background_process = db_fetch_data("SELECT * FROM session where id='" . $_POST['background_id'] . "'");
|
|
if (empty($background_process)) {
|
|
// Create process entry (empty data to indicate the starting point)
|
|
db_store_data("INSERT INTO session (id, data, expiration) values('" . $_POST['background_id'] . "','', unix_timestamp(date_add(now(), interval 1 hour)))");
|
|
|
|
// Create process in the background
|
|
exec("nohup " . $_PHP_CLI . " index_st.php '" . urlencode(serialize($_GET)) . "' '" . urlencode(serialize($_POST)) . "' '" . $_COOKIE['PHPSESSID'] . "' > /dev/null &");
|
|
}
|
|
// Process ready (lenght data > 0)?
|
|
else if (strlen($background_process[0]['data'])) {
|
|
// Remove process entry from database
|
|
db_store_data("DELETE FROM session WHERE id='" . $_POST['background_id'] . "'");
|
|
|
|
// Echo result
|
|
echo $background_process[0]['data'];
|
|
}
|
|
}
|
|
else {
|
|
// Log abuse!!!
|
|
DBG("MTinfo abuse, Someone is trying to abuse MTinfo!!" . $_POST['background_id']);
|
|
|
|
// Display error page
|
|
echo _("An error occured, please contact") . " " . "Dual Inventive!";
|
|
|
|
exit;
|
|
}
|
|
}
|
|
// Handle "normal" pages and call second stage
|
|
else {
|
|
require_once("index_st.php");
|
|
}
|
|
?>
|