test_user(); $core->load_lang(); $function = new functions(); $sec = new security(); $_SESSION['error'] = ""; if (isset($_GET['id'])) { if ($_GET['id'] == "last"){ $sId = $_SESSION['new_id']; unset($_SESSION['new_id']); } else $sId = $_GET['id']; } else { $sId = ""; } $sId = $function->wash($_GET['id'], "num", _THE_DOC); if (! empty($_SESSION['error'])) { header("location: " . $_SESSION['config']['businessappurl'] . "index.php"); exit(); } else { $db = new dbquery(); $db->connect(); $db->query( "SELECT coll_id, res_id_master FROM res_view_attachments WHERE (res_id = " . $sId . " OR res_id_version = ".$sId.") AND res_id_master = ".$_REQUEST['res_id_master'] ." ORDER BY relation desc" ); $res = $db->fetch_object(); $collId = $res->coll_id; $resIdMaster = $res->res_id_master; $where2 = ""; foreach (array_keys($_SESSION['user']['security']) as $key) { if ($collId == $key) { $where2 = " and ( " . $_SESSION['user']['security'][$key]['DOC']['where'] . " ) "; } } $table = $sec->retrieve_table_from_coll($collId); $db->query( "SELECT res_id FROM " . $table . " WHERE res_id = " . $resIdMaster ); //$db->show(); if ($db->nb_result() == 0) { $_SESSION['error'] = _THE_DOC . " " . _EXISTS_OR_RIGHT . "…"; header( "location: " . $_SESSION['config']['businessappurl'] . "index.php" ); exit(); } else { $db->query( "SELECT docserver_id, path, filename, format FROM res_view_attachments WHERE (res_id = " . $sId . " OR res_id_version = ".$sId.") AND res_id_master = ".$_REQUEST['res_id_master'] ." ORDER BY relation desc" ); if ($db->nb_result() == 0) { $_SESSION['error'] = _THE_DOC . " " . _EXISTS_OR_RIGHT . "…"; header( "location: " . $_SESSION['config']['businessappurl'] . "index.php" ); exit(); } else { $line = $db->fetch_object(); $docserver = $line->docserver_id; $path = $line->path; $filename = $line->filename; $format = "pdf"; $db->query( "select path_template from " . _DOCSERVERS_TABLE_NAME . " where docserver_id = '" . $docserver . "'" ); //$db->show(); $lineDoc = $db->fetch_object(); $docserver = $lineDoc->path_template; $file = $docserver . $path . $filename; $file = str_replace("#", DIRECTORY_SEPARATOR, $file); $file = str_replace(pathinfo($file, PATHINFO_EXTENSION), "pdf",$file); if (strtoupper($format) == "MAARCH") { if (file_exists($file)) { $myfile = fopen($file, "r"); $data = fread($myfile, filesize($file)); fclose($myfile); $content = stripslashes($data); $core->load_html(); $core->load_header(); ?>