Votez pour l'artiste que vous aimerez voir en concert !

[Amélioration] RSS sur les catégories

Recherche
Posté le 21/06/2007 à 22:21
ssjgotrunk
Mangaka anonyme
Avatar de ssjgotrunk
Alertes
Inscrit le 11/01/2007
Messages : 11
Hors ligne
L'idéé simple(really simple) serait de créer un flux rss (really simple syndication) intégré aux sites pour être notifié des nouvelles entrées
dans la totalité et filtré par catégories

En attendant pour palier au manque;
un code à placer dans un fichier php sur un site perso, qui s'utilise avec en parametre la catégorie

monsite.fr/xxx/nautiljon_rss.php?cat=ost
monsite.fr/xxx/nautiljon_rss.php?cat=jmusic
etc....

avec dans nautiljon_rss.php le code
<?
// This program is public domain. Do with this what you want.
// It is derived from Gnews2rss (http://www.voidstar.com/gnews2rss.php )
// by Barijaona Ramaholimihaso


// -------------------------------------------------- --------------------------

// URL to parse
$url = "http://www.nautiljon.com/".$_GET['cat'];;

// do not scrap before this text
$ignore_before = "<table id=\"dernier_ajouts\" >";

// encoding
$encoding = "iso-8859-1";

// description

// language
$channel_language = "fr-fr";

// regular expression pattern, and positions
// of interesting stuff delimited by parenthesis in the pattern
$itemregexp = "/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/";

$url_match_number = 1;
$title_match_number = 2;
$desc_match_number = 3;

// This is used to suppress some tags and makes writing the search pattern easier
$searchable_tags = "<A><B><BR><BLOCKQUOTE><CENTER><DD><DL><DT><HR><I> <IMG><LI><OL><P><PRE><U><UL>";

//------------------------------------------------ -- ----------------------------

$allowable_tags = "<A><B><BR><BLOCKQUOTE><CENTER><DD><DL><DT><HR><I> <IMG><LI><OL><P><PRE><U><UL>";

header("Cache-Control: public");

header("Content-Type: text/xml");

preg_match("/(http:\/\/([^\/]*))/i", $url, $matches);
$root = $matches[1]."/";

if ($fp = @fopen($url, "r")) {
while (!feof($fp)) $data .= fgets($fp, 128);
fclose($fp);
}

// *******************

eregi("<title>(.*)</title>", $data, $title);

$channel_title = $title[1];

$channel_description = "Nautiljon ".$title[1];

// trash the text before the $ignore_before text
$data = strstr($data,$ignore_before);

// suppress some tags and makes writing the search pattern easier
$data = strip_tags($data, $searchable_tags);

$match_count = preg_match_all($itemregexp, $data, $items);
$match_count = ($match_count > 70) ? 70 : $match_count;

$output .= "<?xml version=\"1.0\" encoding=\"$encoding\" ?>\n";
$output .= "<!DOCTYPE rss >\n";

$output .= "<rss version=\"2.0\">\n";
$output .= " <channel>\n";
$output .= " <title>$channel_title</title>\n";
$output .= " <link>". htmlentities($url) ."</link>\n";
$output .= " <description>$channel_description</description>\n" ;
$output .= " <language>$channel_language</language>\n";
$output .= " <generator>ssjgotrunk</generator>\n";

for ($i=0; $i< $match_count-1; $i++) {

$item_url = $items[$url_match_number][$i];
$item_url = htmlspecialchars($item_url, ENT_QUOTES, $encoding);
$item_url = preg_replace("%^/%", $root, $item_url);

$title = $items[$title_match_number][$i];
$title = strip_tags($title);
$title = htmlspecialchars(html_entity_decode($title, ENT_QUOTES, $encoding), ENT_QUOTES, $encoding);
$title = preg_replace("/&#([0-9]+);/", "&#\${1};", $title);

$desc = $items[$desc_match_number][$i];
$desc = strip_tags($desc, $allowable_tags);
$desc = htmlspecialchars(html_entity_decode($desc, ENT_QUOTES, $encoding), ENT_QUOTES, $encoding);
$desc = preg_replace("/&#([0-9]+);/", "&#\${1};", $desc);

if(strcmp($title,"")!=0){
$output .= " <item>\n";
$output .= " <title>". $title ."</title>\n";
$output .= " <link>". $item_url ."</link>\n";
$output .= " <description>". $desc ."</description>\n";
$output .= " </item>\n";
}
}

$output .= " </channel>\n";
$output .= "</rss>\n";

print $output;

?>

(Edité 1 fois. Dernière édition par ssjgotrunk le 23/06/2007 à 09:50)


Posté le 22/06/2007 à 09:23
Nautiljon
Mokona Fan
Avatar de Nautiljon
Alertes
Inscrit le 09/04/2005
Messages : 2702
Localisation : Dans un autre univers
Hors ligne
Oui, je dois remettre le RSS sur le site, y'en avait sur la V1 mais j'ai pas pris le temps de remettre vu qu'il y a des trucs plus importants à remettre comme la section propositions de films asiatiques, de vidéos et tout ^^

Mais oui quand je le remettrai je ferais un RSS par section ça évitera de venir chercher sur la page d'accueil ! :)


Posté le 22/06/2007 à 14:30
miakachan
Chevalier d'or
Avatar de miakachan
Alertes
Inscrit le 29/04/2007
Messages : 368
Localisation : quand " en ligne" ça veut dire devant le PC XD
Hors ligne
J'ai toujours pas compris ce qu'est un flux RSS :aieaieaie: :bybye:

Forum dédié au manga/anime Death note , Actif ,tout ceux qui aime faire des RPG sont bienvenus , laissez cours à votre imagination ^^ Bonne ambiance , venez y participez vous le regreterez pas !

http://deathnote-rpyaoi.forumsactifs.com/index.htm
Posté le 22/06/2007 à 20:20
Nautiljon
Mokona Fan
Avatar de Nautiljon
Alertes
Inscrit le 09/04/2005
Messages : 2702
Localisation : Dans un autre univers
Hors ligne
Une adresse que tu colles dans un logiciel, c'est comme un outlook si tu veux, sauf qu'au lieu de relever des mails, ça relève des news. Comme ça t'évite d'aller sur tes 5 boites emails (hotmail, gmail, caramail etc.) pour voir tes mails, là ca t'évite d'aller sur tous les sites pour voir les news.


Haut de page

Vous devez être membre pour pouvoir poster un message, identifiez-vous ou inscrivez-vous !