API15:JPath/isOwner
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Method to determine if script owns the path
Syntax
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
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; }
[Edit See Also] SeeAlso:JPath/isOwner
Examples
<CodeExamplesForm />
