Skip to content

file_exists() check while finding prognames creates loads of error log entries due to open_basedir restriction

Hello,

on a shared hosting system with open_basedir restrictions the function getProgramPath floods the log with entries like

file_exists(): open_basedir restriction in effect....

Would it be more efficient and less error producing to search only in accessable paths for the files and if they are executable?

File: utils.php, line 109

function getProgramPath($progname){
    $path_ar = explode(':',getenv('path'));
    $path_ar = array_merge($path_ar, explode(':',getenv('PATH')));
    foreach ($path_ar as $path){
        $supposed_gpath = $path.'/'.$progname;
        if (file_exists($supposed_gpath) and
            is_executable($supposed_gpath)){
            return $supposed_gpath;
        }
    }
    return null;
}

Regards R.

Furthermore, by adding get_include_path() to the paths that are getting searched itis easier on shared hosted systems to add e.g. gpxelevations as"local" pip install,as on a shared hosting environment global instalation and changing of PATH is usually impossible. (perhaps like: path_ar = array_merge(path_ar, explode(':',get_include_path()));

Then someone could add in e.g. config.php something like

set_include_path(get_include_path() . ":" . '/path/to/user/.local/bin'); $CONFIG = array ( ...

Edited by Julien Veyssier