/**----------------------------------------------- * * Rooty, 2018 * * * This software is protected by copyright, please * read the file COPYRIGHT. * This program is distributed in the hope that it * will be useful, but without any warranty; without * even the implied warranty of merchantability or * fitness for a particular purpose. Please * read the file LICENCE. * * Fichier bb.php * *Ce fichier contient la classe bb * * @author Rooty * @since 2005/03/09 * @link www.rooty.me * @version 0.3 * @package package * @subpackage bb * @copyright Copyright © 2009-2018, Rooty */ if ( !defined('SYSTEM_IN') ) { die("Hacking attempt"); } /** * Classe bb * * Permet la gestion du wyziwig de phpBB. * @package package * @subpackage bb */ class BB { /** * @var chaine * @access private * @desc nom du rep */ var $dir = ""; /**#@+ * @access private */ /** * @var chaine * @desc nom de l'élément du formulaire */ var $name = null; /** * @var chaine * @desc nom du formulaire */ var $form = null; /** * @var chaine * @desc valeur de la chaine html */ var $string = null; /** * @var booleen * @desc affichage des smiles oui/non */ var $smile = null; /**#@-*/ // // Constructor // /** * Constructeur de la classe bb * * @param chaine nom du champ * @param chaine nom du formulaire * @param chaine valeur de la chaine à afficher * @param chaine vrai ou faux pour l'utilisation des icones */ function bb($name, $form, $string, $smile=true) { global $CONF_LIB_PATH; require_once($CONF_LIB_PATH."lib/package/wysi/bb/bbcode.php"); require_once($CONF_LIB_PATH."lib/package/wysi/bb/functions_post.php"); $this->name =$name; $this->form =$form; $this->string =$string; $this->smile =$smile; $this->dir =$GLOBALS["SYSTEM_TEMPLATE_PATH"].$GLOBALS['SYSTEM_TEMPLATE_DIR']."/media/"; } /** * Display retourne la chaine d'affichage du wizi wig */ function Display() { global $CONF_DATA_PATH; $name =$this->name; $form =$this->form; $string =$this->string; $smile =$this->smile; $element=$form.".".$name; $html=' '; if ($smile==true) { $html.=' '; } $html.='
 Couleur:  Taille: Fermer les Balises

'.$this->DisplaySmile().'
'; return $html; } /** * ReturnData : retourne les données à partir de la chaine postée * @return chaine au format html */ function ReturnData() { global $_POST, $CONF_LIB_PATH; $name =$this->name; $form =$this->form; $message =$this->string; $smile =$this->smile; // $message=isset($_POST[$name])?$_POST[$name]:""; /* $html_on=1; $bbcode_on=1; $smilies_on=1; $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; $preview_message = stripslashes(prepare_message(addslashes(unprepare_message($message)), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); $preview_message = bbencode_second_pass($preview_message, $bbcode_uid); $preview_message = make_clickable($preview_message); $preview_message = $preview_message; $preview_message = str_replace("\n", '
', $preview_message); if ($this->smile) { $preview_message=$this->ReplaceSmile($preview_message); } return $preview_message;*/ /* adjust include_path to include PEAR */ // ini_set('include_path', ini_get('include_path').':'.$GLOBALS["CONF_LIB_PATH"].'lib/PEAR'); /* require PEAR and the parser */ require_once('PEAR.php'); require_once('HTML/BBCodeParser.php'); /* get options from the ini file */ $config = parse_ini_file($CONF_LIB_PATH.'lib/package/wysi/bb/bbcodeparser.ini', true); $options = &PEAR::getStaticProperty('HTML_BBCodeParser', '_options'); $options = $config['HTML_BBCodeParser']; unset($options); /* do yer stuff! */ $parser = new HTML_BBCodeParser(); $parser->setText($message); $parser->parse(); $parsed = $parser->getParsed(); $parsed = str_replace(chr(10), "
", $parsed); // $parsed = str_replace(" ", " ", $parsed); $parsed = $this->ReplaceSmile($parsed); return $parsed; } /** * ReturnDependancy : retourne la chaine d'appel aux javascript indispenssable * *

Retourne la chaine Javascript Avec le bon chemin (en fonction de SYSTEM_PATH)

* @return chaine chaine d'appel javascript */ function ReturnDependency() { return 'bb.js'; } /** * DisplaySmile : retourne la chaine des smile pour la saisie * @return chaine */ function DisplaySmile() { $name =$this->name; $form =$this->form; $string =$this->string; $smile =$this->smile; $element=$form.".".$name; $html='
Very Happy Smile Sad Surprised
Shocked Confused Cool Laughing
Mad Razz Embarassed Crying or Very sad
Evil or Very Mad Twisted Evil Rolling Eyes Wink
Exclamation Question Idea Arrow
'; return $html; } /** * ReplaceSmile() : remplasse les smile par leur image * *

Retourne la chaine Javascript Avec le bon chemin (en fonction de SYSTEM_PATH)

* @param chaine * @return chaine */ function ReplaceSmile($string) { $string=str_replace(":!:", 'Exclamation', $string); $string=str_replace(":?:", 'Question', $string); $string=str_replace(":oops:", 'Embarassed', $string); $string=str_replace(":D", 'Very Happy', $string); $string=str_replace(":)", 'Smile', $string); $string=str_replace(":(", 'Sad', $string); $string=str_replace(":o", 'Surprised', $string); $string=str_replace(":shock:", 'Shocked', $string); $string=str_replace(":?", 'Confused', $string); $string=str_replace("8)", 'Cool', $string); $string=str_replace(":lol:", 'Laughing', $string); $string=str_replace(":x", 'Mad', $string); $string=str_replace(":P", 'Razz', $string); $string=str_replace(":cry:", 'Crying or Very sad', $string); $string=str_replace(":evil:", 'Evil or Very Mad', $string); $string=str_replace(":twisted:", 'Twisted Evil', $string); $string=str_replace(":roll:", 'Rolling Eyes', $string); $string=str_replace(":wink:", 'Wink', $string); $string=str_replace(":idea:", 'Idea', $string); $string=str_replace(":arrow:", 'Arrow', $string); return $string; } /** * HtmlToBBSmile : remplasse les images par leur smile * @param chaine * @return chaine */ function HtmlToBBSmile($string) { $string=str_replace('Very Happy', ":D", $string); $string=str_replace('Smile', ":)",$string); $string=str_replace('Sad', ":(", $string); $string=str_replace('Surprised', ":o", $string); $string=str_replace('Shocked', ":shock:", $string); $string=str_replace('Confused', ":?", $string); $string=str_replace('Cool', "8)", $string); $string=str_replace('Laughing', ":lol:", $string); $string=str_replace('Mad', ":x", $string); $string=str_replace('Razz', ":P", $string); $string=str_replace('Embarassed', ":oops:", $string); $string=str_replace('Crying or Very sad', ":cry:", $string); $string=str_replace('Evil or Very Mad', ":evil:", $string); $string=str_replace('Twisted Evil', ":twisted:", $string); $string=str_replace('Rolling Eyes', ":roll:", $string); $string=str_replace('Wink', ":wink:", $string); $string=str_replace('Exclamation', ":!:", $string); $string=str_replace('Question', ":?:", $string); $string=str_replace('Idea', ":idea:", $string); $string=str_replace('Arrow', ":arrow:", $string); return $string; } /** * HtmlToBB : remplasse les images par leur smile * @param chaine * @return chaine */ function HtmlToBB($string) { # Gestion des bold $string=str_replace("", "[b]", $string); $string=str_replace("", "[/b]", $string); # Gestion des italic $string=str_replace("", "[i]", $string); $string=str_replace("", "[/i]", $string); # Gestion des underline $string=str_replace("", "[u]", $string); $string=str_replace("", "[/u]", $string); # Gestion des smile if ($this->smile) { $string=$this->HtmlToBBSmile($string); } # Gestion des images $string=str_replace('', "[/img]", $string); # Gestion des images $string=str_replace('', "]", $string); # Gestion des couleurs $string=str_replace('', "]", $string); $string=str_replace('', "[size]", $string); # Gestion des couleurs $string=str_replace('', "]", $string); $string=str_replace('', "[color]", $string); return $string; } /** * IsVideJs :permet de savoir en javascript si le champ est vide * *

donne le nom de la fonction ou l'appel permettant de determiner si vide en js

* * @return chaine chaine d'appel javascript */ function IsVideJs() { return '(document.'.$this->form.'.'.$this->name.'.value=="")?true:false;'; } } ?>