Jessica Posted February 23, 2008 Share Posted February 23, 2008 I've never had this problem before since I've never had to use a host with safe_mode. I can't find anything on the net about safe_mode affecting the require or include functions: index.php <?php require_once('cal_base.php'); ?> cal_base.php <?php ini_set('display_errors', 1); error_reporting(E_ALL); $library = array('O', 'Admin', 'DB', 'Lib', 'Calendar', 'Event', 'HTML_Safe', 'SmartForm/SmartForm'); foreach($library AS $lib){ require_once('/lib/'.$lib.'.class.php'); } ?> I have tried all sorts of things for lib, every path I can think of, I have tried setting the include path: http://www.php.net/manual/en/function.set-include-path.php I have also tried require, include and include_once I don't have access to php.ini at the system level. Errors: Warning: main(): SAFE MODE Restriction in effect. The script whose uid is 523 is not allowed to access ./lib/O.class.php owned by uid 2296 in /home/www/amapolaranch/redesign/cal_base.php on line 23 Warning: main(lib/O.class.php): failed to open stream: Success in /home/www/amapolaranch/redesign/cal_base.php on line 23 Fatal error: main(): Failed opening required 'lib/O.class.php' (include_path='.:../:./') in /home/www/amapolaranch/redesign/cal_base.php on line 23 Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/ Share on other sites More sharing options...
darkfreaks Posted February 23, 2008 Share Posted February 23, 2008 according to what i read include,require, require_once,include_once will produce that error in safe mode. best thing to do is find a new host i hate to be blunt but you would need access to php.ini to turn it off. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-474699 Share on other sites More sharing options...
Bauer418 Posted February 23, 2008 Share Posted February 23, 2008 Quote from PHP.net When safe_mode is on, PHP checks to see if the owner of the current script matches the owner of the file to be operated on by a file function or its directory. Unfortunate. Is there a file manager available in your control panel where you can chown the file? Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-474700 Share on other sites More sharing options...
darkfreaks Posted February 23, 2008 Share Posted February 23, 2008 all those functions are limited in safe mode including Require,Include,include_once,require_once,include_path,set_include_path Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-474706 Share on other sites More sharing options...
jazz Posted February 23, 2008 Share Posted February 23, 2008 All the functions that use the wrappers to access files are effectively restricted under safe mode. So, it would be normal for require to be restricted by it. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-474773 Share on other sites More sharing options...
PFMaBiSmAd Posted February 23, 2008 Share Posted February 23, 2008 If the file was FTP'ed or uploaded through the control panel to the server, it is likely "owned" by the user account of the FTP server/control panel. Doing what Bauer418 suggested of changing the owner to be that of the web server/hosting account will allow php to access the file with safe mode on. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-474777 Share on other sites More sharing options...
Jessica Posted February 23, 2008 Author Share Posted February 23, 2008 Thanks, I wish it explained more clearly the affected functions in the php docs. Or maybe I'm actually turning blonde. Couldn't I chown the file using php? Or is that going to be affected as well? I will check out the site again when I get back to my computer. Unfortunately changing hosts is not an option, as I was contracted by a designer for their client, I don't think he'd want to change the host. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-474786 Share on other sites More sharing options...
Jessica Posted February 23, 2008 Author Share Posted February 23, 2008 Also, why does it not have a problem require()ing the first file? Only the ones in lib? Maybe I should move them from the lib folder to the www folder. I'll try that. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-474793 Share on other sites More sharing options...
Bauer418 Posted February 24, 2008 Share Posted February 24, 2008 Because you are not the owner of the lib files. Did you create them/upload them? Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-474832 Share on other sites More sharing options...
Jessica Posted February 25, 2008 Author Share Posted February 25, 2008 Yes. It worked when I moved them to the root dir. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-476318 Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 cool now i know how to escape this problem if i ever have a host who uses it Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-476325 Share on other sites More sharing options...
Bauer418 Posted February 25, 2008 Share Posted February 25, 2008 cool now i know how to escape this problem if i ever have a host who uses it PHP6 eliminates safe mode, so when it becomes mainstream you'll never have a problem with it. jesi: check the permissions on the lib directory itself, not on the files inside it. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-476349 Share on other sites More sharing options...
Jessica Posted February 25, 2008 Author Share Posted February 25, 2008 The permissions or the owner? I can only check the permissions via FTP, I don't have any other access. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-476374 Share on other sites More sharing options...
Bauer418 Posted February 25, 2008 Share Posted February 25, 2008 I meant owner . Sorry. Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-476377 Share on other sites More sharing options...
Jessica Posted February 25, 2008 Author Share Posted February 25, 2008 I created and uploaded the folder and files via FTP, but then I reuploaded them into the root folder. It's working now. The host claims they turned it off, but it still gives the error if I try to require a file in a lower folder. They also promised they upgraded to 5 and the phpinfo() is 4.4 so they're **** Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-476390 Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 If they are running php4 and php5 dual you might be able to configure it in a .htaccess file if your host permits you to execute .htaccess files (Apache of course) .htacces line: AddHandler application/x-httpd-php5 .php Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-476408 Share on other sites More sharing options...
Jessica Posted February 26, 2008 Author Share Posted February 26, 2008 I tried that and then whenever you tried to go to the site it asked you to download the file. I have used a host who runs both before :/ Quote Link to comment https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/#findComment-476487 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.