protected static function secureEncode($basedir, $source)
    {
        $components = parse_url($source);
        if (!isset($components['scheme'])) {
            // relative path
            if (\tao_helpers_File::securityCheck($source, false)) {
                if (file_exists($basedir . $source)) {
                    return 'data:' . \tao_helpers_File::getMimeType($basedir . $source) . ';'
                        . 'base64,' . base64_encode(file_get_contents($basedir . $source));
                } else {
                    throw new \tao_models_classes_FileNotFoundException($source);
                }
            } else {
                throw new \common_exception_Error('Invalid source path "' . $source . '"');
            }
        } else {
            // url, just return it as is
            return $source;
        }
    }
protected static function secureEncode($basedir, $source)
    {
        $components = parse_url($source);
        if (!isset($components['scheme'])) {
            // relative path
            if (\tao_helpers_File::securityCheck($source, false)) {
                if (file_exists($basedir . $source)) {
                    return 'data:' . \tao_helpers_File::getMimeType($basedir . $source) . ';'
                        . 'base64,' . base64_encode(file_get_contents($basedir . $source));
                } else {
                    throw new \tao_models_classes_FileNotFoundException($source);
                }
            } else {
                throw new \common_exception_Error('Invalid source path "' . $source . '"');
            }
        } else {
            // url, just return it as is
            return $source;
        }
    }
protected static function secureEncode ( $ basedir , $ source ) { $ components = parse_url ( $ source ) ; if ( ! isset ( $ components [ 'scheme' ] ) ) { // relative path if ( \ tao_helpers_File :: securityCheck ( $ source , false ) ) { if ( file_exists ( $ basedir . $ source ) ) { return 'data:' . \ tao_helpers_File :: getMimeType ( $ basedir . $ source ) . ';' . 'base64,' . base64_encode ( file_get_contents ( $ basedir . $ source ) ) ; } else { throw new \ tao_models_classes_FileNotFoundException ( $ source ) ; } } else { throw new \ common_exception_Error ( 'Invalid source path "' . $ source . '"' ) ; } } else { // url, just return it as is return $ source ; } }
Verify paths and encode the file

@param string $basedir
@param string $source
@throws \tao_models_classes_FileNotFoundException
@throws \common_exception_Error
@return string
Verify paths and encode the file