lib/ezutils/classes/ezsys.php
protected static function getValidwwwDir( $phpSelf, $scriptFileName, $index )
    {
        if ( !isset( $phpSelf[1] ) || empty($index) || strpos( $phpSelf, $index ) === false )
            return false;

        // validate $index straight away
        if ( strpos( $scriptFileName, $index ) === false )
            return null;

        // optimize '/index.php' pattern
        if ( $phpSelf === "/{$index}" )
            return '';

        $phpSelfParts = explode( $index, $phpSelf );
        $validateDir = $phpSelfParts[0];
        // remove first path if home dir
        if ( $phpSelf[1] === '~' )
        {
            $uri = explode( '/', ltrim( $validateDir, '/' ) );
            $userName = ltrim( array_shift( $uri ), "~" );

            // validating that we have user/ in path
            if ( !strpos( $scriptFileName, $userName ."/" ) )
            {
                return null;
            }

            $validateDir = '/' . implode( '/', $uri );
        }

        if ( !empty( $validateDir ) )
        {
            // validate directly with phpself part
            if ( strpos( $scriptFileName, $validateDir ) !== false )
                return trim( $phpSelfParts[0], '/' );

            // validate with windows path
            if ( strpos( $scriptFileName, str_replace( '/', '\\', $validateDir ) ) !== false )
                return trim( $phpSelfParts[0], '/' );
        }

        return null;
    }
protected static function getValidwwwDir( $phpSelf, $scriptFileName, $index )
    {
        if ( !isset( $phpSelf[1] ) || empty($index) || strpos( $phpSelf, $index ) === false )
            return false;

        // validate $index straight away
        if ( strpos( $scriptFileName, $index ) === false )
            return null;

        // optimize '/index.php' pattern
        if ( $phpSelf === "/{$index}" )
            return '';

        $phpSelfParts = explode( $index, $phpSelf );
        $validateDir = $phpSelfParts[0];
        // remove first path if home dir
        if ( $phpSelf[1] === '~' )
        {
            $uri = explode( '/', ltrim( $validateDir, '/' ) );
            $userName = ltrim( array_shift( $uri ), "~" );

            // validating that we have user/ in path
            if ( !strpos( $scriptFileName, $userName ."/" ) )
            {
                return null;
            }

            $validateDir = '/' . implode( '/', $uri );
        }

        if ( !empty( $validateDir ) )
        {
            // validate directly with phpself part
            if ( strpos( $scriptFileName, $validateDir ) !== false )
                return trim( $phpSelfParts[0], '/' );

            // validate with windows path
            if ( strpos( $scriptFileName, str_replace( '/', '\\', $validateDir ) ) !== false )
                return trim( $phpSelfParts[0], '/' );
        }

        return null;
    }
protected static function getValidwwwDir ( $ phpSelf , $ scriptFileName , $ index ) { if ( ! isset ( $ phpSelf [ 1 ] ) || empty ( $ index ) || strpos ( $ phpSelf , $ index ) === false ) return false ; // validate $index straight away if ( strpos ( $ scriptFileName , $ index ) === false ) return null ; // optimize '/index.php' pattern if ( $ phpSelf === "/{$index}" ) return '' ; $ phpSelfParts = explode ( $ index , $ phpSelf ) ; $ validateDir = $ phpSelfParts [ 0 ] ; // remove first path if home dir if ( $ phpSelf [ 1 ] === '~' ) { $ uri = explode ( '/' , ltrim ( $ validateDir , '/' ) ) ; $ userName = ltrim ( array_shift ( $ uri ) , "~" ) ; // validating that we have user/ in path if ( ! strpos ( $ scriptFileName , $ userName . "/" ) ) { return null ; } $ validateDir = '/' . implode ( '/' , $ uri ) ; } if ( ! empty ( $ validateDir ) ) { // validate directly with phpself part if ( strpos ( $ scriptFileName , $ validateDir ) !== false ) return trim ( $ phpSelfParts [ 0 ] , '/' ) ; // validate with windows path if ( strpos ( $ scriptFileName , str_replace ( '/' , '\\' , $ validateDir ) ) !== false ) return trim ( $ phpSelfParts [ 0 ] , '/' ) ; } return null ; }
Generate wwwdir from phpSelf if valid accoring to scriptFileName
and return null if invalid and false if there is no index in phpSelf

@param string $phpSelf
@param string $scriptFileName
@param string $index
@return string|null|false String in form 'path/path2' if valid, null if not
and false if $index is not  part of phpself
Generate wwwdir from phpSelf if valid accoring to scriptFileName and return null if invalid and false if there is no index in phpSelf