+ Reply to Thread
Results 1 to 4 of 4

Thread: Notice using FILEUPLOAD (in debug mode)

  1. #1
    Join Date
    Aug 2008
    Posts
    6

    Default Notice using FILEUPLOAD (in debug mode)

    Hi,

    If run the script with define('DEBUG',true); and encountered following behavior. It's not an error, but looks like a bug which php is covering.

    Version 8.05
    Line numbers refer frommail.php from the download formmail.zip

    In line 6814 in function function SubstituteValueWorker the following statement

    if (is_array($aSubstituteValues[$s_name]))

    leads to the notice

    Notice: Undefined index: upload_file in formail.php on line 6814

    if upload_file is the name of an <input type="file" name="upload_file" ...>

    Reason: in line 6811 and 6812 two checks were performed if the variable exists and is not empty.

    if (IsFieldSet($s_name,$aSubstituteValues) &&
    !TestFieldEmpty($s_name,$aSubstituteValues,$s_mesg))


    Both function do not check the array given in the function parameter (here $aSubstituteValues) if FILEUPLOAD is set.

    function IsFieldSet($s_fld,$a_main_vars)
    {
    global $aFileVars;

    return (isset($a_main_vars[$s_fld]) ||
    (FILEUPLOADS && isset($aFileVars[$s_fld])));
    }

    Don't know if it's wroth a fix, because it doesn't lead to an error... but the two functions are really bad software design, which leads to this issue.

    Regards,
    Lonny

  2. #2
    Join Date
    Dec 2003
    Posts
    3,900

    Default Re: Notice using FILEUPLOAD (in debug mode)

    Hi,

    Quote Originally Posted by lonny27 View Post
    In line 6814 in function function SubstituteValueWorker the following statement
    Quote Originally Posted by lonny27 View Post

    if (is_array($aSubstituteValues[$s_name]))


    Yes. The code should be:
    PHP Code:
            if (isset($aSubstituteValues[$s_name]) &&
                
    is_array($aSubstituteValues[$s_name])) 
    if (IsFieldSet($s_name,$aSubstituteValues) &&
    !TestFieldEmpty($s_name,$aSubstituteValues,$s_mesg))

    Both function do not check the array given in the function parameter (here
    $aSubstituteValues) if FILEUPLOAD is set.



    Not quite true. Both functions do check the array in the function parameter ($aSubstituteValues) regardless of the setting of FILEUPLOAD.

    The problem is that IsFieldSet and TestFieldEmpty try to cope with "fields" of any type, including file upload fields.

    Originally, they didn't and only dealt with non-file fields. Software evolution often causes little problems like this.

    Don't know if it's wroth a fix, because it doesn't lead to an error... but the two functions are really bad software design, which leads to this issue.
    Unfortunately, PHP provides some fields in a different array. File upload fields are in a different array to all other fields, and this makes coding quite difficult. Plus, you add in the option of disabling file uploads.

    Anyway, easily fixed.

    Unfortunately, I've never seen these error messages out of PHP, otherwise the code would have been corrected earlier. Perhaps a new version of PHP is behaving differently.


    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Aug 2008
    Posts
    6

    Default Re: Notice using FILEUPLOAD (in debug mode)

    Not quite true. Both functions do check the array in the function parameter ($aSubstituteValues) regardless of the setting of FILEUPLOAD.

    The problem is that IsFieldSet and TestFieldEmpty try to cope with "fields" of any type, including file upload fields.

    Originally, they didn't and only dealt with non-file fields. Software evolution often causes little problems like this.
    Yes, the array gets checked. What I wanted to say was, that the result of the function IsFieldSet($s_fld,$a_main_vars) is if
    true: yes, $s_fld is set in $a_main_vars
    false: maybe, $s_fld is set in $a_main_vars

    But I understand that software evolution leads sometimes to strange constructs
    With more than 10.000 lines the script is quite complex, and due to the fact that it's procedural and not object oriented makes it even more difficult to extend.

    Anyway it's a great script and it's one of the best documented open source projects I've ever seen!

    Best regards,
    Lonny

  4. #4
    Join Date
    Dec 2003
    Posts
    3,900

    Default Re: Notice using FILEUPLOAD (in debug mode)

    Hi,

    Quote Originally Posted by lonny27 View Post
    Yes, the array gets checked. What I wanted to say was, that the result of the
    Quote Originally Posted by lonny27 View Post
    function IsFieldSet($s_fld,$a_main_vars) is if
    true: yes,
    $s_fld is set in $a_main_vars
    false: maybe,
    $s_fld is set in $a_main_vars


    I'm not sure what you're saying above.

    IsFieldSet always returns true if $s_fld is set in $a_main_vars.

    If $s_fld is set in $aFileVars, then the function returns true if you've configured to enable file uploads.

    The logic is exactly right for the purpose of the function.

    With more than 10.000 lines the script is quite complex, and due to the fact that it's procedural and not object oriented makes it even more difficult to extend.
    The next major version is being re-written as object-oriented. This will allow us to easily exclude code people don't want, thereby reducing the size of the script for people who only want basic functionality.

    Anyway it's a great script and it's one of the best documented open source projects I've ever seen!
    Thanks.

    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. fileupload error conditions1
    By sunadumari in forum Community Support
    Replies: 0
    Last Post: 23-May-2007, 08:10 PM
  2. HTML mode problems ????
    By dmitryseliv in forum FormMail Subscription Support
    Replies: 2
    Last Post: 12-Nov-2005, 12:35 AM
  3. An error occurred while......Warning: SAFE MODE Restriction
    By Eric1971 in forum FormMail Subscription Support
    Replies: 1
    Last Post: 29-Jun-2004, 09:32 PM
  4. SAFE MODE Restriction in effect???
    By ptr in forum FormMail Subscription Support
    Replies: 4
    Last Post: 25-May-2004, 09:08 PM
  5. Notice: Undefined index: SCRIPT_FILENAME
    By jhartwick in forum FormMail Subscription Support
    Replies: 2
    Last Post: 18-Jan-2004, 06:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts