/**
* 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;
}