Перейти к контенту
  • 0

RSS Как прописать вывод присоеденённых картинок.


gogamus

Вопрос

RSS Как прописать вывод присоеденённых картинок. Показываютса только смайлы, но присоеденённые картинки не выводит? Кто поможет? :(

 

 

<?
/*  --------------------------------------------------------
  < setting [paramètres] >
-------------------------------------------------------- */
// IPB's setting [Paramètres d'IPB] :
$RSS['FORUM_ID']   = array(1,2,3,4,5,6,7,8);		  // News forum id		   [iD du forum contenant les news].
$RSS['NEWS_LIMIT']    = 30;		    // Show a max of x news		 [Nombre maximum de news à afficher].
$RSS['BOARD_URL']   = '';    // IPB board's url		   [url du forum IPB].
$RSS['BOARD_PATH']   = './';		 // 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']   = 'l';		 // Website's name		   [Nom du site web].
$RSS['HOME_DESCRIPTION'] = ' too';	   // Website's description		 [Description du site].
$RSS['HOME_URL']   = 't';	  // Website's url		   [url du site web].
$RSS['LANGUAGE']   = 'en';		   // Website's language		 [Langue du site].
$RSS['COPYRIGHT']   = '(c) 2005 by VJ All Rights Reserved';	    // Your copyright		  [Copyright de votre flux].
$RSS['DOCS']    = '';		   // RSS documentations		 [Documentation explicative].	   
$RSS['WEBMASTER']   = '';	    // 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'].'/style_images/1/logo.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'] = 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 <madromas@yahoo.com>
 * @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 MadRomas
 * @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();
}

/**
 * Récupération des différentes news (item).
 * @author MadRomas
 * @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 ".$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() )
  {
   $item .= "<item>
		  <pubDate>".gmdate('r', $row['post_date'])."</pubDate>
		  <title>".$row['title']."</title>
 <description>".$this->html2text($row['post'])."</description>
		  <link>".$this->RSS['BOARD_URL']."/topic".$row['tid'].".html</link>
	   </item>";
  }
 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 MadRomas
 * @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( '#<!--emo(.*?)-->(.*?)<!--endemo-->#ie', '',  $text );  // Vire les émoticons.
   $text = preg_replace( '#<a (.+?)>(.*?)</a>#is',	 '\\2',  $text );  // Vire le HTML.
   $text = preg_replace( '#<b>(.*?)</b>#is',	   '\\1',  $text );
   $text = preg_replace( '#<u>(.*?)</u>#is',	   '\\1',  $text );
   $text = preg_replace( '#<i>(.*?)</i>#is',	   '\\1',  $text );
   $text = preg_replace( '#<div (.+?)>(.*?)</div>#is',    '\\2',  $text );
   $text = preg_replace( '#<span (.+?)>(.*?)</span>#is',   '\\2',  $text );
   $text = preg_replace( '#<!--(.+?)-->#is',	  '',  $text );  // Vire d'autre chose .
   $text = str_replace ( '<br />',		 "\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( '#<!--emo(.*?)-->(.*?)<!--endemo-->#ie', '',  $text );  // Vire les émoticons.
   $text = preg_replace( '#<!--(.+?)-->#is',	  '',  $text );  // Vire d'autre chose .
   $text = str_replace ( '€',		   '€', $text );
   $text = '<![CDATA['.$text.']]>'; 
  }

 return $text;
}

/**
  * Génération du fichier RSS.
 * @author LLaumgui <llaumgui@xperience-fr.net>
 * @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");

 /* <?xml-stylesheet href='rss.css' type='text/css'?> */
 $backend = "<?xml version='1.0' encoding='".$this->RSS['CHARSET']."'?>
 <rss version='".$this->RSS['RSS_version'].".0'>
  <channel>
   <title>".$this->RSS['HOME_NAME']."</title>
   <link>".$this->RSS['HOME_URL']."</link>
   <generator>RSS VJ v".$this->RSS['RSS_IPB_VERSION']."</generator>
   <description>".$this->RSS['HOME_DESCRIPTION']."</description>
   <lastBuildDate>".gmdate('r')."</lastBuildDate>";
   if ( !empty($this->RSS['LANGUAGE']) ) { $backend .= "<language>".$this->RSS['LANGUAGE']."</language>"; }
   if ( !empty($this->RSS['COPYRIGHT']) ) { $backend .= "<copyright>".$this->RSS['COPYRIGHT']."</copyright>"; }
   if ( !empty($this->RSS['DOCS']) )  { $backend .= "<docs>".$this->RSS['DOCS']."</docs>"; }
   if ( !empty($this->RSS['WEBMASTER']) )
 {
  $backend .= "
   <managingEditor>".$this->RSS['WEBMASTER']."</managingEditor> 
<webMaster>".$this->RSS['WEBMASTER']."</webMaster>";
 }
   if ( $this->RSS['HOME_LOGO'] != null && $this->RSS['RSS_version'] > 1 )
 {
  $backend .= "<image>
   <url>".$this->RSS['HOME_LOGO']."</url>
   <link>".$this->RSS['HOME_URL']."</link>
   <title>".$this->RSS['HOME_NAME']."</title>
   <width>".$this->RSS['HOME_LOGO_WIDTH']."</width>
   <height>".$this->RSS['HOME_LOGO_HEIGHT']."</height>
   <description>".$this->RSS['HOME_DESCRIPTION']."</description>
  </image>";
 }
 /*
  * Item : les news :
  */
 $backend .= $this->getItem();

 /*
  * Fin du fichier RSS :
  */
 $backend .= "</channel>
 </rss>";

 $this->destructor();

 return $backend;
}
/**
  * Pseudo destructeur, sert à rien mais peut servir plus tard en php5.
 * @author LLaumgui <llaumgui@xperience-fr.net>
 * @since 1.5.
  */
 function destructor(){

  $this->DB->close_DB();
}

} // EOC
?>

Ссылка на комментарий
Поделиться на других сайтах

Рекомендуемые сообщения

  • 0

в функции function getItem()

переписать алгоритм

в цикле

while ( $row = $this->DB->fetch_row() )

не формировать рсс, а подготавливать массив данных для (1)формирования рсс, (2)запроса к таблице аттачей

затем делать запрос к таблице аттачей по (2), формировать данные по картинкам (3) и сращивать для вывода (1) и (3) и возвращать результат

Ссылка на комментарий
Поделиться на других сайтах

  • 0

оказалось в 1.3 все настолько просто, что стыд и позор

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, p.attach_id
					 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() )
  {
   $attach="";
   if($row['attach_id']) $attach="<br/><img src='{$this->RSS['HOME_URL']}/uploads/{$row['attach_id']}' alt='img' />";
   $item .= "<item>
					  <pubDate>".gmdate('r', $row['post_date'])."</pubDate>
					  <title>".$row['title']."</title>
	 <description>".$this->html2text($row['post'].$attach)."</description>
					  <link>".$this->RSS['BOARD_URL']."/topic".$row['tid'].".html</link>
			   </item>";
  }
 return $item;
}

Ссылка на комментарий
Поделиться на других сайтах

  • 0

БРАВО!!! Спасибо большое.

 

Да кастати, если кто то будет использовать этот рсс, то знайте, смайлики не прописываютса, хотя должны. Мне это не нужно, так, чтоб знали. :x:

Изменено пользователем Roman A Zagorodni
Ссылка на комментарий
Поделиться на других сайтах

Присоединиться к обсуждению

Вы можете ответить сейчас, а зарегистрироваться позже. Если у вас уже есть аккаунт, войдите, чтобы ответить от своего имени.

Гость
Ответить на вопрос...

×   Вы вставили отформатированный текст.   Удалить форматирование

  Допустимо не более 75 смайлов.

×   Ваша ссылка была автоматически заменена на медиа-контент.   Отображать как ссылку

×   Ваши публикации восстановлены.   Очистить редактор

×   Вы не можете вставить изображения напрямую. Загрузите или вставьте изображения по ссылке.

Зарузка...
×
×
  • Создать...

Важная информация

Находясь на нашем сайте, вы соглашаетесь на использование файлов cookie, а также с нашим положением о конфиденциальности Политика конфиденциальности и пользовательским соглашением Условия использования.