*/ include("session.php"); $_SESSION['error'] =""; $table = "res_x"; if(file_exists($_SESSION['config']['lang'].'.php')) { include($_SESSION['config']['lang'].'.php'); } else { $_SESSION['error'] = "Language file missing...
"; } if(empty($_REQUEST['mode']) || !isset($_REQUEST['mode'])) { $_SESSION['error'] .= _NO_MODE_DEFINED.'.
'; header("location: generate_answer.php?model=".$_REQUEST['model_id']); exit; } else { require_once("class_functions.php"); require_once("class_db.php"); $conn = new dbquery(); $conn->connect(); if(empty($_REQUEST['model_content']) || !isset($_REQUEST['model_content'])) { $_SESSION['error'] .= _NO_CONTENT.'.
'; if($_REQUEST['mode'] == 'add') { header("location: generate_answer.php?model=".$_REQUEST['model_id']."&mode=".$_REQUEST['mode']); } else { header("location: generate_answer.php?id=".$_REQUEST['id_rep']."&mode=".$_REQUEST['mode']); } exit; } else { if($_REQUEST['mode'] == "add" ) { $signing = 'NULL'; if( isset($_POST['signing']) && $_POST['signing'] != "0" ) $signing = "'".$_POST['signing']."'"; if(empty($_REQUEST['answer_title']) || !isset($_REQUEST['answer_title'])) { $_REQUEST['answer_title'] = $_SESSION['courrier']['res_id']."_".$_REQUEST['model_label'].date("dmY"); } $path_tmp = $_SESSION['config']['tmpdir'].DIRECTORY_SEPARATOR.$_REQUEST['answer_title'].".txt"; $myfile = fopen($path_tmp, "w"); if(!$myfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: generate_answer.php?model=".$_REQUEST['model_id']); exit; } fwrite($myfile, $_REQUEST['model_content']); fclose($myfile); $conn->query("SELECT DOCSERVER_ID, PATH_TEMPLATE, SIZE_LIMIT, ACTUAL_SIZE FROM ".$_SESSION['tablename']['docservers']." WHERE IS_READONLY = 'N' AND ENABLED = 'Y' "); if($conn->nb_result() == 0) { $_SESSION['error'] .= _NO_AVAILABLE_DOCSERVER."."._MORE_INFOS." : ".$_SESSION['config']['adminname'].".
"; } else { $info = $conn->fetch_object(); $docserver_id = $info->DOCSERVER_ID; $file_size = filesize($path_tmp); $docserver_size = $info->ACTUAL_SIZE + $file_size; if($info->SIZE_LIMIT > 0 && $docserver_size >= $info->SIZE_LIMIT) { $_SESSION['error'] .= _NOT_ENOUGH_DISK_SPACE."."._MORE_INFOS." : ".$_SESSION['config']['adminname'].".
"; header("location: generate_answer.php?model=".$_REQUEST['model_id']); exit; } else { $path_template = $info->PATH_TEMPLATE; require("class_docserver.php"); $docserver = new docserver(); $result = $docserver->store($docserver_id,$path_template,$path_tmp,"txt",$file_size); if( !is_array($result) || count($result) < 2 ) { echo $_SESSION['error'] = $docserver->get_last_error()." ".$_SESSION['config']['adminname'].".
"; header("location: enregistrement_doc.php"); exit; } $destination_rept = $result['destination_rept']; $file_destination_name = $result['file_destination_name']; $destination_rept = substr($destination_rept,strlen($path_template),4); $path_tmp = $_SESSION['config']['tmpdir'].DIRECTORY_SEPARATOR.$_REQUEST['answer_title'].".txt"; $destination_rept = str_replace(DIRECTORY_SEPARATOR,'#',$destination_rept); $_SESSION['courrier']['description'] = addslashes($_SESSION['courrier']['description']); $conn->query("INSERT INTO ".$table." ( TITLE, RELATION, FORMAT, CREATION_DATE, DOCSERVER_ID, PATH, FILENAME, FILESIZE, STATUS, TYPIST, TYPE_ID, SOURCE, SIGNING ) VALUES ('".addslashes($_REQUEST['answer_title'])."', '".$_SESSION['courrier']['res_id']."', 'TXT', now() ,'".$docserver_id."','" .$destination_rept."','".$file_destination_name.".txt',".$file_size .",'REP','".$_SESSION['user']['UserId'] ."','".$_SESSION['courrier']['type_id']."','Editor', ".$signing." )"); // $conn->show(); if($_SESSION['history']['resadd'] == "true") { require_once("class_history.php"); $hist = new history(); $hist->add($table, $_SESSION['courrier']['res_id'],"ADD", _NEW_ANSWER_ADDED." : ".$_SESSION['courrier']['identifier']." (".$_SESSION['courrier']['type_id'].")"); } if ($_SESSION['origin'] == "cloture") {?> '; header("location: generate_answer.php?model=".$_REQUEST['model_id']); exit; } else { $conn->query("select DOCSERVER_ID, PATH, FILENAME from ".$table." where RES_ID = ".$_REQUEST['id_rep']); if($conn->nb_result() == 0) { $_SESSION['error'] = _NO_DOC_OR_NO_RIGHTS."..."; header("location: index.php"); exit; } else { $line = $conn->fetch_object(); $docserver = $line->DOCSERVER_ID; $path = $line->PATH; $filename = $line->FILENAME; $conn->query("select PATH_TEMPLATE from ".$_SESSION['tablename']['docservers']." where DOCSERVER_ID = '".$docserver."'"); $line_doc = $conn->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); $myfile = fopen($file, "w"); if(!$myfile) { $_SESSION['error'] .= _FILE_OPEN_ERROR.'.
'; header("location: generate_answer.php?id=".$_REQUEST['id_rep']); exit; } fwrite($myfile, $_REQUEST['model_content']); fclose($myfile); if($_SESSION['history']['resup'] == "true") { require_once("class_history.php"); $hist = new history(); $hist->add($table, $_SESSION['courrier']['res_id'],"UP", _ANSWER_UPDATED." : ".$_SESSION['courrier']['identifier']." (".$_SESSION['courrier']['type_id'].")"); } if ($_SESSION['origin'] == "cloture") {?>