cvs: pear /HTTP_Upload Upload.php

From: Date: Wed, 28 Nov 2001 17:11:00 +0000
Subject: cvs: pear /HTTP_Upload Upload.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1424@lists.php.net to get a copy of this message
cox Wed Nov 28 12:11:00 2001 EDT Modified files: /pear/HTTP_Upload Upload.php Log: Reversed the params of in_array (thank Hans Westerbeek <hw@xs4all.nl> for reporting it so fast) Added in-line docs for the new file extensions check feature Index: pear/HTTP_Upload/Upload.php diff -u pear/HTTP_Upload/Upload.php:1.12 pear/HTTP_Upload/Upload.php:1.13 --- pear/HTTP_Upload/Upload.php:1.12 Sat Nov 24 15:29:09 2001 +++ pear/HTTP_Upload/Upload.php Wed Nov 28 12:11:00 2001 @@ -7,7 +7,7 @@ // // ********************************************** // -// $Id: Upload.php,v 1.12 2001/11/24 20:29:09 cox Exp $ +// $Id: Upload.php,v 1.13 2001/11/28 17:11:00 cox Exp $ /* * Pear File Uploader class. Easy and secure managment of files @@ -518,23 +518,39 @@ return $this->errorCode($this->upload['error']); } + /** + * Function to restrict the valid extensions on file uploads + * + * @param array $exts File extensions to validate + * @param string $mode The type of validation: + * 1) 'deny' Will deny only the supplied extensions + * 2) 'accept' Will accept only the supplied extensions + * as valid + * @access public + */ function setValidExtensions($exts, $mode = 'deny') { $this->_extensions_check = $exts; $this->_extensions_mode = $mode; } + /** + * Evaluates the validity of the extensions set by setValidExtensions + * + * @return bool False on non valid extension, true if they are valid + * @access private + */ function _evalValidExtensions() { $exts = $this->_extensions_check; settype($exts, 'array'); if ($this->_extensions_mode == 'deny') { - if (in_array($exts, $this->getProp('ext'))) { + if (in_array($this->getProp('ext'), $exts)) { return false; } // mode == 'accept' } else { - if (!in_array($exts, $this->getProp('ext'))) { + if (!in_array($this->getProp('ext'), $exts)) { return false; } }

« previous php.pear.cvs (#1424) next »