<commit_before><?php

class remote_fsDriver extends AbstractDriver 
{
	
	function remote_fsDriver($driverName, $filePath, $repository){
		parent::AbstractDriver($driverName, INSTALL_PATH."/plugins/ajxp.fs/fsActions.xml", $repository);
		unset($this->actions["upload"]);
		// ADD additional actions
		$this->xmlFilePath = INSTALL_PATH."/plugins/ajxp.remote_fs/additionalActions.xml";
		$this->parseXMLActions();
	}
	
	function switchAction($action, $httpVars, $filesVars){		
		$sessionId = "";
		$crtRep = ConfService::getRepository();
		$httpClient = $this->getRemoteConnexion($sessionId);
		$httpVars["ajxp_sessid"] = $sessionId;
		$method = "get";
		if($action == "edit" && isSet($httpVars["save"])) $method = "post";
		if($method == "get"){
			$httpClient->get($crtRep->getOption("URI"), $httpVars);
		}else{			
			$httpClient->post($crtRep->getOption("URI"), $httpVars);
		}
		// check if session is expired
		if(strpos($httpClient->getHeader("content-type"), "text/xml") !== false && strpos($httpClient->getContent(), "require_auth") != false){
			$httpClient = $this->getRemoteConnexion($sessionId, true);
			$httpVars["ajxp_sessid"] = $sessionId;
			$method = "get";
			if($method == "get"){
				$httpClient->get($crtRep->getOption("URI"), $httpVars);
			}else{			
				$httpClient->post($crtRep->getOption("URI"), $httpVars);
			}
		}

		switch ($action){			
			case "image_proxy":
				$size=strlen($httpClient->content);
				header("Content-Type: ".Utils::getImageMimeType(basename($httpVars["file"]))."; name=\"".basename($httpVars["file"])."\"");
				header("Content-Length: ".$size);
				header('Cache-Control: public');							
			break;
			case "download":
				$size=strlen($httpClient->content);
				$filePath = $httpVars["file"];
				header("Content-Type: application/force-download; name=\"".basename($filePath)."\"");
				header("Content-Transfer-Encoding: binary");
				header("Content-Length: ".$size);
				header("Content-Disposition: attachment; filename=\"".basename($filePath)."\"");
				header("Expires: 0");
				header("Cache-Control: no-cache, must-revalidate");
				header("Pragma: no-cache");
				// For SSL websites, bug with IE see article KB 323308
				if (ConfService::getConf("USE_HTTPS")==1 && preg_match('/ MSIE /',$_SERVER['HTTP_USER_AGENT'])){
					header("Cache-Control:");
					header("Pragma:");
				}<commit_msg>Directly pass received headers, just skip "content-encoding", that may be set to "gzip"<commit_after><?php

class remote_fsDriver extends AbstractDriver 
{
	
	function remote_fsDriver($driverName, $filePath, $repository){
		parent::AbstractDriver($driverName, INSTALL_PATH."/plugins/ajxp.fs/fsActions.xml", $repository);
		unset($this->actions["upload"]);
		// ADD additional actions
		$this->xmlFilePath = INSTALL_PATH."/plugins/ajxp.remote_fs/additionalActions.xml";
		$this->parseXMLActions();
	}
	
	function switchAction($action, $httpVars, $filesVars){		
		$sessionId = "";
		$crtRep = ConfService::getRepository();
		$httpClient = $this->getRemoteConnexion($sessionId);
		$httpVars["ajxp_sessid"] = $sessionId;
		$method = "get";
		if($action == "edit" && isSet($httpVars["save"])) $method = "post";
		if($method == "get"){
			$httpClient->get($crtRep->getOption("URI"), $httpVars);
		}else{			
			$httpClient->post($crtRep->getOption("URI"), $httpVars);
		}
		// check if session is expired
		if(strpos($httpClient->getHeader("content-type"), "text/xml") !== false && strpos($httpClient->getContent(), "require_auth") != false){
			$httpClient = $this->getRemoteConnexion($sessionId, true);
			$httpVars["ajxp_sessid"] = $sessionId;
			$method = "get";
			if($method == "get"){
				$httpClient->get($crtRep->getOption("URI"), $httpVars);
			}else{			
				$httpClient->post($crtRep->getOption("URI"), $httpVars);
			}
		}

		switch ($action){			
			case "image_proxy":
				$size=strlen($httpClient->content);
				header("Content-Type: ".Utils::getImageMimeType(basename($httpVars["file"]))."; name=\"".basename($httpVars["file"])."\"");
				header("Content-Length: ".$size);
				header('Cache-Control: public');							
			break;
			case "download":
				$size=strlen($httpClient->content);
				foreach ($httpClient->headers as $key=>$value){
					if($key != "content-encoding"){
						header(ucfirst($key).": ".$value);
					}
				}
{'fraction_non_alphanumeric': 0.20331079505712288, 'fraction_numerical': 0.0018652366519002097, 'mean_word_length': 4.876712328767123, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '253586', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1428, 'n_words': 226}