API16

JPath/isOwner

< API16:JPath

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

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


Advertisement