UBB.Dev
Posted By: catcherman Automatic Email Hyperlinking - 08/07/2003 1:39 AM
Since UBB already automatically hyperlinks full url's when posting a message, I was wondering if it's possible to do the same with email addresses.

Ease of use is so important to many members and it's always easier, for them, when things can happen automatically.

If I type [email protected] it sould come out as user@domain.com without me having to use the UBB Code.

What do you think?
Posted By: Brett Re: Automatic Email Hyperlinking - 08/07/2003 8:44 AM
Code
in ubb_lib.cgi
# find:
return ($check);

# add above:
$check =~ s/(^|s)([^<>@]+)@([a-z0-9-_.]+)(.|,|))?/$1<a href="mailto:$2@$3">$2@$3</a>$4/si;
Not tested, but that should work.
Posted By: catcherman Re: Automatic Email Hyperlinking - 08/07/2003 8:57 AM
Close, but here's what I got when I put in my email address ([email protected]):

fishing.com

The mailto: worked so when I clicked it I got my mail client come up with a message to fishing.com.
Posted By: catcherman Re: Automatic Email Hyperlinking - 08/07/2003 9:03 AM
I added a backslash before the two @ at the end of the line and it seems to work now.

Sound right?
Posted By: catcherman Re: Automatic Email Hyperlinking - 08/07/2003 9:08 AM
Oooh, there's a problem...

It works when you post it, but if you edit the post it runs the process again making this:

Posted By: catcherman Re: Automatic Email Hyperlinking - 08/08/2003 9:26 PM
Bump. Any more help available out there???
Posted By: catcherman Re: Automatic Email Hyperlinking - 08/14/2003 11:13 PM
bump.2
Posted By: Brett Re: Automatic Email Hyperlinking - 08/15/2003 8:21 AM
I have tried thinking why this isn't going through right, i'm still not sure, but i have a few ideas. Try replacing that above $check =~ with
Code
$check =~ s/(^|s)([^@[]+)@(S+).([a-z]{2,3})(.|,|))?/$1<a href="mailto:$2@$3.$4">$2@$3.$4</a>$5/si;
Posted By: Ian Spence Re: Automatic Email Hyperlinking - 08/15/2003 8:42 AM
Code
There was a compilation error while loading the UBB.classic libraries and data files: 

syntax error at /home/httpd/vhosts/alforadmin.com/cgi-bin/ubb_lib.cgi line 1810, near "=~ =~"
Compilation failed in require at ultimatebb.cgi line 139.


Please make sure that you uploaded the CGI and Variables files to the proper directory, permissions are set properly on the files, and that paths in the control panel are set correctly.
I don't suggest trying that code
Posted By: Brett Re: Automatic Email Hyperlinking - 08/15/2003 11:18 AM
Oops! Had an extra =~, sorry. Fixed.
Posted By: Ian Spence Re: Automatic Email Hyperlinking - 08/15/2003 12:35 PM
ok, this has to be the coolest bug ever.

I post "[email protected]"

it leaves that as regular text. It then adds [email]@.[/email] to EVERYONE'S sig! It's between the sig and the sig divider. If they don't have a sig, it makes their sig only [email]@.[/email] (note, the email tags were converted so it would email @.)

http://www.alforadmin.com/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=10;t=000011;p=2#000025 there's an example, but it shows up in all posts that have been replied to since I tried it. I'll leave it in so you can see it.
Posted By: Brett Re: Automatic Email Hyperlinking - 08/15/2003 1:23 PM
Argh...

Sorry, i don't have a test board to try this out. You put that into the auto_url sub, right? I'm gonna have to look at this closer...
Posted By: Ian Spence Re: Automatic Email Hyperlinking - 08/15/2003 11:02 PM
Code
sub auto_url {
my $check = shift;
$check =~ s/(^|s)(http://S+)(.|,|))?/$1<a href="$2" target="_blank">$2</a>$3/isg;
$check =~ s/(^|s)(https://S+)(.|,|))?/$1<a href="$2" target="_blank">$2</a>$3/isg;
$check =~ s/(^|s)(ftp://S+)(.|,|))?/$1<a href="$2" target="_blank">$2</a>$3/isg;
$check =~ s/(^|s)(www.S+)(.|,|))?/$1<a href="http://$2" target="_blank">$2</a>$3/isg;
$check =~ s/<a href="(.+?)." target="_blank">(.+?).</a>/<a href="$1" target="_blank">$2</a>./si;
$check =~ s/(^|s)([^@[]+)@(S+).([a-z]{2,3})(.|,|))?/$1<a href="mailto:$2@$3.$4">$2@$3.$4</a>$5/si;
return ($check);
} # end auto_url
that's what I have now. (the error was happening before I installed the other hack you did(removing the period)
Posted By: Brett Re: Automatic Email Hyperlinking - 08/26/2003 5:03 AM
Finally, got a test board up and tested this out.
Code
$check =~ s/(^|s)([^<>@]+)@([a-z0-9-_.]+)(.|,|))?/$1<a href="mailto:$2@$3">$2@$3</a>$4/si;
Probably should put that above the url/period one, jic.
Posted By: Ian Spence Re: Automatic Email Hyperlinking - 08/26/2003 5:45 AM
ummm... one more problem. If I have a line break before the email, it becomes
Code
<a href="mailto:
[email protected]">
I don't think that's right tipsy

also, it won't convert more than one email per post :-/
Posted By: Brett Re: Automatic Email Hyperlinking - 08/26/2003 8:09 AM
Whoops, didn't take them into account. Here's a better patch.
Code
$check =~ s/(^|s)([^<>@nrs]+)@([a-z0-9-_.nrs]+)(.|,|))?/$1<a href="mailto:$2@$3">$2@$3</a>$4/si;
Posted By: Ian Spence Re: Automatic Email Hyperlinking - 08/26/2003 10:28 PM
ok, couple more problems.

any line breaks after the email get added to it. also, it'll sometime take the next line and add it to the link

http://www.alforadmin.com/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=10;t=000014;p=1#000005 < an example
Posted By: Charles Capps Re: Automatic Email Hyperlinking - 08/26/2003 10:59 PM
Try processing it and turning it into an [email] tag set, then let the regular processor take it from there...
© UBB.Developers