dolibarr 19.0.4
geturl.lib.php File Reference

This file contains functions dedicated to get URLs. More...

Go to the source code of this file.

Functions

 getURLContent ($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
 Function to get a content from an URL (use proxy if proxy defined).
 
 isIPAllowed ($iptocheck, $localurl)
 Is IP allowed.
 
 getDomainFromURL ($url, $mode=0)
 Function get second level domain name.
 
 getRootURLFromURL ($url)
 Function root url from a long url For example: https://www.abc.mydomain.com/dir/page.html return 'https://www.abc.mydomain.com' For example: http://www.abc.mydomain.com/ return 'https://www.abc.mydomain.com'.
 
 removeHtmlComment ($content)
 Function to remove comments into HTML content.
 

Detailed Description

This file contains functions dedicated to get URLs.

Definition in file geturl.lib.php.

Function Documentation

◆ getDomainFromURL()

getDomainFromURL ( $url,
$mode = 0 )

Function get second level domain name.

For example: https://www.abc.mydomain.com/dir/page.html return 'mydomain'

Parameters
string$urlFull URL.
int$mode0=return 'mydomain', 1=return 'mydomain.com', 2=return 'abc.mydomain.com'
Returns
string Returns domaine name

Definition at line 346 of file geturl.lib.php.

Referenced by SMTPs\_server_authenticate(), and SMTPs\sendMsg().

◆ getRootURLFromURL()

getRootURLFromURL ( $url)

Function root url from a long url For example: https://www.abc.mydomain.com/dir/page.html return 'https://www.abc.mydomain.com' For example: http://www.abc.mydomain.com/ return 'https://www.abc.mydomain.com'.

Parameters
string$urlFull URL.
Returns
string Returns root url

Definition at line 398 of file geturl.lib.php.

Referenced by getAllImages().

◆ getURLContent()

getURLContent ( $url,
$postorget = 'GET',
$param = '',
$followlocation = 1,
$addheaders = array(),
$allowedschemes = array('http', 'https'),
$localurl = 0,
$ssl_verifypeer = -1 )

Function to get a content from an URL (use proxy if proxy defined).

Support Dolibarr setup for timeout and proxy. Enhancement of CURL to add an anti SSRF protection:

  • you can set MAIN_SECURITY_ANTI_SSRF_SERVER_IP to set static ip of server
  • common local lookup ips like 127.*.*.* are automatically added
Parameters
string$urlURL to call.
string$postorget'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE'
string$paramParameters of URL (x=value1&y=value2) or may be a formated content with $postorget='PUTALREADYFORMATED'
integer$followlocation0=Do not follow, 1=Follow location.
string[]$addheadersArray of string to add into header. Example: ('Accept: application/xrds+xml', ....)
string[]$allowedschemesList of schemes that are allowed ('http' + 'https' only by default)
int$localurl0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed.
int$ssl_verifypeer-1=Auto (no ssl check on dev, check on prod), 0=No ssl check, 1=Always ssl check
Returns
array Returns an associative array containing the response from the server array('http_code'=>http response code, 'content'=>response, 'curl_error_no'=>errno, 'curl_error_msg'=>errmsg...)

Definition at line 41 of file geturl.lib.php.

References dol_syslog(), getDolGlobalInt(), getDolGlobalString(), and isIPAllowed().

Referenced by MailmanSpip\callMailman(), check_user_password_openid_connect(), PartnershipUtils\checkDolibarrBacklink(), getAllImages(), Setup\getCheckIntegrity(), GoogleAPI\getGeoCoordinatesOfAddress(), SimpleOpenID\GetOpenIDServer(), RssParser\parser(), PriceGlobalVariableUpdater\process(), ICal\read_file(), InterfaceWebhookTriggers\runTrigger(), and BlockedLogAuthority\syncSignatureWithAuthority().

◆ isIPAllowed()

isIPAllowed ( $iptocheck,
$localurl )

Is IP allowed.

Parameters
string$iptocheckIP to check
int$localurl0=external url only, 1=internal url only
Returns
string Error message or ''

Definition at line 288 of file geturl.lib.php.

References getDolGlobalString().

Referenced by getURLContent().

◆ removeHtmlComment()

removeHtmlComment ( $content)

Function to remove comments into HTML content.

Parameters
string$contentText content
Returns
string Returns text without HTML comments

Definition at line 418 of file geturl.lib.php.