function DeleteFileFromRepository($s_fld) { global $aFileVars, $FILE_REPOSITORY; if (!FILEUPLOADS || $FILE_REPOSITORY === "") { // // nothing to do // return false; } if (($a_upload = GetFileInfo($s_fld)) === false) { return false; } if (isset($a_upload["in_repository"]) && $a_upload["in_repository"]) { if (isset($a_upload["saved_as"]) && !empty($a_upload["saved_as"])) { @unlink($a_upload["saved_as"]); } } DeleteFileInfo($s_fld); return true; }
function DeleteFileFromRepository($s_fld) { global $aFileVars; if (!Settings::get('FILEUPLOADS') || Settings::get('FILE_REPOSITORY') === "") { return false; } if (($a_upload = GetFileInfo($s_fld)) === false) { return false; } if (isset($a_upload["in_repository"]) && $a_upload["in_repository"]) { if (isset($a_upload["saved_as"]) && !empty($a_upload["saved_as"])) { @unlink($a_upload["saved_as"]); } } DeleteFileInfo($s_fld); return true; }
public static function get_file_list($path = '') { if (!$path) { $path = self::get_cwd(); } $advancedmode = self::check_advanced_mode(); $filemod = cms_utils::get_module('FileManager'); $showhiddenfiles = $filemod->GetPreference('showhiddenfiles', '1'); $result = array(); $gCms = cmsms(); $config = $gCms->GetConfig(); // convert the cwd into a real path... slightly different for advanced mode. $realpath = self::join_path($config['root_path'], $path); $dir = @opendir($realpath); if (!$dir) { return false; } while ($file = readdir($dir)) { if ($file == '.') { continue; } if ($file == '..') { // can we go up. if ($path == self::get_default_cwd()) { continue; } } else { if ($file[0] == '.' || $file[0] == '_' || $file[0] == '~') { if ($showhiddenfiles != 1 || !$advancedmode) { continue; } } } if (substr($file, 0, 6) == 'thumb_') { //Ignore thumbnail files of showing thumbnails is off if ($filemod->GetPreference('showthumbnails', '1') == '1') { continue; } } // build the file info array. $fullname = self::join_path($realpath, $file); $info = array(); $info['name'] = $file; $info['dir'] = FALSE; $info['image'] = FALSE; $info['archive'] = FALSE; $statinfo = stat($fullname); if (is_dir($fullname)) { $info['dir'] = true; $info['ext'] = ''; $info['fileinfo'] = GetFileInfo($fullname, '', true); } else { $info['size'] = $statinfo['size']; $info['date'] = $statinfo['mtime']; $info['url'] = self::join_path($config['root_url'], $path, $file); $info['url'] = str_replace('\\', '/', $info['url']); // windoze both sucks, and blows. $explodedfile = explode('.', $file); $info['ext'] = array_pop($explodedfile); $info['fileinfo'] = GetFileInfo(self::join_path($realpath, $file), $info['ext'], false); } // test for archive $info['archive'] = self::is_archive_file($file); // test for image $info['image'] = self::is_image_file($file); if (function_exists('posix_getpwuid')) { $userinfo = @posix_getpwuid($statinfo['uid']); $info['fileowner'] = isset($userinfo['name']) ? $userinfo['name'] : $filemod->Lang('unknown'); } else { $info['fileowner'] = 'N/A'; } $info['writable'] = is_writable(self::join_path($realpath, $file)); if (function_exists('posix_getpwuid')) { $info['permissions'] = $filemod->FormatPermissions($statinfo['mode'], $filemod->GetPreference('permissionstyle', 'xxx')); } else { if ($info['writable']) { $info['permissions'] = 'R'; } else { $info['permissions'] = 'R'; } } $result[] = $info; } $tmp = usort($result, 'filemanager_utils::_FileManagerCompareFiles'); return $result; }
function GetFileList(&$path, $advancedmode = false) { //echo "<b>$path</b>"; $showhiddenfiles = $this->GetPreference("showhiddenfiles", "1"); $result = array(); $gCms = cmsms(); $config = $gCms->GetConfig(); $realpath = $this->Slash($config["root_path"], $path); if ($this->IntruderCheck($realpath, $advancedmode)) { $realpath = $config["uploads_path"]; $path = str_replace($config["root_path"], "", $realpath); $path = $this->Slashes($path); } $dir = @opendir($realpath); if (!$dir) { return false; } while ($file = readdir($dir)) { if ($file == ".") { continue; } if ($file == "..") { if ($advancedmode) { if ($path == "/") { continue; } } else { if ($path == $this->upDir()) { continue; } } } else { if ($file[0] == ".") { if ($showhiddenfiles != 1 || !$advancedmode) { continue; } } } if (substr($file, 0, 6) == "thumb_") { //Ignore thumbnail files of showing thumbnails is off if ($this->GetPreference("showthumbnails", "1") == "1") { continue; } } $info = array(); $info["name"] = $file; $statinfo = stat($this->Slash($realpath, $file)); if (is_dir($this->Slash($realpath, $file))) { $info["dir"] = true; $info["ext"] = ""; $info["fileinfo"] = GetFileInfo($this->Slash($realpath, $file), "", true); } else { $info["dir"] = false; $info["size"] = $statinfo["size"]; $info["date"] = $statinfo["mtime"]; $info["url"] = $this->Slashes($config["root_url"] . $this->Slash($path, $file)); $explodedfile = explode('.', $file); $info["ext"] = array_pop($explodedfile); $info["fileinfo"] = GetFileInfo($this->Slash($realpath, $file), $info["ext"], false); } if (in_array(strtolower($info["ext"]), array("gif", "jpg", "jpeg", "png"))) { $info["image"] = true; } else { $info["image"] = false; } //print_r($statinfo); if (function_exists("posix_getpwuid")) { $userinfo = @posix_getpwuid($statinfo["uid"]); $info["fileowner"] = isset($userinfo['name']) ? $userinfo['name'] : $this->Lang('unknown'); } else { $info["fileowner"] = "N/A"; } $info["writable"] = is_writable($this->Slash($realpath, $file)); if (function_exists("posix_getpwuid")) { $info["permissions"] = $this->FormatPermissions($statinfo["mode"], $this->GetPreference("permissionstyle", "xxx")); } else { if ($info["writable"]) { $info["permissions"] = "R"; } else { $info["permissions"] = "R"; } } $result[] = $info; } $result = $this->columnSort($result); return $result; }
function GetFileSize($s_fld) { if (($a_upload = GetFileInfo($s_fld)) !== false) { return $a_upload['size']; } return false; }
function GetFiles() { global $mediaDirectory; global $sequenceDirectory; global $musicDirectory; global $videoDirectory; global $effectDirectory; global $scriptDirectory; global $logDirectory; global $uploadDirectory; global $docsDirectory; $dirName = $_GET['dir']; check($dirName, "dirName", __FUNCTION__); if ($dirName == "Sequences") { $dirName = $sequenceDirectory; } else { if ($dirName == "Music") { $dirName = $musicDirectory; } else { if ($dirName == "Videos") { $dirName = $videoDirectory; } else { if ($dirName == "Effects") { $dirName = $effectDirectory; } else { if ($dirName == "Scripts") { $dirName = $scriptDirectory; } else { if ($dirName == "Logs") { $dirName = $logDirectory; } else { if ($dirName == "Uploads") { $dirName = $uploadDirectory; } else { if ($dirName == "Docs") { $dirName = $docsDirectory; } else { return; } } } } } } } } $doc = new DomDocument('1.0'); $root = $doc->createElement('Files'); $root = $doc->appendChild($root); foreach (scandir($dirName) as $fileName) { if ($fileName != '.' && $fileName != '..') { GetFileInfo($root, $doc, $dirName, $fileName); } } if ($_GET['dir'] == "Logs") { if (file_exists("/var/log/messages")) { GetFileInfo($root, $doc, "", "/var/log/messages"); } if (file_exists("/var/log/syslog")) { GetFileInfo($root, $doc, "", "/var/log/syslog"); } } // Thanks: http://stackoverflow.com/questions/7272938/php-xmlreader-problem-with-htmlentities $trans = array_map('utf8_encode', array_flip(array_diff(get_html_translation_table(HTML_ENTITIES), get_html_translation_table(HTML_SPECIALCHARS)))); echo strtr($doc->saveHTML(), $trans); }