diff --git a/php/classes/WebServer.php b/php/classes/WebServer.php
index f134f96..8eb7cab 100644
--- a/php/classes/WebServer.php
+++ b/php/classes/WebServer.php
@@ -73,8 +73,8 @@ class WebResultMgr
 class WebServer
 {
 	private $isSoap = false;
-	private $userID, $userPWD, $sessionID;
-	private $wsUserMgr;
+	private $userID, $userPWD, $sessionID, $IPclient;
+// 	private $wsUserMgr;
 	private $resultMgr;
 	private $dataFileName;
 	private $requestManager = null;
@@ -146,16 +146,7 @@ class WebServer
  */
 	private  function getIPclient()
 	{
-		if (getenv('REMOTE_ADDR'))  {
-			$realIP = getenv('REMOTE_ADDR');
-		}
-		else {
-			//get local IP
-			$command="hostname -i";
-			$realIP = exec($command);
-		}
-
-		return $realIP;
+		return $this->wsUserMgr->getIPClient();
 	}
 
 	private function rrmdir($dir)
@@ -178,12 +169,10 @@ class WebServer
 
 	protected function initUserMgr() 
 	{
-		if (isset($this->wsUserMgr))
-			return array('success' => true);
-			
-		$this->wsUserMgr = new WSUserMgr();
-		$this->wsUserMgr->init($this->userID, $this->userPWD, $this->sessionID, $this->isSoap);
+		$wsUserMgr = new WSUserMgr();
+		$wsUserMgr->init($this->userID, $this->userPWD, $this->sessionID, $this->isSoap);
 		
+		$this->IPclient = $wsUserMgr->getIPClient();
 		return array('success' => true);
 	}
 
@@ -406,7 +395,7 @@ class WebServer
 			$this->requestManager = new RequestManagerClass();
 		
 		try {
-			$plotResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PARAMS, $requestObject);
+			$plotResult = $this->requestManager->runIHMRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, $requestObject);
 		} catch (Exception $e) {
 				$this->throwError("plotError", "Exeption detected : ".$e->getMessage());
 		}
@@ -436,37 +425,12 @@ class WebServer
 			$this->requestManager = new RequestManagerClass();
 			
 		try {
-			$res = $this->requestManager->runWSRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PROCESSGETINFO, null, $id);
+			$res = $this->requestManager->runWSRequest($this->userID, 'unknown', FunctionTypeEnumClass::PROCESSGETINFO, null, $id);
 		} catch (Exception $e) {
 			return array("error" => $e->getMessage());
 			//	$this->throwError("serverError", "Exeption detected : ".$e->getMessage());
 		}
-// 	 [success] => 1
-//     [id] => process_t7ovpn_1520344095_13119
-//     [name] => download_1520344108
-//     [status] => done
-//     [jobType] => download
-//     [info] =>  imf
-//     [start] => 06-03-2018 13:48:15
-//     [stop] => 06-03-2018 15:40:20
-//     [folder] => DDEUQzrM_
-//     [result] => result_EUQzrM
-//     [format] => unknown
-//     [compression] => 0
-
-// 	 [success] => 1
-//     [id] => process_t7ovpn_1520344095_13119
-//     [name] => download_1520344108
-//     [status] => in_progress
-//     [jobType] => download
-//     [info] =>  imf
-//     [start] => 06-03-2018 13:48:15
-//     [stop] => unknown
-//     [folder] => DDEUQzrM_
-//     [result] => result_EUQzrM
-//     [format] => unknown
-//     [compression] => 0
-
+		
 		if (!$res['success']) {
 			$this->throwError("processError","Cannot retrieve process $id info");
 		}
@@ -478,20 +442,21 @@ class WebServer
 		if ($res['error']) {
 			$this->throwError("processError","Process $id error code");
 		}
-		
-	//	$vars = $this->getVarsFromRunningPath($result['runningpath']);
-		
-// 		if (!$vars['success']) {
-// 			$this->throwError("processError","Process $id : cannot generate file name for result : ".$vars['message']);
-// 		}
-// 		
-// 		$resultFile = glob($result['runningpath']."result_*");
-// 		
-// 		$tempFilePath = $result['runningpath'].$resultFile.$vars['kernelExtension'];
-// 
-// 		$outputFilePath = WSRESULT.$vars['dataFileName'].$vars['wsExtension'];
-		
-		return  array('success' => true,'status' => $res['status']); //$this->finishDownloadRequest($id, $tempFilePath, $outputFilePath);
+	
+//     [success] => 1
+//     [id] => process_jckrDz_1520873370_11632
+//     [name] => download_1520873382
+//     [status] => done
+//     [jobType] => download
+//     [info] =>  imf
+//     [start] => 12-03-2018 16:49:30
+//     [stop] => 12-03-2018 16:51:49
+//     [folder] => DDfqlbZr_
+//     [result] => download_imf_1484352000_1494806400.txt
+//     [format] => 
+//     [compression] => 0
+		$this->cleanProcess($res['id']);
+		return  array('success' => true, 'status' => $res['status'],  'dataFileURLs' => WSConfigClass::getUrl().$res['result']);
 	}
 	
 	
@@ -543,27 +508,18 @@ class WebServer
 	{
 		$res = $this->init($data);
     
-		$resMgr = $this->initUserMgr();
-
 		if (!$res['success']){
 			$this->throwError("requestError", "Cannot parse request"); 
 		}
 
+		$resMgr = $this->initUserMgr();
+
 		$vars = $res['vars'];
 
 		if (strtotime($vars["stopTime"]) <= strtotime($vars["startTime"])){
 			$this->throwError("requestError", "Requested time interval should be greater than 0");
 		}
- 
-		$dataFileName = $this->getDataFileName($vars);
-
-		if ($dataFileName['success']) {
-			$this->dataFileName = $dataFileName['fileName'];
-		}
-		else {
-			$this->throwError("requestError", $dataFileName['message']);
-		}
-
+		
 		$paramId = array();
 		array_push($paramId, $vars["parameterID"]);
 
@@ -585,9 +541,7 @@ class WebServer
 		$res = $this->doDownloadRequest(
 					array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]),
 					array("params" => $paramId),
-					array("userName" => $this->userID, "userPwd" => $this->userPWD, "sessionID" => $this->sessionID),
-					array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream),
-			$dataFileName);
+					array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream));
  
 		if ($res['success']) 
 			return $res;
@@ -636,7 +590,6 @@ class WebServer
 			$orbParam = $orbitesParam['parameterID'];
 		}
 		else {
-			//$orbParam = 'successEstfalse';
 			$this->throwError("requestError", $orbitesParam['message']);
 		}
      
@@ -665,9 +618,7 @@ class WebServer
 		$res = $this->doDownloadRequest(
 					array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $vars["sampling"]),
 					array("params" => $paramId),
-					array("userName" => $this->userID, "userPwd" => $this->userPWD, "sessionID" => $this->sessionID),
-					array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream),
-			$dataFileName);
+					array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream));
  	 
 		if ($res['success']) return $res;
  
@@ -753,9 +704,7 @@ class WebServer
 		$res = $this->doDownloadRequest(
 					array("startTime" => $vars["startTime"], "stopTime" => $vars["stopTime"], "sampling" => $sampling),
 					array("params" => $paramId),
-					array("userName" => $this->userID, "userPwd" => $this->userPWD, "sessionID" => $this->sessionID),
-					array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream),
-			$dataFileName);
+					array("format" => $vars["outputFormat"], "timeFormat"=> $timeFormat, "gzip"=>$gzip, "stream"=>$stream));
   
 		if ($res['success']) return $res;
 
@@ -837,10 +786,8 @@ class WebServer
 		        'compression'     => $compression];
 	}
 
-	protected function doDownloadRequest($interval,$paramList,$user,$formatInfo,$dataFileName) 
+	protected function doDownloadRequest($interval, $paramList, $formatInfo) 
 	{
-		$fileInfo = $this->getFormatInfo($formatInfo['format'], $formatInfo['timeFormat'], $formatInfo['gzip']); 
-		
 		if (!isset($this->paramLoader))
 			$this->paramLoader = new IHMUserParamLoaderClass();
 
@@ -870,10 +817,9 @@ class WebServer
 				}
 				$param->paramid = "wsd_".$res['name'];
 			}
-			else{
+			else {
 				$param->paramid = $paramId;
 			}
-			
 			$params[] = $param;
 		}
 
@@ -882,16 +828,16 @@ class WebServer
 						"startDate" => $interval['startTime'],
 						"stopDate" => $interval['stopTime'],
 						"list" => $params,
-						"fileformat" => 'ASCII',
-						"timeformat" => 'ISO08601',
-						"compression" => 0
+						"fileformat" => $formatInfo['format'],
+						"timeformat" => $formatInfo['timeFormat'],
+						"compression" => $formatInfo['gzip']
 			);	
 			
 		if (!isset($this->requestManager))
 			$this->requestManager = new RequestManagerClass();
 		 
 		try {
-			$downloadResult = $this->requestManager->runWSRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PARAMS, WSConfigClass::DOWNLOAD, $obj);
+			$downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, WSConfigClass::DOWNLOAD, $obj);
 		} catch (Exception $e) {
 			$this->throwError("executionError", "Exception detected : ".$e->getMessage()); 
 		}
@@ -904,39 +850,25 @@ class WebServer
 			return ['success' => true, 'status' => 'in progress', 'id' => $downloadResult['id']];
 		} elseif ($downloadResult['status'] == 'done') 
 		{
-			$resTempFilePath = USERWORKINGDIR.'/'.$downloadResult['folder'].'/'.$downloadResult['result'].$fileInfo['kernelExtension'];
-			$resOutputFilePath = WSRESULT.$this->dataFileName.$fileInfo['wsExtension'];
-			return $this->finishDownloadRequest($downloadResult['id'], $resTempFilePath, $resOutputFilePath);
+			$this->cleanProcess($downloadResult['id']);
+			return array('success' => true, 'status' => 'done', 'dataFileURLs' => WSConfigClass::getUrl().$downloadResult['result']);
 		} else {
 			return ['success' => false, 'message' => 'Unknown status ' . $downloadResult['status']];
 		} 
 	}
 	
-	private function finishDownloadRequest($id, $resTempFilePath, $resOutputFilePath)
+	private function cleanProcess($id)
 	{
-		if (!file_exists($resTempFilePath)) {
-			$this->throwError("serverError", "Cannot retrieve result file $resTempFilePath");
-	    }
-
-		rename($resTempFilePath, $resOutputFilePath);
-		// chmod($resOutputFilePath, 0664);
-		
-		$outputURL = 'http://' . str_replace(BASE_PATH, $_SERVER['SERVER_NAME'] . APACHE_ALIAS, $resOutputFilePath);
-
-		$obj = (object)array(
-			'id' => $id
-		);
+		$obj = (object)array('id' => $id);
    
 		if (!isset($this->requestManager))
 			$this->requestManager = new RequestManagerClass();
 
-// 		try {
-// 			$downloadResult = $this->requestManager->runIHMRequest($this->userID, $this->getIPclient(), FunctionTypeEnumClass::PROCESSDELETE, $obj);
-// 		} catch (Exception $e) {
-// 			error_log("Can not delete file $resOutputFilePath: $e");
-// 		}
-
-		return array('success' => true, 'status' => 'done', 'dataFileURLs' => $outputURL);
+		try {
+			$downloadResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PROCESSDELETE, WSConfigClass::DOWNLOAD, $obj);
+		} catch (Exception $e) {
+			$this->throwError("cleanProcessError", $e->getMessage());
+		}
 	}
 
 	protected function getDataFileName($vars, $multiParam = false)
@@ -966,48 +898,5 @@ class WebServer
 			return array('success' => false, 'message' => $message);
 		}
 	}
-	
-	private function getVarsFromRunningPath($runningPath)
-	{
-		$filePath = $runningPath . "request_0.xml";
-		
-		if (!file_exists($filePath)) {
-			return ['success' => false, 'message' => 'Failed to open request file'];
-		}
-		
-		$requestXml = new DOMDocument();
-		$requestXml->load($filePath);
-		$fileFormat = $requestXml->getElementsByTagName('fileFormat')->item(0)->nodeValue;
-		$timeFormat = $requestXml->getElementsByTagName('timeFormat')->item(0)->nodeValue;
-		$gzip = 0; // todo $requestXml->getElementsByTagName('gzip')->item(0)->nodeValue;
-
-		// get kernelExtension, wsExtension, fileFormat, timeFormat, compression:
-		$vars = $this->getFormatInfo($fileFormat, $timeFormat, $gzip);
-
-		$vars['parameterID'] = $requestXml->getElementsByTagName('param')->item(0)->getAttribute('id');
-
-		$ddStart    = $requestXml->getElementsByTagName('startTime')->item(0)->nodeValue;
-		$ddInterval = $requestXml->getElementsByTagName('timeInterval')->item(0)->nodeValue;
-		$vars['startTime'] = CommonClass::DDTimeToIso($ddStart);
-		$vars['stopTime'] = CommonClass::DDStartIntervalToStopIso($ddStart, $ddInterval);
-
-		$sampling = $requestXml->getElementsByTagName('sampling')->item(0);
-		if (!is_null($sampling))
-			$vars['sampling'] = $sampling->nodeValue;
-
-		if (in_array(null, $vars, true)) {
-			return ['success' => false,
-				    'message' => 'Can not create data file name - a value is missing in the request file'];
-		}
-
-		$dataFileName = $this->getDataFileName($vars, false);
-		if (!$dataFileName['success']) {
-			return $dataFileName;
-		}
-		$vars['dataFileName'] = $dataFileName['fileName'];
-		$vars['success'] = true;
-		
-		return $vars;
-	}
 }
 ?>
\ No newline at end of file
--
libgit2 0.21.2