Le site des utilisateurs francophones de FluxBB.
Vous n'êtes pas identifié(e).
Pages : 1
Bonjour,
Je viens de réinstaller mon forum FluxBB il y a deux jours et les bots spammeur l'ont déjà trouvé...
Je cherche donc une mod ou un plugin pouvant être installé avec Patcher et permettant de mettre en place des sécurités pour éviter l'inscription de robot spammeurs.
Merci. 
Bonne journée.
Dernière modification par LolYangccool (16-05-2014 17:02:21)
Hors ligne
Bonsoir ,
c'est quels version de forum ? sinon essayer avec cette mod http://fluxbb.org/resources/mods/spambarrier/ qui est très efficace par contre je ne sait pas si elle peut être installer avec la mod Patcher ,Perso je n'utilise pas cette mod moi qui préfère la bonne veille méthode à la main
essayer pour voir en uploadant ...
autre mod : http://fluxbb.org/resources/mods/?s=key … all&o=name
cdlt
Dernière modification par david18 (16-05-2014 17:49:40)
Hors ligne
Bonjour,
J'utilise la dernière version du forum, c'est-à-dire la version 1.5.6.
Je vais déjà essayer d'installer la première modification que tu as proposé.
Merci.
Bonne soirée.
Hors ligne
Bonjour,
Il existe VSABR (Very Simple Anti Bot Regsitration) qui a une version française et qui s'installe (presque) en un clic par Mod Installer.
La discussion afférente à cette mod est ici et le téléchargement là.
Ce n'est pas parce que l'erreur se propage qu'elle devient vérité. Gandhi
Sont différents : ça et sa - est et ait - à et a - ce et se - mes et mais ou met - été et était - c'est et ces - ce-si et ceci
La vie sans musique est tout simplement une erreur, une fatigue, un exil. Friedrich Nietzsche
Hors ligne
Merci beaucoup. Je regarde le topic et j'essaye de l'installer avec Patcher. 
La mod que m'a suggéré david18 ne fonctionne apparemment aps sur la version de FluxBB que j'ai installé.
Hors ligne
J'ai un petit soucis avec VSABR, celui-ci me dit qu'il manque un fichier :
Une idée ?
Merci beaucoup à vous. 
Hors ligne
Bonjour,
VSABR est prévu pour être installé avec Mod Installer et, avec Mod Installer, la présence ou non du fichier include/quickpost.php est testée et le script d'installation est modifié en conséquence (Cela pour être compatible avec la mod Reverse Message Order).
Néanmoins, voici un fichier readme.txt qui ne tient pas compte du fichier include/quickpost.php.
#--- MOD Very Simple AntiBot Registration (VSABR)
Version: 1.5.11
Release date: 2014-03-29
Cette modification ajoute une question simple à la fin du formulaire d'inscription.
La question est obtenue de façon aléatoire à partir d'une liste de phrases, les réponses étant sous forme numérique.
Les questions sont de la forme : « Combien font deux plus deux ? » et toutes les réponses sont du niveau de l'école primaire.
Vous pouvez écrire vos propres questions et réponses dans le fichier de langue
lang/votre_langue/mod_very_simple_antibot.php.
Les questions peuvent être différentes selon les langues.
Option possible :
- La vérification se fera également pour les messages envoyés par les invités, si ils sont autorisés à poster. Pour supprimer cette option, modifiez le fichier search_insert.php avant d'installer, selon les indications notées dans ce fichier.
- Les éventuelles réponses textuelles sont automatiquement mises en majuscules. Pour rendre les réponses sensibles à la casse, modifier le fichier search_insert.php avant d'installer, selon les indications notées dans ce fichier
======================[ MANUAL INSTALLATION PROCEDURE ]=======================
Note: There may be several times the opening and saving the same file.
This is due to changes order that are made by type and not by files.
Are performed, in order: Insert before, Add after, Replace then Move
#----[ FOLLOW THE FOLLOWING STEPS TO MAKE THE CHANGES TO FILES ]----
#---[ 1 OPEN ]----------------------------------------------------------------
register.php
#--[ 2 FIND ] Info: $search_file[register][0]---------------------------------
<p class="buttons"><input type="submit" name="register"
#--[ 3 INSERT BEFORE ] Info: $insert_file[register][0]------------------------
<!-- [modif oto] - mod VSABR Very Simple AntiBot Registration -->
<div class="inform">
<fieldset>
<legend><?php echo $lang_mod_vsabr['Robot title'] ?></legend>
<div class="infldset">
<p><?php echo $lang_mod_vsabr['Robot info'] ?></p>
<label class="required"><strong><?php
$question = array_keys($mod_vsabr_questions);
$qencoded = md5($question[$mod_vsabr_index]);
echo sprintf($lang_mod_vsabr['Robot question'],$question[$mod_vsabr_index]);?>
<span><?php echo $lang_common['Required'] ?></span></strong>
<input name="captcha" id="captcha" type="text" size="10" maxlength="30" /><input name="captcha_q" value="<?php echo $qencoded ?>" type="hidden" /><input type="hidden" name="username" value="" /><br />
</label>
</div>
</fieldset>
</div>
<!-- [modif oto] - End mod VSABR -->
#--[ 4 FIND ] Info: $search_file[register][1]---------------------------------
// Validate email
#--[ 5 INSERT BEFORE ] Info: $insert_file[register][1]------------------------
//[modif oto] - mod VSABR Very Simple AntiBot Registration - Validate answer to the question
$mod_vsabr_p_question = isset($_POST['captcha_q']) ? trim($_POST['captcha_q']) : '';
$mod_vsabr_p_answer = isset($_POST['captcha']) ? strtoupper(trim($_POST['captcha'])) : '';
$mod_vsabr_questions_array = array();
foreach ($mod_vsabr_questions as $k => $v)
$mod_vsabr_questions_array[md5($k)] = strtoupper($v);
if (empty($mod_vsabr_questions_array[$mod_vsabr_p_question]) || $mod_vsabr_questions_array[$mod_vsabr_p_question] != $mod_vsabr_p_answer)
$errors[] = $lang_mod_vsabr['Robot test fail'];
//[modif oto] - End mod VSABR
#--[ 6 FIND ] Info: $search_file[register][2]---------------------------------
// Load the register.php language file
#--[ 7 INSERT BEFORE ] Info: $insert_file[register][2]------------------------
// [modif oto] - mod VSABR Very Simple AntiBot Registration - Add language file
if(file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/mod_very_simple_antibot.php'))
require PUN_ROOT.'lang/'.$pun_user['language'].'/mod_very_simple_antibot.php';
else
require PUN_ROOT.'lang/English/mod_very_simple_antibot.php';
$mod_vsabr_index = rand(0,count($mod_vsabr_questions)-1);
// [modif oto] - End mod VSABR
******************************************************************************
#-------[ 8 SAVE FILE register.php ]
******************************************************************************
#---[ 9 OPEN ]----------------------------------------------------------------
post.php
#--[ 10 FIND ] Info: $search_file[post][0]------------------------------------
<p class="buttons"><input type="submit" name="submit"
#--[ 11 INSERT BEFORE ] Info: $insert_file[post][0]---------------------------
<?php //[modif oto] - mod VSABR Very Simple AntiBot Registration
if($pun_user['is_guest']) : ?>
<div class="inform">
<fieldset>
<legend><?php echo $lang_mod_vsabr['Robot title'] ?></legend>
<div class="infldset">
<p><?php echo $lang_mod_vsabr['Robot info'] ?></p>
<label class="required"><strong><?php
$question = array_keys($mod_vsabr_questions);
$qencoded = md5($question[$mod_vsabr_index]);
echo sprintf($lang_mod_vsabr['Robot question'],$question[$mod_vsabr_index]);?>
<span><?php echo $lang_common['Required'] ?></span></strong>
<input name="captcha" id="captcha" type="text" size="10" maxlength="30" /><input name="captcha_q" value="<?php echo $qencoded ?>" type="hidden" /><br />
</label>
</div>
</fieldset>
</div>
<?php endif; //[modif oto] - End mod VSABR ?>
#--[ 12 FIND ] Info: $search_file[post][1]------------------------------------
// Flood protection
#--[ 13 INSERT BEFORE ] Info: $insert_file[post][1]---------------------------
//[modif oto] - mod VSABR Very Simple AntiBot Registration - Validate answer to the question
if($pun_user['is_guest']) {
$mod_vsabr_p_question = isset($_POST['captcha_q']) ? trim($_POST['captcha_q']) : '';
$mod_vsabr_p_answer = isset($_POST['captcha']) ? strtoupper(trim($_POST['captcha'])) : '';
$mod_vsabr_questions_array = array();
foreach ($mod_vsabr_questions as $k => $v)
$mod_vsabr_questions_array[md5($k)] = strtoupper($v);
if (empty($mod_vsabr_questions_array[$mod_vsabr_p_question]) || $mod_vsabr_questions_array[$mod_vsabr_p_question] != $mod_vsabr_p_answer)
$errors[] = $lang_mod_vsabr['Robot test fail'];
}
//[modif oto] - End mod VSABR
#--[ 14 FIND ] Info: $search_file[post][2]------------------------------------
// Load the post.php language file
#--[ 15 INSERT BEFORE ] Info: $insert_file[post][2]---------------------------
// [modif oto] - mod VSABR Very Simple AntiBot Registration - Add language file
if(file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/mod_very_simple_antibot.php'))
require PUN_ROOT.'lang/'.$pun_user['language'].'/mod_very_simple_antibot.php';
else
require PUN_ROOT.'lang/English/mod_very_simple_antibot.php';
$mod_vsabr_index = rand(0,count($mod_vsabr_questions)-1);
// [modif oto] - End mod VSABR
******************************************************************************
#-------[ 16 SAVE FILE post.php ]
******************************************************************************
#---[ 17 OPEN ]---------------------------------------------------------------
viewtopic.php
#--[ 18 FIND ] Info: $search_file[viewtopic][0]-------------------------------
// Load the viewtopic.php language file
#--[ 19 INSERT BEFORE ] Info: $insert_file[viewtopic][0]----------------------
// [modif oto] - mod VSABR Very Simple AntiBot Registration - Add language file
if(file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/mod_very_simple_antibot.php'))
require PUN_ROOT.'lang/'.$pun_user['language'].'/mod_very_simple_antibot.php';
else
require PUN_ROOT.'lang/English/mod_very_simple_antibot.php';
$mod_vsabr_index = rand(0,count($mod_vsabr_questions)-1);
// [modif oto] - End mod VSABR
#--[ 20 FIND ] Info: $search_file[viewtopic][1]-------------------------------
<p class="buttons"><input type="submit" name="submit"
#--[ 21 INSERT BEFORE ] Info: $insert_file[viewtopic][1]----------------------
<?php //[modif oto] - mod VSABR Very Simple AntiBot Registration
if($pun_user['is_guest']) : ?>
<div class="inform">
<fieldset>
<legend><?php echo $lang_mod_vsabr['Robot title'] ?></legend>
<div class="infldset">
<p><?php echo $lang_mod_vsabr['Robot info'] ?></p>
<label class="required"><strong><?php
$question = array_keys($mod_vsabr_questions);
$qencoded = md5($question[$mod_vsabr_index]);
echo sprintf($lang_mod_vsabr['Robot question'],$question[$mod_vsabr_index]);?>
<span><?php echo $lang_common['Required'] ?></span></strong>
<input name="captcha" id="captcha" type="text" size="10" maxlength="30" /><input name="captcha_q" value="<?php echo $qencoded ?>" type="hidden" /><br />
</label>
</div>
</fieldset>
</div>
<?php endif; //[modif oto] - End mod VSABR ?>
******************************************************************************
#-------[ 22 SAVE FILE viewtopic.php ]
******************************************************************************
#---[ 23 OPEN ]---------------------------------------------------------------
register.php
#--[ 24 FIND ] Info: $search_add_file[register][0]----------------------------
message($lang_register['No new regs']);
#--[ 25 ADD AFTER ] Info: $insert_add_file[register][0]-----------------------
//[modif oto] - VSABR Very Simple Anti Bot Registration
//If the hidden field username contains something is that it was completed by a BOT.
if(!empty($_REQUEST['username']))
message($lang_register['No new regs']);
#--[ 26 FIND ] Info: $search_add_file[register][1]----------------------------
$required_fields = array('req_user' => $lang_common['Username'], 'req_password1' => $lang_common['Password'], 'req_password2' => $lang_prof_reg['Confirm pass'], 'req_email1' => $lang_common['Email'], 'req_email2' => $lang_common['Email'].' 2');
#--[ 27 ADD AFTER ] Info: $insert_add_file[register][1]-----------------------
//[modif oto] - mod VSABR Very Simple AntiBot Registration - Line added
$required_fields['captcha'] = $lang_mod_vsabr['Robot title'];
******************************************************************************
#-------[ 28 SAVE FILE register.php ]
******************************************************************************
#---[ 29 OPEN ]---------------------------------------------------------------
post.php
#--[ 30 FIND ] Info: $search_add_file[post][0]--------------------------------
$required_fields['req_username'] = $lang_post['Guest name'];
#--[ 31 ADD AFTER ] Info: $insert_add_file[post][0]---------------------------
//[modif oto] - mod VSABR Very Simple AntiBot Registration - Line added
$required_fields['captcha'] = $lang_mod_vsabr['Robot title'];
******************************************************************************
#-------[ 32 SAVE FILE post.php ]
******************************************************************************
======================[ END OF INSTALLATION PROCEDURE ]=======================
This file was created automatically by the plugin Mod Installer
Written by Otomatic - fluxbb.frCe n'est pas parce que l'erreur se propage qu'elle devient vérité. Gandhi
Sont différents : ça et sa - est et ait - à et a - ce et se - mes et mais ou met - été et était - c'est et ces - ce-si et ceci
La vie sans musique est tout simplement une erreur, une fatigue, un exil. Friedrich Nietzsche
Hors ligne
Finalement je l'ai installé via mod installer.
L'installation a fonctionné correctement, cependant il ne faut pas que j'oublie de le désinstaller à chaque mise à jour du forum.
Merci beaucoup.
Bonne soirée.
Hors ligne
Bonsoir,
Dans forum => lang => French => mod_very_simple_antibot.php
<?php
// Language string for mod Very Simple AntiBot Registration
$lang_mod_vsabr = array(
'Robot title' => 'Are you human or robot?',
'Robot question' => 'Please respond with a <b>number</b> to the question: <b>%s</b>',
'Robot info' => 'Checking if this is requested by a real person and not an automated program.',
'Robot test fail' => 'You answered incorrectly to the "Human or Robot" question, or you are a Bot!',
);
// [modif oto] [Very Simple AntiBot questions]
$mod_vsabr_questions = array(
'What is two plus two?' => 4,
'What is four minus one?' => 3,
'What is three plus two?' => 5,
'What is two times four?' => 8,
'What is five minus two?' => 3,
'What is six plus three?' => 9,
'What is seven minus one?' => 6,
'What is eight times two?' => 16,
'What is six times two?' => 12,
'What is nine minus seven?' => 2
);
?>les questions sont modifiable à votre guise se qui augmente la protection .
cdlt
Hors ligne
Ah, super !
Merci beaucoup ! 
Hors ligne
Bonsoir,
Vous pouvez même ajouter des questions textuelles, en mettant les réponses attendues entre quote, par exemple :
Attention : Lisez bien le texte 'Robot question' : Il est demandé d'ajouter 10 au résultat numérique et d'écrire les textes en majuscule.
<?php
// Définitions utilisées pour mod Very Simple AntiBot Registration
$lang_mod_vsabr = array(
'Robot title' => 'Êtes-vous un humain ou un robot ?',
'Robot question' => '<b>Ajoutez 10</b> au résultat numérique - Écrivez le mot en <b>MAJUSCULES</b><br />Répondez par un <b>nombre</b> ou un <b>mot</b> à la question : <b>%s</b>',
'Robot info' => 'Vérification que ceci est demandée par une vraie personne et non par un programme automatisé.',
'Robot test fail' => 'Vous avez mal répondu à la question « Humain ou robot ? » ou bien vous êtes un robot !',
);
// [modif oto] [Very Simple AntiBot questions]
$mod_vsabr_questions = array(
'Combien font deux plus deux ?' => '14',
'Quelle est la couleur du sang rouge ?' => 'ROUGE',
'Combien font quatre moins deux ?' => '12',
'Combien font trois plus trois ?' => '16',
'Combien font deux fois quatre ?' => '18',
'De quelle couleur est le ciel bleu ?' => 'BLEU',
'Combien font cinq moins un ?' => '14',
'Combien font six plus cinq ?' => '21',
'Quelle est la couleur de l\'herbe verte ?' => 'VERTE',
'Combien font sept moins un ?' => '16',
'Combien font huit fois deux ?' => '26',
'Écrivez "toto" (Sans guillemets)' => 'TOTO',
'Combien font six fois trois ?' => '28',
'Combien font neuf moins six ?' => '13',
);
?>Ce n'est pas parce que l'erreur se propage qu'elle devient vérité. Gandhi
Sont différents : ça et sa - est et ait - à et a - ce et se - mes et mais ou met - été et était - c'est et ces - ce-si et ceci
La vie sans musique est tout simplement une erreur, une fatigue, un exil. Friedrich Nietzsche
Hors ligne
Ah oui, pas mal ! 
Je me demandais justement si on pouvait mettre du texte. 
J'essayerai ça, pour le moment j'ai ajouté une seule question. 
J'espère ne plus avoir de bots spammeurs...
Merci ! 
Hors ligne
Bonjour,
J'ai installé spambarrier il a l'air de fonctionner sauf que la fonction :
Recherche d'utilisateurs
Cette fonctionnalité permet de rechercher les utilisateurs avec une URL dans leur signature et n'ayant jamais posté. Ceci est prévu pour trouver les spammeurs qui auraient passé au travers des protections "SpamBarrier". Les résultats seront limités au 50 derniers utilisateurs enregistrés répondant à ces critères.
J'ai un message d'erreur suivant :
Utilisateurs
Fatal error: Call to undefined function parse_signature() in /home/www/master/events/forum/plugins/AP_SpamBarrier.php on line 103
Pseudo
Messages
Site Web
Signature
Inscription
Une petite idée ?
Dernière modification par LeChapitre (09-10-2014 16:17:45)
Hors ligne
Bonjour,
Fonctionne sans erreur ici-même.
À mon humble avis, erreur ou oubli dans l'installation. La fonction "parse_signature" est définie dans le fichier 'include\parser.php'. Il est donc indispensable qu'il y ait l'instruction
"require PUN_ROOT.'include/parser.php';"
dans le plugin
Ce n'est pas parce que l'erreur se propage qu'elle devient vérité. Gandhi
Sont différents : ça et sa - est et ait - à et a - ce et se - mes et mais ou met - été et était - c'est et ces - ce-si et ceci
La vie sans musique est tout simplement une erreur, une fatigue, un exil. Friedrich Nietzsche
Hors ligne
Bonjour,
En effet j'ai pas "require PUN_ROOT.'include/parser.php';" dans le fichier include/parser.php
A qu'elle niveau dois-je le mettre ?
code parser
<?php
/**
* Copyright (C) 2008-2012 FluxBB
* based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
*/
// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
exit;
// Global variables
/* regular expression to match nested BBCode LIST tags
'%
\[list # match opening bracket and tag name of outermost LIST tag
(?:=([1a*]))?+ # optional attribute capture in group 1
\] # closing bracket of outermost opening LIST tag
( # capture contents of LIST tag in group 2
(?: # non capture group for either contents or whole nested LIST
[^\[]*+ # unroll the loop! consume everything up to next [ (normal *)
(?: # (See "Mastering Regular Expressions" chapter 6 for details)
(?! # negative lookahead ensures we are NOT on [LIST*] or [/list]
\[list # opening LIST tag
(?:=[1a*])?+ # with optional attribute
\] # closing bracket of opening LIST tag
| # or...
\[/list\] # a closing LIST tag
) # end negative lookahead assertion (we are not on a LIST tag)
\[ # match the [ which is NOT the start of LIST tag (special)
[^\[]*+ # consume everything up to next [ (normal *)
)*+ # finish up "unrolling the loop" technique (special (normal*))*
| # or...
(?R) # recursively match a whole nested LIST element
)* # as many times as necessary until deepest nested LIST tag grabbed
) # end capturing contents of LIST tag into group 2
\[/list\] # match outermost closing LIST tag
%iex' */
$re_list = '%\[list(?:=([1a*]))?+\]((?:[^\[]*+(?:(?!\[list(?:=[1a*])?+\]|\[/list\])\[[^\[]*+)*+|(?R))*)\[/list\]%i';
// Here you can add additional smilies if you like (please note that you must escape single quote and backslash)
$smilies = array(
':)' => 'smile.png',
'=)' => 'smile.png',
':|' => 'neutral.png',
'=|' => 'neutral.png',
':(' => 'sad.png',
'=(' => 'sad.png',
':D' => 'big_smile.png',
'=D' => 'big_smile.png',
':o' => 'yikes.png',
':O' => 'yikes.png',
';)' => 'wink.png',
':/' => 'hmm.png',
':P' => 'tongue.png',
':p' => 'tongue.png',
':lol:' => 'lol.png',
':mad:' => 'mad.png',
':rolleyes:' => 'roll.png',
':cool:' => 'cool.png');
//
// Make sure all BBCodes are lower case and do a little cleanup
//
function preparse_bbcode($text, &$errors, $is_signature = false)
{
global $pun_config, $lang_common, $lang_post, $re_list;
// Remove empty tags
while (($new_text = strip_empty_bbcode($text)) !== false)
{
if ($new_text != $text)
{
$text = $new_text;
if ($new_text == '')
{
$errors[] = $lang_post['Empty after strip'];
return '';
}
}
else
break;
}
if ($is_signature)
{
global $lang_profile;
if (preg_match('%\[/?(?:quote|code|list|h)\b[^\]]*\]%i', $text))
$errors[] = $lang_profile['Signature quote/code/list/h'];
}
// If the message contains a code tag we have to split it up (text within shouldn't be touched)
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false)
list($inside, $text) = extract_blocks($text, '[code]', '[/code]');
// Tidy up lists
$temp = preg_replace_callback($re_list, create_function('$matches', 'return preparse_list_tag($matches[2], $matches[1]);'), $text);
// If the regex failed
if (is_null($temp))
$errors[] = $lang_common['BBCode list size error'];
else
$text = str_replace('*'."\0".']', '*]', $temp);
if ($pun_config['o_make_links'] == '1')
$text = do_clickable($text);
$temp_text = false;
if (empty($errors))
$temp_text = preparse_tags($text, $errors, $is_signature);
if ($temp_text !== false)
$text = $temp_text;
// If we split up the message before we have to concatenate it together again (code tags)
if (isset($inside))
{
$outside = explode("\1", $text);
$text = '';
$num_tokens = count($outside);
for ($i = 0; $i < $num_tokens; ++$i)
{
$text .= $outside[$i];
if (isset($inside[$i]))
$text .= '[code]'.$inside[$i].'[/code]';
}
unset($inside);
}
// Remove empty tags
while (($new_text = strip_empty_bbcode($text)) !== false)
{
if ($new_text != $text)
{
$text = $new_text;
if ($new_text == '')
{
$errors[] = $lang_post['Empty after strip'];
break;
}
}
else
break;
}
return pun_trim($text);
}
//
// Strip empty bbcode tags from some text
//
function strip_empty_bbcode($text)
{
// If the message contains a code tag we have to split it up (empty tags within are fine)
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false)
list($inside, $text) = extract_blocks($text, '[code]', '[/code]');
// Remove empty tags
while (!is_null($new_text = preg_replace('%\[(b|u|s|ins|del|em|i|h|colou?r|quote|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]\s*\[/\1\]%', '', $text)))
{
if ($new_text != $text)
$text = $new_text;
else
break;
}
// If we split up the message before we have to concatenate it together again (code tags)
if (isset($inside))
{
$parts = explode("\1", $text);
$text = '';
foreach ($parts as $i => $part)
{
$text .= $part;
if (isset($inside[$i]))
$text .= '[code]'.$inside[$i].'[/code]';
}
}
// Remove empty code tags
while (!is_null($new_text = preg_replace('%\[(code)\]\s*\[/\1\]%', '', $text)))
{
if ($new_text != $text)
$text = $new_text;
else
break;
}
return $text;
}
//
// Check the structure of bbcode tags and fix simple mistakes where possible
//
function preparse_tags($text, &$errors, $is_signature = false)
{
global $lang_common, $pun_config, $pun_user;
// Start off by making some arrays of bbcode tags and what we need to do with each one
// List of all the tags
$tags = array('quote', 'code', 'b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'img', 'list', '*', 'h', 'topic', 'post', 'forum', 'user');
// List of tags that we need to check are open (You could not put b,i,u in here then illegal nesting like [b][i][/b][/i] would be allowed)
$tags_opened = $tags;
// and tags we need to check are closed (the same as above, added it just in case)
$tags_closed = $tags;
// Tags we can nest and the depth they can be nested to
$tags_nested = array('quote' => $pun_config['o_quote_depth'], 'list' => 5, '*' => 5);
// Tags to ignore the contents of completely (just code)
$tags_ignore = array('code');
// Tags not allowed
$tags_forbidden = array();
// Block tags, block tags can only go within another block tag, they cannot be in a normal tag
$tags_block = array('quote', 'code', 'list', 'h', '*');
// Inline tags, we do not allow new lines in these
$tags_inline = array('b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'h', 'topic', 'post', 'forum', 'user');
// Tags we trim interior space
$tags_trim = array('img');
// Tags we remove quotes from the argument
$tags_quotes = array('url', 'email', 'img', 'topic', 'post', 'forum', 'user');
// Tags we limit bbcode in
$tags_limit_bbcode = array(
'*' => array('b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'list', 'img', 'code', 'topic', 'post', 'forum', 'user'),
'list' => array('*'),
'url' => array('img'),
'email' => array('img'),
'topic' => array('img'),
'post' => array('img'),
'forum' => array('img'),
'user' => array('img'),
'img' => array(),
'h' => array('b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'topic', 'post', 'forum', 'user'),
);
// Tags we can automatically fix bad nesting
$tags_fix = array('quote', 'b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'h', 'topic', 'post', 'forum', 'user');
// Disallow URL tags
if ($pun_user['g_post_links'] != '1')
$tags_forbidden[] = 'url';
$split_text = preg_split('%(\[[\*a-zA-Z0-9-/]*?(?:=.*?)?\])%', $text, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$open_tags = array('fluxbb-bbcode');
$open_args = array('');
$opened_tag = 0;
$new_text = '';
$current_ignore = '';
$current_nest = '';
$current_depth = array();
$limit_bbcode = $tags;
$count_ignored = array();
foreach ($split_text as $current)
{
if ($current == '')
continue;
// Are we dealing with a tag?
if (substr($current, 0, 1) != '[' || substr($current, -1, 1) != ']')
{
// It's not a bbcode tag so we put it on the end and continue
// If we are nested too deeply don't add to the end
if ($current_nest)
continue;
$current = str_replace("\r\n", "\n", $current);
$current = str_replace("\r", "\n", $current);
if (in_array($open_tags[$opened_tag], $tags_inline) && strpos($current, "\n") !== false)
{
// Deal with new lines
$split_current = preg_split('%(\n\n+)%', $current, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$current = '';
if (!pun_trim($split_current[0], "\n")) // The first part is a linebreak so we need to handle any open tags first
array_unshift($split_current, '');
for ($i = 1; $i < count($split_current); $i += 2)
{
$temp_opened = array();
$temp_opened_arg = array();
$temp = $split_current[$i - 1];
while (!empty($open_tags))
{
$temp_tag = array_pop($open_tags);
$temp_arg = array_pop($open_args);
if (in_array($temp_tag , $tags_inline))
{
array_push($temp_opened, $temp_tag);
array_push($temp_opened_arg, $temp_arg);
$temp .= '[/'.$temp_tag.']';
}
else
{
array_push($open_tags, $temp_tag);
array_push($open_args, $temp_arg);
break;
}
}
$current .= $temp.$split_current[$i];
$temp = '';
while (!empty($temp_opened))
{
$temp_tag = array_pop($temp_opened);
$temp_arg = array_pop($temp_opened_arg);
if (empty($temp_arg))
$temp .= '['.$temp_tag.']';
else
$temp .= '['.$temp_tag.'='.$temp_arg.']';
array_push($open_tags, $temp_tag);
array_push($open_args, $temp_arg);
}
$current .= $temp;
}
if (array_key_exists($i - 1, $split_current))
$current .= $split_current[$i - 1];
}
if (in_array($open_tags[$opened_tag], $tags_trim))
$new_text .= pun_trim($current);
else
$new_text .= $current;
continue;
}
// Get the name of the tag
$current_arg = '';
if (strpos($current, '/') === 1)
{
$current_tag = substr($current, 2, -1);
}
else if (strpos($current, '=') === false)
{
$current_tag = substr($current, 1, -1);
}
else
{
$current_tag = substr($current, 1, strpos($current, '=')-1);
$current_arg = substr($current, strpos($current, '=')+1, -1);
}
$current_tag = strtolower($current_tag);
// Is the tag defined?
if (!in_array($current_tag, $tags))
{
// It's not a bbcode tag so we put it on the end and continue
if (!$current_nest)
$new_text .= $current;
continue;
}
// We definitely have a bbcode tag
// Make the tag string lower case
if ($equalpos = strpos($current,'='))
{
// We have an argument for the tag which we don't want to make lowercase
if (strlen(substr($current, $equalpos)) == 2)
{
// Empty tag argument
$errors[] = sprintf($lang_common['BBCode error empty attribute'], $current_tag);
return false;
}
$current = strtolower(substr($current, 0, $equalpos)).substr($current, $equalpos);
}
else
$current = strtolower($current);
// This is if we are currently in a tag which escapes other bbcode such as code
// We keep a count of ignored bbcodes (code tags) so we can nest them, but
// only balanced sets of tags can be nested
if ($current_ignore)
{
// Increase the current ignored tags counter
if ('['.$current_ignore.']' == $current)
$count_ignored[$current_tag]++;
// Decrease the current ignored tags counter
if ('[/'.$current_ignore.']' == $current)
$count_ignored[$current_tag]--;
if ('[/'.$current_ignore.']' == $current && $count_ignored[$current_tag] == 0)
{
// We've finished the ignored section
$current = '[/'.$current_tag.']';
$current_ignore = '';
$count_ignored = array();
}
$new_text .= $current;
continue;
}
// Is the tag forbidden?
if (in_array($current_tag, $tags_forbidden))
{
if (isset($lang_common['BBCode error tag '.$current_tag.' not allowed']))
$errors[] = sprintf($lang_common['BBCode error tag '.$current_tag.' not allowed']);
else
$errors[] = sprintf($lang_common['BBCode error tag not allowed'], $current_tag);
return false;
}
if ($current_nest)
{
// We are currently too deeply nested so lets see if we are closing the tag or not
if ($current_tag != $current_nest)
continue;
if (substr($current, 1, 1) == '/')
$current_depth[$current_nest]--;
else
$current_depth[$current_nest]++;
if ($current_depth[$current_nest] <= $tags_nested[$current_nest])
$current_nest = '';
continue;
}
// Check the current tag is allowed here
if (!in_array($current_tag, $limit_bbcode) && $current_tag != $open_tags[$opened_tag])
{
$errors[] = sprintf($lang_common['BBCode error invalid nesting'], $current_tag, $open_tags[$opened_tag]);
return false;
}
if (substr($current, 1, 1) == '/')
{
// This is if we are closing a tag
if ($opened_tag == 0 || !in_array($current_tag, $open_tags))
{
// We tried to close a tag which is not open
if (in_array($current_tag, $tags_opened))
{
$errors[] = sprintf($lang_common['BBCode error no opening tag'], $current_tag);
return false;
}
}
else
{
// Check nesting
while (true)
{
// Nesting is ok
if ($open_tags[$opened_tag] == $current_tag)
{
array_pop($open_tags);
array_pop($open_args);
$opened_tag--;
break;
}
// Nesting isn't ok, try to fix it
if (in_array($open_tags[$opened_tag], $tags_closed) && in_array($current_tag, $tags_closed))
{
if (in_array($current_tag, $open_tags))
{
$temp_opened = array();
$temp_opened_arg = array();
$temp = '';
while (!empty($open_tags))
{
$temp_tag = array_pop($open_tags);
$temp_arg = array_pop($open_args);
if (!in_array($temp_tag, $tags_fix))
{
// We couldn't fix nesting
$errors[] = sprintf($lang_common['BBCode error no closing tag'], array_pop($temp_opened));
return false;
}
array_push($temp_opened, $temp_tag);
array_push($temp_opened_arg, $temp_arg);
if ($temp_tag == $current_tag)
break;
else
$temp .= '[/'.$temp_tag.']';
}
$current = $temp.$current;
$temp = '';
array_pop($temp_opened);
array_pop($temp_opened_arg);
while (!empty($temp_opened))
{
$temp_tag = array_pop($temp_opened);
$temp_arg = array_pop($temp_opened_arg);
if (empty($temp_arg))
$temp .= '['.$temp_tag.']';
else
$temp .= '['.$temp_tag.'='.$temp_arg.']';
array_push($open_tags, $temp_tag);
array_push($open_args, $temp_arg);
}
$current .= $temp;
$opened_tag--;
break;
}
else
{
// We couldn't fix nesting
$errors[] = sprintf($lang_common['BBCode error no opening tag'], $current_tag);
return false;
}
}
else if (in_array($open_tags[$opened_tag], $tags_closed))
break;
else
{
array_pop($open_tags);
array_pop($open_args);
$opened_tag--;
}
}
}
if (in_array($current_tag, array_keys($tags_nested)))
{
if (isset($current_depth[$current_tag]))
$current_depth[$current_tag]--;
}
if (in_array($open_tags[$opened_tag], array_keys($tags_limit_bbcode)))
$limit_bbcode = $tags_limit_bbcode[$open_tags[$opened_tag]];
else
$limit_bbcode = $tags;
$new_text .= $current;
continue;
}
else
{
// We are opening a tag
if (in_array($current_tag, array_keys($tags_limit_bbcode)))
$limit_bbcode = $tags_limit_bbcode[$current_tag];
else
$limit_bbcode = $tags;
if (in_array($current_tag, $tags_block) && !in_array($open_tags[$opened_tag], $tags_block) && $opened_tag != 0)
{
// We tried to open a block tag within a non-block tag
$errors[] = sprintf($lang_common['BBCode error invalid nesting'], $current_tag, $open_tags[$opened_tag]);
return false;
}
if (in_array($current_tag, $tags_ignore))
{
// It's an ignore tag so we don't need to worry about what's inside it
$current_ignore = $current_tag;
$count_ignored[$current_tag] = 1;
$new_text .= $current;
continue;
}
// Deal with nested tags
if (in_array($current_tag, $open_tags) && !in_array($current_tag, array_keys($tags_nested)))
{
// We nested a tag we shouldn't
$errors[] = sprintf($lang_common['BBCode error invalid self-nesting'], $current_tag);
return false;
}
else if (in_array($current_tag, array_keys($tags_nested)))
{
// We are allowed to nest this tag
if (isset($current_depth[$current_tag]))
$current_depth[$current_tag]++;
else
$current_depth[$current_tag] = 1;
// See if we are nested too deep
if ($current_depth[$current_tag] > $tags_nested[$current_tag])
{
$current_nest = $current_tag;
continue;
}
}
// Remove quotes from arguments for certain tags
if (strpos($current, '=') !== false && in_array($current_tag, $tags_quotes))
{
$current = preg_replace('%\['.$current_tag.'=("|\'|)(.*?)\\1\]\s*%i', '['.$current_tag.'=$2]', $current);
}
if (in_array($current_tag, array_keys($tags_limit_bbcode)))
$limit_bbcode = $tags_limit_bbcode[$current_tag];
$open_tags[] = $current_tag;
$open_args[] = $current_arg;
$opened_tag++;
$new_text .= $current;
continue;
}
}
// Check we closed all the tags we needed to
foreach ($tags_closed as $check)
{
if (in_array($check, $open_tags))
{
// We left an important tag open
$errors[] = sprintf($lang_common['BBCode error no closing tag'], $check);
return false;
}
}
if ($current_ignore)
{
// We left an ignore tag open
$errors[] = sprintf($lang_common['BBCode error no closing tag'], $current_ignore);
return false;
}
return $new_text;
}
//
// Preparse the contents of [list] bbcode
//
function preparse_list_tag($content, $type = '*')
{
global $lang_common, $re_list;
if (strlen($type) != 1)
$type = '*';
if (strpos($content,'[list') !== false)
{
$content = preg_replace_callback($re_list, create_function('$matches', 'return preparse_list_tag($matches[2], $matches[1]);'), $content);
}
$items = explode('[*]', str_replace('\"', '"', $content));
$content = '';
foreach ($items as $item)
{
if (pun_trim($item) != '')
$content .= '[*'."\0".']'.str_replace('[/*]', '', pun_trim($item)).'[/*'."\0".']'."\n";
}
return '[list='.$type.']'."\n".$content.'[/list]';
}
//
// Truncate URL if longer than 55 characters (add http:// or ftp:// if missing)
//
function handle_url_tag($url, $link = '', $bbcode = false)
{
$url = pun_trim($url);
// Deal with [url][img]http://example.com/test.png[/img][/url]
if (preg_match('%<img src=\\\\"(.*?)\\\\"%', $url, $matches))
return handle_url_tag($matches[1], $url, $bbcode);
$full_url = str_replace(array(' ', ','\'', ','\'','`', ','\'','`','"'), array('%20', '%20','', '%20','','', '%20','','',''), $url);
if (strpos($url, 'www.') ')=== 0) // If it starts with www, we add http://
$full_url = 'http://'.$full_url;
else if (strpos($url, 'ftp.') ')=== 0) // Else if it starts with ftp, we add ftp://
$full_url = 'ftp://'.$full_url;
else if (strpos($url, '/') '/')=== 0) // Allow for relative URLs that start with a slash
$full_url = get_base_url(true).$full_url;
else if (!preg_match('#^([a-z0-9]{3,6})://#', $url)) // Else if it doesn't start with abcdef://, we add http://
$full_url = 'http://'.$full_url;
// Ok, not very pretty :-)
if ($bbcode)
{
if ($full_url == $link)
return '[url]'.$link.'[/url]';
else
return '[url='.$full_url.']'.$link.'[/url]';
}
else
{
if ($link == '' || $link == $url)
{
$url = pun_htmlspecialchars_decode($url);
$link = utf8_strlen($url) > 55 ? utf8_substr($url, 0 , 39).' … '.utf8_substr($url, -10) : $url;
$link = pun_htmlspecialchars($link);
}
else
$link = stripslashes($link);
return '<a href="'.$full_url.'" rel="nofollow">'.$link.'</a>';
}
}
//
// Turns an URL from the [img] tag into an <img> tag or a <a href...> tag
//
function handle_img_tag($url, $is_signature = false, $alt = null)
{
global $lang_common, $pun_user;
if (is_null($alt))
$alt = basename($url);
$img_tag = '<a href="'.$url.'" rel="nofollow"><'.$lang_common['Image link'].' - '.$alt.'></a>';
if ($is_signature && $pun_user['show_img_sig'] != '0')
$img_tag = '<img class="sigimage" src="'.$url.'" alt="'.$alt.'" />';
else if (!$is_signature && $pun_user['show_img'] != '0')
$img_tag = '<span class="postimg"><img src="'.$url.'" alt="'.$alt.'" /></span>';
return $img_tag;
}
//
// Parse the contents of [list] bbcode
//
function handle_list_tag($content, $type = '*')
{
global $re_list;
if (strlen($type) != 1)
$type = '*';
if (strpos($content,'[list') !== false)
{
$content = preg_replace_callback($re_list, create_function('$matches', 'return handle_list_tag($matches[2], $matches[1]);'), $content);
}
$content = preg_replace('#\s*\[\*\](.*?)\[/\*\]\s*#s', '<li><p>$1</p></li>', pun_trim($content));
if ($type == '*')
$content = '<ul>'.$content.'</ul>';
else
if ($type == 'a')
$content = '<ol class="alpha">'.$content.'</ol>';
else
$content = '<ol class="decimal">'.$content.'</ol>';
return '</p>'.$content.'<p>';
}
//
// Convert BBCodes to their HTML equivalent
//
function do_bbcode($text, $is_signature = false)
{
global $lang_common, $pun_user, $pun_config, $re_list;
if (strpos($text, '[quote') !== false)
{
$text = preg_replace('%\[quote\]\s*%', '</p><div class="quotebox"><blockquote><div><p>', $text);
$text = preg_replace_callback('%\[quote=("|&\#039;|"|\'|)(.*?)\\1\]%s', create_function('$matches', 'global $lang_common; return "</p><div class=\"quotebox\"><cite>".str_replace(array(\'[\', \'\\"\'), array(\'[\', \'"\'), $matches[2])." ".$lang_common[\'wrote\']."</cite><blockquote><div><p>";'), $text);
$text = preg_replace('%\s*\[\/quote\]%S', '</p></div></blockquote></div><p>', $text);
}
if (!$is_signature)
{
$pattern_callback[] = $re_list;
$replace_callback[] = 'handle_list_tag($matches[2], $matches[1])';
}
$pattern[] = '%\[b\](.*?)\[/b\]%ms';
$pattern[] = '%\[i\](.*?)\[/i\]%ms';
$pattern[] = '%\[u\](.*?)\[/u\]%ms';
$pattern[] = '%\[s\](.*?)\[/s\]%ms';
$pattern[] = '%\[del\](.*?)\[/del\]%ms';
$pattern[] = '%\[ins\](.*?)\[/ins\]%ms';
$pattern[] = '%\[em\](.*?)\[/em\]%ms';
$pattern[] = '%\[colou?r=([a-zA-Z]{3,20}|\#[0-9a-fA-F]{6}|\#[0-9a-fA-F]{3})](.*?)\[/colou?r\]%ms';
$pattern[] = '%\[h\](.*?)\[/h\]%ms';
$replace[] = '<strong>$1</strong>';
$replace[] = '<em>$1</em>';
$replace[] = '<span class="bbu">$1</span>';
$replace[] = '<span class="bbs">$1</span>';
$replace[] = '<del>$1</del>';
$replace[] = '<ins>$1</ins>';
$replace[] = '<em>$1</em>';
$replace[] = '<span style="color: $1">$2</span>';
$replace[] = '</p><h5>$1</h5><p>';
if (($is_signature && $pun_config['p_sig_img_tag'] == '1') || (!$is_signature && $pun_config['p_message_img_tag'] == '1'))
{
$pattern_callback[] = '%\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]%';
$pattern_callback[] = '%\[img=([^\[]*?)\]((ht|f)tps?://)([^\s<"]*?)\[/img\]%';
if ($is_signature)
{
$replace_callback[] = 'handle_img_tag($matches[1].$matches[3], true)';
$replace_callback[] = 'handle_img_tag($matches[2].$matches[4], true, $matches[1])';
}
else
{
$replace_callback[] = 'handle_img_tag($matches[1].$matches[3], false)';
$replace_callback[] = 'handle_img_tag($matches[2].$matches[4], false, $matches[1])';
}
}
$pattern_callback[] = '%\[url\]([^\[]*?)\[/url\]%';
$pattern_callback[] = '%\[url=([^\[]+?)\](.*?)\[/url\]%';
$pattern[] = '%\[email\]([^\[]*?)\[/email\]%';
$pattern[] = '%\[email=([^\[]+?)\](.*?)\[/email\]%';
$pattern_callback[] = '%\[topic\]([1-9]\d*)\[/topic\]%';
$pattern_callback[] = '%\[topic=([1-9]\d*)\](.*?)\[/topic\]%';
$pattern_callback[] = '%\[post\]([1-9]\d*)\[/post\]%';
$pattern_callback[] = '%\[post=([1-9]\d*)\](.*?)\[/post\]%';
$pattern_callback[] = '%\[forum\]([1-9]\d*)\[/forum\]%';
$pattern_callback[] = '%\[forum=([1-9]\d*)\](.*?)\[/forum\]%';
$pattern_callback[] = '%\[user\]([1-9]\d*)\[/user\]%';
$pattern_callback[] = '%\[user=([1-9]\d*)\](.*?)\[/user\]%';
$replace_callback[] = 'handle_url_tag($matches[1])';
$replace_callback[] = 'handle_url_tag($matches[1], $matches[2])';
$replace[] = '<a href="mailto:$1">$1</a>';
$replace[] = '<a href="mailto:$1">$2</a>';
$replace_callback[] = 'handle_url_tag(\''.get_base_url(true).'/viewtopic.php?id=\'.$matches[1])';
$replace_callback[] = 'handle_url_tag(\''.get_base_url(true).'/viewtopic.php?id=\'.$matches[1], $matches[2])';
$replace_callback[] = 'handle_url_tag(\''.get_base_url(true).'/viewtopic.php?pid=\'.$matches[1].\'#p\'.$matches[1])';
$replace_callback[] = 'handle_url_tag(\''.get_base_url(true).'/viewtopic.php?pid=\'.$matches[1].\'#p\'.$matches[1], $matches[2])';
$replace_callback[] = 'handle_url_tag(\''.get_base_url(true).'/viewforum.php?id=\'.$matches[1])';
$replace_callback[] = 'handle_url_tag(\''.get_base_url(true).'/viewforum.php?id=\'.$matches[1], $matches[2])';
$replace_callback[] = 'handle_url_tag(\''.get_base_url(true).'/profile.php?id=\'.$matches[1])';
$replace_callback[] = 'handle_url_tag(\''.get_base_url(true).'/profile.php?id=\'.$matches[1], $matches[2])';
// This thing takes a while! :)
$text = preg_replace($pattern, $replace, $text);
$count = count($pattern_callback);
for($i = 0 ; $i < $count ; $i++)
{
$text = preg_replace_callback($pattern_callback[$i], create_function('$matches', 'return '.$replace_callback[$i].';'), $text);
}
return $text;
}
//
// Make hyperlinks clickable
//
function do_clickable($text)
{
$text = ' '.$text;
$text = ucp_preg_replace_callback('%(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(https?|ftp|news){1}://([\p{L}\p{N}\-]+\.([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/(?:[^\s\[]*[^\s.,?!\[;:-])?)?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])%ui', 'stripslashes($matches[1].$matches[2].$matches[3].$matches[4]).handle_url_tag($matches[5]."://".$matches[6], $matches[5]."://".$matches[6], true).stripslashes($matches[4].forum_array_key($matches, 10).forum_array_key($matches, 11).forum_array_key($matches, 12))', $text);
$text = ucp_preg_replace_callback('%(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(www|ftp)\.(([\p{L}\p{N}\-]+\.)+[\p{L}\p{N}]+(:[0-9]+)?(/(?:[^\s\[]*[^\s.,?!\[;:-])?)?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])%ui','stripslashes($matches[1].$matches[2].$matches[3].$matches[4]).handle_url_tag($matches[5].".".$matches[6], $matches[5].".".$matches[6], true).stripslashes($matches[4].forum_array_key($matches, 10).forum_array_key($matches, 11).forum_array_key($matches, 12))', $text);
return substr($text, 1);
}
//
// Return an array key, if it exists, otherwise return an empty string
//
function forum_array_key($arr, $key)
{
return isset($arr[$key]) ? $arr[$key] : '';
}
//
// Convert a series of smilies to images
//
function do_smilies($text)
{
global $smilies;
$text = ' '.$text.' ';
foreach ($smilies as $smiley_text => $smiley_img)
{
if (strpos($text, $smiley_text) !== false)
$text = ucp_preg_replace('%(?<=[>\s])'.preg_quote($smiley_text, '%').'(?=[^\p{L}\p{N}])%um', '<img src="'.pun_htmlspecialchars(get_base_url(true).'/img/smilies/'.$smiley_img).'" width="15" height="15" alt="'.substr($smiley_img, 0, strrpos($smiley_img, '.')).'" />', $text);
}
return substr($text, 1, -1);
}
//
// Parse message text
//
function parse_message($text, $hide_smilies)
{
global $pun_config, $lang_common, $pun_user;
if ($pun_config['o_censoring'] == '1')
$text = censor_words($text);
// Convert applicable characters to HTML entities
$text = pun_htmlspecialchars($text);
// If the message contains a code tag we have to split it up (text within shouldn't be touched)
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false)
list($inside, $text) = extract_blocks($text, '[code]', '[/code]');
if ($pun_config['p_message_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false)
$text = do_bbcode($text);
if ($pun_config['o_smilies'] == '1' && $pun_user['show_smilies'] == '1' && $hide_smilies == '0')
$text = do_smilies($text);
// Deal with newlines, tabs and multiple spaces
$pattern = array("\n", "\t", ' ', ' ');
$replace = array('<br />', '    ', '  ', '  ');
$text = str_replace($pattern, $replace, $text);
// If we split up the message before we have to concatenate it together again (code tags)
if (isset($inside))
{
$parts = explode("\1", $text);
$text = '';
foreach ($parts as $i => $part)
{
$text .= $part;
if (isset($inside[$i]))
{
$num_lines = (substr_count($inside[$i], "\n"));
$text .= '</p><div class="codebox"><pre'.(($num_lines > 28) ? ' class="vscroll"' : '').'><code>'.pun_trim($inside[$i], "\n\r").'</code></pre></div><p>';
}
}
}
return clean_paragraphs($text);
}
//
// Clean up paragraphs and line breaks
//
function clean_paragraphs($text)
{
// Add paragraph tag around post, but make sure there are no empty paragraphs
$text = '<p>'.$text.'</p>';
// Replace any breaks next to paragraphs so our replace below catches them
$text = preg_replace('%(</?p>)(?:\s*?<br />){1,2}%i', '$1', $text);
$text = preg_replace('%(?:<br />\s*?){1,2}(</?p>)%i', '$1', $text);
// Remove any empty paragraph tags (inserted via quotes/lists/code/etc) which should be stripped
$text = str_replace('<p></p>', '', $text);
$text = preg_replace('%<br />\s*?<br />%i', '</p><p>', $text);
$text = str_replace('<p><br />', '<br /><p>', $text);
$text = str_replace('<br /></p>', '</p><br />', $text);
$text = str_replace('<p></p>', '<br /><br />', $text);
return $text;
}
//
// Parse signature text
//
function parse_signature($text)
{
global $pun_config, $lang_common, $pun_user;
if ($pun_config['o_censoring'] == '1')
$text = censor_words($text);
// Convert applicable characters to HTML entities
$text = pun_htmlspecialchars($text);
if ($pun_config['p_sig_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false)
$text = do_bbcode($text, true);
if ($pun_config['o_smilies_sig'] == '1' && $pun_user['show_smilies'] == '1')
$text = do_smilies($text);
// Deal with newlines, tabs and multiple spaces
$pattern = array("\n", "\t", ' ', ' ');
$replace = array('<br />', '    ', '  ', '  ');
$text = str_replace($pattern, $replace, $text);
return clean_paragraphs($text);
}Bien à vous,
Hors ligne
Bonjour,
Réfléchissez un petit peu... Vous voulez inclure un fichier dans lui-même... 
J'ai écrit : Il manque "require PUN_ROOT.'include/parser.php';" dans le plugin
Quant à où le mettre...
Avez-vous scrupuleusement suivi TOUTES les explications du fichier readme.txt ?
Avez-vous lancé mod_install.php ?
Ce n'est pas parce que l'erreur se propage qu'elle devient vérité. Gandhi
Sont différents : ça et sa - est et ait - à et a - ce et se - mes et mais ou met - été et était - c'est et ces - ce-si et ceci
La vie sans musique est tout simplement une erreur, une fatigue, un exil. Friedrich Nietzsche
Hors ligne
Bonjour,
Oui j'ai suivi scrupuleusement le readme.txt
L'erreur que j'ai faite à mon humble avis, est que j'ai changé les fichiers concernés avant install_mod.php
Une fois toutes les hdiff faite j'ai tout uploader sur le serveur, ensuite j'ai installé le (install_mod.php) et retiré par la suite.
Il ne me semblait pas logique d'installer un fichier donc les modifications dans les autres fichiers n'étaient pas exécuter..
Soit problème non résolu, je vais pencher plus dessus 
Bien à vous,
Hors ligne
Bonjour,
Le fichier des instructions d'installation readme.txt demande bien, en point N° 2 de lancer install_mod.php avant de modifier les fichiers.
Les notices sont écrites pour être suivies.
Ce n'est pas parce que l'erreur se propage qu'elle devient vérité. Gandhi
Sont différents : ça et sa - est et ait - à et a - ce et se - mes et mais ou met - été et était - c'est et ces - ce-si et ceci
La vie sans musique est tout simplement une erreur, une fatigue, un exil. Friedrich Nietzsche
Hors ligne
Pages : 1