I know that phpFreeChat convert links automaticly, but only nicks starting with http:// so if i type "www.mypage.com" it doesnt work (at least for me didnt work hehe) so i made a modification to convert the words started by www. into http://www. so the chat script can convert them to clickable links, and i have added the email convertion too, so if i type my_email@server.com it will convert it to mailto:my_email@server.com
hope you guys like it.
Ok, it will be all in the file "/src/commands/send.class.php"
- Code: Select all
line 4, after the "require_once.." and before the "class ..." add this function:
function convertLinks($text) {
if(substr($text,0,4) == 'www.')
{$text = str_replace($text,' '.$text, $text);}
$text = eregi_replace('([[:space:]()(>)[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)','\1http://\2', $text);
$text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})','<a href="mailto:\1">\1</a>', $text);
return $text;
}
//-----------------------------------
//----------------------------------
line 70, replace:
$msgid = $ct->write($recipient, $nick, "send", $text);
with:
$text = convertLinks($text);
$msgid = $ct->write($recipient, $nick, "send", $text);
//--------------------------------
That should work ok, it does for me, and i havent found any bug yet so i think it must work with you too, i know is kind of simple but it works!!
Hope you like it.