Title: Enabled Encryption malforming documents
Last modified: August 24, 2016

---

# Enabled Encryption malforming documents

 *  [Medowar](https://wordpress.org/support/users/medowar/)
 * (@medowar)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/)
 * Hello,
 * I have an issue with this Plugin and Downloading any sort of Document, when encryption
   is enabled. This malformes the downloaded documents.
 * I have already reinstalled the plugin, but this did not fix it.
 * Examples are:
    TXT: Left: redownloaded Version Right: Original [http://puu.sh/hH8rv/2699e013ca.png](http://puu.sh/hH8rv/2699e013ca.png)
 * Full Files are linked below.
 * PDF:
    Left: redownloaded Version Right: Original [http://puu.sh/hH8zr/6ba7938905.png](http://puu.sh/hH8zr/6ba7938905.png)
 * Full Files:
    [http://cdn.germangang.com/content/008/test-pdf-original.pdf](http://cdn.germangang.com/content/008/test-pdf-original.pdf)
   [http://cdn.germangang.com/content/008/test-pdf-redownloaded.pdf](http://cdn.germangang.com/content/008/test-pdf-redownloaded.pdf)
   [http://cdn.germangang.com/content/008/test-txt-original.txt](http://cdn.germangang.com/content/008/test-txt-original.txt)
   [http://cdn.germangang.com/content/008/test-txt-redownloaded.txt](http://cdn.germangang.com/content/008/test-txt-redownloaded.txt)
 * [https://wordpress.org/plugins/file-away/](https://wordpress.org/plugins/file-away/)

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6111922)
 * Try disabling debug messages. If you have erorrs on your site, and debug messages
   enabled, they will be written into any document being pushed to client from server.
 *  Thread Starter [Medowar](https://wordpress.org/support/users/medowar/)
 * (@medowar)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6111928)
 * define(‘WP_DEBUG’, false); is already set.
 * And file away does not have such an option, or at least did I not find it yet.
 * Also now it also happens in unencrypted mode.
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6111929)
 * If stats are enabled, it is still pushing the downloads from server to client,
   with or without encryption enabled. File Away has no debug writing mode, no.
 * File Away itself simply pushes files to the client from the server when stats
   or encryption are enabled.
 *  Thread Starter [Medowar](https://wordpress.org/support/users/medowar/)
 * (@medowar)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6111932)
 * Yes, thank you, I can confirm this. Disabling stats and encryption did fix this.
 * But we want to use encryption, since the documents shared are private Documents
   and we dont want them to be publicly accessable. As a temporary fix, disabling
   stats and encryption is sufficient, but this is not a long-term Solution.
 * It is to note, that this Problem only appears since the last update(either 3.9.5
   or 3.9.6), and since this is a bug, that can definitely be traced to your implementation,
   it would be very nice, if you could fix this, or we would have to switch to a
   different Plugin.
 * If you need any additional Informations, please come back to me.
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6111933)
 * I’ll look into it.
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6111936)
 * There were no changes made to the download class between 3.9.5 and 3.9.6. The
   only difference between 3.9.6 and earlier 3.9 versions is between 3.9.1, and 
   the difference pertains to how I get the basename of the file, which wouldn’t
   affect you, since it’s a setting, and certainly wouldn’t affect the contents 
   of the file itself. Here’s the difference:
 * 3.9.1:
    `$name = basename($file);`
 * 3.9.6:
    `$name = fileaway_utility::basename($file);`
 * And here’s that function:
 *     ```
       public static function basename($path_file)
       {
       	return fileaway_definitions::$pathinfo ? self::pathinfo($path_file, PATHINFO_BASENAME) : basename($path_file);
       }
       ```
   
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6111939)
 * I’m still looking into it.
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6112001)
 * I’m able to duplicate your issue with `test-txt-original.txt` but I am able to
   download `test-pdf-original.pdf` just fine every time with no issues, in 3.9.5
   AND in 3.9.6.
 * I am still trying to figure out why the lines are being removed from test-txt-
   original.txt because I have another (private) plugin that uses the exact same
   download function as File Away, to the letter, and my private plugin downloads
   the test-txt-original.txt just fine, while with File Away’s it downloads with
   lines removed. The files are identical, and the functions are identical. So it’s
   a conundrum.
 * But, by the way, I’m getting the line-removal with test-txt-original.txt in versions
   going all the way back to File Away 3.9. (I don’t have an earlier version handy
   at the moment, but I’ll try to find one.)
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6112004)
 * It occurs in 3.8.4 also, with the text file.
 *  Thread Starter [Medowar](https://wordpress.org/support/users/medowar/)
 * (@medowar)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6112225)
 * Any update?
 * Just trested it with a PDF and Problem still exists.
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6112226)
 * Like I said, I tested it with the same pdf file you linked above, and it downloaded
   fine for me, so I can’t troubleshoot what I can’t duplicate, on that score. I
   do get the issue with the .txt file, but I haven’t found a solution for that 
   yet. It’s inexplicable to me as I use the exact same download code in another
   plugin of mine, and the issue with the .txt file doesn’t occur there. Can’t nail
   it down.
 *  Thread Starter [Medowar](https://wordpress.org/support/users/medowar/)
 * (@medowar)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6112227)
 * Can you give me the sourcecode of the Plugins and different Versions, so I can
   do some research on my own?
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6112228)
 * The other plugin is proprietary, but as I said, the function is precisely identical,
   to the letter.
 * Here’s the function for version 3.0:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Description: File Transfer");
       			header("Content-Type: application/force-download");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					flush();
       					ob_clean();
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   
 * Here’s the function for version 3.1:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Description: File Transfer");
       			header("Content-Type: application/force-download");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					flush();
       					ob_clean();
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   
 * Here’s the function for version 3.5:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			$mime = $this->mimes(strtolower(substr(strrchr($file, '.'), 1)));
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Type: ".$mime);
       			//header("Content-Type: application/octet-stream;");
       			//header("Content-Type: application/force-download");
       			header("Content-Description: File Transfer");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			//header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			ob_end_flush();
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   
 * Here’s the function for version 3.6:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			$mime = $this->mimes(strtolower(substr(strrchr($file, '.'), 1)));
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Type: ".$mime);
       			//header("Content-Type: application/octet-stream;");
       			//header("Content-Type: application/force-download");
       			header("Content-Description: File Transfer");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			//header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			ob_end_flush();
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   
 * Here’s the function for 3.6.1:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			$mime = $this->mimes(strtolower(substr(strrchr($file, '.'), 1)));
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Type: ".$mime);
       			//header("Content-Type: application/octet-stream;");
       			//header("Content-Type: application/force-download");
       			header("Content-Description: File Transfer");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			//header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			ob_end_flush();
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   
 * Here’s the function for 3.6.2:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			$mime = $this->mimes(strtolower(substr(strrchr($file, '.'), 1)));
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Type: ".$mime);
       			//header("Content-Type: application/octet-stream;");
       			//header("Content-Type: application/force-download");
       			header("Content-Description: File Transfer");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			//header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			ob_end_flush();
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   
 * Here’s the function for 3.7:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			$mime = $this->mimes(strtolower(substr(strrchr($file, '.'), 1)));
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Type: ".$mime);
       			//header("Content-Type: application/octet-stream;");
       			//header("Content-Type: application/force-download");
       			header("Content-Description: File Transfer");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			//header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			ob_end_flush();
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   
 * Here’s the function for 3.8:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			$mime = $this->mimes(strtolower(substr(strrchr($file, '.'), 1)));
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Type: ".$mime);
       			//header("Content-Type: application/octet-stream;");
       			//header("Content-Type: application/force-download");
       			header("Content-Description: File Transfer");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			//header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			ob_end_flush();
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   
 * Here’s the function for 3.8.1:
 *     ```
       public function download()
       		{
       			$file = $this->decrypt($_GET['fileaway']);
       			$file = fileaway_utility::urlesc($file, true);
       			if(!is_file($file)) die('Sorry. That file could not be found.');
       			if(!wp_verify_nonce($_GET['nonce'], 'fileaway-download')) die('Sorry. The download could not be verified.');
       			$name = basename($file);
       			$size = filesize($file);
       			$mime = $this->mimes(strtolower(substr(strrchr($file, '.'), 1)));
       			header("Pragma: public");
       			header("Expires: 0");
       			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       			header("Content-Type: ".$mime);
       			//header("Content-Type: application/octet-stream;");
       			//header("Content-Type: application/force-download");
       			header("Content-Description: File Transfer");
       			header("Content-Disposition: attachment; filename=\"$name\"");
       			//header("Content-Transfer-Encoding: binary");
       			header("Content-Length: " . $size);
       			ob_end_flush();
       			set_time_limit(0);
       			$file = @fopen($file, 'rb');
       			if($file)
       			{
       				while(!feof($file))
       				{
       					print(fread($file, 1024*8));
       					if(connection_status()!=0)
       					{
       						@fclose($file);
       						die();
       					}
       				}
       				@fclose($file);
       			}
       			die();
       		}
       ```
   

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Enabled Encryption malforming documents’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/file-away_e3e2e1.svg)
 * [File Away](https://wordpress.org/plugins/file-away/)
 * [Support Threads](https://wordpress.org/support/plugin/file-away/)
 * [Active Topics](https://wordpress.org/support/plugin/file-away/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/file-away/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/file-away/reviews/)

## Tags

 * [encryption](https://wordpress.org/support/topic-tag/encryption/)
 * [malformed](https://wordpress.org/support/topic-tag/malformed/)
 * [pdf](https://wordpress.org/support/topic-tag/pdf/)

 * 13 replies
 * 2 participants
 * Last reply from: [thomstark](https://wordpress.org/support/users/thomstark/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/enabled-encryption-malforming-documents/#post-6112228)
 * Status: not resolved