Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

api_validate_upload_url()

Description

Validate URL supplied in APIs create resource or upload by URL. Requires the URL hostname to be added in config $api_upload_urls

Parameters

ColumnTypeDefaultDescription
$url string The full URL.

Return

bool Returns true if a valid URL is found.

Location

include/api_functions.php lines 232 to 259

Definition

 
function api_validate_upload_url($url)
    {
    
$url filter_var($urlFILTER_VALIDATE_URLFILTER_FLAG_PATH_REQUIRED);
    if (
$url === false)
        {
        return 
false;
        }

    
$url_parts parse_url($url);

    if (
in_array($url_parts['scheme'], BLOCKED_STREAM_WRAPPERS))
        {
        return 
false;
        }

    global 
$api_upload_urls;
    if (!isset(
$api_upload_urls))
        {
        return 
true// For systems prior to this config.
        
}

    if (
in_array($url_parts['host'], $api_upload_urls))
        {
        return 
true;
        }

    return 
false;
    }

This article was last updated 25th April 2024 21:35 Europe/London time based on the source file dated 25th April 2024 17:25 Europe/London time.