Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/92614-safe-mode-affecting-require/
Share on other sites

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?

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.

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.

cool now i know how to escape this problem if i ever have a host who uses it ;D

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.

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 ****

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.