2 #-----------------------------------------------------#
3 # Plugin : Couteau Suisse - Licence : GPL #
4 # Auteur : Patrice Vanneufville, 2007 #
5 # Contact : patrice¡.!vanneufville¡@!laposte¡.!net #
6 # Infos : http://www.spip-contrib.net/?article2166 #
7 #-----------------------------------------------------#
8 if (!defined("_ECRIRE_INC_VERSION")) return;
10 // compatibilite spip 1.9
11 if(!function_exists(ajax_retour
)) {
12 function ajax_retour($corps) {
13 $c = $GLOBALS['meta']["charset"];
14 header('Content-Type: text/html; charset='. $c);
15 $c = '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n";
20 if(defined('_SPIP19100') && !function_exists('spip_xml_load')) {
21 function spip_xml_load($url){
22 include_spip('inc/distant');
23 $texte = recuperer_page($url);
24 include_spip('inc/plugin');
25 return parse_plugin_xml($texte);
29 function exec_cs_boite_rss_dist() {
30 if (!cout_autoriser()) {
31 include_spip('inc/minipres');
32 echo defined('_SPIP19100')?
minipres( _T('avis_non_acces_page')):minipres();
35 $force = _request('force');
38 // on cherche le flux rss toutes les deux heures
40 $lastmodified = @file_exists(_DIR_RSS_TMP
)?
@filemtime(_DIR_RSS_TMP
):0;
41 if (time()-$lastmodified < 2*3600) lire_fichier(_DIR_RSS_TMP
, $p);
43 if(strlen($p)) { ajax_retour($p); return; }
44 include_spip('action/editer_site');
45 include_spip('inc/xml');
46 $r = spip_xml_load(_CS_RSS_SOURCE
);
47 if (function_exists('spip_xml_match_nodes')) $c = spip_xml_match_nodes(',^item$,', $r, $r2);
49 $r2= array_shift(array_shift(array_shift(array_shift($r))));
54 $c = count($r3); $p='';
55 for($i=0; $i<min($c, 12); $i++
) {
56 $l = $r3[$i]['link'][0];
57 $t = str_replace('&', '&', htmlentities($r3[$i]['title'][0], ENT_NOQUOTES
, "UTF-8"));
58 $t = preg_replace(',\s*€(¦)?,', ' (…)', $t);
59 $t = preg_replace(',^(.*?):,', "• <a href='$l' class='spip_out' target='_cout'>$1</a>:", $t);
60 $p .= "<li style='padding-top:0.6em;'>$t</li>";
63 include(_DIR_PLUGIN_COUTEAU_SUISSE
.'cout_fonctions');
64 $p = '<span style="color: red;">'._T('couteauprive:erreur:probleme', array('pb'=>cs_lien(_CS_RSS_SOURCE
,_T('couteauprive:erreur:distant')))).'</span>';
66 include_spip('inc/filtres');
67 $du = affdate_heure(date('Y-m-d H:i:s',time()));
68 $p = '<ul style="list-style-type:none; padding:0; margin:0; ">'.$p
69 .'</ul><p class="spip_xx-small"><b>'
70 ._T('couteauprive:rss_edition')."</b><br/>$du</p>";
71 if($c) ecrire_fichier(_DIR_RSS_TMP
, $p);