From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/Filter/File/Encrypt.php | 101 ++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 library/vendor/Zend/Filter/File/Encrypt.php (limited to 'library/vendor/Zend/Filter/File/Encrypt.php') diff --git a/library/vendor/Zend/Filter/File/Encrypt.php b/library/vendor/Zend/Filter/File/Encrypt.php new file mode 100644 index 0000000..16be9df --- /dev/null +++ b/library/vendor/Zend/Filter/File/Encrypt.php @@ -0,0 +1,101 @@ +_filename; + } + + /** + * Sets the new filename where the content will be stored + * + * @param string $filename (Optional) New filename to set + * @return Zend_Filter_File_Encryt + */ + public function setFilename($filename = null) + { + $this->_filename = $filename; + return $this; + } + + /** + * Defined by Zend_Filter_Interface + * + * Encrypts the file $value with the defined settings + * + * @param string $value Full path of file to change + * @return string The filename which has been set, or false when there were errors + */ + public function filter($value) + { + if (!file_exists($value)) { + throw new Zend_Filter_Exception("File '$value' not found"); + } + + if (!isset($this->_filename)) { + $this->_filename = $value; + } + + if (file_exists($this->_filename) and !is_writable($this->_filename)) { + throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable"); + } + + $content = file_get_contents($value); + if (!$content) { + throw new Zend_Filter_Exception("Problem while reading file '$value'"); + } + + $encrypted = parent::filter($content); + $result = file_put_contents($this->_filename, $encrypted); + + if (!$result) { + throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'"); + } + + return $this->_filename; + } +} -- cgit v1.2.3