I use a Linux hosting with cPanel as admin control panel. cPanel has a file decompress option. I upload all of my project files as a TAR.GZ file and decompress them in my FTP, but the problem is that the file permissions will be set to 555 when decompressing. So I can't execute them.
I need a PHP script that can set the permissions for all files and folders to simething like 777 , starting from a base folder.
Anyone can help me?
Need a CHMOD script...
Moderator: General Moderators
- daven
- Forum Contributor
- Posts: 332
- Joined: Tue Dec 17, 2002 1:29 pm
- Location: Gaithersburg, MD
- Contact:
To chmod stuff via PHP, you need to do the following:
Manually set the base folder to 777 so that PHP can modify stuff inside of it
The below function should get you on the proper track. Warning: I have not tested it, and wrote it off the top of my head so I am not positive it works, but it should.
Manually set the base folder to 777 so that PHP can modify stuff inside of it
The below function should get you on the proper track. Warning: I have not tested it, and wrote it off the top of my head so I am not positive it works, but it should.
Code: Select all
<?php
function list_dir_contents($dir){
if ($handle = opendir($dir)){ // open the directory
while (false !== ($file = readdir($handle))){
if ($file != "." && $file != ".." && !is_link($file)){
if(is_dir($dir.$file)){
list_dir_contents($dir.$file); // if the file is a directory, do a recursive call
}
else{
chmod($dir.$file,0777); # ftp_chmod($ftp_conn,
}
}
}
closedir($handle);
}
chmod($dir,0777)
}
?>