Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

File: /home/thiosh/public_html/changeleperms

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

Page 1 of 1

#! /usr/bin/php <?php /*Set permissions of directories (SPECIFICALLY THOSE IN htdocs) to 755, their sub-folders to 755 and files to 644 in current directory. HOW TO SET FOLDER AND FILER PERMISSIONS 1. Place this file inside the parent of the folder whose perms will be altered, e.g. if a folder /htdocs/pear is to be altered, put this file under /htdocs (NB: the current folder is denoted by the "." arg to fn SetPerms - DO NOT CHANGE THIS ".") 2. Enter the name of the folder to be altered as the arg for the SetPerm fn AT THE BOTTOM OF THIS SCRIPT e.g. Setperm("pear") */ function SetPerms ( $dir = "." )//current directory is the arg passed to this fn. { $listDir = array(); if( $handler = opendir ( $dir )) { while (( $sub = readdir ( $handler )) !== FALSE ) { if ( $sub != "." && $sub != ".." ) { // found file if( is_file ( $dir . "/" . $sub )) { echo "File: $dir/$sub\n" ; chmod ( $dir . "/" . $sub , 0644 ); // found directory } else if( is_dir ( $dir . "/" . $sub )) { echo "Dir: $dir/$sub :\n" ; chmod ( $dir . "/" . $sub , 0755 ); SetPerms ( $dir . "/" . $sub ); } } } closedir ( $handler ); } return $listDir ; } SetPerms ( "virtuemart1" ); ?>

You might also like