Customizing SMF > Tips and Tricks
Limit smilies per post
Grudge:
OK. Well... my old code was *really* bad and this isn't much better but it's quick and easy.
Open sources/post.php
Find:
--- Code: --- // Preparse code. (Zef)
if ($user_info['is_guest'])
$user_info['name'] = $_POST['guestname'];
preparsecode($_POST['message']);
--- End code ---
Add directly under it:
--- Code: --- $smileyLimit = 12;
$prev = substr_count($_POST['message'],'<IMG') + substr_count($_POST['message'],'<img');
$tempmsg = DoUBBC($_POST['message'], 1);
if ((substr_count($tempmsg,'<IMG') + substr_count($tempmsg,'<img')) > ($prev + $smileyLimit))
fatal_error('You may not use more than ' . $smileyLimit . ' smileys in your post!');
--- End code ---
Then just change $smileyLimit to the limit. Note - this counts smileys and images (it's better this way). It pretty n00bie like code but it should work and not mess up people posting code etc :)
If you want to count just smilies make the line starting $prev equal:
--- Code: ---$prev = substr_count($_POST['message'],'<IMG') + substr_count($_POST['message'],'<img') + substr_count($_POST['message'],'[img') + substr_count($_POST['message'],'[IMG');
--- End code ---
Hope this works - haven't tested it. No blamesies if it doesn't :P
Owdy:
Grudge, that worked perfectly. THank u! :D
Owdy:
Hmmm, how can i ad back link in that smoothly?
Grudge:
I assume you mean so members don't lose their posts... OK. I'll come up with something a sec :)
Owdy:
Yes, thats what i ment. :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version