Project

General

Profile

Bug #15095 » substUrlsInPlainText_fixed.php

Administrator Admin, 2005-10-18 11:52

 
function substUrlsInPlainText($message,$urlmode='76',$index_script_url='') {
// Substitute URLs with shorter links:
$urlSplit=explode('http://',$message);
reset($urlSplit);
while(list($c,$v)=each($urlSplit)) {
if ($c) {
$newParts = split('[[:space:]]|\)|\(',$v,2);
$newURL='http://'.$newParts[0];
switch((string)$urlmode) {
case 'all':
$newURL=t3lib_div::makeRedirectUrl($newURL,0,$index_script_url);
break;
case '76':
$newURL=t3lib_div::makeRedirectUrl($newURL,76,$index_script_url);
break;
}
$urlSplit[$c]=$newURL.substr($v,strlen($newParts[0]));
}
}

$message=implode('',$urlSplit);
$urlSplit=explode('https://',$message);
reset($urlSplit);
while(list($c,$v)=each($urlSplit)) {
if ($c) {
$newParts = split('[[:space:]]|\)|\(',$v,2);
$newURL='https://'.$newParts[0];
switch((string)$urlmode) {
case 'all':
$newURL=t3lib_div::makeRedirectUrl($newURL,0,$index_script_url);
break;
case '76':
$newURL=t3lib_div::makeRedirectUrl($newURL,76,$index_script_url);
break;
}
$urlSplit[$c]=$newURL.substr($v,strlen($newParts[0]));
}
}

$message=implode('',$urlSplit);
return $message;
}
(1-1/2)