Previous Thread
Next Thread
Print Thread
Rate Thread
#56104 08/06/2003 6:39 PM
Joined: May 2001
Posts: 283
Member
Member
Offline
Joined: May 2001
Posts: 283
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?

Sponsored Links
Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
Joined: May 2001
Posts: 1,042
Likes: 7
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.

Joined: May 2001
Posts: 283
Member
Member
Offline
Joined: May 2001
Posts: 283
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.

Joined: May 2001
Posts: 283
Member
Member
Offline
Joined: May 2001
Posts: 283
I added a backslash before the two @ at the end of the line and it seems to work now.

Sound right?

Joined: May 2001
Posts: 283
Member
Member
Offline
Joined: May 2001
Posts: 283
Oooh, there's a problem...

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


Sponsored Links
Joined: May 2001
Posts: 283
Member
Member
Offline
Joined: May 2001
Posts: 283
Bump. Any more help available out there???

Joined: May 2001
Posts: 283
Member
Member
Offline
Joined: May 2001
Posts: 283
bump.2

Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
Joined: May 2001
Posts: 1,042
Likes: 7
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;

Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
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

Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
Joined: May 2001
Posts: 1,042
Likes: 7
Oops! Had an extra =~, sorry. Fixed.

Sponsored Links
Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
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.

Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
Joined: May 2001
Posts: 1,042
Likes: 7
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...

Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
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)

Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
Joined: May 2001
Posts: 1,042
Likes: 7
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.

Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
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 :-/

Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
Joined: May 2001
Posts: 1,042
Likes: 7
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;

Joined: Jan 2003
Posts: 3,456
Likes: 2
Master Hacker
Master Hacker
Offline
Joined: Jan 2003
Posts: 3,456
Likes: 2
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

Joined: Jan 2000
Posts: 5,073
Admin Emeritus
Admin Emeritus
Joined: Jan 2000
Posts: 5,073
Try processing it and turning it into an [email] tag set, then let the regular processor take it from there...


UBB.classic: Love it or hate it, it was mine.

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)