#native_company# #native_desc#
#native_cta#

CHMOD

By Andrew Teg
on July 26, 2004

Version: 1.0a

Type: Full Script

Category: File Management

License: GNU General Public License

Description: This little 30 line script allows you to browse your entire site and CHMOD any file on the site to 0777 or whatever CHMOD you put into the script. This is helpful if you have images or files you cannot delete via FTP because of a script error in your code or for example, a CMS. See file for more notes.

echo "<body><html>";
// This script is for performing a CHMOD on web-owned folders
//		and files since you can't CHMOD those direct in FTP.
// Simply put, Go navigates to a new folder, view views a file,
//		and clicking on a folder or file CHMODs it.
// I named it chmod.php and that works well for me at least.
// Should be nothing to setup as it detects the default path.
// If you get "Operation not permitted" as a warning then it 
//		means you should be able to change it directly in FTP.
if ($mydir == "")	$mydir = realpath(".");		//No Trailing Slash
echo "<H2>CHMODDER in ".$mydir."</H2>";
if ($action=="") {
	echo "<table border=1><th>CHMOD<th>Action";
	if ($handle = opendir($mydir)) { 
		while (false !== ($myfile = readdir($handle))) {  
			if ($myfile != "." && $myfile != "..") { 
				echo "<tr><td><a href=$PHP_SELF?mydir=$mydir&myfile=$myfile&action=chmod>".$myfile . "</a>"; 
				if(is_dir($mydir."/".$myfile) )
					echo "<td><a href=$PHP_SELF?mydir=$mydir/$myfile&append=$append$myfile/>Go</a>";
				elseif(is_file($mydir."/".$myfile) )
					echo "<td><a href=".$append.$myfile." target=_blank>View</a></td>";
				echo "</tr>";
	}	}	} 
	closedir($handle);  
} elseif ($action == "chmod") {
	chmod("$mydir/$myfile", 0777);  // decimal; probably incorrect  
	echo "chmodded <B>".$myfile."</B>";
} 
echo "</table></body></html>";