- MOD Titre: Détection de l'écriture SMS
- MOD Auteur: Aramiil
- MOD Traduction: n/a
- Sujet officiel phpBB.com: n/a
- MOD Description: Ce MOD détecte automatiquement l'écriture SMS et envoi un MP pour prévenir l'administrateur. Totalement configurable, tant au point de vu de la détection (par mots-clés ou par taille des mots) que des critères (nombre de mots et de lettres par mots) ou de l'action à effectuer (bloquage du message ou envoi d'un PM à l'administrateur).
- MOD Version: 1.0.3
- Compatibilité EasyMOD: Non testé
- Niveau d'installation: Facile
- Temps d'installation: 10 minutes
- Téléchargements: Ici
- Captures d'écran:
- Démonstrations:
- n/a
- Notes:
- la notice d'installation de ce mod se trouve dans Dectection_ecriture_SMS/français/Detection_Ecriture_SMS.txt
- Mises à Jour / Correctifs:
- Dans includes/functions.php, remplacer :
par :Code : Tout sélectionner
// //Fonction anti-sms // function sms_write($text, $mess_id, $action=1, $min_letter=3, $min_words=5, $percent=2, $admin_id=2) { //preparation des variables global $db; global $board_config; global $lang; $table_text = preg_split("/[\s[:punct:]]+/",$text); $compte = 0; $count_text = count($table_text); //chargement au besoin du fichier contenant les clefs SMS if($board_config['SMS_use_file']) { $file = file('admin/SMS_words.txt'); foreach($file as $t => $temp) { $file[$t] = rtrim($temp); } $ban_words = array_change_key_case($file, CASE_LOWER); $table_text = array_change_key_case($table_text, CASE_LOWER); $difference = array_diff($table_text, $ban_words); $compte = ($count_text - count($difference) == 0) ? '0' : ($count_text / $percent) + 1; } else { //verification de chaque mot for($t = 0; $t < $count_text; $t++) { if(strlen($table_text[$t]) <= $min_letter) $compte++; } } //test final if($count_text > $min_words && ($count_text / $percent) < $compte ) { //on regarde ce que l'on doit faire if($action == 0) { message_die(GENERAL_ERROR, $lang['SMS_message']); } else { //on envoi un pm à l'admin $html_on = 1; $bbcode_on = 1; $smilies_on = 1; $attach_sig = 1; $user_sig = $lang['SMS_sign']; $sql = "SELECT user_id, username, user_notify_pm, user_email, user_lang, user_active FROM " . USERS_TABLE . " WHERE user_id = " . $admin_id; if ( !($result = $db->sql_query($sql)) ) { $error = TRUE; $error_msg = $lang['No_such_user']; } $to_userdata = $db->sql_fetchrow($result); $to_username = $to_userdata['username']; $privmsg_subject = trim(strip_tags($lang['SMS_possible'])); $bbcode_uid = make_bbcode_uid(); $privmsg_message = prepare_message(sprintf($lang['SMS_error'], $mess_id, $board_config['server_name'] . $board_config['script_path'], $mess_id), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); $msg_time = time(); $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $privmsg_subject) . "', " . $admin_id . ", " . $to_userdata['user_id'] . ", $msg_time, '127.0.0.1', $html_on, $bbcode_on, $smilies_on, $attach_sig)"; if ( !($result = $db->sql_query($sql_info, BEGIN_TRANSACTION)) ) { message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info); } $privmsg_sent_id = $db->sql_nextid(); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . str_replace("\'", "''", $privmsg_message) . "')"; if ( !$db->sql_query($sql, END_TRANSACTION) ) { message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info); } $sql = "UPDATE " . USERS_TABLE . " SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " WHERE user_id = " . $to_userdata['user_id']; if ( !$status = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql); } } } return false; }
Code : Tout sélectionner
// //Fonction anti-sms // function sms_write($text, $mess_id, $action=1, $min_letter=3, $min_words=5, $percent=2, $admin_id=2) { //preparation des variables global $db; global $board_config; global $lang; $table_text = preg_split("/[\s[:punct:]]+/",$text); $compte = 0; $count_text = count($table_text); $word_with_problems = $lang['SMS_words_with_problems']; //chargement au besoin du fichier contenant les clefs SMS if($board_config['SMS_use_file']) { $file = file('admin/SMS_words.txt'); foreach($file as $t => $temp) { $file[$t] = rtrim($temp); } $ban_words = array_change_key_case($file, CASE_LOWER); $table_text = array_change_key_case($table_text, CASE_LOWER); $difference = array_diff($table_text, $ban_words); $sms_word = array_diff($table_text, $difference); foreach($sms_word as $mot) { if(count($sms_word) <= 1) { $word_with_problems = $lang['SMS_word_with_problems']; $word_with_problems .= $mot; } else { $word_with_problems .= $mot . ', ' ; } } $compte = ($count_text - count($difference) == 0) ? '0' : ($count_text / $percent) + 1; } else { //verification de chaque mot for($t = 0; $t < $count_text; $t++) { if(strlen($table_text[$t]) <= $min_letter) { $compte++; $word_with_problems .= $table_text[$t] . ', '; } } } //test final if($count_text > $min_words && ($count_text / $percent) < $compte ) { //on regarde ce que l'on doit faire if($action == 0) { message_die(GENERAL_ERROR, $lang['SMS_message'] . $word_with_problems); } else { //on envoi un pm à l'admin $html_on = 1; $bbcode_on = 1; $smilies_on = 1; $attach_sig = 1; $user_sig = $lang['SMS_sign']; $sql = "SELECT user_id, username, user_notify_pm, user_email, user_lang, user_active FROM " . USERS_TABLE . " WHERE user_id = " . $admin_id; if ( !($result = $db->sql_query($sql)) ) { $error = TRUE; $error_msg = $lang['No_such_user']; } $to_userdata = $db->sql_fetchrow($result); $to_username = $to_userdata['username']; $privmsg_subject = trim(strip_tags($lang['SMS_possible'])); $bbcode_uid = make_bbcode_uid(); $privmsg_message = prepare_message(sprintf($lang['SMS_error'], $mess_id, $board_config['server_name'] . $board_config['script_path'], $mess_id), $html_on, $bbcode_on, $smilies_on, $bbcode_uid); $msg_time = time(); $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $privmsg_subject) . "', " . $admin_id . ", " . $to_userdata['user_id'] . ", $msg_time, '127.0.0.1', $html_on, $bbcode_on, $smilies_on, $attach_sig)"; if ( !($result = $db->sql_query($sql_info, BEGIN_TRANSACTION)) ) { message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info); } $privmsg_sent_id = $db->sql_nextid(); $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . str_replace("\'", "''", $privmsg_message) . "')"; if ( !$db->sql_query($sql, END_TRANSACTION) ) { message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info); } $sql = "UPDATE " . USERS_TABLE . " SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " WHERE user_id = " . $to_userdata['user_id']; if ( !$status = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql); } } } return false; }
Et ajouter dans language/lang_french/lang_main.php après
Code : Tout sélectionner
// // That's all Folks! // -------------------------------------------------
Résultat :Code : Tout sélectionner
$lang['SMS_words_with_problems'] = '<br><br><b>Mots détectés comme SMS dans votre message: </b>'; $lang['SMS_word_with_problems'] = '<br><br><b>Mot détecté comme SMS dans votre message : </b>';
- Dans includes/functions.php, remplacer :