-------------------------------------------------------- */ // IPB's setting [Paramtres d'IPB] : //$RSS['FORUM_ID'] = array(1,7,8,9,24,48,51); // News forum id [ID du forum contenant les news]. $RSS['FORUM_ID'] = array(12,25,1,51,7,8,48,21,22,29,23,33,3,4,5,11,13,14,15,16,17,18,19,20,24,30); $RSS['NEWS_LIMIT'] = 48; // Show a max of x news [Nombre maximum de news afficher]. $RSS['BOARD_URL'] = 'http://www.awro.ru/on/'; // IPB board's url [URL du forum IPB]. $RSS['BOARD_PATH'] = './'; // Board PATH [PATH du forum]. $RSS['CHARSET'] = 'utf-8'; // Charset [Encodage des caractres]. $RSS['TRUNCATE_NEWS'] = 400; // Truncate news to x characters(null for full news) [Tronquer les news x caractres]. // Website [Site web] : $RSS['HOME_NAME'] = 'Ragnarok Online: AWRO'; // Website's name [Nom du site web]. $RSS['HOME_DESCRIPTION'] = 'AWRO: Ragnarok Online'; // Website's description [Description du site]. $RSS['HOME_URL'] = 'http://www.awro.ru/on'; // Website's url [URL du site web]. $RSS['LANGUAGE'] = 'ru-ru'; // Website's language [Langue du site]. $RSS['COPYRIGHT'] = 'AWRO ©2005-2011'; // Your copyright [Copyright de votre flux]. $RSS['DOCS'] = ''; // RSS documentations [Documentation explicative]. $RSS['WEBMASTER'] = 'cara@awro.ru (-= Cara =-)'; // 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'] = $RSS['HOME_URL'].'/uploads/awro.gif'; // 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'] = 53; // Logo's hieght [Hauteur du logo]. /* -------------------------------------------------------- < / setting [paramtres] > -------------------------------------------------------- */ 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); $rss = new rss(); echo $rss->getRSS(); class rss{ var $DB; // Connexion la base de donnes. var $RSS = array ( // Paramtre du rss. 'FORUM_ID' => '', // Paramtres 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 rss(){ global $RSS; /* * Rcupration & dtermination des paramtres : */ foreach ( $RSS as $_OPTION => $_SETTING ) { $this->RSS[$_OPTION] = $_SETTING; } /* * Dtermination du nombre de news afficher via le paramtre $_GET['limit']. * /!\ Ne peut tre suprieur la valeur dfinie dans la configuration ($RSS['NEWS_LIMIT']). */ if ( !empty($_GET['limit']) && intval($_GET['limit']) <= $this->RSS['NEWS_LIMIT'] ) { $this->RSS['NEWS_LIMIT'] = intval($_GET['limit']); } /* * Dtermination de la version de RSS utiliser (RSS1 ou RSS2) rcupre par le paramtre * $_GET['rss']. Si les news sont tronques, le code HTML est alors converti en texte et ce * paramtre 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 donnes made in SSI.php. * @author Matthew Mecham * @since 1.5 */ function connection() { require_once ROOT_PATH.'conf_global.php'; require ( ROOT_PATH.'sources/Drivers/'.$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(); } /** * Rcupration des diffrentes news (item). * @author LLaumgui * @since 1.5. * @return String Code XML des items. */ function getItem() { $item = ''; // Rcupration de la liste des forum : $forum_id = implode( ",", $this->RSS['FORUM_ID'] ); //Requte : $this->DB->query(" SELECT t.tid, t.title, p.post_date, p.post, p.pid FROM ".$this->DB->obj['sql_tbl_prefix']."topics t LEFT JOIN ".$this->DB->obj['sql_tbl_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() ) { //awro //$buffer = $this->RSS['BOARD_URL']."/index.php?showtopic=".$row['tid']; $buffer = $this->RSS['BOARD_URL']."/topic".$row['tid']."s0.html"; $item .= " ".gmdate('r', $row['post_date'])." ".$row['title']." ".$this->html2text($row['post'])." ".$buffer." ".$buffer." \n"; } return $item; } /** * @return String Texte brut. */ function html2text($text){ global $RSS; if ( $this->RSS['TRUNCATE_NEWS'] != null || $this->RSS['RSS_version'] == 1 ) { $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 ( '
', "\n", $text ); $text = preg_replace( '##is', ']]>', $text ); //$text = str_replace ( '', 'Euro', $text ); /* * On coupe : */ if ( mb_strlen($text) >= $this->RSS['TRUNCATE_NEWS'] && $this->RSS['TRUNCATE_NEWS'] != null ) //awro { $text = mb_substr($text, 0, $this->RSS['TRUNCATE_NEWS']); $espace = mb_strrpos($text, " "); $text = mb_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; } /** * @return String Code XML du fichier rss. */ function getRSS() { /* * Header et partie dcrivant le site : */ header("Content-Type: text/xml; charset=".$this->RSS['CHARSET']); header("Cache-Control: no-cache"); /* */ $rss = "RSS['CHARSET']."'?> ".$this->RSS['HOME_NAME']." ".$this->RSS['HOME_URL']." RSS :: AWRO news ".$this->RSS['HOME_DESCRIPTION']." ".gmdate('r')."\n"; if ( !empty($this->RSS['LANGUAGE']) ) { $rss .= "".$this->RSS['LANGUAGE']."\n"; } if ( !empty($this->RSS['COPYRIGHT']) ) { $rss .= "".$this->RSS['COPYRIGHT']."\n"; } if ( !empty($this->RSS['DOCS']) ) { $rss .= "".$this->RSS['DOCS']."\n"; } if ( !empty($this->RSS['WEBMASTER']) ) { $rss .= "".$this->RSS['WEBMASTER']."\n ".$this->RSS['WEBMASTER']."\n"; } if ( $this->RSS['HOME_LOGO'] != null && $this->RSS['RSS_version'] > 1 ) { $rss .= " ".$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']." \n"; } /* * Item : les news : */ $rss .= $this->getItem(); /* * Fin du fichier RSS : */ $rss .= " "; $this->destructor(); return $rss; } /** * Pseudo destructeur, sert rien mais peut servir plus tard en php5. * @author LLaumgui * @since 1.5. */ function destructor(){ $this->DB->close_DB(); } } // EOC ?>