XoopsCore25
XoopsCore25 copied to clipboard
./include/functions.php - formatURL :: Add ability to set secure URL
Enhancement Add a 2nd parameter to formatURL() function to allow requesting a secure url. For backward compatibility function should return http as the default.
/**
* formatURL()
*
* @param mixed $url
* @param bool $secure true to return https, else return http
* @return mixed|string
*/
function formatURL($url, $secure=false)
{
$url = trim($url);
if ($url != '') {
if ((!preg_match('/^http[s]*:\/\//i', $url)) && (!preg_match('/^ftp*:\/\//i', $url)) && (!preg_match('/^ed2k*:\/\//i', $url))) {
$url = (bool)$secure ? 'https://' . $url : 'http://' . $url;
}
}
return $url;
}