Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   Ownership/Permission issues (http://www.greenguysboard.com/board/showthread.php?t=33100)

Useless 2006-07-20 04:45 PM

Ownership/Permission issues
 
Is there a PHP function that allows one to create directories with a script that doesn't make them owned by the server? Or, is there a function that can successfuly delete directories that have been created by a PHP script instead of giving me the "Fuck You - You Suck/Don't Have Permission" error like rmdir?

HC-Majick 2006-07-20 05:27 PM

edit: just noticed the rmdir part... |banghead|

Code:

// Sets All Permissions
chmod("mydirectory", 0777);
?>

before your rmdir fuction??

Beaver Bob 2006-07-25 03:24 AM

useless, I've always found it easier to have PHP use FTP. I've never had much luck any other way. If FTP extensions aren't installed with the version of PHP on your server, have your system admin do that first.

This function can be used to make a directory, the values you need to replace in this are $server, $user, and $pass. The first argument needs to be the absolute path of where you want to create your directory, the second is the name of the new directory.

PHP Code:

// create directory through FTP connection
function FtpMkdir($path$newDir) {
  
       
$server='255.255.255.255'// ftp server
       
$connection ftp_connect($server); // connection
 
       // login to ftp server
       
$user "USERNAME";
       
$pass "PASSWORD";
       
$result ftp_login($connection$user$pass);

   
// check if connection was made
     
if ((!$connection) || (!$result)) {
       return 
false;
       exit();
       } else {
         
ftp_chdir($connection$path); // go to destination dir
       
if(ftp_mkdir($connection,$newDir)) { // create directory
           
return $newDir;
       } else {
           return 
false;       
       }
   
ftp_close($connection); // close connection
   
}




Useless 2006-07-25 11:02 AM

Thank you Beaver Bob. I'll give that try. Now all I have to do is remember what I was trying to do when I asked the question. ;)

Beaver Bob 2006-07-25 09:31 PM

hope it helps you out :) The reason for using FTP is so the directories you create will belong to you and you should have no problems removing them or modifying stuff.


All times are GMT -4. The time now is 06:47 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc