CHMODding script.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anguz
    Member
    • Mar 2004
    • 47

    CHMODding script.

    I've found myself having to fix many files and dirs to the correct 644/755 permissions here, and it can get boring and time consuming after just a moment. So I ended up writting a script that'll do just that from the dir it's placed in, down to every subdir. It's written in PHP and am posting it here for anyone that may find it useful.


    PHP Code:
    <?php

    chmod__recursive
    (dirname($_SERVER['SCRIPT_FILENAME']) . '/');

    function 
    chmod__recursive($dir)
    {
        
    $dirh opendir($dir);

        while((
    $file readdir($dirh)) !== false)
        {
            if (
    $file == '.' || $file == '..')
                continue;
            if (
    is_dir($dir $file))
            {
                
    chmod($dir $file0755);
                
    chmod__recursive($dir $file '/');
                continue;
            }
            if (
    is_file($dir $file))
                
    chmod($dir $file0644);
        }

        
    closedir($dirh);
    }

    ?>
  • Jonathan
    Senior Member
    • Mar 2004
    • 1229

    #2
    I went ahead and moved this to the PHP, MySQL, & Perl forum
    since it covers PHP; pretty good script btw
    "How can someone be so distracted yet so focused?"
    - C

    Comment

    Working...