Ejemplo n.º 1
0
 function delete_folder($directory)
 {
     foreach ((array) $this->get_subfolder($directory) as $folder) {
         $this->delete_folder($folder);
     }
     foreach ((array) $this->get_files($directory) as $file) {
         Unlink($file);
     }
     RmDir($directory);
 }
Ejemplo n.º 2
0
function RmDirR($xdir)
{
    $d = dir($xdir);
    while ($entry = $d->read()) {
        if ($entry != "." && $entry != "..") {
            if (Is_Dir($xdir . "/" . $entry)) {
                RmDirR($xdir . "/" . $entry);
            } else {
                echo "Deleting {$xdir}/{$entry}<br>\n";
                UnLink($xdir . "/" . $entry);
            }
        }
    }
    $d->close();
    RmDir($xdir);
}
Ejemplo n.º 3
0
                 return SPrintF("ERROR: не возможно удалить файл (%s)\n", $File);
             }
         }
         #-------------------------------------------------------------------------------
         $Dir = DirName($File);
         #-------------------------------------------------------------------------------
         $Files = IO_Scan($Dir);
         if (Is_Error($Files)) {
             return SPrintF("---\n%s\n---\n", Implode("\n", Array_Slice($__SYSLOG, Count($__SYSLOG) - 20)));
         }
         #-------------------------------------------------------------------------------
         if (!Count($Files)) {
             #-------------------------------------------------------------------------------
             echo SPrintF("Удаление директории (%s)\n", $Dir);
             #-------------------------------------------------------------------------------
             if (!@RmDir($Dir)) {
                 return SPrintF("ERROR: не возможно удалить директорию (%s)\n", $Dir);
             }
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
 if (isset($Answer['Added'])) {
     #-------------------------------------------------------------------------------
     foreach ($Answer['Added'] as $Added) {
         #-------------------------------------------------------------------------------
         $File = $Added['File'];
         #-------------------------------------------------------------------------------
Ejemplo n.º 4
0
function DeleteUploadedFile($Table, $ID)
{
    #-------------------------------------------------------------------------------
    $Path = GetFilePath($Table, $ID);
    #-------------------------------------------------------------------------------
    if (File_Exists($Path['FilePath'])) {
        #-------------------------------------------------------------------------------
        Debug(SPrintF('[system/libs/Upload]: delete file: %s', $Path['FilePath']));
        #-------------------------------------------------------------------------------
        if (!UnLink($Path['FilePath'])) {
            return new gException('CANNOT_DELETE_FILE', SPrintF('Не удалось удалить файл: %s', $File['FilePath']));
        }
        #-------------------------------------------------------------------------------
        @RmDir($Path['FileDir']);
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    return TRUE;
    #-------------------------------------------------------------------------------
}
Ejemplo n.º 5
0
function zRmDir($path)
{
    $directory = dir($path);
    while ($entry = $directory->read()) {
        if ($entry != "." && $entry != "..") {
            if (Is_Dir($path . "/" . $entry)) {
                zRmDir($path . "/" . $entry);
            } else {
                @UnLink($path . "/" . $entry);
            }
        }
    }
    $directory->close();
    @RmDir($path);
}
Ejemplo n.º 6
0
function lock_dir($name = "")
{
    //ディレクトリロック
    if ($name == "") {
        $name = "lock";
    }
    // 3分以上前のディレクトリなら解除失敗とみなして削除
    if (file_exists($name) && filemtime($name) < time() - 180) {
        @RmDir($name);
    }
    do {
        if (@MkDir($name, 0777)) {
            return 1;
        }
        sleep(1);
        // 一秒待って再トライ
        $i++;
    } while ($i < 5);
    return 0;
}
Ejemplo n.º 7
0
function IO_RmDir($Folder)
{
    #-------------------------------------------------------------------------------
    $Folder = Preg_Replace('/\\/{2,}/', '/', rTrim($Folder, '/'));
    #-------------------------------------------------------------------------------
    if (StrPos(SPrintF('/%s/', $Folder), SYSTEM_PATH) === FALSE) {
        return ERROR | @Trigger_Error(SPrintF('[IO_RmDir]: ошибка безопасности при удалении (%s)', $Folder));
    }
    #-------------------------------------------------------------------------------
    $Entities = IO_Scan($Folder, FALSE);
    if (Is_Error($Entities)) {
        return ERROR | @Trigger_Error('[IO_RmDir]: не удалось получить содержимое папки');
    }
    #-------------------------------------------------------------------------------
    if (Count($Entities)) {
        #-------------------------------------------------------------------------------
        foreach ($Entities as $Entity) {
            #-------------------------------------------------------------------------------
            $Entity = SPrintF('%s/%s', $Folder, $Entity);
            #-------------------------------------------------------------------------------
            if (Is_Dir($Entity)) {
                #-------------------------------------------------------------------------------
                if (Is_Error(IO_RmDir($Entity))) {
                    return ERROR | @Trigger_Error(SPrintF('[IO_RmDir]: ошибка рекурсивного вызова при удалении (%s)', $Entity));
                }
                #-------------------------------------------------------------------------------
            } else {
                #-------------------------------------------------------------------------------
                if (!UnLink($Entity)) {
                    return ERROR | @Trigger_Error(SPrintF('[IO_RmDir]: ошибка при удалении файла (%s)', $Entity));
                }
                #-------------------------------------------------------------------------------
            }
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    if (!@RmDir($Folder)) {
        return ERROR | @Trigger_Error(SPrintF('[IO_RmDir]: ошибка при удалении директории (%s)', $Folder));
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return TRUE;
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}
Ejemplo n.º 8
0
     }
 }
 #-------------------------------------------------------------------------------
 if (!Count($__ERRORS)) {
     #-------------------------------------------------------------------------------
     $Files = array('INSTALL', 'install.settings', 'install.my.cnf', 'install/index.php', 'install');
     #-------------------------------------------------------------------------------
     foreach ($Files as $File) {
         #-------------------------------------------------------------------------------
         $File = SPrintF('%s/%s', SYSTEM_PATH, $File);
         #-------------------------------------------------------------------------------
         if (File_Exists($File)) {
             #-------------------------------------------------------------------------------
             if (Is_Dir($File)) {
                 #-------------------------------------------------------------------------------
                 if (!@RmDir($File)) {
                     Error(SPrintF('Не возможно удалить директорию (%s)', $File));
                 }
                 #-------------------------------------------------------------------------------
             } else {
                 #-------------------------------------------------------------------------------
                 if (!@UnLink($File)) {
                     Error(SPrintF('Не возможно удалить файл (%s)', $File));
                 }
                 #-------------------------------------------------------------------------------
             }
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
Ejemplo n.º 9
0
function RmDirm($dirName)
{
    $dirName = urldecode($dirName);
    if (is_dir($dirName)) {
        if (substr($dirName, -1) != "/") {
            $dirName .= "/";
        }
        $d = opendir($dirName);
        while ($entry = readdir($d)) {
            if ($entry != "." && $entry != "..") {
                if (is_dir($dirName . $entry)) {
                    RmDirm($dirName . $entry);
                } else {
                    @unlink($dirName . $entry);
                }
            }
        }
        closedir($d);
        RmDir($dirName);
    }
}