diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2005-05-05 16:55:05 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2005-05-05 16:55:05 +0000 |
commit | b576d6af0a9c0c78f379ca09069648d87364e1a0 (patch) | |
tree | eb73ff0919d865a420a2dd4cc71409f59da76ebd /phpBB/includes/functions_upload.php | |
parent | 16e50db4baf39877fe3e02a13dfc57983b12f414 (diff) | |
download | forums-b576d6af0a9c0c78f379ca09069648d87364e1a0.tar forums-b576d6af0a9c0c78f379ca09069648d87364e1a0.tar.gz forums-b576d6af0a9c0c78f379ca09069648d87364e1a0.tar.bz2 forums-b576d6af0a9c0c78f379ca09069648d87364e1a0.tar.xz forums-b576d6af0a9c0c78f379ca09069648d87364e1a0.zip |
- some cross-db related changes
- putting active bots array into cache
git-svn-id: file:///svn/phpbb/trunk@5140 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_upload.php')
-rw-r--r-- | phpBB/includes/functions_upload.php | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 250b948c7d..28041c87fa 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -56,6 +56,12 @@ class filespec // Opera adds the name to the mime type $this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype; + + if (!$this->mimetype) + { + $this->mimetype = 'application/octetstream'; + } + $this->extension = array_pop(explode('.', strtolower($this->realname))); // Try to get real filesize from temporary folder (not always working) ;) @@ -122,7 +128,12 @@ class filespec function is_uploaded() { - return (file_exists($this->filename) && is_uploaded_file($this->filename)) ? true : false; + if (!$this->local && !is_uploaded_file($this->filename)) + { + return false; + } + + return (file_exists($this->filename)) ? true : false; } function remove() @@ -394,8 +405,64 @@ class fileupload } // Move file from another location to phpBB - function local_upload($source_file) + function local_upload($source_file, $filedata = false) { + global $user; + + $form_name = 'local'; + + $_FILES[$form_name]['local_mode'] = true; + $_FILES[$form_name]['tmp_name'] = $source_file; + + if ($filedata === false) + { + $_FILES[$form_name]['name'] = basename($source_file); + $_FILES[$form_name]['size'] = 0; + $_FILES[$form_name]['type'] = ''; + } + else + { + $_FILES[$form_name]['name'] = $filedata['realname']; + $_FILES[$form_name]['size'] = $filedata['size']; + $_FILES[$form_name]['type'] = $filedata['type']; + } + + $file = new filespec($_FILES[$form_name], $this); + + if ($file->init_error) + { + $file->error[] = ''; + return $file; + } + + if (isset($_FILES[$form_name]['error'])) + { + $error = $this->assign_internal_error($_FILES[$form_name]['error']); + + if ($error !== false) + { + $file->error[] = $error; + return $file; + } + } + + // PHP Upload filesize exceeded + if ($file->get('filename') == 'none') + { + $file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); + return $file; + } + + // Not correctly uploaded + if (!$file->is_uploaded()) + { + $file->error[] = $user->lang[$this->error_prefix . 'NOT_UPLOADED']; + return $file; + } + + $this->common_checks($file); + + return $file; } /** |