示例#1
0
 public function RSSComplet()
 {
     log::add('rss', 'debug', '/**************************************************/');
     log::add('rss', 'debug', '/*                                                */');
     log::add('rss', 'debug', '/*    Lancement de la recherche de flux RSS       */');
     log::add('rss', 'debug', '/*                                                */');
     log::add('rss', 'debug', '/**************************************************/');
     $lien_dossier = realpath(dirname(__FILE__) . '/../../flux_rss');
     log::add('rss', 'debug', 'Lien du dossier RSS :' . $lien_dossier);
     $handle = opendir($lien_dossier . '/');
     while (false !== ($fichier = readdir($handle))) {
         if ($fichier != "." && $fichier != "..") {
             unlink($lien_dossier . '/' . $fichier);
         }
     }
     log::add('rss', 'debug', '////////////////////////////////////////////////////');
     foreach (rss::byType('rss') as $rss_plugin) {
         log::add('rss', 'debug', 'params :' . $rss_plugin->getId());
         $parametre = $rss_plugin->getId();
         $nom_json_parametre = array();
         log::add('rss', 'debug', '----------------------------------------------------');
         foreach (cmd::byEqLogicId($parametre) as $cmd_rss_plugin) {
             $lien_recuperation = $lien_dossier . '/' . rss::myUrlEncode($cmd_rss_plugin->getName()) . '.json';
             log::add('rss', 'debug', 'fichier tester :' . $lien_recuperation);
             $derniere_description = null;
             if ($cmd_rss_plugin->getIsVisible() == 1) {
                 $array_push = rss::myUrlEncode($cmd_rss_plugin->getName());
                 array_push($nom_json_parametre, $array_push);
                 $configuration_rss = $cmd_rss_plugin->getConfiguration();
                 $lien_rss = $configuration_rss['lien_rss'];
                 $nbr = $configuration_rss['nbr_article'];
                 $name_rss = $cmd_rss_plugin->getName();
                 log::add('rss', 'debug', 'Lien :' . $lien_rss . ' ,Nombre :' . $nbr . ' ,Nom :' . $name_rss);
                 $array_rss_avant = RSS_Links($lien_rss, $nbr);
                 log::add('rss', 'debug', 'Retour RSS :' . json_encode($array_rss_avant));
                 log::add('rss', 'debug', 'Retour premier titre RSS :' . $array_rss_avant[0][1]['title']);
                 log::add('rss', 'debug', 'Nous avons une nouveauté :' . $array_rss_avant[0][1]['title']);
                 $array_rss = array('name_rss' => $name_rss, 'lien_rss' => $lien_rss, 'contenu' => $array_rss_avant);
                 $json_array = json_encode($array_rss);
                 $file_rss = fopen($lien_recuperation, 'w');
                 fwrite($file_rss, $json_array);
                 fclose($file_rss);
                 log::add('rss', 'debug', 'Nouveau Fichier enregistré');
             } else {
                 log::add('rss', 'debug', 'N est pas selectionne');
             }
             log::add('rss', 'debug', '----------------------------------------------------');
             $nom_json_parametre_json = json_encode($nom_json_parametre);
             $file_rss_get = fopen($lien_dossier . '/fluxrss_' . $rss_plugin->getId() . '.json', 'w');
             fwrite($file_rss_get, $nom_json_parametre_json);
             fclose($file_rss_get);
         }
         log::add('rss', 'debug', '////////////////////////////////////////////////////');
     }
 }
<p>This demo loads a remote RSS feed and displays only the links of each entry 
  below.<br>
  It makes use of PHP and the rsslib.php library to extract and display the information.</p>
<p> Type the URL of a RSS file: </p>
<FORM name="rss" method="POST" action="rss-links.php">
<p>
	<INPUT type="submit" value="Submit">
</p>
  <p> 
    <input type="text" name="dyn" size="48" value="http://www.xul.fr/rss.xml">
  </p>
</FORM><?php 
if (isset($_POST)) {
    $posted =& $_POST;
} else {
    $posted =& $HTTP_POST_VARS;
}
if ($posted != false && count($posted) > 0) {
    $url = $posted["dyn"];
    if ($url != false) {
        echo RSS_Links($url, 15);
    }
}
?>




</body>
</html>