BlackKite Posted July 14, 2006 Share Posted July 14, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/ Share on other sites More sharing options...
zq29 Posted July 14, 2006 Share Posted July 14, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-57793 Share on other sites More sharing options...
GingerRobot Posted July 14, 2006 Share Posted July 14, 2006 I may be wrong, but could you not add the new files in something another than public_html? Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-57798 Share on other sites More sharing options...
ShogunWarrior Posted July 14, 2006 Share Posted July 14, 2006 But public_html is the public facing folder isn't it? Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-57830 Share on other sites More sharing options...
GingerRobot Posted July 14, 2006 Share Posted July 14, 2006 public_html is the folder you can access from the internet. But im pretty sure you can write things to folders higher up than puclic_html with a php script because you can use relative links. Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-57834 Share on other sites More sharing options...
BlackKite Posted July 14, 2006 Author Share Posted July 14, 2006 Is there a way to set it tp 777 and then drop it back to 755 using php?And yes I could have it so it creates files in a higher folder, but what if someone wants to put something in their main public_html folder. Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-58053 Share on other sites More sharing options...
zq29 Posted July 14, 2006 Share Posted July 14, 2006 chmod() Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-58057 Share on other sites More sharing options...
BlackKite Posted July 14, 2006 Author Share Posted July 14, 2006 Aah, would make sense. Ok, I'll give it a try. Thanks ;) Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-58078 Share on other sites More sharing options...
BlackKite Posted July 15, 2006 Author Share Posted July 15, 2006 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 777if (ftp_chmod($conn_id, 0777, $file) !== false) { echo "$file chmoded successfully to 777\n";} else { echo "could not chmod $file\n";}// close the connectionftp_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 22Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 25Fatal error: Call to undefined function: ftp_chmod() in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 28[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-58384 Share on other sites More sharing options...
BlackKite Posted July 15, 2006 Author Share Posted July 15, 2006 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-58594 Share on other sites More sharing options...
ShogunWarrior Posted July 15, 2006 Share Posted July 15, 2006 The errors means that DNS lookup is failing.Can you not connect to your site via FTP and change the permissions? Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-58602 Share on other sites More sharing options...
BlackKite Posted July 15, 2006 Author Share Posted July 15, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/14563-simple-create-a-file-problem/#findComment-58618 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.