コード例 #1
0
function 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 = get_dirs($full, $prefix . $entry . '/');
        if (is_array($tmp) && count($tmp)) {
            $res = array_merge($res, $tmp);
        }
    }
    closedir($dh);
    return $res;
}
コード例 #2
0
ファイル: action.upload.php プロジェクト: RTR-ITF/usse-cms
 protected function after_uploaded_file($fileobject)
 {
     // here we may do image handling, and other cruft.
     if (is_object($fileobject) && $fileobject->name != '') {
         $mod = cms_utils::get_module('FileManager');
         $parms = array();
         $parms['file'] = filemanager_utils::join_path(filemanager_utils::get_full_cwd(), $fileobject->name);
         if ($mod->GetPreference('create_thumbnails')) {
             $thumb = cms_utils::generate_thumbnail($parms['file']);
             if ($thumb) {
                 $params['thumb'] = $thumb;
             }
         }
         $str = $fileobject->name . ' uploaded to ' . filemanager_utils::get_full_cwd();
         if (isset($params['thumb'])) {
             $str .= ' and a thumbnail was generated';
         }
         audit('', $mod->GetName(), $str);
         $mod->SendEvent('OnFileUploaded', $parms);
     }
 }
コード例 #3
0
ファイル: action.move.php プロジェクト: RTR-ITF/usse-cms
 }
 if (!is_readable($src)) {
     $errors[] = $this->Lang('insufficientpermission', $file);
     continue;
 }
 if (file_exists($dest)) {
     $errors[] = $this->Lang('fileexistsdest', $file);
     continue;
 }
 $thumb = '';
 $src_thumb = '';
 $dest_thumb = '';
 if (filemanager_utils::is_image_file($file)) {
     $tmp = 'thumb_' . $file;
     $src_thumb = filemanager_utils::join_path($basedir, $cwd, $tmp);
     $dest_thumb = filemanager_utils::join_path($basedir, $destdir, $tmp);
     if (file_exists($src_thumb)) {
         // have a thumbnail
         $thumb = $tmp;
         if (!is_readable($src_thumb)) {
             $errors[] = $this->Lang('insufficientpermission', $thumb);
             continue;
         }
         if (file_exists($dest_thumb)) {
             $errors[] = $this->Lang('fileexistsdest', $thumb);
             continue;
         }
     }
 }
 // here we can move the file/dir
 $res = rename($src, $dest);
コード例 #4
0
ファイル: action.unpack.php プロジェクト: RTR-ITF/usse-cms
    $selall = unserialize($selall);
}
if (count($selall) == 0) {
    $params["fmerror"] = "nofilesselected";
    $this->Redirect($id, "defaultadmin", $returnid, $params);
}
if (count($selall) > 1) {
    $params["fmerror"] = "morethanonefiledirselected";
    $this->Redirect($id, "defaultadmin", $returnid, $params);
}
$config = cmsms()->GetConfig();
$filename = $this->decodefilename($selall[0]);
$src = filemanager_utils::join_path($config['root_path'], filemanager_utils::get_cwd(), $filename);
if (!file_exists($src)) {
    $params["fmerror"] = "filenotfound";
    $this->Redirect($id, "defaultadmin", $returnid, $params);
}
include_once dirname(__FILE__) . '/easyarchives/EasyArchive.class.php';
$archive = new EasyArchive();
$destdir = filemanager_utils::join_path($config['root_path'], filemanager_utils::get_cwd());
if (!endswith($destdir, '/')) {
    $destdir .= '/';
}
$res = $archive->extract($src, $destdir);
$paramsnofiles["fmmessage"] = "unpacksuccess";
//strips the file data
$this->Audit('', "File Manager", "Unpacked file: " . $src);
$this->Redirect($id, "defaultadmin", $returnid, $paramsnofiles);
#
# EOF
#
コード例 #5
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;
 }
コード例 #6
0
ファイル: action.changedir.php プロジェクト: RTR-ITF/usse-cms
if (!$this->CheckPermission("Modify Files") && !$this->AdvancedAccessAllowed()) {
    exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['showtemplate']) && $_GET['showtemplate'] == 'false') {
    echo filemanager_utils::get_cwd();
    exit;
}
if (!isset($params["newdir"]) || !isset($params["path"])) {
    $this->Redirect($id, 'defaultadmin');
}
$newdir = $params["newdir"];
$path = filemanager_utils::join_path(filemanager_utils::get_cwd(), $newdir);
try {
    if (isset($params['ajax'])) {
        filemanager_utils::set_cwd(trim($newdir));
    } else {
        filemanager_utils::set_cwd($path);
        $this->Redirect($id, 'defaultadmin');
    }
} catch (Exception $e) {
    audit('', 'FileManager', 'Attempt to set working directory to an invalid location: ' . $newdir);
    if (isset($params['ajax'])) {
        exit('ERROR');
    }
}
//echo $params["path"];
if (isset($params['ajax'])) {
    echo 'OK';
}
exit;
$this->Redirect($id, 'defaultadmin', $returnid, array("path" => $path));
コード例 #7
0
ファイル: action.chmodfile.php プロジェクト: RTR-ITF/usse-cms
<?php

if (!function_exists("cmsms")) {
    exit;
}
if (!$this->AccessAllowed() && !$this->AdvancedAccessAllowed()) {
    exit;
}
if (!isset($params["filename"]) || !isset($params["path"])) {
    $this->Redirect($id, 'defaultadmin');
}
if (filemanager_utils::test_invalid_path($params['path'])) {
    $this->Redirect($id, 'defaultadmin', $returnid, array("fmerror" => "fileoutsideuploads"));
}
$config =& $gCms->GetConfig();
$fullname = $this->Slash($params["path"], $params["filename"]);
$fullname = $this->Slash($config["root_path"], $fullname);
if (isset($params["newmode"])) {
    //echo deleting;die();
    if (isset($params["cancel"])) {
        $this->Redirect($id, "defaultadmin", $returnid, array("path" => $params["path"], "fmmessage" => "chmodcancelled"));
    } else {
        $newmode = $this->GetModeFromTable($params);
        if (isset($params["quickmode"]) && $params["quickmode"] != "") {
            $newmode = $params["quickmode"];
        }
        //echo $newmode;die();
        if ($this->SetMode($newmode, $fullname)) {
            $this->Redirect($id, "defaultadmin", $returnid, array("path" => $params["path"], "fmmessage" => "chmodsuccess"));
        } else {
            $this->Redirect($id, "defaultadmin", $returnid, array("path" => $params["path"], "fmerror" => "chmodfailure"));
コード例 #8
0
    $this->SetPreference("showhiddenfiles", 1);
} else {
    $this->SetPreference("showhiddenfiles", 0);
}
if (isset($params["showthumbnails"])) {
    $this->SetPreference("showthumbnails", 1);
} else {
    $this->SetPreference("showthumbnails", 0);
}
if (isset($params["iconsize"])) {
    $this->SetPreference("iconsize", $params["iconsize"]);
}
if (isset($params["permissionflavor"])) {
    $this->SetPreference("permissionflavor", $params["permissionflavor"]);
}
if (isset($params["uploadboxes"])) {
    $this->SetPreference("uploadboxes", $params["uploadboxes"]);
}
if (isset($params["permissionstyle"])) {
    $this->SetPreference("permissionstyle", $params["permissionstyle"]);
}
if (isset($params["thousanddelimiter"])) {
    $this->SetPreference("thousanddelimiter", $params["thousanddelimiter"]);
}
if (isset($params["create_thumbnails"])) {
    $this->SetPreference('create_thumbnails', (int) $params['create_thumbnails']);
}
filemanager_utils::set_cwd('/');
$this->SetMessage($this->Lang('settingssaved'));
$this->SetCurrentTab('settings');
$this->RedirectToAdminTab();
コード例 #9
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"];
コード例 #10
0
ファイル: uploadview.php プロジェクト: rainbow-studio/cmsms
<?php

if (!function_exists("cmsms")) {
    exit;
}
if (!$this->CheckPermission('Modify Files')) {
    exit;
}
$smarty->assign('path', $path);
$smarty->assign('prompt_path', $this->Lang('uploadfilesto'));
$smarty->assign('formstart', $this->CreateFormStart($id, 'upload', $returnid, "post", "multipart/form-data"));
$smarty->assign('url', str_replace('&amp;', '&', $this->create_url($id, 'upload', $returnid)) . '&showtemplate=false');
$smarty->assign('actionid', $id);
$smarty->assign('maxfilesize', $config["max_upload_size"]);
$smarty->assign('submit', $this->CreateInputSubmit($id, "ok", $this->Lang("ok"), "", ""));
$smarty->assign('formend', $this->CreateFormEnd());
$post_max_size = filemanager_utils::str_to_bytes(ini_get('post_max_size'));
$upload_max_filesize = filemanager_utils::str_to_bytes(ini_get('upload_max_filesize'));
$smarty->assign('max_chunksize', min($upload_max_filesize, $post_max_size - 1024));
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
    $smarty->assign('is_ie', 1);
}
$smarty->assign('action_url', $this->create_url('m1_', 'upload', $returnid));
$smarty->assign('ie_upload_message', $this->Lang('ie_upload_message'));
echo $this->ProcessTemplate('uploadview.tpl');
コード例 #11
0
ファイル: action.rename.php プロジェクト: RTR-ITF/usse-cms
//for initial input box
if (isset($params["newname"])) {
    $newname = $params["newname"];
    if (!filemanager_utils::is_valid_filename($newname)) {
        echo $this->ShowErrors($this->Lang("invaliddestname"));
    } else {
        $cwd = filemanager_utils::get_cwd();
        $fullnewname = filemanager_utils::join_path(filemanager_utils::get_full_cwd(), trim($params['newname']));
        if (file_exists($fullnewname)) {
            echo $this->ShowErrors($this->Lang("namealreadyexists"));
            //fallthrough
        } else {
            $fulloldname = filemanager_utils::join_path(filemanager_utils::get_full_cwd(), $oldname);
            if (@rename($fulloldname, $fullnewname)) {
                $thumboldname = filemanager_utils::join_path(filemanager_utils::get_full_cwd(), 'thumb_' . $oldname);
                $thumbnewname = filemanager_utils::join_path(filemanager_utils::get_full_cwd(), 'thumb_' . trim($params['newname']));
                if (file_exists($thumboldname)) {
                    @rename($thumboldname, $thumbnewname);
                }
                $this->SetMessage($this->Lang('renamesuccess'));
                $this->Audit('', "File Manager", "Renamed file: " . $fullnewname);
                $this->Redirect($id, "defaultadmin", $returnid, $paramsnofiles);
            } else {
                $this->SetError($this->Lang('renameerror'));
                $this->Redirect($id, "defaultadmin", $returnid, $params);
            }
        }
    }
}
if (is_array($params['selall'])) {
    $params['selall'] = serialize($params['selall']);
コード例 #12
0
ファイル: action.thumb.php プロジェクト: RTR-ITF/usse-cms
if (count($selall) > 1) {
    $params["fmerror"] = "morethanonefiledirselected";
    $this->Redirect($id, "defaultadmin", $returnid, $params);
}
$advancedmode = filemanager_utils::check_advanced_mode();
$basedir = $config['root_path'];
$config = cmsms()->GetConfig();
$filename = $this->decodefilename($selall[0]);
$src = filemanager_utils::join_path($basedir, filemanager_utils::get_cwd(), $filename);
if (!file_exists($src)) {
    $params["fmerror"] = "filenotfound";
    $this->Redirect($id, "defaultadmin", $returnid, $params);
}
$thumb = filemanager_utils::join_path($basedir, filemanager_utils::get_cwd(), 'thumb_' . $filename);
if (isset($params['submit'])) {
    $thumb = filemanager_utils::join_path($basedir, filemanager_utils::get_cwd(), 'thumb_' . $filename);
    $thumb = cms_utils::generate_thumbnail($src);
    if (!$thumb) {
        $params["fmerror"] = "thumberror";
    } else {
        $params["fmmessage"] = "thumbsuccess";
    }
    $this->Redirect($id, "defaultadmin", $returnid, $params);
}
//
// build the form
//
$smarty->assign('filename', $filename);
$smarty->assign('filespec', $src);
$smarty->assign('thumb', $thumb);
$smarty->assign('thumbexists', file_exists($thumb));
コード例 #13
0
ファイル: action.copy.php プロジェクト: RTR-ITF/usse-cms
     $errors[] = $this->Lang('insufficientpermission', $file);
     continue;
 }
 if (file_exists($dest)) {
     $errors[] = $this->Lang('fileexistsdest', basename($dest));
     continue;
 }
 $thumb = '';
 $src_thumb = '';
 $dest_thumb = '';
 if (filemanager_utils::is_image_file($file)) {
     $tmp = 'thumb_' . $file;
     $src_thumb = filemanager_utils::join_path($basedir, $cwd, $tmp);
     $dest_thumb = filemanager_utils::join_path($basedir, $destdir, $tmp);
     if ($destname) {
         $dest_thumb = filemanager_utils::join_path($basedir, $destdir, 'thumb_' . $destname);
     }
     if (file_exists($src_thumb)) {
         $thumb = $tmp;
         // have a thumbnail
         if (!is_readable($src_thumb)) {
             $errors[] = $this->Lang('insufficientpermission', $thumb);
             continue;
         }
         if (file_exists($dest_thumb)) {
             $errors[] = $this->Lang('fileexistsdest', $thumb);
             continue;
         }
     }
 }
 // here we can move the file/dir
コード例 #14
0
<?php

if (!function_exists("cmsms")) {
    exit;
}
if (!$this->CheckPermission('Modify Files')) {
    exit;
}
$sortby = $this->GetPreference("sortby", "nameasc");
$path = filemanager_utils::get_cwd();
$filelist = filemanager_utils::get_file_list($path);
$config = $gCms->GetConfig();
$this->smarty->assign('currentpath', $this->Lang("currentpath"));
$this->smarty->assign('path', $path);
$this->smarty->assign('hiddenpath', $this->CreateInputHidden($id, "path", $path));
$this->smarty->assign('formstart', $this->CreateFormStart($id, 'fileaction', $returnid));
$themeObject = cms_utils::get_theme_object();
$titlelink = $this->Lang("filename");
$newsort = "";
if ($sortby == "nameasc") {
    $newsort = "namedesc";
    $titlelink .= "+";
} else {
    $newsort = "nameasc";
    if ($sortby == "namedesc") {
        $titlelink .= "-";
    }
}
$params["newsort"] = $newsort;
$titlelink = $this->CreateLink($id, "defaultadmin", $returnid, $titlelink, $params);
$this->smarty->assign('filenametext', $titlelink);
コード例 #15
0
<?php

if (!cmsms()) {
    exit;
}
if (!$this->CheckPermission("Modify Files") && !$this->AdvancedAccessAllowed()) {
    exit;
}
if (!isset($params["newdirname"]) || !isset($params["path"])) {
    $this->Redirect($id, 'defaultadmin');
}
if ($this->IntruderCheck($params["path"])) {
    $this->Redirect($id, 'defaultadmin', $returnid, array("fmerror" => "fileoutsideuploads"));
}
$params["newdirname"] = trim($params["newdirname"]);
if (!filemanager_utils::is_valid_filename($params['newdirname'])) {
    $this->Redirect($id, 'defaultadmin', $returnid, array("fmerror" => "invalidnewdir"));
}
$config =& $gCms->GetConfig();
$newdir = $this->Slash($params["path"], $params["newdirname"]);
$newdir = $this->Slash($config["root_path"], $newdir);
//echo $newdir; die();
if (is_dir($newdir)) {
    $this->Redirect($id, 'defaultadmin', $returnid, array("fmerror" => "direxists"));
}
$message = "";
$error = "";
if (mkdir($newdir)) {
    $message = "newdirsuccess";
    // put mention into the admin log
    $this->Audit(0, "File Manager", "Created new directory: " . $params["newdirname"]);