/usr/share/php/LetoDMS/Core/inc.FileUtils.php is in php-letodms-core 3.3.11-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | <?php
/**
* Implementation of various file system operations
*
* @category DMS
* @package LetoDMS_Core
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010 Uwe Steinmann
* @version Release: 3.3.11
*/
/**
* Class to represent a user in the document management system
*
* @category DMS
* @package LetoDMS_Core
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010 Uwe Steinmann
* @version Release: 3.3.11
*/
class LetoDMS_Core_File {
function renameFile($old, $new) {
return @rename($old, $new);
}
function removeFile($file) {
return @unlink($file);
}
function copyFile($source, $target) {
return @copy($source, $target);
}
function moveFile($source, $target) {
if (!@copyFile($source, $target))
return false;
return @removeFile($source);
}
function renameDir($old, $new) {
return @rename($old, $new);
}
function makeDir($path) {
if( !is_dir( $path ) ){
$res=@mkdir( $path , 0777, true);
if (!$res) return false;
}
return true;
/* some old code
if (strncmp($path, DIRECTORY_SEPARATOR, 1) == 0) {
$mkfolder = DIRECTORY_SEPARATOR;
}
else {
$mkfolder = "";
}
$path = preg_split( "/[\\\\\/]/" , $path );
for( $i=0 ; isset( $path[$i] ) ; $i++ )
{
if(!strlen(trim($path[$i])))continue;
$mkfolder .= $path[$i];
if( !is_dir( $mkfolder ) ){
$res=@mkdir( "$mkfolder" , 0777);
if (!$res) return false;
}
$mkfolder .= DIRECTORY_SEPARATOR;
}
return true;
// patch from alekseynfor safe_mod or open_basedir
global $settings;
$path = substr_replace ($path, "/", 0, strlen($settings->_contentDir));
$mkfolder = $settings->_contentDir;
$path = preg_split( "/[\\\\\/]/" , $path );
for( $i=0 ; isset( $path[$i] ) ; $i++ )
{
if(!strlen(trim($path[$i])))continue;
$mkfolder .= $path[$i];
if( !is_dir( $mkfolder ) ){
$res= @mkdir( "$mkfolder" , 0777);
if (!$res) return false;
}
$mkfolder .= DIRECTORY_SEPARATOR;
}
return true;
*/
}
function removeDir($path) {
$handle = @opendir($path);
while ($entry = @readdir($handle) )
{
if ($entry == ".." || $entry == ".")
continue;
else if (is_dir($path . $entry))
{
if (!self::removeDir($path . $entry . "/"))
return false;
}
else
{
if (!@unlink($path . $entry))
return false;
}
}
@closedir($handle);
return @rmdir($path);
}
function copyDir($sourcePath, $targetPath) {
if (mkdir($targetPath, 0777)) {
$handle = @opendir($sourcePath);
while ($entry = @readdir($handle) ) {
if ($entry == ".." || $entry == ".")
continue;
else if (is_dir($sourcePath . $entry)) {
if (!self::copyDir($sourcePath . $entry . "/", $targetPath . $entry . "/"))
return false;
} else {
if (!@copy($sourcePath . $entry, $targetPath . $entry))
return false;
}
}
@closedir($handle);
}
else
return false;
return true;
}
function moveDir($sourcePath, $targetPath) {
if (!copyDir($sourcePath, $targetPath))
return false;
return removeDir($sourcePath);
}
// code by Kioob (php.net manual)
function gzcompressfile($source,$level=false) {
$dest=$source.'.gz';
$mode='wb'.$level;
$error=false;
if($fp_out=@gzopen($dest,$mode)) {
if($fp_in=@fopen($source,'rb')) {
while(!feof($fp_in))
@gzwrite($fp_out,fread($fp_in,1024*512));
@fclose($fp_in);
}
else $error=true;
@gzclose($fp_out);
}
else $error=true;
if($error) return false;
else return $dest;
}
}
?>
|