8000 Warning issued for array key SCRIPT_FILENAME · Issue #83 · mimecorg/webissues · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Warning issued for array key SCRIPT_FILENAME #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
durangod opened this issue Jul 1, 2024 · 2 comments
Open

Warning issued for array key SCRIPT_FILENAME #83

durangod opened this issue Jul 1, 2024 · 2 comments

Comments

@durangod
Copy link
durangod commented Jul 1, 2024

PHP Warning: Undefined array key "SCRIPT_FILENAME" in /home/username/sitename/subdir/system/bootstrap.inc.php on line 141

I understand this is just a warning and i did try to post this on your forum but i was not able to register on your forum because i never got a verify email from the forum, so i am posting here.

First thanks for doing this script, i really like it... :)

This warning i believe is caused because server SCRIPT_FILENAME is not always populated on some servers, so it needs to be qualified first.

in bootstrap.inc.php you have the following code

public static function getScriptPath()
    {
        if ( defined( 'WI_SCRIPT_PATH' ) )
            return WI_SCRIPT_PATH;

        $path = $_SERVER[ 'SCRIPT_FILENAME' ];
        
        $real = realpath( $path );
        if ( $real )
            $path = $real;
        $path = str_replace( '\\', '/', $path );

        return $path;
    }

$path value needs to be wrapped inside an if statement to be sure that SCRIPT_FILENAME has a value. Im not sure what value (referrer) it should have or i would do the code for you and post it here. I just wanted to give you a heads up so you know this was causing a warning without the if statement. :)

I think this may work

  public static function getScriptPath()
    {
        if ( defined( 'WI_SCRIPT_PATH' ) )
            return WI_SCRIPT_PATH;
            
        //dave mod
        
        if(!empty($_SERVER[ 'SCRIPT_FILENAME' ]))
        {
            
          $path = $_SERVER[ 'SCRIPT_FILENAME' ]; 
          
        }else{
            
               $path = __FILE__;
            
             }

        //original code 
        //$path = $_SERVER[ 'SCRIPT_FILENAME' ];
        
        //end mod
        
        $real = realpath( $path );
        if ( $real )
            $path = $real;
        $path = str_replace( '\\', '/', $path );

        return $path;
    }

@mimecorg
Copy link
Owner
mimecorg commented Jul 4, 2024

To be honest it's the first time I see $_SERVER[ 'SCRIPT_FILENAME' ] not being defined. What server do you use?

I'm not sure if using __FILE__ instead will work correctly because it will refer to boostrap.inc.php, not the script which is being executed.

@durangod
Copy link
Author
durangod commented Jul 4, 2024

Server config is

cPanel Version | 118.0 (build 12)
Apache Version | 2.4.59
MySQL Version | 10.6.18-MariaDB-cll-lve-log
Architecture | x86_64
Operating System | linux
Perl Version | 5.26.3
Kernel Version | 4.18.0-513.18.1.lve.el8.x86_64
PHP Version | 8.1

Just FYI, i have seen that warning come up with other processes as well from different files, so it appears it may be a php issue or some global issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0