JPath/isOwner
From Joomla! Documentation
< API16: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 "API16" 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
Syntax[edit]
static 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]
public static 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
$blank = '';
JFile::write($test, $blank, false);
// Test ownership
$return = (fileowner($test) == fileowner($path));
// Delete the test file
JFile::delete($test);
return $return;
}
return false;
}
Examples[edit]
Code Examples[edit]