DokuWiki

It's better when it's simple

Инструменты пользователя

Инструменты сайта


ru:tips:fixperms.php

fixperms.php

Когда «ДокуВики» создаёт файлы, они создаются от имени веб-сервера. Если разрешения установлены неверно и у вас есть только FTP-доступ к хостингу, то может возникнуть ситуация, когда вы не сможете удалить файлы, созданные «ДокуВикой». Приведенный ниже скрипт поможет вам вернуть контроль над файлами и папками, и выставить им верные права. Просто положите этот скрипт в корневую директорию своей вики и запустите, открыв бразуером.

:!: Используйте этот скрипт только если вы понимаете, что делаете.

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);
   }
}
?>
ru/tips/fixperms.php.txt · Последнее изменение: 2010-12-05 18:37 — Aleksandr

Если не указано иное, содержимое этой вики предоставляется на условиях следующей лицензии: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki