*/
include("session.php");
//$_SESSION['req_type'] = "view";
//$_SESSION['req_id'] = $_GET['id'];
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");
require_once("class_security.php");
require_once("test_page.php");
$function = new functions();
$sec = new security();
if(isset($_GET['id']))
{
$s_id = $_GET['id'];
}
else
{
$s_id = "";
}
if(isset($_GET['gdd']))
{
$Vls_gdd = $_GET['gdd'];
}
else
{
$Vls_gdd = "";
}
$s_id = $function->wash($_GET['id'], "num", _THE_DOC);
if(!empty($_SESSION['error']))
{
?>
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;
}
$connexion->query("SELECT RES_ID, DOCSERVER_ID, PATH, FILENAME, FORMAT, CUSTOM_T1 as DEPARTMENT, SOURCE, STATUS, RELATION FROM ".$table." where RES_ID = ".$s_id);
//$connexion->show();
if($_SESSION['origin'] <> "basket" && $_SESSION['origin'] <> "validation" && $_SESSION['origin'] <> "details")
{
if($Vls_gdd!="yes" OR !$_SESSION['config']['gdd'])
{
$right = $sec->test_right_doc($table, $s_id);
if(!$right)
{
echo"
";
exit();
}
}
}
$line = $connexion->fetch_object();
$department = $line->DEPARTMENT;
$docserver = $line->DOCSERVER_ID;
$path = $line->PATH;
$filename = $line->FILENAME;
$format = $line->FORMAT;
$source = $line->SOURCE;
$status = $line->STATUS;
$filesize = $line->FILESIZE;
$relation = $line->RELATION;
$docserver_id = $line->DOCSERVER_ID;
$rel_status = '';
if($status == 'REP' && $source == 'Editor')
{
$connexion->query('select STATUS from res_x where RES_ID = '.$relation);
$res = $connexion->fetch_object();
$rel_status = $res->STATUS;
}
$connexion->query("select PATH_TEMPLATE from ".$_SESSION['tablename']['docservers']." where DOCSERVER_ID = '".$docserver."'");
//$connexion->show();
$line_doc = $connexion->fetch_object();
$docserver = $line_doc->PATH_TEMPLATE;
$file = $docserver.$path.strtolower($filename);
$file = str_replace("#",DIRECTORY_SEPARATOR,$file);
require_once("class_letterbox.php");
$lb = new letterbox();
$lb->increment_viewed_var($table, $s_id, $_SESSION['user']['UserId']);
if($format == "MAARCH")
{
if(file_exists($file))
{
$myfile = fopen($file, "r");
$data = fread($myfile, filesize($file));
fclose($myfile);
$content = stripslashes($data);
?>