Return to Snippet

Revision: 52929
at November 6, 2011 08:12 by madc


Updated Code
function rChmod($path, $filePerm=0664, $dirPerm=0775)
	{ 
		if(!file_exists($path))
			return(false);

		if(is_file($path))
			chmod($path, $filePerm);
		elseif(is_dir($path))
		{
			chmod($path, $dirPerm);
			
			$foldersAndFiles = scandir($path);
			$entries = array_slice($foldersAndFiles, 2);
			foreach($entries as $entry)
				rChmod($path.DIRECTORY_SEPARATOR.$entry, $filePerm, $dirPerm);
		}

		return(true);
	}

Revision: 52928
at November 6, 2011 08:06 by madc


Initial Code
function rChmod($path, $filePerm=0664, $dirPerm=0775)
	{ 
		if(!file_exists($path))
			return(false);

		if(is_file($path))
			chmod($path, $filePerm);
		elseif(is_dir($path))
		{
			chmod($path, $dirPerm);
			
			$foldersAndFiles = scandir($path);
			$entries = array_slice($foldersAndFiles, 2);
			foreach($entries as $entry)
				rChmod($path."/".$entry, $filePerm, $dirPerm);
		}

		return(true);
	}

Initial URL
http://madcity.at/

Initial Description
Heavily based on "Recursive chmod in PHP" by Tenzer ( 03/10/08 http://snipplr.com/view/5350/ )

Initial Title
Recursive chmod in PHP

Initial Tags
php

Initial Language
PHP