*/
include("session.php");
if(file_exists($_SESSION['config']['lang'].'.php'))
{
include($_SESSION['config']['lang'].'.php');
}
else
{
$_SESSION['error'] = "Language file missing...
";
}
require("class_functions.php");
require_once("class_db.php");
$function = new functions();
if(isset($_GET['id']))
{
$s_id = $_GET['id'];
}
else
{
$s_id = "";
}
$s_id = $function->wash($_GET['id'], "num", _THE_DOC);
if(!empty($_SESSION['error']))
{
header("location: index.php");
exit;
}
else
{
$connexion = new dbquery();
$connexion->connect();
$table ="";
if(isset($_SESSION['tablechoice']) && !empty($_SESSION['tablechoice']))
{
$table = $_SESSION['tablechoice'];
}
else
{
$table = $_SESSION['ressources'][0]['tablename'];
}
$where2 = "";
$connexion->query("SELECT IDENTIFIER from ".$table." where RES_ID = ".$s_id);
if($connexion->nb_result() < 1)
{
$_SESSION['error'] = _DOC_NOT_FOUND;
header("location: index.php");
exit;
}
else if( $connexion->nb_result() > 1)
{
$_SESSION['error'] = _DOUBLED_DOC;
header("location: index.php");
exit;
}
$res = $connexion->fetch_object();
$connexion->query("SELECT USER_ID from ".$_SESSION['tablename']['listinstance']." where RES_TABLE = '".$table."' and RES_ID = ".$s_id." and USER_ID = '".$_SESSION['user']['UserId']."'");
if($connexion->nb_result() < 1)
{
for($i=0; $i < count($_SESSION['user']['security']); $i++)
{
if($_SESSION['tablechoice'] == $_SESSION['user']['security'][$i]['table'])
{
$where2 = " and ( ".$_SESSION['user']['security'][$i]['where']." ) ";
}
}
}
$connexion->query("SELECT RES_ID, DOCSERVER_ID, PATH, FILENAME, FORMAT, CUSTOM_T1 as DEPARTMENT, FILESIZE FROM ".$table." where RES_ID = ".$s_id." ".$where2);
if($connexion->nb_result() == 0)
{
$_SESSION['error'] = _NO_DOC_OR_NO_RIGHTS."...";
header("location: index.php");
exit;
}
else
{
$line = $connexion->fetch_object();
$department = $line->DEPARTMENT;
$docserver = $line->DOCSERVER_ID;
$path = $line->PATH;
$filename = $line->FILENAME;
$format = $line->FORMAT;
$size = $line->FILESIZE;
$connexion->query("select PATH_TEMPLATE from ".$_SESSION['tablename']['docservers']." where DOCSERVER_ID = '".$docserver."'");
$line_doc = $connexion->fetch_object();
$docserver = $line_doc->PATH_TEMPLATE;
$file = $docserver.$path.strtolower($filename);
/* if ($_SESSION['config']['system'] == "true")
{
$file = str_replace("#","/",$file);
}
else
{
$file = str_replace("#","\\",$file);
} */
$file = str_replace("#",DIRECTORY_SEPARATOR,$file);
//Begin writing headers
$type_state = false;
require("load_extensions.php");
for($i=0;$i