JPath/isOwner
From Joomla! Documentation
< API15:JPath
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Method to determine if script owns the path
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
isOwner($path)
Parameter Name | Default Value | Description |
---|---|---|
$path | $path Path to check ownership |
Returns[edit]
boolean True if the php script owns the path passed
Defined in[edit]
libraries/joomla/filesystem/path.php
Importing[edit]
jimport( 'joomla.filesystem.path' );
Source Body[edit]
function isOwner($path)
{
jimport('joomla.filesystem.file');
jimport('joomla.user.helper');
$tmp = md5(JUserHelper::genRandomPassword(16));
$ssp = ini_get('session.save_path');
$jtp = JPATH_SITE.DS.'tmp';
// Try to find a writable directory
$dir = is_writable('/tmp') ? '/tmp' : false;
$dir = (!$dir && is_writable($ssp)) ? $ssp : false;
$dir = (!$dir && is_writable($jtp)) ? $jtp : false;
if ($dir)
{
$test = $dir.DS.$tmp;
// Create the test file
JFile::write($test, '');
// Test ownership
$return = (fileowner($test) == fileowner($path));
// Delete the test file
JFile::delete($test);
return $return;
}
return false;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]