Jump to content

Recommended Posts

Hm... wow do I feel like a noob now. Aah well, here it goes.

Im designing a open source control panel in php that allows you to create files and them have them listed on your site automatically without the hassle of going through cpanel (or whatever panel). It gives admin permission to add users so that they can have others add files also. But I'm having a problem that keeps appearing. Depending on if phpsuexec is installed or not directories have to be set to 777 or 755. I pretty sure its really unsafe to set files and folders to 777 , especially your public_html folder. Yet, in order to create a file in public_html I need to set it to 777 or i get a permissions error. Is there any way around this?
Link to comment
https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/
Share on other sites

Can you not CHMOD the directory to 0777, create the file, then drop it back down to 0755? Pain in the arse I know, but I've found that's the only way around issues like this. I've had to do this when peoples servers have been configured in an odd way where PHP runs under a user with odd access-rights...

The amount of time that your files will be set to 0777 would be pretty minimal, a second or so at the absolute most I think.
Ick... thats not working. Seems like I dont have the permission to set permissions via chmod()? I understand though, that theres a way to do it via an ftp connection? I've tried this but I can't quite get it to work. Im putting the following code in...[code]<?php
$file = 'public_html/';

$ftp_user_name = "XXXXXXX";
$ftp_user_pass = "XXXXXXXX";

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// try to chmod $file to 777
if (ftp_chmod($conn_id, 0777, $file) !== false) {
echo "$file chmoded successfully to 777\n";
} else {
echo "could not chmod $file\n";
}

// close the connection
ftp_close($conn_id);
?> [/code]

But apparently this is wrong because I get the following error...[code]Warning: ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 22

Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 25

Fatal error: Call to undefined function: ftp_chmod() in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 28[/code]
Well I can... but that defeats the purpose. I want the script to change it to 777 and then change it back to 750 once complete becuase having yuor public_html at 777 always isn't safe.

Why is it failing, is there an error in the script... something im missing or didnt set right?
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.