10 defined(
'JPATH_PLATFORM') or die;
12 if (!defined('JPATH_ROOT'))
38 $perms = fileperms($path);
42 if (@chmod($path, $perms ^ 0001))
44 @chmod($path, $perms);
64 public static function setPermissions($path, $filemode =
'0644', $foldermode =
'0755')
73 while ($file = readdir($dh))
75 if ($file !=
'.' && $file !=
'..')
77 $fullpath = $path .
'/' . $file;
79 if (is_dir($fullpath))
81 if (!self::setPermissions($fullpath, $filemode, $foldermode))
90 if (!@ chmod($fullpath, octdec($filemode)))
101 if (isset($foldermode))
103 if (!@ chmod($path, octdec($foldermode)))
111 if (isset($filemode))
113 $ret = @ chmod($path, octdec($filemode));
132 $mode = @ decoct(@ fileperms($path) & 0777);
134 if (strlen($mode) < 3)
141 for ($i = 0; $i < 3; $i++)
144 $parsed_mode .= ($mode{$i} & 04) ?
"r" :
"-";
147 $parsed_mode .= ($mode{$i} & 02) ?
"w" :
"-";
150 $parsed_mode .= ($mode{$i} & 01) ?
"x" :
"-";
168 if (strpos($path,
'..') !==
false)
171 throw new Exception(
'JPath::check Use of relative paths not permitted', 20);
176 if ((JPATH_ROOT !=
'') && strpos($path, self::clean(JPATH_ROOT)) !== 0)
178 throw new Exception(
'JPath::check Snooping out of bounds @ ' . $path, 20);
195 public static function clean($path, $ds = DIRECTORY_SEPARATOR)
197 if (!is_string($path))
199 throw new UnexpectedValueException(
'JPath::clean: $path is not a string.');
210 elseif (($ds ==
'\\') && ($path[0] ==
'\\' ) && ( $path[1] ==
'\\' ))
212 $path =
"\\" . preg_replace(
'#[/\\\\]+#', $ds, $path);
216 $path = preg_replace(
'#[/\\\\]+#', $ds, $path);
233 jimport(
'joomla.filesystem.file');
235 $tmp = md5(mt_rand());
236 $ssp = ini_get(
'session.save_path');
237 $jtp = JPATH_SITE .
'/tmp';
240 $dir = is_writable(
'/tmp') ?
'/tmp' :
false;
241 $dir = (!$dir && is_writable($ssp)) ? $ssp :
false;
242 $dir = (!$dir && is_writable($jtp)) ? $jtp :
false;
246 $test = $dir .
'/' . $tmp;
253 $return = (fileowner($test) == fileowner($path));
274 public static function find($paths, $file)
277 if (!is_array($paths) && !($paths instanceof Iterator))
279 settype($paths,
'array');
283 foreach ($paths as $path)
286 $fullname = $path .
'/' . $file;
289 if (strpos($path,
'://') ===
false)
295 $path = realpath($path);
296 $fullname = realpath($fullname);
305 if (file_exists($fullname) && substr($fullname, 0, strlen($path)) == $path)