Пример #1
0
function dirmv($source, $destination)
{
    if (is_dir($source)) {
        @mkdir($destination);
        $directory = dir($source);
        while (FALSE !== ($readdirectory = $directory->read())) {
            if ($readdirectory == '.' || $readdirectory == '..') {
                continue;
            }
            $PathDir = $source . '/' . $readdirectory;
            if (is_dir($PathDir)) {
                dirmv($PathDir, $destination . '/' . $readdirectory);
                continue;
            }
            rename($PathDir, $destination . '/' . $readdirectory);
        }
        $directory->close();
    } else {
        rename($source, $destination);
    }
}
Пример #2
0
function dirmv($source, $dest, $overwrite = false, $funcloc = NULL)
{
    if (is_null($funcloc)) {
        $dest .= '/' . strrev(substr(strrev($source), 0, strpos(strrev($source), '/')));
        $funcloc = '/';
    }
    if (!is_dir($dest . $funcloc)) {
        mkdir($dest . $funcloc);
    }
    // make subdirectory before subdirectory is copied
    if ($handle = opendir($source . $funcloc)) {
        // if the folder exploration is sucsessful, continue
        while (false !== ($file = readdir($handle))) {
            // as long as storing the next file to $file is successful, continue
            if ($file != '.' && $file != '..') {
                $path = $source . $funcloc . $file;
                $path2 = $dest . $funcloc . $file;
                if (is_file($path)) {
                    if (!is_file($path2)) {
                        if (!@rename($path, $path2)) {
                            // echo '<font color="red">File ('.$path.') could not be moved, likely a permissions problem.</font>';
                        }
                    } elseif ($overwrite) {
                        if (!@unlink($path2)) {
                            // echo 'Unable to overwrite file ("'.$path2.'"), likely to be a permissions problem.';
                        } else {
                            if (!@rename($path, $path2)) {
                                // echo '<font color="red">File ('.$path.') could not be moved while overwritting, likely a permissions problem.</font>';
                            }
                        }
                    }
                } elseif (is_dir($path)) {
                    dirmv($source, $dest, $overwrite, $funcloc . $file . '/');
                    //recurse!
                    rmdir($path);
                }
            }
        }
        closedir($handle);
    }
}
Пример #3
0
 $plugins->run_hook("admin_actions_edit_top");
 if ($file->size > 0) {
     $links[] = mai_img("arr.gif") . " <a href='{$set->url}/data/file/{$file->id}/" . mai_converturl($file->name) . ".html'>{$file->name} </a>";
 } else {
     $links[] = mai_img("arr.gif") . " <a href='{$set->url}/data/{$file->id}/" . mai_converturl($file->name) . ".html'>{$file->name} </a>";
 }
 if ($_POST['name']) {
     $path = "/files" . $_POST['path'];
     $dirid = $db->get_row("SELECT id FROM `" . MAI_PREFIX . "files` WHERE `path`='" . $path . "'")->id;
     $real_path = $path . "/" . basename($file->path);
     if ($db->query("UPDATE `" . MAI_PREFIX . "files` SET `name`='" . $db->escape($_POST['name']) . "', `icon`='" . $db->escape($_POST['icon']) . "', `indir`='" . $dirid . "', `path`= '" . $db->escape($real_path) . "', `description`='" . $db->escape($_POST['description']) . "' WHERE `id`='{$file->id}'")) {
         if ($file->path != $real_path) {
             if (is_file(".." . $file->path)) {
                 rename(".." . $file->path, ".." . $real_path);
             } else {
                 dirmv(".." . $file->path, ".." . $real_path);
                 $db->query("UPDATE `" . MAI_PREFIX . "files` SET `path`=replace(`path`,'" . $db->escape($file->path) . "','" . $db->escape($real_path) . "') WHERE `path` LIKE '" . $db->escape($file->path) . "%'");
             }
         }
         $form .= "<div class='green'>{$lang->saved}</div>";
         $file->icon = $_POST['icon'];
         // to keep it updated
         $file->name = $_POST['name'];
         // to keep it updated
         $file->path = $real_path;
         // to keep it updated
         $file->description = $_POST['description'];
         // to keep it updated
         $plugins->run_hook("admin_actions_edit");
     }
 }