View Issue Details

IDProjectCategoryView StatusLast Update
0002812mantisbtbugtrackerpublic2003-12-13 04:44
ReporterreporterAssigned Tovboctor  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Platformx86OSWindows 2000 
Product Versiongit trunk 
Summary0002812: Docs file upload functionality broken
Description

"Docs" file upload is not working properly. Seems like sources were modified to work also with register_globals turned off, but file upload functionality remains broken after mentioned change. Just try to reproduce bug (upload some doc, does not matter if into disk or database) and if reproduction succeed, try to use my patch for fixing it. It worked well for me.

Steps To Reproduce

Try to upload doc file.

Additional Information

This patch was posted also into MantisBT-DEV mailinglist.

Nepto, <a href="http://nepto.sk/">http://nepto.sk/</a>

TagsNo tags attached.

Activities

reporter

reporter

2002-12-26 16:31

reporter   ~0003575

Here is patch. I do not know, why is file upload functionality disabled here.


--- /home/ondrej/prog/CVS-others/mantisbt/proj_doc_add.php Tue Dec 17 12:35:29 2002
+++ proj_doc_add.php Thu Dec 26 16:54:35 2002
@@ -15,11 +15,12 @@
$result = 0;
$good_upload = 0;
$disallowed = 0;

  • extract( $HTTP_POST_FILES['f_file'], EXTR_PREFIX_ALL, 'f' );
  • // note that underscore '_' is automatically appended into prefix
  • extract( $HTTP_POST_FILES['f_file'], EXTR_PREFIX_ALL, 'f_file' );

    if ( !file_type_check( $f_file_name ) ) {
    $disallowed = 1;

  • } else if ( is_uploaded_file( $f_file ) ) {
  • } else if ( is_uploaded_file( $f_file_tmp_name ) ) {
    $good_upload = 1;

    # grab the file path

    @@ -30,12 +31,12 @@
    $f_description = string_prepare_textarea( $f_description );

    $f_file_name = $g_project_cookie_val.'-'.$f_file_name;
  • $t_file_size = filesize( $f_file );
  • $t_file_size = filesize( $f_file_tmp_name );

    switch ( $g_file_upload_method ) {
        case DISK:  if ( !file_exists( $t_file_path.$f_file_name ) ) {
                        umask( 0333 );  # make read only
  • copy($f_file, $t_file_path.$f_file_name);
  • copy($f_file_tmp_name, $t_file_path.$f_file_name);
    $query = "INSERT INTO mantis_project_file_table
    (id, project_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content)
    VALUES
    @@ -45,7 +46,7 @@
    }
    break;
    case DATABASE:
  • $t_content = addslashes( fread ( fopen( $f_file, 'rb' ), $t_file_size ) );
  • $t_content = addslashes( fread ( fopen( $f_file_tmp_name, 'rb' ), $t_file_size ) );
    $query = "INSERT INTO mantis_project_file_table
    (id, project_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content)
    VALUES
jfitzell

jfitzell

2003-01-02 15:16

reporter   ~0003585

the code in that file has not been updated to use gpc_get_file() and other new api functions, which is why it hasn't been tested yet. I'm working alphabetically through the files fixing them with new apis. So if no on gets to this before then I'll hit it at that point.

reporter

reporter

2003-01-20 04:00

reporter   ~0003632

I've patched it another way -- trying to use gpc (modeled after bug_file_add). If you want it (tested only in the case "DATABASE" email me: <a href="mailto:jmisiure@elka.pw.edu.pl" target="_new">jmisiure@elka.pw.edu.pl</a>

vboctor

vboctor

2003-02-27 01:32

manager   ~0003856

This is fixed in 0.18.0a3. I didn't use the patches here since I wasn't aware of this bug back then. The new code uses gpc_get_file().