PHP Code:
function links_preg2($arr)
{
global $set;
if (preg_match('#^http://' . preg_quote($_SERVER['HTTP_HOST']) . '#',$arr[2]))
return $arr[1] . '<a href="' . $arr[2] . '">' . $arr[2] . '</a>' . $arr[4];
else
return $arr[1] . '<a' . ($set['web'] ? ' target="_blank"' : null) . ' href="http://' . $_SERVER['HTTP_HOST'] . '/go.php?go=' . base64_encode(html_entity_decode($arr[2])) . '">Link</a>' . $arr[4];
}
function links($msg)
{
global $set;
if ($set['bb_img'])$msg = preg_replace_callback('/\[img\](.+)\[\/img\]/isU', 'img_preg', $msg);
if ($set['bb_url'])$msg = preg_replace_callback('/\[url=(.+)\](.+)\[\/url\]/isU', 'links_preg1', $msg);
if ($set['bb_http'])$msg = preg_replace_callback('~(^|\s)([a-z]+://([^ \r\n\t`\'"]+))(\s|$)~iu', 'links_preg2', $msg);
return $msg;
}
-each time when a user post a url: http://youtube.com/watch?blablabla , i want to show on the site : Link youtube
-each time when a user post a url" http://www.facebook.com/picture/etcetcetctjkjk , i want to show on the site: Link facebook
Anyone have an ideea how to make something like this? I gues that with preg_replace or url_parsing but i don't know how
Comment