Re: cvs: pear /HTTP_Upload Upload.php
| From: | Jon Parise | Date: | Tue, 11 Sep 2001 02:42:12 +0000 |
| Subject: | Re: cvs: pear /HTTP_Upload Upload.php | ||
| References: | 1 | Groups: | php.pear.cvs |
| Request: | Send a blank email to pear-cvs+get-831@lists.php.net to get a copy of this message | ||
On Tue, Sep 11, 2001 at 01:32:52AM -0000, Sterling Hughes wrote:
> Index: pear/HTTP_Upload/Upload.php
> diff -u pear/HTTP_Upload/Upload.php:1.3 pear/HTTP_Upload/Upload.php:1.4
> --- pear/HTTP_Upload/Upload.php:1.3 Tue Aug 14 21:25:27 2001
> +++ pear/HTTP_Upload/Upload.php Mon Sep 10 21:32:52 2001
> @@ -7,7 +7,7 @@
> //
> // **********************************************
> //
> -// $Id: Upload.php,v 1.3 2001/08/15 01:25:27 cox Exp $
> +// $Id: Upload.php,v 1.4 2001/09/11 01:32:52 sterling Exp $
>
> /**
> * Pear File Uploader class. Easy and secure managment of files
> @@ -201,6 +201,8 @@
>
> class HTTP_Upload_File extends HTTP_Upload_Error
> {
> + var $_seeded = 0;
> +
> /**
> * Assoc array with file properties
> * @var array
> @@ -274,7 +276,11 @@
> */
> function nameToUniq ()
> {
> - srand((double) microtime() * 1000000);
> + if (! $this->_seeded) {
> + srand((double) microtime() * 1000000);
> + $this->_seeded = 1;
> + }
> +
> $uniq = uniqid(rand());
> return $uniq . '.' .
> $this->nameToSafe($this->upload['ext'],10);
> }
> @@ -416,4 +422,4 @@
> return $this->errorCode($this->upload['error']);
> }
> }
> -?>
> \ No newline at end of file
> +?>
Because that new flag is only accessed in the nameToUniq()
function, it might be considered cleaner to make it a
function-level static variable instead of a private class
variable.
--
Jon Parise (jon@csh.rit.edu) . Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/ : Computer Science House
Member