Fix newsportal code to create clickable links
This commit is contained in:
parent
5288a72716
commit
59a21be4a0
|
@ -877,40 +877,17 @@ function html_parse($text) {
|
||||||
} else {
|
} else {
|
||||||
$target=' ';
|
$target=' ';
|
||||||
}
|
}
|
||||||
// regular expressions that will be applied to every word in the text
|
|
||||||
$regexp_replace=array(
|
|
||||||
'http://((\.*([-a-z0-9_/~@?=%#;+]|&)+)+)' =>
|
|
||||||
'<a'.$target.'href="http://\1">http://\1</a>',
|
|
||||||
'(www\.[-a-z]+\.(de|pl|cz|sk|tk|tv|cc|cx|biz|us|uk|info|int|eu|dk|org|net|at|ch|com))' =>
|
|
||||||
'<a'.$target.'href="http://\1">\1</a>',
|
|
||||||
'https://([-a-z0-9_./~@?=%#&;\n]+)' =>
|
|
||||||
'<a'.$target.'href="https://\1">https://\1</a>',
|
|
||||||
'gopher://([-a-z0-9_./~@?=%\n]+)' =>
|
|
||||||
'<a'.$target.'href="gopher://\1">gopher://\1</a>',
|
|
||||||
'news://([-a-z0-9_./~@?=%\n]+)' =>
|
|
||||||
'<a'.$target.'href="news://\1">news://\1</a>',
|
|
||||||
'ftp://([-a-z0-9_./~@?=%\n]+)' =>
|
|
||||||
'<a'.$target.'href="ftp://\1">ftp://\1</a>',
|
|
||||||
//'([-a-z0-9_./n]+)@([-a-z0-9_.]+)' =>
|
|
||||||
// $_SESSION["loggedin"]!==true ? '(e-Mail)' :
|
|
||||||
// '<a href="mailto:\1@\2">\1@\2</a>'
|
|
||||||
);
|
|
||||||
$ntext="";
|
$ntext="";
|
||||||
// split every line into it's words
|
// split every line into it's words
|
||||||
$words=explode(" ",$text);
|
$words=explode(" ",$text);
|
||||||
$n=count($words);
|
$n=count($words);
|
||||||
for($i=0; $i<$n; $i++) {
|
for($i=0; $i<$n; $i++) {
|
||||||
$word=$words[$i];
|
$word=$words[$i];
|
||||||
// test, if we need the slow walk through all the regular expressions
|
if(preg_match('/https?\:\/\/[^\",]+/i', $word)) {
|
||||||
if(preg_match('/www|\:|@/i',$word)) {
|
$nlink = preg_replace('/(\<|\>);/', '', $word);
|
||||||
// apply the regular expressions to the word until a matching
|
$nword = '<a '.$target.' href="'.$nlink.'">'.$word.'</a>';
|
||||||
// expression is found
|
if($nword!=$word) {
|
||||||
foreach ($regexp_replace as $key => $value) {
|
$word=$nword;
|
||||||
$nword=preg_replace('/{$key}/i',$value,$word);
|
|
||||||
if($nword!=$word) {
|
|
||||||
$word=$nword;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add the spaces between the words
|
// add the spaces between the words
|
||||||
|
|
Loading…
Reference in New Issue