Current location: Hot Scripts Forums » Programming Languages » PHP » Safe mode and fopen


Safe mode and fopen

Reply
  #1 (permalink)  
Old 06-22-05, 12:52 PM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Safe mode and fopen

I am writing a script that creates minisites from a form.

I have this script:-
PHP Code:

$templatename "minitemplate.php" ;


$pathtotemplate '../' "$templatename;

$mkdir '../' $_POST['suburl'] ;

$newtemplatename $mkdir "/template.php" ;

mkdir($mkdir0777) ;
 
fopen($newtemplatename"x") ; 
and it generates this error:-
Code:
Warning: SAFE MODE Restriction in effect. The script whose uid is 804 is not allowed to access /home/virtual/site138/fst/var/www/minisites/myband owned by uid 48 in /home/virtual/site138/fst/var/www/minisites/join/addband.php on line 17

Warning: fopen("../myband/template.php", "x") - No such file or directory in /home/virtual/site138/fst/var/www/minisites/join/addband.php on line 17
As I am creating the directory with chmod of 777 it shouldn't be generating these errors- what could I do to to make this work? Maybe there's some workaround or function I missed? Or is there a way to create a file using ftp or something (I logged in to the ftp server higher up in the script)

Any help would be frabjulous,
xox
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-22-05, 03:03 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
its a safe mode restriction, you need to turn safe mode off! if you do not own the server than talk to your host...
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-23-05, 05:58 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Hm, so there's absolutely no way to do it in safe mode?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-23-05, 10:02 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
obviously not...
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-23-05, 10:12 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Well I used ftp_mkdir($ftpconnection, "$mkdir") ; and that thinks it's working- but the folder dosn't seem to exist in anywheres on the server.

I think it might be a php restriction rather than a restriction anywhere else on the server- is there a way of doing it with perl or some other cgi? Sorry if I'm sounding stupid- but It'd really be helpful if this script worked...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 06-26-05, 05:20 AM
Brian Brian is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,

Ok, your original problem, as you figured out, is that SafeMode is enabled (yuck, don't know why hosts find it nessecary to enable it ). Anyways, you found your way around that, I believe.

Make sure that when your using FTP to create a folder, or edit files, that you move to the correct directory first. IE, say you login in your root folder, you need to navigate to public_html and then, say, /subsites/. Here is what you would do (minus the connection code):

PHP Code:

ftp_chdir($ftpconnection"public_html");

ftp_chdir($ftpconnection"subsites");
ftp_mkdir($ftpconnection$suburl); 
Now I'm only about 90% sure that this will work under safe mode, but should it work, a new folder would be created: http://domain/subsites/<SUBURL>. My best suggestion to you, is that you request your host to disable safemode. It will make your life sooo much easier

I hope this helps, and that this code is correct. Good luck and happy coding

Cheers,

Last edited by Brian; 06-26-05 at 05:26 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 06-26-05, 06:21 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
I have asked them so *fingers crossed*

I suggested that if they're still paranoid they could just add the folder to the omitted folders (or whatever it's called) in the php.ini file- here's hoping the person who answers it knows what they're talking about
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 08:26 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.