You can only turn off open_basedir from the php.ini file.
The issue as I see in this thread there is the path was not correct or being found. open_basedir has nothing to do with the issue only that the entered path is not the same as the reported path. That is why you note I asked more than once what was the true correct path.
Your path is not being reported from the server level. The $path variable is passed to the script by DIR but that returns nothing which is your issue so you can do as the gentlemen did set a $path statement at the top of the function get_gal_dir