-------------------------------------------------------- */ // IPB's setting [Paramètres d'IPB] : $RSS['FORUM_ID'] = array(2, 1); // News forum id $RSS['NEWS_LIMIT'] = 10; // Show a max of x news [Nombre maximum de news à afficher]. $RSS['BOARD_URL'] = 'http://www.unitedspongebob.com/forums'; // IPB board's url [URL du forum IPB]. $RSS['BOARD_PATH'] = './forums/'; // Board PATH [PATH du forum]. $RSS['CHARSET'] = 'ISO-8859-1'; // Charset [Encodage des caractères]. $RSS['TRUNCATE_NEWS'] = null; // Truncate news to x characters(null for full news) [Tronquer les news à x caractères]. // Website [Site web] : $RSS['HOME_NAME'] = 'United SpongeBob'; // Website's name [Nom du site web]. $RSS['HOME_DESCRIPTION'] = 'Your Source for SpongeBob'; // Website's description [Description du site]. $RSS['HOME_URL'] = 'http://www.spongezone.net'; // Website's url [URL du site web]. $RSS['LANGUAGE'] = 'en'; // Website's language [Langue du site]. $RSS['COPYRIGHT'] = 'SpongeZone.net ©2005'; // Your copyright [Copyright de votre flux]. $RSS['DOCS'] = ''; // RSS documentations [Documentation explicative]. $RSS['WEBMASTER'] = 'cmonkey@spongezone.net'; // Admin's email [Email de l'admin]. // Website's logo (null for not) [Le logo de votre site (mettre null pour aucun)] : $RSS['HOME_LOGO'] = null; // Websites's logo [Image pour illustrer vos flux]. $RSS['HOME_LOGO_WIDTH'] = 144; // Logo's width (beetween 1 and 144) [Largeur du logo]. $RSS['HOME_LOGO_HEIGHT'] = 56; // Logo's hieght [Hauteur du logo]. /* -------------------------------------------------------- < / setting [paramètres] > -------------------------------------------------------- */ define( 'ROOT_PATH' , $RSS['BOARD_PATH'] ); define( 'USE_SHUTDOWN', 1 ); define( 'IN_IPB', 1 ); define( 'IN_DEV', 0 ); error_reporting (E_ERROR | E_WARNING | E_PARSE); set_magic_quotes_runtime(0); $backend = new backend(); echo $backend->getRSS(); /** * Classe générant le fichier backend. * @author LLaumgui */ class backend{ var $DB; // Connexion à la base de données. var $RSS = array ( // Paramètre du backend. 'FORUM_ID' => '', // Paramètres d'IPB 'NEWS_LIMIT' => '', 'BOARD_URL' => '', 'BOARD_PATH' => '', 'CHARSET' => '', 'TRUNCATE_NEWS' => '', 'HOME_NAME' => '', // Site web 'HOME_DESCRIPTION' => '', 'HOME_URL' => '', 'LANGUAGE' => '', 'COPYRIGHT' => '', 'DOCS' => '', 'WEBMASTER' => '', 'HOME_LOGO' => '', // Logo 'HOME_LOGO_WIDTH' => '', 'HOME_LOGO_HEIGHT' => '', 'RSS_version' => '', 'RSS_IPB_VERSION' => '1.5', ); /** * Constructeur de la classe. * @author LLaumgui * @since 1.5. */ function backend(){ global $RSS; /* * Récupération & détermination des paramètres : */ foreach ( $RSS as $_OPTION => $_SETTING ) { $this->RSS[$_OPTION] = $_SETTING; } /* * Détermination du nombre de news à afficher via le paramètre $_GET['limit']. * /!\ Ne peut être supérieur à la valeur définie dans la configuration ($RSS['NEWS_LIMIT']). */ if ( !empty($_GET['limit']) && intval($_GET['limit']) <= $this->RSS['NEWS_LIMIT'] ) { $this->RSS['NEWS_LIMIT'] = intval($_GET['limit']); } /* * Détermination de la version de RSS à utiliser (RSS1 ou RSS2) récupérée par le paramètre * $_GET['rss']. Si les news sont tronquées, le code HTML est alors converti en texte et ce * paramètre ne sert à rien ;). */ if ( intval($_GET['rss']) == 1 ) { $this->RSS['RSS_version'] = 1; } else { $this->RSS['RSS_version'] = 2; } $this->connection(); } /** * Connexion à la base de données made in SSI.php. * @author Matthew Mecham * @since 1.5 */ function connection() { require_once ROOT_PATH.'conf_global.php'; $INFO['sql_driver'] = ! $INFO['sql_driver'] ? 'mysql' : strtolower($INFO['sql_driver']); require ( ROOT_PATH.'ips_kernel/class_db_'.$INFO['sql_driver'].".php" ); $this->DB = new db_driver; $this->DB->obj['sql_database'] = $INFO['sql_database']; $this->DB->obj['sql_user'] = $INFO['sql_user']; $this->DB->obj['sql_pass'] = $INFO['sql_pass']; $this->DB->obj['sql_host'] = $INFO['sql_host']; $this->DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix']; $this->DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$INFO['sql_driver'].'_queries.php'; $this->DB->obj['use_shutdown'] = USE_SHUTDOWN; $this->DB->connect(); } /** * Récupération des différentes news (item). * @author LLaumgui * @since 1.5. * @return String Code XML des items. */ function getItem() { $item = ''; // Récupération de la liste des forum : $forum_id = implode( ",", $this->RSS['FORUM_ID'] ); //Requête : $this->DB->query(" SELECT t.tid, t.title, p.post_date, p.post, p.pid FROM ".SQL_PREFIX."topics t LEFT JOIN ".SQL_PREFIX."posts p ON (p.new_topic = 1 AND p.topic_id = t.tid) WHERE t.forum_id IN (".$forum_id.") AND t.approved=1 ORDER BY t.tid DESC LIMIT 0, ".$this->RSS['NEWS_LIMIT']); while ( $row = $this->DB->fetch_row() ) { $item .= " ".gmdate('r', $row['post_date'])." ".$row['title']." ".$this->html2text($row['post'])." ".$this->RSS['BOARD_URL']."/index.php?showtopic=".$row['tid']." "; } return $item; } /** * Permettant de convertir de l'HTML en texte afin de ne pas couper une balise en plein milieu. * Permet aussi via cette conversion de passer en RSS 1.0. * @author LLaumgui * @since 1.5. * @param $text String HTML à convertir en texte. * @return String Texte brut. */ function html2text($text){ global $RSS; if ( $this->RSS['TRUNCATE_NEWS'] != null || $this->RSS['RSS_version'] == 1 ) { /* * Afin de ne pas couper une balise HTML en plein milieu, je passe tout en texte brut... */ $text = preg_replace( '#\[(.+?)\](.+?)\[/(.+?)\]#is', '' , $text ); // Vire le bbCode. $text = preg_replace( '#(.*?)#ie', '', $text ); // Vire les émoticons. $text = preg_replace( '#(.*?)#is', '\\2', $text ); // Vire le HTML. $text = preg_replace( '#(.*?)#is', '\\1', $text ); $text = preg_replace( '#(.*?)#is', '\\1', $text ); $text = preg_replace( '#(.*?)#is', '\\1', $text ); $text = preg_replace( '#
(.*?)
#is', '\\2', $text ); $text = preg_replace( '#(.*?)#is', '\\2', $text ); $text = preg_replace( '##is', '', $text ); // Vire d'autre chose ;). $text = str_replace ( '
', "\n", $text ); $text = str_replace ( '€', 'Euro', $text ); /* * On coupe : */ if ( strlen($text) >= $this->RSS['TRUNCATE_NEWS'] && $this->RSS['TRUNCATE_NEWS'] != null ) { $text = substr($text, 0, $this->RSS['TRUNCATE_NEWS']); $espace = strrpos($text, " "); $text = substr($text, 0, $espace); $text .= '...'; } } else { /* * Je passe en mode HTML : */ $text = preg_replace( '#\[(.+?)\](.+?)\[/(.+?)\]#is', '' , $text ); // Vire le bbCode. $text = preg_replace( '#(.*?)#ie', '', $text ); // Vire les émoticons. $text = preg_replace( '##is', '', $text ); // Vire d'autre chose ;). $text = str_replace ( '€', '€', $text ); $text = ''; } return $text; } /** * Génération du fichier RSS. * @author LLaumgui * @since 1.5. * @return String Code XML du fichier backend. */ function getRSS() { /* * Header et partie décrivant le site : */ header("Content-Type: text/xml; charset=".$this->RSS['CHARSET']); header("Cache-Control: no-cache"); /* */ $backend = "RSS['CHARSET']."'?> ".$this->RSS['HOME_NAME']." ".$this->RSS['HOME_URL']." RSS IPB news ".$this->RSS['RSS_IPB_VERSION']." ".$this->RSS['HOME_DESCRIPTION']." ".gmdate('r').""; if ( !empty($this->RSS['LANGUAGE']) ) { $backend .= "".$this->RSS['LANGUAGE'].""; } if ( !empty($this->RSS['COPYRIGHT']) ) { $backend .= "".$this->RSS['COPYRIGHT'].""; } if ( !empty($this->RSS['DOCS']) ) { $backend .= "".$this->RSS['DOCS'].""; } if ( !empty($this->RSS['WEBMASTER']) ) { $backend .= "".$this->RSS['WEBMASTER']." ".$this->RSS['WEBMASTER'].""; } if ( $this->RSS['HOME_LOGO'] != null && $this->RSS['RSS_version'] > 1 ) { $backend .= " ".$this->RSS['HOME_LOGO']." ".$this->RSS['HOME_URL']." ".$this->RSS['HOME_NAME']." ".$this->RSS['HOME_LOGO_WIDTH']." ".$this->RSS['HOME_LOGO_HEIGHT']." ".$this->RSS['HOME_DESCRIPTION']." "; } /* * Item : les news : */ $backend .= $this->getItem(); /* * Fin du fichier RSS : */ $backend .= " "; $this->destructor(); return $backend; } /** * Pseudo destructeur, sert à rien mais peut servir plus tard en php5. * @author LLaumgui * @since 1.5. */ function destructor(){ $this->DB->close_DB(); } } // EOC ?>