function exec_cs_boite_rss_dist() { cs_minipres(); // Constantes distantes include_spip('cout_define'); if(defined('_CS_PAS_DE_DISTANT')) { ajax_retour(_T('couteauprive:version_distante_off')); return; } $p = ''; // on cherche le flux rss toutes les _CS_RSS_UPDATE minutes $force = _request('force')=='oui'; if(!$force) { $lastmodified = @file_exists(_CS_TMP_RSS)?@filemtime(_CS_TMP_RSS):0; if(time()-$lastmodified < _CS_RSS_UPDATE) lire_fichier(_CS_TMP_RSS, $p); } if(strlen($p)) { ajax_retour($p); return; } include_spip('inc/filtres'); include_spip('action/editer_site'); include_spip('inc/xml'); $r = spip_xml_load(_CS_RSS_SOURCE); if(function_exists('spip_xml_match_nodes')) $c = spip_xml_match_nodes(',^item$,', $r, $r2); else { $r2 = !is_array($r)?array():array_shift(array_shift(array_shift(array_shift($r)))); $c = count($r2); } if($c) { $r3 = &$r2['item']; $c = count($r3); $p=''; for($i=0; $i<min($c, _CS_RSS_COUNT); $i++) { $l = $r3[$i]['link'][0]; $d = affdate_court(date('Y-m-d', strtotime($r3[$i]['pubDate'][0]))); $t = str_replace('&', '&', htmlentities($r3[$i]['title'][0], ENT_NOQUOTES, "UTF-8")); $t = preg_replace(',\s*€(¦)?,', ' (…)', $t); $t = preg_replace(',^(.*?):,', "• <a href='$l' class='spip_out' target='_cout'>$1</a> <i>($d)</i><br/>", $t); $p .= "<li style='padding-top:0.6em;'>$t</li>"; } } else { // pour cs_lien() include_spip('cout_fonctions'); $p = '<span style="color: red;">'._T('couteauprive:erreur:probleme', array('pb'=>cs_lien(_CS_RSS_SOURCE,_T('couteauprive:erreur:distant')))).'</span>'; } $du = affdate_heure(date('Y-m-d H:i:s',time())); $p = '<ul style="list-style-type:none; padding:0; margin:0; ">'.$p .'</ul><p class="spip_xx-small" style="border-top:solid gray thin;"><b>' ._T('couteauprive:rss_edition')."</b><br/>$du</p>" .'<p style="text-align:right"><a href="' .generer_url_ecrire('admin_couteau_suisse','var_mode=calcul', true).'" onclick="' ."javascipt:jQuery('div.cs_boite_rss').children().css('opacity', 0.5).parent().load('".generer_url_ecrire('cs_boite_rss', 'force=oui', true).'\');return false;">' ._T('couteauprive:rss_actualiser').'</a> | <a href="' ._CS_RSS_SOURCE.'">' ._T('couteauprive:rss_source').'</a></p>'; if($c) ecrire_fichier(_CS_TMP_RSS, $p); ajax_retour($p); }
function exec_cs_version_dist() { cs_minipres(); $version = _request('version'); $force = _request('force')=='oui'; // pour la version disponible, on regarde toutes les 2h00 $maj = isset($GLOBALS['meta']['tweaks_maj'])?unserialize($GLOBALS['meta']['tweaks_maj']):array(0, ''); if (!$force && $maj[1] && (time()-$maj[0] < 2*3600)) $distant = $maj[1]; else { include_spip('inc/distant'); $distant = recuperer_page(_URL_CS_PLUGIN_XML); if ($distant) $distant = $maj[1] = preg_match(',<version>([0-9.]+)</version>,', $distant, $regs)?$regs[1]:''; $maj[0] = time(); if ($distant) ecrire_meta('tweaks_maj', serialize($maj)); ecrire_metas(); } include_spip('inc/texte'); include_spip('cout_fonctions'); // fonctions pour les pipelines if (!$distant) return ajax_retour('<span style="color: red;">'._T('couteauprive:erreur:probleme', array('pb'=>cs_lien(_URL_CS_PLUGIN_XML,_T('couteauprive:erreur:distant')))).'</span>'); ajax_retour(ptobr(propre($distant==$version?_T('couteauprive:version_a_jour'):( $distant?_T('couteauprive:version_nouvelle', array('version' => "[{$distant}->http://files.spip.org/spip-zone/couteau_suisse.zip]")):'' )))); }