Previous Thread
Next Thread
Print Thread
Rate Thread
#213043 11/26/2001 11:03 PM
Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
Here's an adaptation of Gerrit's automatic smileys hack, posted on the Perl board on https://www.ubbdev.com/threads/perl/showthreaded.pl?Cat=&Board=custom&Number=34040

With this hack, smileys are automatically converted to markup, so if you type in :-) , you get []https://www.ubbdev.com/threads/php/images/icons/smile.gif[/] , etc

In ubbt.inc.php, after line 442 which is
$Body = eregi_replace("\[$lang[ICON_WINK]\]","<img src="$config[images]/icons/wink.gif">",$Body);

enter the following section:

// Automatically convert text smileys to graphics ***** Added *****
$Body = eregi_replace("\:-\)","<img src="$config[images]/icons/smile.gif">",$Body);
$Body = eregi_replace("\}\:-\(","<img src="$config[images]/icons/mad.gif">",$Body);
$Body = eregi_replace("\:-\(","<img src="$config[images]/icons/frown.gif">",$Body);
$Body = eregi_replace("\:-o","<img src="$config[images]/icons/blush.gif">",$Body);
$Body = eregi_replace("8-\)","<img src="$config[images]/icons/cool.gif">",$Body);
$Body = eregi_replace("\:-\}","<img src="$config[images]/icons/crazy.gif">",$Body);
$Body = eregi_replace("\:-D","<img src="$config[images]/icons/laugh.gif">",$Body);
$Body = eregi_replace("\:-O","<img src="$config[images]/icons/shocked.gif">",$Body);
$Body = eregi_replace("\:-P","<img src="$config[images]/icons/tongue.gif">",$Body);
$Body = eregi_replace("\;-\)","<img src="$config[images]/icons/wink.gif">",$Body);

That should be it!
Max

Sponsored Links
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
nice one []https://www.ubbdev.com/threads/php/images/icons/smile.gif[/]

This is being done on 5.5 as well, helps my slow fingers for sure :)

Do most people use the - in smilies? As in :-), or do you just type in smile ? I've been used to the shorter method for so long, I guess it would be easy enough to just add both to the files so they both work smile


- Allen wavey
- What Drives You?
Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
I actually use the short form myself - but I kindof like forcing the "-", that way there are fewer "accidental" translations.

Some users don't like the automatic translation, find the graphics goofy, and this way they're not forced to switch off Markup to make their posts.

Just my 2 cents.

By the way, please note that I modified one of the smileys: the original "mad" symbol, >:-( , was giving me problems for some reason, so I modified it to }:-(

Cheers,
Max

Joined: Oct 2000
Posts: 60
Power User
Power User
Offline
Joined: Oct 2000
Posts: 60
It's because of html tags. I actually made a hack to do smileys a while back. You can find my version here in the various subdirectories. The only real differences between versions are the line numbers updated.

This line in particular is probably what you're looking for:
$Body = eregi_replace("<br<img src="$config[images]/icons/mad.gif">","<br><img src="$config[images]/icons/frown.gif">",$Body);

Bommer #213047 11/28/2001 10:21 AM
Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
Thanks powerlord,

but that's not it... I continue to have a problem with > .

If I'm interpreting your line correctly, it would correct situations where a newline is followed by :-( , and the closing bracket of <br> is getting incorrectly incorporated into the translation.

The actual situation I'm describing is that >:-( is not getting translated into "mad" at all, the > is getting ignored and I get the following:
>[]https://www.ubbdev.com/threads/php/images/icons/frown.gif[/] instead of []https://www.ubbdev.com/threads/php/images/icons/mad.gif[/]

As soon as I replace the closing bracket with another character, the problem goes away.

Regards,
Max

Sponsored Links
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
we use mad in ubb, you might consider that one... it's easy to type and all smile


- Allen wavey
- What Drives You?
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Does your regex for mad come before frown? If frown comes first then it is going to match that first and give you this problem.


UBB.threads Developer
Sally #213050 11/28/2001 11:27 AM
Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
Nope... that was actually my first thought. I tried removing all other translations, with no success.

Note that I was having the same problem in Perl, as per the discussion on https://www.ubbdev.com/threads/perl/showthreaded.pl?Cat=&Board=custom&Number=43145 .

I wonder if it's something specific to my server/php/mysql installation. In any case, I don't think it's too important: I think I disagree with the use of > as part of an automatically translated smiley: it creates too many exception conditions, that would need to be reverse-translated. These were heroically identified by Powerlord on http://www.vgmusic.com/~powerlord/wwwthreads/5.4.4php/Smileys.txt

Max

Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
Well, that's not too different from using the traditional markup.
Max

Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Ah, it's probably the > that is doing it. Normally this is an HTML character, so it get's translated to > on boards where HTML is not enabled. Which is probably why it isn't matching.


UBB.threads Developer
Sponsored Links
Sally #213053 11/28/2001 3:35 PM
Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
Ah, ok, that makes sense. I'll stick to } , since I don't want to have multiple translation/untranslation routines depending on whether html is enabled or not on that particular post (I allow users to select).
Max

Joined: Oct 2000
Posts: 60
Power User
Power User
Offline
Joined: Oct 2000
Posts: 60
That's probably a good idea.

I'd be interested in seeing how Scream does it in the next version. I prefer getting rid of my hacks in favor of built in functions. :)

Oh, you might have noticed an adaptation of Eileen's Icons4Attachments in my directories. I'm surprised that Scream hasn't made something like that part of the main distribution, or at least the part that has an icon next to the word Attachment.

The one next to the topics in expanded mode on the postlist page isn't all that important, but my users like having a visual to cue them in to what type of file is attached. (Did I mention that one of my sites boards has a lot of files attached?)

Bommer #213055 11/28/2001 6:06 PM
Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
> I prefer getting rid of my hacks in favor of built in functions.

Same here!

> Oh, you might have noticed an adaptation of Eileen's
> Icons4Attachments in my directories

I don't use icons on my boards... too many gizmos make me dizzy :)

Max

Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3


- Allen wavey
- What Drives You?

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
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
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)