Ejemplo n.º 1
0
}
$config = cmsms()->GetConfig();
$cwd = filemanager_utils::get_cwd();
$dirlist = filemanager_utils::get_dirlist();
if (!count($dirlist)) {
    $params["fmerror"] = "nodestinationdirs";
    $this->Redirect($id, "defaultadmin", $returnid, $params);
}
$errors = array();
$destloc = '';
if (isset($params['submit'])) {
    $destdir = trim($params['destdir']);
    if ($destdir == $cwd) {
        $errors[] = $this->Lang('movedestdirsame');
    }
    $advancedmode = filemanager_utils::check_advanced_mode();
    $basedir = $config['root_path'];
    if (count($errors) == 0) {
        $destloc = filemanager_utils::join_path($basedir, $destdir);
        if (!is_dir($destloc) || !is_writable($destloc)) {
            die($destloc);
            $errors[] = $this->Lang('invalidmovedir');
        }
    }
    if (count($errors) == 0) {
        foreach ($selall as $file) {
            $src = filemanager_utils::join_path($basedir, $cwd, $file);
            $dest = filemanager_utils::join_path($basedir, $destdir, $file);
            if (!file_exists($src)) {
                $errors[] = $this->Lang('filenotfound') . " {$file}";
                continue;
Ejemplo n.º 2
0
 function GetThumbnailLink($file, $path)
 {
     $gCms = cmsms();
     $config = $gCms->GetConfig();
     $advancedmode = filemanager_utils::check_advanced_mode();
     $basedir = $config['root_path'];
     $baseurl = $config['root_url'];
     $filepath = $basedir . '/' . $path;
     $url = $baseurl . '/' . $path;
     $image = "";
     $imagepath = $this->Slashes($filepath . "/thumb_" . $file["name"]);
     if (!file_exists($imagepath)) {
         $image = $this->GetFileIcon($file["ext"], $file["dir"]);
     } else {
         $imageurl = $url . '/thumb_' . $file["name"];
         $image = "<img src=\"" . $imageurl . "\" alt=\"" . $file["name"] . "\" title=\"" . $file["name"] . "\" />";
     }
     $result = "<a href=\"" . $file["url"] . "\" target=\"_blank\">";
     $result .= $image;
     $result .= "</a>";
     return $result;
 }
Ejemplo n.º 3
0
 public static function test_invalid_path($path)
 {
     $gCms = cmsms();
     $config = $gCms->GetConfig();
     $advancedmode = filemanager_utils::check_advanced_mode();
     $prefix = $config['root_path'];
     $path = self::join_path($prefix, $path);
     $path = realpath($path);
     if ($path === FALSE) {
         return true;
     }
     if (!$advancedmode) {
         // uploading in 'non advanced mode', path has to start with the upload dir.
         if (!startswith($path, $config["uploads_path"])) {
             return true;
         }
     } else {
         // advanced mode, path has to start with the root path.
         if (!startswith($path, $config["root_path"])) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 4
0
    }
    if ($fmmodule) {
        $file["fileicon"] = $fmmodule->GetFileIcon($file["ext"], $file["isdir"]);
    }
    if (!$file["isdir"]) {
        $info = @stat($file["fullpath"]);
        if ($info) {
            $file["size"] = $info["size"];
        }
    }
    $files[] = $file;
}
$d->close();
usort($files, 'sortfiles');
$showfiles = array();
if (filemanager_utils::check_advanced_mode() && $startdir != $config['root_path'] && startswith($startdir, $config['root_path']) || $startdir != $config['uploads_path'] && startswith($startdir, $config['uploads_path'])) {
    // changedir up... causing problems
    $onerow = new stdClass();
    $onerow->isdir = "1";
    $onerow->thumbnail = "";
    $onerow->dimensions = "";
    $onerow->size = "";
    $newsubdir = '/..';
    $onerow->namelink = $this->CreateLink($id, "filepicker", $returnid, "[..]", array("subdir" => $newsubdir, "showtemplate" => "false", "type" => $type));
    $showfiles[] = $onerow;
}
$filecount = 0;
$dircount = 0;
foreach ($files as $file) {
    $onerow = new stdClass();
    $onerow->name = $file["name"];
 public static function get_dirlist()
 {
     $config = cmsms()->GetConfig();
     $mod = cms_utils::get_module('FileManager');
     $showhiddenfiles = $mod->GetPreference('showhiddenfiles');
     $startdir = $config['root_path'];
     $prefix = '/';
     $advancedmode = filemanager_utils::check_advanced_mode();
     if (!$advancedmode) {
         $startdir = $config['uploads_path'];
         $prefix = '/' . basename($config['uploads_path']) . '/';
     }
     // now get a simple list of all of the directories we have 'write' access to.
     if (!function_exists('fmutils_get_dirs')) {
         function fmutils_get_dirs($startdir, $prefix = '')
         {
             $res = array();
             if (!is_dir($startdir)) {
                 return;
             }
             global $showhiddenfiles;
             $dh = opendir($startdir);
             while (false !== ($entry = readdir($dh))) {
                 if ($entry == '.') {
                     continue;
                 }
                 $full = filemanager_utils::join_path($startdir, $entry);
                 if (!is_dir($full)) {
                     continue;
                 }
                 if (!$showhiddenfiles && ($entry[0] == '.' || $entry[0] == '_')) {
                     continue;
                 }
                 if ($entry == '.svn' || $entry == '.git') {
                     continue;
                 }
                 $res[$prefix . $entry] = $prefix . $entry;
                 $tmp = fmutils_get_dirs($full, $prefix . $entry . '/');
                 if (is_array($tmp) && count($tmp)) {
                     $res = array_merge($res, $tmp);
                 }
             }
             closedir($dh);
             return $res;
         }
     }
     $output = fmutils_get_dirs($startdir, $prefix);
     if (is_array($output) && count($output)) {
         $output['/' . basename($startdir)] = '/' . basename($startdir);
         ksort($output);
     }
     return $output;
 }