Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: Owdy in September 27, 2004, 11:56:40 VORMITTAG

Titel: Limit smilies per post
Beitrag von: Owdy in September 27, 2004, 11:56:40 VORMITTAG
edit: use the mod please http://custom.simplemachines.org/mods/index.php?mod=430
Titel: Re: Limit smilies per post
Beitrag von: [Unknown] in September 27, 2004, 05:29:50 NACHMITTAGS
<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]
Titel: Re: Limit smilies per post
Beitrag von: DeadMetal in Oktober 25, 2004, 12:04:10 NACHMITTAGS
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.
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Oktober 25, 2004, 12:16:50 NACHMITTAGS
Yes, it wont show any errors unless you dont ad that lang string to your lang file.
Titel: Re: Limit smilies per post
Beitrag von: DeadMetal in Oktober 25, 2004, 12:38:58 NACHMITTAGS
I did add that string to my (dutch) language  file, but no error shows up.
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Oktober 25, 2004, 12:46:00 NACHMITTAGS
Test account? Url? :) Does it work with english?
Titel: Re: Limit smilies per post
Beitrag von: DeadMetal in Oktober 25, 2004, 02:21:04 NACHMITTAGS
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.)
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Oktober 25, 2004, 02:23:37 NACHMITTAGS
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 :)
Titel: Re: Limit smilies per post
Beitrag von: DeadMetal in Oktober 27, 2004, 03:46:06 VORMITTAG
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 :)
Titel: Re: Limit smilies per post
Beitrag von: [Unknown] in Oktober 27, 2004, 05:07:16 VORMITTAG
Soon I will release the package SDK, version 1.0.  Hopefully.

-[Unknown]
Titel: Re: Limit smilies per post
Beitrag von: mcalan2001 in Januar 02, 2005, 07:18:44 VORMITTAG
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?
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Januar 02, 2005, 09:31:06 VORMITTAG
It works just fine in my forum. Have you done this?

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

-[Unknown]
Titel: Re: Limit smilies per post
Beitrag von: Fanta in Januar 04, 2005, 10:34:34 VORMITTAG
Where do I put that code?
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Januar 04, 2005, 01:54:24 NACHMITTAGS
Look what code says ;)
Titel: Re: Limit smilies per post
Beitrag von: mcalan2001 in März 04, 2005, 12:39:17 NACHMITTAGS
Zitat von: [Unknown] in Januar 02, 2005, 09:44:54 NACHMITTAGS
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.
Titel: Re: Limit smilies per post
Beitrag von: Kraig K. in April 08, 2005, 09:15:18 VORMITTAG
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.
Titel: Re: Limit smilies per post
Beitrag von: Kraig K. in April 27, 2005, 10:32:12 VORMITTAG
??
Titel: Re: Limit smilies per post
Beitrag von: Mike Frith in Juni 15, 2005, 12:26:31 NACHMITTAGS
thanks the code works great... thanks guys
Titel: Re: Limit smilies per post
Beitrag von: dtm.exe in Juni 15, 2005, 01:03:18 NACHMITTAGS
I find this to be useful, especially for the users on my forum ;).

-Dan The Man
Titel: Re: Limit smilies per post
Beitrag von: Mike Frith in Juni 15, 2005, 01:36:35 NACHMITTAGS
yeah definatly... nice and simple to do as well... didnt take too long
Titel: Re: Limit smilies per post
Beitrag von: Reinno in Dezember 12, 2005, 07:41:01 NACHMITTAGS
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.
Titel: Re: Limit smilies per post
Beitrag von: JayBachatero in Dezember 12, 2005, 07:47:46 NACHMITTAGS
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
Titel: Re: Limit smilies per post
Beitrag von: Jay T in April 20, 2006, 09:42:12 NACHMITTAGS
Not working. Here is my section of the post.php code.

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']);
Titel: Re: Limit smilies per post
Beitrag von: Owdy in April 22, 2006, 10:08:57 VORMITTAG
WFM

heres mine in that area:

// 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!
Titel: Re: Limit smilies per post
Beitrag von: Jay T in April 24, 2006, 08:26:56 VORMITTAG
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?
Titel: Re: Limit smilies per post
Beitrag von: Jay T in April 28, 2006, 08:17:37 VORMITTAG
No one?
Titel: Re: Limit smilies per post
Beitrag von: CeZa in April 29, 2006, 01:16:39 NACHMITTAGS
ok thanks unknown! ;)
Titel: Re: Limit smilies per post
Beitrag von: geezmo in Mai 06, 2006, 07:09:26 VORMITTAG
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.
Titel: Re: Limit smilies per post
Beitrag von: geezmo in Mai 07, 2006, 04:47:56 NACHMITTAGS
anyone?
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Mai 08, 2006, 11:56:29 VORMITTAG
Zitat von: geezmo in Mai 07, 2006, 04:47:56 NACHMITTAGS
anyone?

Run this via package manager. Works with SMF 1.1 RC2 with english language. Enjoy.
Titel: Re: Limit smilies per post
Beitrag von: GetRank in Juni 16, 2006, 12:48:09 NACHMITTAGS
Thanks.. works great
Titel: Re: Limit smilies per post
Beitrag von: PrizeLive.com in Juli 09, 2006, 07:07:42 NACHMITTAGS
Installed smoothly and modified to allow 5 smilies.... Thanks!!
Titel: Re: Limit smilies per post
Beitrag von: Brianw1212 in Juli 16, 2006, 07:57:59 NACHMITTAGS
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
Titel: Re: Limit smilies per post
Beitrag von: PrizeLive.com in Juli 16, 2006, 08:02:57 NACHMITTAGS
Zitat von: Brianw1212 in Juli 16, 2006, 07:57:59 NACHMITTAGS
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:

$txt['error_smiley_limit'] = 'Max 3 smiles please. Remove smilies and try again.

Replace With:

$txt['error_smiley_limit'] = 'Max 4 smiles please. Remove smilies and try again.

In Post.php

Find:

$smileyLimit = 3;

Replace With:

$smileyLimit = 4;

That should do it for you...  ;D
Titel: Re: Limit smilies per post
Beitrag von: Brianw1212 in Juli 16, 2006, 08:13:37 NACHMITTAGS
Zitat von: SurfExcelerator.com in Juli 16, 2006, 08:02:57 NACHMITTAGS
Zitat von: Brianw1212 in Juli 16, 2006, 07:57:59 NACHMITTAGS
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:

$txt['error_smiley_limit'] = 'Max 3 smiles please. Remove smilies and try again.

Replace With:

$txt['error_smiley_limit'] = 'Max 4 smiles please. Remove smilies and try again.

In Post.php

Find:

$smileyLimit = 3;

Replace With:

$smileyLimit = 4;

That should do it for you...  ;D

Great!

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

Titel: Re: Limit smilies per post
Beitrag von: Brianw1212 in Juli 16, 2006, 08:54:42 NACHMITTAGS
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
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Juli 16, 2006, 11:12:21 NACHMITTAGS
Zitat von: Brianw1212 in Juli 16, 2006, 07:57:59 NACHMITTAGS
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 ;)
Zitat von: Owdy in September 27, 2004, 11:56:40 VORMITTAG

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

Titel: Re: Limit smilies per post
Beitrag von: Brianw1212 in Juli 18, 2006, 03:44:40 VORMITTAG
Zitat von: Owdy in Juli 16, 2006, 11:12:21 NACHMITTAGS
Zitat von: Brianw1212 in Juli 16, 2006, 07:57:59 NACHMITTAGS
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 ;)
Zitat von: Owdy in September 27, 2004, 11:56:40 VORMITTAG

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
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Juli 18, 2006, 01:25:56 NACHMITTAGS
That i dont know. My php isint that good ;D
Titel: Re: Limit smilies per post
Beitrag von: Brianw1212 in Juli 18, 2006, 01:55:54 NACHMITTAGS
Zitat von: Owdy in Juli 18, 2006, 01:25:56 NACHMITTAGS
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

Titel: Re: Limit smilies per post
Beitrag von: RODEOSOLSTICE in Januar 17, 2007, 12:52:44 NACHMITTAGS
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!
Titel: Re: Limit smilies per post
Beitrag von: RODEOSOLSTICE in Januar 17, 2007, 08:04:09 NACHMITTAGS
Zitat von: RODEOSOLSTICE in Januar 17, 2007, 12:52:44 NACHMITTAGS
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??
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Juni 14, 2007, 03:25:38 NACHMITTAGS
Code updated for SMF 1.1.2. Please read first post.
Titel: Re: Limit smilies per post
Beitrag von: MultiformeIngegno in November 17, 2008, 05:50:43 NACHMITTAGS
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! ;)
Titel: Re: Limit smilies per post
Beitrag von: Diabolo.ca in November 18, 2008, 03:31:34 VORMITTAG
Just a few small changes needed to make it work in 2.0 beta 4. The new edits:

<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:
Zitat/* 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.
Titel: Re: Limit smilies per post
Beitrag von: sirNemanjapro in Juli 14, 2010, 06:53:44 NACHMITTAGS
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?
Titel: Re: Limit smilies per post
Beitrag von: MultiformeIngegno in Juli 15, 2010, 08:40:54 VORMITTAG
Does this still work with RC3? I repeat that IMO this feature should be available by default...
Titel: Re: Limit smilies per post
Beitrag von: Owdy in Juli 15, 2010, 09:19:47 VORMITTAG
http://custom.simplemachines.org/mods/index.php?mod=430