API16:JPath/isOwner
From Joomla! Documentation
Description
Method to determine if script owns the path
Syntax
static isOwner($path)
| Parameter Name | Default Value | Description |
|---|---|---|
| $path | $path Path to check ownership |
Returns
boolean True if the php script owns the path passed
Defined in
libraries/joomla/filesystem/path.php
Importing
jimport( 'joomla.filesystem.path' );
Source Body
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
Code Examples