Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Owdy on September 27, 2004, 11:56:40 AM

Title: Limit smilies per post
Post by: Owdy on September 27, 2004, 11:56:40 AM
edit: use the mod please http://custom.simplemachines.org/mods/index.php?mod=430
Title: Re: Limit smilies per post
Post by: [Unknown] on September 27, 2004, 05:29:50 PM
Code: [Select]
<edit file>
Sources/Post.php
</edit file>

<search for>
$post_errors[] = 'long_message';
</search for>

<add after>
if (isset($_POST['message']))
{
$smileyLimit = 3;

$prev = substr_count($_POST['message'], '[img') + substr_count($_POST['message'], '[IMG');
$tempmsg = doUBBC($_POST['message'], true);
if (substr_count($tempmsg, '<img') > ($prev + $smileyLimit))
$post_errors[] = 'smiley_limit';
}
</add after>

<edit file>
Themes/default/languages/Post.english.php
</edit file>

<search for>
?>
</search for>

<add before>
$txt['error_smiley_limit'] = 'You can ad x smilies per post. Remove some smilyes and try again.';
</add before>

-[Unknown]
Title: Re: Limit smilies per post
Post by: DeadMetal on October 25, 2004, 12:04:10 PM
Unfortunately it doesn't work at my forum. It correctly checks the number of smileys but does not show an error message when the message exeeds the limit.

My forum is dutch (I don't have english language files installed), so added the $txt phrase to Post.dutch.php
Using SMF RC2.
Title: Re: Limit smilies per post
Post by: Owdy on October 25, 2004, 12:16:50 PM
Yes, it wont show any errors unless you dont ad that lang string to your lang file.
Title: Re: Limit smilies per post
Post by: DeadMetal on October 25, 2004, 12:38:58 PM
I did add that string to my (dutch) language  file, but no error shows up.
Title: Re: Limit smilies per post
Post by: Owdy on October 25, 2004, 12:46:00 PM
Test account? Url? :) Does it work with english?
Title: Re: Limit smilies per post
Post by: DeadMetal on October 25, 2004, 02:21:04 PM
I found the solution. I was running RC2 for Charter members and upgrading to the public RC2 solved the problem. I thought both versions were the same, but it seems that they are not.

Allright, it works great now, thanks.
I manually edited the files, is there a way to automate it, because of the format used? (<add before>  etc.)
Title: Re: Limit smilies per post
Post by: Owdy on October 25, 2004, 02:23:37 PM
It should work fine from beta6.

You can make mod from it to automate. I have made mod all my hackcs, so upgrade is easyer :)
Title: Re: Limit smilies per post
Post by: DeadMetal on October 27, 2004, 03:46:06 AM
The charter member RC2 version didn't show me errors at all (no error when no subject entered for example), so it's not the fault of this mod, but was perhaps a forum bug. It works great on the public RC2.

I searched the forum but couldn't fine any information about it: how can I create mods myself? The idea of making mods of all the hacks is great :)
Title: Re: Limit smilies per post
Post by: [Unknown] on October 27, 2004, 05:07:16 AM
Soon I will release the package SDK, version 1.0.  Hopefully.

-[Unknown]
Title: Re: Limit smilies per post
Post by: mcalan2001 on January 02, 2005, 07:18:44 AM
Help please.

On release RC2 I had worked out that the error message should be in Errors.english.php and it worked fine.

However in Final, the limit works, but I don't get an error message again.

Has there been a change in the way these messages are handled?
Title: Re: Limit smilies per post
Post by: Owdy on January 02, 2005, 09:31:06 AM
It works just fine in my forum. Have you done this?

<edit file>
Themes/default/languages/Post.english.php
</edit file>
Title: Re: Limit smilies per post
Post by: mcalan2001 on January 02, 2005, 10:54:58 AM
I have done exactly the same as on RC2, but it just doesn't seem to find the error message.
Title: Re: Limit smilies per post
Post by: Owdy on January 02, 2005, 10:56:37 AM
I use code what [Unknown] posted, and it works. I have no idea why it wont work for you.
Title: Re: Limit smilies per post
Post by: [Unknown] on January 02, 2005, 09:44:54 PM
Make sure you've scrolled down and viewed the whole thing.

-[Unknown]
Title: Re: Limit smilies per post
Post by: Fanta on January 04, 2005, 10:34:34 AM
Where do I put that code?
Title: Re: Limit smilies per post
Post by: Owdy on January 04, 2005, 01:54:24 PM
Look what code says ;)
Title: Re: Limit smilies per post
Post by: mcalan2001 on March 04, 2005, 12:39:17 PM
Make sure you've scrolled down and viewed the whole thing.
-[Unknown]

Found it  :D

At some point around RC2, it seems that the messages directory changed names, from 'Languages' to 'languages'. So I have both on my server.
Guess which one I edited.
The wrong one.
Title: Re: Limit smilies per post
Post by: Kraig K. on April 08, 2005, 09:15:18 AM
In addition to this mod, how about being able to limit the consecutive use of the same smiley?
i.e. only being able to put  :) :) :) say once or twice.
Title: Re: Limit smilies per post
Post by: Kraig K. on April 27, 2005, 10:32:12 AM
??
Title: Re: Limit smilies per post
Post by: Mike Frith on June 15, 2005, 12:26:31 PM
thanks the code works great... thanks guys
Title: Re: Limit smilies per post
Post by: dtm.exe on June 15, 2005, 01:03:18 PM
I find this to be useful, especially for the users on my forum ;).

-Dan The Man
Title: Re: Limit smilies per post
Post by: Mike Frith on June 15, 2005, 01:36:35 PM
yeah definatly... nice and simple to do as well... didnt take too long
Title: Re: Limit smilies per post
Post by: Reinno on December 12, 2005, 07:41:01 PM
I know this topic is kinda old so sorry for posting but with the next SMF release soon to come and blah blah...  :P

Ok, what I wanted to suggest was whether it would be possible to implement this great feature into SMF before the 1.1 Final release? Just thought I wanted to add my two cents here. This is a great mod.
Title: Re: Limit smilies per post
Post by: JayBachatero on December 12, 2005, 07:47:46 PM
At this moment all feature additions have been stopped and its bug checking/code cleaning time.  Maybe it will make it to 1.2/2.0.

-JayBachatero
Title: Re: Limit smilies per post
Post by: Jay T on April 20, 2006, 09:42:12 PM
Not working. Here is my section of the post.php code.

Code: [Select]
elseif (!empty($modSettings['max_messageLength']) && strlen($_POST['message']) > $modSettings['max_messageLength'])
{
$post_errors[] = 'long_message';
if (isset($_POST['message']))
{
$smileyLimit = 3;

$prev = substr_count($_POST['message'], '[img') + substr_count($_POST['message'], '[IMG');
$tempmsg = doUBBC($_POST['message'], true);
if (substr_count($tempmsg, '<img') > ($prev + $smileyLimit))
$post_errors[] = 'smiley_limit';
}
unset($_POST['message']);
Title: Re: Limit smilies per post
Post by: Owdy on April 22, 2006, 10:08:57 AM
WFM

heres mine in that area:

Code: [Select]
// Check the subject and message.
if (!isset($_POST['subject']) || htmltrim__recursive($_POST['subject']) == '')
$post_errors[] = 'no_subject';
if (!isset($_POST['message']) || htmltrim__recursive($_POST['message']) == '')
$post_errors[] = 'no_message';
elseif (!empty($modSettings['max_messageLength']) && $func['strlen']($_POST['message']) > $modSettings['max_messageLength'])
$post_errors[] = 'long_message';

 if (isset($_POST['message']))
 {
 $smileyLimit = 3;

 $prev = substr_count($_POST['message'], '[img') + substr_count($_POST['message'], '[IMG');
 $tempmsg = doUBBC($_POST['message'], true);
 if (substr_count($tempmsg, '<img') > ($prev + $smileyLimit))
 $post_errors[] = 'smiley_limit';
 }
if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && htmltrim__recursive($_POST['evtitle']) == '')
$post_errors[] = 'no_event';
// You are not!
Title: Re: Limit smilies per post
Post by: Jay T on April 24, 2006, 08:26:56 AM
Not sure but it doesnt work. I tried your code too, as it is a little different.

I really need this. Can you help me figure it out?
Title: Re: Limit smilies per post
Post by: Jay T on April 28, 2006, 08:17:37 AM
No one?
Title: Re: Limit smilies per post
Post by: CeZa on April 29, 2006, 01:16:39 PM
ok thanks unknown! ;)
Title: Re: Limit smilies per post
Post by: geezmo on May 06, 2006, 07:09:26 AM
Ok now I'm confused here. Can somebody summarize which templates needed to be edited, which codes need to be replaced, and what codes should be added if I want to apply this to 1.1 RC2. The posts here are rather confusing so I hope somebody here can update this mod. Thanks.
Title: Re: Limit smilies per post
Post by: geezmo on May 07, 2006, 04:47:56 PM
anyone?
Title: Re: Limit smilies per post
Post by: Owdy on May 08, 2006, 11:56:29 AM
anyone?

Run this via package manager. Works with SMF 1.1 RC2 with english language. Enjoy.
Title: Re: Limit smilies per post
Post by: GetRank on June 16, 2006, 12:48:09 PM
Thanks.. works great
Title: Re: Limit smilies per post
Post by: PrizeLive.com on July 09, 2006, 07:07:42 PM
Installed smoothly and modified to allow 5 smilies.... Thanks!!
Title: Re: Limit smilies per post
Post by: Brianw1212 on July 16, 2006, 07:57:59 PM
Hi guys, installed this mod and it works great.. my only question is how do i change the number of smileys allowed in a post? The default is set at 3, but I want to change it to 4 if possible.

Thanks
Title: Re: Limit smilies per post
Post by: PrizeLive.com on July 16, 2006, 08:02:57 PM
Hi guys, installed this mod and it works great.. my only question is how do i change the number of smileys allowed in a post? The default is set at 3, but I want to change it to 4 if possible.

Thanks

In Modifications.english.php

Find:

Code: [Select]
$txt['error_smiley_limit'] = 'Max 3 smiles please. Remove smilies and try again.
Replace With:

Code: [Select]
$txt['error_smiley_limit'] = 'Max 4 smiles please. Remove smilies and try again.
In Post.php

Find:

Code: [Select]
$smileyLimit = 3;
Replace With:

Code: [Select]
$smileyLimit = 4;
That should do it for you...  ;D
Title: Re: Limit smilies per post
Post by: Brianw1212 on July 16, 2006, 08:13:37 PM
Hi guys, installed this mod and it works great.. my only question is how do i change the number of smileys allowed in a post? The default is set at 3, but I want to change it to 4 if possible.

Thanks

In Modifications.english.php

Find:

Code: [Select]
$txt['error_smiley_limit'] = 'Max 3 smiles please. Remove smilies and try again.
Replace With:

Code: [Select]
$txt['error_smiley_limit'] = 'Max 4 smiles please. Remove smilies and try again.
In Post.php

Find:

Code: [Select]
$smileyLimit = 3;
Replace With:

Code: [Select]
$smileyLimit = 4;
That should do it for you...  ;D

Great!

I'll try it tonight..  thanks alot   :)

Title: Re: Limit smilies per post
Post by: Brianw1212 on July 16, 2006, 08:54:42 PM
Just one more quick question...

Is there a way to limit the smileys in an actual post and have it not count the ones that are included in a quote?

For example, since installing the smiley mod, alot of my members have been complaining that when they quote someone who has used 3 smileys in their post, they're not allowed to use any because the limit per post is 3.. so they're having to go back and edit out the smileys in the quote in order to post some smileys of their own...

I'm curious if there is a fix for this..  thanks
Title: Re: Limit smilies per post
Post by: Owdy on July 16, 2006, 11:12:21 PM
Hi guys, installed this mod and it works great.. my only question is how do i change the number of smileys allowed in a post? The default is set at 3, but I want to change it to 4 if possible.

Thanks
First post ;)

You can set that limit number in this $smileyLimit = 3;

Title: Re: Limit smilies per post
Post by: Brianw1212 on July 18, 2006, 03:44:40 AM
Hi guys, installed this mod and it works great.. my only question is how do i change the number of smileys allowed in a post? The default is set at 3, but I want to change it to 4 if possible.

Thanks
First post ;)

You can set that limit number in this $smileyLimit = 3;


Owdy, I'm going to direct this to you because it's your mod. I don't know if you read my previous post or not, but I was wondering if there was a way to limit the smileys per post and not have the ones in a quote to count towards the limit amount. For example, if the limit is 3, and i quote someone who has used 2 in his post, i can only use 1 because he already used 2 and i'm quoting him.. Is there any way to get around that?

Thanks
Title: Re: Limit smilies per post
Post by: Owdy on July 18, 2006, 01:25:56 PM
That i dont know. My php isint that good ;D
Title: Re: Limit smilies per post
Post by: Brianw1212 on July 18, 2006, 01:55:54 PM
That i dont know. My php isint that good ;D

I'm attempted to play around with it myself and see if i could figure it out.. although i can guarantee your php is better than my php   :D

Title: Re: Limit smilies per post
Post by: RODEOSOLSTICE on January 17, 2007, 12:52:44 PM
smileyLimit.zip

This is a great mod, and I definatly need it. It works on my V1.1, but not on V1.1.1

Any way to get it working for V1.1.1

and, newbie question. What is RC2 and RC3??

thanks!
Title: Re: Limit smilies per post
Post by: RODEOSOLSTICE on January 17, 2007, 08:04:09 PM
smileyLimit.zip

This is a great mod, and I definatly need it. It works on my V1.1, but not on V1.1.1

Any way to get it working for V1.1.1

and, newbie question. What is RC2 and RC3??

thanks!

Please forgive me, I found the solution here:
http://www.simplemachines.org/community/index.php?topic=107685.msg898559#msg898559

I'd still like to know what RC1 etc means??
Title: Re: Limit smilies per post
Post by: Owdy on June 14, 2007, 03:25:38 PM
Code updated for SMF 1.1.2. Please read first post.
Title: Re: Limit smilies per post
Post by: MultiformeIngegno on November 17, 2008, 05:50:43 PM
Hi, I dredge this old topic to ask you how can I limit the number of smilies per post in SMF 2.0b4.. please help me! :)

'bye! ;)
Title: Re: Limit smilies per post
Post by: Diabolo.ca on November 18, 2008, 03:31:34 AM
Just a few small changes needed to make it work in 2.0 beta 4. The new edits:
Code: [Select]
<edit file>
Sources/Post.php
</edit file>

<search for>
    $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
</search for>

<add after>
      if (isset($_POST['message']))
 {
 $smileyLimit = 3;

$prev = substr_count(strtolower($_POST['message']), '[img');
 $tempmsg = parse_bbc($_POST['message'], true);
 if (substr_count($tempmsg, '<img') > ($prev + $smileyLimit))
 $post_errors[] = 'smiley_limit';
 }
</add after>

<edit file>
Themes/default/languages/Modifications.english.php
</edit file>

<search for>
?>
</search for>

<add before>
$txt['error_smiley_limit'] = 'You can only have 3 smileys per post. Remove some smileys and try again.';
</add before>

But here's the kicker that had me puzzled at first. Read the comments at the beginning of index.english.php:
Quote
/* Important note about language files in SMF 2.0 upwards:
   1) All language entries in SMF 2.0 are cached. All edits should therefore be made through the admin menu. If you do
      edit a language file manually you will not see the changes in SMF until the cache refreshes. To manually refresh
      the cache go to Admin => Maintenance => Clean Cache.

In other words, with 2.0, until you delete the old cache files you won't see the warning you added, although the posts with more than 3 smileys will still be rejected.

I assume similar updates could be made to the official mod (http://custom.simplemachines.org/mods/index.php?mod=430) as well to update for 2.0.
Title: Re: Limit smilies per post
Post by: sirNemanjapro on July 14, 2010, 06:53:44 PM
Is this working for SMF 1.1.11 or is there option in the board?

I have just checked, 1.1.11 doesn't have an limit number of smileys per post.


So, question is. Can I use this code that is updated for my installation?
Title: Re: Limit smilies per post
Post by: MultiformeIngegno on July 15, 2010, 08:40:54 AM
Does this still work with RC3? I repeat that IMO this feature should be available by default...
Title: Re: Limit smilies per post
Post by: Owdy on July 15, 2010, 09:19:47 AM
http://custom.simplemachines.org/mods/index.php?mod=430