DokuWiki

It's better when it's simple

User Tools

Site Tools


Sidebar

Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community


Follow us on Facebook, Twitter and other social networks.

tips:fixperms.php

fixperms.php

When DokuWiki creates a file it is owned by the webserver. When the permissions are set very restrictive and you only have FTP access it may mean you will be unable to delete DokuWiki created files. The following script will help you to regain control by chmod'ing all files and directories to be writable by everyone. Simply drop it into your DokuWiki directory via FTP and run it by opening it in your Browser.

:!: Only use this script if you know what you're doing.

fixperms.php
<?php
/**
 * When you call this file it will make all files and directories
 * in it's own directory and all directories below writable by
 * everyone
 *
 * You can use this to (re)gain control on files owned by the
 * apache process.
 *
 * Only use it if you really know that this is what you want.
 * Delete the file immediately after using it!
 */
 
header("Content-Type: text/plain");
 
echo "starting...\n";
flush();
traverse(dirname(__FILE__));
echo "finished...\n";
 
function traverse($dir){
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            //skip hidden files and upper dirs
            if(preg_match('/^[\._]/',$file)) continue;
            if(is_dir($dir.'/'.$file)){
                if(@chmod($dir.'/'.$file,0777)){
                    echo "chmod 0777 $dir/$file OK\n";
                }else{
                    echo "chmod 0777 $dir/$file FAILED\n";
                }
                flush();
                traverse($dir.'/'.$file);
                continue;
            }
            if(@chmod($dir.'/'.$file,0666)){
                echo "chmod 0666 $dir/$file OK\n";
            }else{
                echo "chmod 0666 $dir/$file FAILED\n";
            }
            flush();
       }
       closedir($dh);
   }
}
?>
tips/fixperms.php.txt · Last modified: 2009-07-29 23:28 by andi