If somebody wants to add an adminCP-option to replace the hardcoded '8', please go ahead.
Code: Select all
##############################################################
## MOD Title: LimitSmiliesPerPost
## MOD Author: R. U. Serious <[email protected]> www.handykoelsch.de
## MOD Description: This will display an error message, when the number of smilies
## used in a post is more than 8.
## MOD Version: 0.9.6
##
## Installation Level: easy
## Installation Time: 8 Minutes
## Files To Edit: posting.php,
## includes/bbcode.php,
## languages/lang_english/lang_main.php
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/
##############################################################
## Author Notes:
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
function smiley_sort($a, $b)
#
#-----[ BEFORE, ADD ]------------------------------------------
#
//BEGIN LimitSmiliesPerPost MOD
function smilies_count($message)
{
static $orig, $repl;
if (!isset($orig))
{
global $db, $board_config;
$orig = $repl = array();
$sql = 'SELECT code, smile_url FROM ' . SMILIES_TABLE;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset($result);
usort($smilies, 'smiley_sort');
$number=0;
for($i = 0; $i < count($smilies); $i++)
{
$orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/";
$repl[] = '<img src="'. $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['smile_url'] . '" border="0" />';
$number += preg_match_all($orig[$i], ' ' . $message . ' ', $repl );
// $message = preg_replace($orig[$i], $repl[$i], ' ' . $message . ' ');
// $message = substr($message, 1, -1);
}
}
return $number;
}
//END LimitSmiliesPerPost MOD
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!
// -------------------------------------------------
#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['limitsmilies_error'] = "You can use a maximum of 8 smilies in a single post.<br /><br /> However your current post contains %s smilies."; // %s - number of smilies
#
#-----[ OPEN ]------------------------------------------
#
posting.php
#
#-----[ FIND ]------------------------------------------
# This is for preview-warning
obtain_word_list($orig_word, $replacement_word);
#
#-----[ AFTER, ADD ]------------------------------------------
#
$number_of_smilies=smilies_count($message);
if ($number_of_smilies > 8)
{
message_die(GENERAL_ERROR, sprintf( $lang['limitsmilies_error'], $number_of_smilies));
}
#
#-----[ FIND ]------------------------------------------
# This is for posting/submit-warning
$bbcode_uid = '';
#
#-----[ AFTER, ADD ]------------------------------------------
#
$number_of_smilies=smilies_count($message);
if ($number_of_smilies > 8)
{
message_die(GENERAL_ERROR, 'test'.sprintf( $lang['limitsmilies_error'], $number_of_smilies));
}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM