<?php // Ůńïčøđē

/**
 * @file index.php
 * @brief Page qui récupère les flux rss de plusieurs sites alternatifs.
 *
 * @note les URLs ont été récupérées sur le site http://info.pinterac.net 
 *
 * @author hughes monget
 * @see http://monget.com/
 * @see http://info.pinterac.net 
 * https://www.000webhost.com/features
 *
 */

 //phpinfo(); exit;
 
error_reporting(E_ALL E_NOTICE E_STRICT E_DEPRECATED E_WARNING);
set_time_limit(0);
$arr_ini_set = array('log_errors' => 0'display_errors' => 1'error_log' => 0'html_errors' => 0'date.timezone' => 'Europe/Paris');
array_walk($arr_ini_set, function($v$k) { ini_set($k$v); } );
if (!
setlocale(LC_ALL'french')) { echo 'locale not set'; }

//header('Content-Type: text/html; charset=UTF-8');
ini_set('default_charset''UTF-8');

if (isset(
$_REQUEST['source']))
{
    
highlight_file(__FILE__);
    exit;
}


if (!
extension_loaded('curl'))
{
    exit(
'L\'extension curl doit être activée dans : '.php_ini_loaded_file());
}

define('NOMBRE_MAX_NEWS'10);

define('REPERTOIRE_CACHE'dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR);
define('DUREE_CACHE_SECONDE'3600);

$int_time time();

if (isset(
$_REQUEST['flush']))
{
    foreach(
glob(REPERTOIRE_CACHE.'*') as $str_fichier)
    {
        if (
is_file($str_fichier))
        {
            
unlink($str_fichier);
        }
    }
}

echo
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Agrégateur d\'Informations Alternatives</title>
        <meta name="description" content="Agrégateur d\'Informations Alternatives" />
        <meta name="keywords" content="" />
        <style type="text/css">
        <!--
        body { color: #999; background: #000; }
        a:link { color: #999; }
        a:visited { color: #666; }
        a:hover { color: #999; }
        a:active { color: #999; }
        a { text-decoration: none; }
        -->
        </style>
    </head>
    <body>
'
;

/*
SOURCE : https://bonnesnouvellesinfo.fr/2015/10/06/sites-dinformation-independants/

http://www.egaliteetreconciliation.fr/
https://fr.wikipedia.org/wiki/Atlantico
https://www.mediapart.fr/
http://www.agoravox.fr/
https://www.faitsetdocuments.com/index.html numéro payant
http://www.les-crises.fr/
http://reseauinternational.net/
https://mrmondialisation.org/
https://lesmoutonsenrages.fr/
http://russeurope.hypotheses.org/    RussEurope est le carnet de Jacques Sapir
http://www.medias-presse.info/
http://www.bastamag.net/
http://www.voltairenet.org/ Thierry Meyssan
http://www.jovanovic.com/blog.htm
http://www.alternatives-economiques.fr/    TINA
http://www.reporterre.net/
https://www.rivarol.com/
https://lareleveetlapeste.fr/
http://lesakerfrancophone.fr/
http://www.politis.fr/
https://planetes360.fr/
http://www.acrimed.org/
http://www.panamza.com/
http://www.michelcollon.info/
https://www.breizh-info.com/
http://www.dedefensa.org/
http://www.kaizen-magazine.com/
http://arretsurinfo.ch/
http://www.fakirpresse.info/
http://www.pauljorion.com/blog/
https://reflets.info/
http://www.cercledesvolontaires.fr/
http://www.ojim.fr/  ’Observatoire des journalistes et de l’information médiatique
http://rebellyon.info/
http://leseconoclastes.fr/
http://wanted-pedo.com/bis/
http://www.agenceinfolibre.fr/
http://www.lagedefaire-lejournal.fr/

http://kadertahri.canalblog.com Islam un Héritage, une Voie de vérité !

http://infojmoderne.com juif

SOURCE : https://www.20minutes.fr/high-tech/2936119-20201221-sites-publie-plus-intox-coronavirus-france

FL24.net
RiposteLaique.com
LesMoutonsRebelles.com
LeCourrier-du-Soir.com
FranceSoir.fr
NS2017.wordpress.com
NoSignalFound.fr
ReseauInternational.net
Breizh-Info.com
Medias-Presse. info
+ Mirastnews.net

--
https://www.youtube.com/channel/UCT67YOMntJxfRnO_9bXDpvw LE MEDIA

https://www.thinkerview.com

*/

// Définition de la liste des URL
$mix_liste_url = <<<URL
http://www.opex360.com/feed/
https://www.thinkerview.com/feed/podcast
https://www.ojim.fr/feed/
http://leseconoclastes.fr/feed/
https://tribune-diplomatique-internationale.com/feed/
https://lesmoutonsrebelles.com/feed/
https://lemediaen442.fr/feed/
http://covidemence.com/feed/
https://escapethecity.life/feed
http://h16free.com/feed
https://french.alahednews.com.lb/rss/322
https://www.contrepoints.org/feed
https://www.tribunejuive.info/feed/
https://www.breizh-info.com/category/actualite-societale/sante/feed/
https://www.courrierinternational.com/feed/all/rss.xml
https://francais.rt.com/rss
https://www.bastamag.net/spip.php?page=backend
http://lesmoutonsenrages.fr/feed/atom/
https://www.crashdebug.fr/?format=feed&type=atom
http://echelledejacob.blogspot.com/feeds/posts/default
http://fawkes-news.blogspot.com/feeds/posts/default
https://fr.sputniknews.com/export/rss2/archive/index.xml
http://feeds.feedburner.com/les-crises-fr
http://fr.sott.net/xml_engine/signs_rss
http://reseauinternational.net/feed/
http://www.lelibrepenseur.org/feed/
http://www.alternatives-economiques.fr/rss.xml
http://www.actu-environnement.com/ae/news/archives/rss.php4
http://feeds.feedburner.com/agoravox/gEOF
http://www.cafe-sciences.org/feed/
http://www.acrimed.org/spip.php?page=backend
http://portail.cea.fr/_layouts/15/i2i/web/ceasrchrss.ashx?pid=3748&wid=g_9cac7691_a0b2_4e18_850e_0aeff2541696
http://www.futura-sciences.com/rss/actualites.xml
http://www.infoetsecret.com/rss
http://alyaexpress-news.com/feed/
http://www.notre-planete.info/news/news.xml
http://www.techno-science.net/include/news.xml
http://survivreauchaos.blogspot.com/feeds/posts/default?alt=rss
https://www.sciencesetavenir.fr/rss.xml
http://www.panamza.com/?feed=rss2
http://www.juif.org/rss/infos.rss
https://lilianeheldkhawam.com/feed/
https://www.infolibertaire.net/feed/
https://www.tvlibertes.com/feed
https://www.revolutionpermanente.fr/spip.php?page=backend
https://www.valeursactuelles.com/feed?post_type=post
https://www.20minutes.fr/feeds/rss-une.xml
https://actu.fr/rss.xml
https://reporterre.net/spip.php?page=backend-simple
https://www.legrandsoir.info/spip.php?page=backend&id_article=37762
https://www.chroniquesdugrandjeu.com/rss
http://dedefensa.org/rss
https://leblogdenathaliemp.com/feed/
https://lecourrierdesstrateges.fr/feed/
https://stratpol.com/feed/
https://brunobertez.com/feed/
https://geopolitique-profonde.com/feed/
https://katehon.com/fr/rss.xml

#https://leblogalupus.com/feed/
#http://www.2012un-nouveau-paradigme.com/rss
#http://www.fakirpresse.info/spip.php?page=backend
#https://www.voltairenet.org/spip.php?page=backend&id_secteur=1110&lang=fr
#https://ecohmag.com/feed/
#https://fl24.net/feed/
#https://www.mediapart.fr/articles/feed

#http://www.lesmysteresdarkebi.com/rss.xml
#http://www.lesinrocks.com/actualite/feed/
#http://www.cercledesvolontaires.fr/feed/
#http://etat-du-monde-etat-d-etre.net/feed
#http://ilfattoquotidiano.fr/feed/
#http://overblog.superfeedr.com/

#http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_day.atom
#http://lechemindeleveil.blogspot.com/feeds/posts/default
#http://spread-the-truth777.blogspot.com/feeds/posts/default?alt=rss
#http://verite-cache.over-blog.com/rss
#http://flux.consoglobe.com/consoglobe
#http://www.lejournalinternational.fr/xml/syndication.rss
#http://fukushima-diary.com/feed/

#https://lesmitrons.fr/feed/
#http://www.agenceinfolibre.fr/feed/
#http://www.nouvelobs.com/rss.xml
#http://quenelplus.com/feed
#http://www.pluxactu.com/feed/rss
#http://juste-geek.com/feed/
#http://laleveedesvoiles.fr/feed/
#http://openews.eu/feed/
#http://sport365.feedsportal.com/c/356/f/599869/index.rss
#http://www.chaos-controle.com/rss.xml
#http://www.labosvj.fr/feed/
#http://interconscience.blogspot.com/feeds/posts/default
#http://allainjules.com/feed/
#http://lejournaldusiecle.com/feed/
#https://lesalternatifs.info/feed/

URL;

// Extraction de la liste.
$mix_liste_url explode("\n"$mix_liste_url);
$mix_liste_url array_map('trim'$mix_liste_url);
$mix_liste_url array_filter($mix_liste_url);
//$mix_liste_url = array_filter($mix_liste_url, create_function('$s', 'return !preg_match(\'/^\s*#/\', $s);'));
$mix_liste_url array_filter($mix_liste_url, function($s) { return !preg_match('/^\s*#/'$s); } ) ;
$mix_liste_url array_unique($mix_liste_url);
shuffle($mix_liste_url);

//$mix_liste_url = array_filter($mix_liste_url, create_function('$s', 'return (stripos($s, \'portail.cea.fr\') !== FALSE);'));

//$mix_liste_url = array('https://www.crashdebug.fr/?format=feed&type=atom');

$arr_debug = array();

echo 
'<hr />';

// Parcours des URLS.
foreach ($mix_liste_url as $str_url)
{
    
$arr_debug[$str_url] = time();
        
    
$str_chemin_cache REPERTOIRE_CACHE.md5($str_url).'.xml';

    
$int_derniere_modification is_file($str_chemin_cache) ? filemtime($str_chemin_cache) : 0;
    
    
// Récupération du flux rss atom.
    
$str_xml '';
    if ((
time() - $int_derniere_modification) < DUREE_CACHE_SECONDE)
    {
        
// Gestion d'un cache.
        
$str_xml file_get_contents($str_chemin_cache);
    }
    else
    {
        
// Requête http: récupération du flux rss atom.
        // On passe par curl car certains sites bloquent les robots.
        
$res_curl curl_init();
        
curl_setopt($res_curlCURLOPT_URL$str_url);
        
curl_setopt($res_curlCURLOPT_USERAGENT'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.172 Safari/537.36 Vivaldi/2.5.1525.48');
        
curl_setopt($res_curlCURLOPT_HTTPHEADER, array('Accept: text/html,application/xhtml+xml,application/xml''Accept-Language: fr-FR,fr''Cache-Control: max-age=0''Upgrade-Insecure-Requests: 1'));
        
curl_setopt($res_curlCURLOPT_HEADERFALSE);
        
curl_setopt($res_curlCURLOPT_RETURNTRANSFERTRUE);
        
curl_setopt($res_curlCURLOPT_SSL_VERIFYPEERFALSE);
        
curl_setopt($res_curlCURLOPT_FOLLOWLOCATIONTRUE);
        
curl_setopt($res_curlCURLOPT_HTTP_VERSIONCURL_HTTP_VERSION_1_1);
        
curl_setopt($res_curlCURLOPT_TIMEOUT3);
        
$str_xml curl_exec($res_curl);
        
$int_code_erreur curl_getinfo($res_curlCURLINFO_HTTP_CODE);
        if (
$int_code_erreur == 200)
        {
            
file_put_contents($str_chemin_cache$str_xml);
            
touch($str_chemin_cache);
            
$int_derniere_modification is_file($str_chemin_cache) ? filemtime($str_chemin_cache) : 0;
        }
        else
        {
            echo 
'<div><b>'.$str_url.' - erreur http '.strval($int_code_erreur).'</b></div>';
            echo 
'<p>'.pathinfo($str_chemin_cachePATHINFO_FILENAME).'</p>';
        }
        
curl_close($res_curl);
    }
    
    
// Chargement du xml du flux rss.
    
$obj_dom_document = new DomDocument();
    
//if (strpos($str_xml, '<?xml') === 0 && $obj_dom_document->loadXml($str_xml))
    
if ($str_xml)
    {
        
$str_xml preg_replace('/&(rsquo|thinsp);?/'''$str_xml);
        
$str_xml preg_replace('#<description>.*</description>#siU'''$str_xml);
    }
    if (
strlen($str_xml) > && @$obj_dom_document->loadXml($str_xml))
    {
        
$obj_dom_xpath = new DomXpath($obj_dom_document);

        
// Titre du site.
        
$obj_dom_nodelist_title $obj_dom_xpath->query('//*[local-name() = "title"]');
        
$str_title = ($obj_dom_nodelist_title->length) ? $obj_dom_nodelist_title->item(0)->nodeValue '';
        
// Lien vers le site.
        
$obj_dom_nodelist_link $obj_dom_xpath->query('//*[local-name() = "link"]');
        
$str_link '';
        if (
$obj_dom_nodelist_link->length)
        {
            
$str_link $obj_dom_nodelist_link->item(0)->getAttribute('href');
            
$str_link $str_link $str_link $obj_dom_nodelist_link->item(0)->nodeValue;
        }
        if (!
$str_title && $str_link)
        {
            
$str_title $str_link;
        }

        echo 
'<h1><a href="'.htmlspecialchars($str_link).'" target="_blank">'.htmlspecialchars($str_title).'</a></h1>';

        
// Liste des news.
        
$obj_dom_nodelist_entry $obj_dom_xpath->query('//*[local-name() = "entry"]|//*[local-name() = "item"]');
        if (
$obj_dom_nodelist_entry->length)
        {
            echo 
"\n".'<ul>';
            for (
$ii 0$ii $obj_dom_nodelist_entry->length$ii++)
            {
                if (
$ii == NOMBRE_MAX_NEWS) { break; }
                
                
// Récupération du titre de la news.
                
$obj_dom_nodelist_title $obj_dom_xpath->query('.//*[local-name() = "title"]'$obj_dom_nodelist_entry->item($ii));
                
$str_title = ($obj_dom_nodelist_title->length) ? $obj_dom_nodelist_title->item(0)->nodeValue '';
                
                
// Récupération du lien de la news.
                // Problème 1: il peut y avoir plusieurs liens alors on part à la recherche du bon.
                
$obj_dom_nodelist_link $obj_dom_xpath->query('.//*[local-name() = "link"]|.//*[local-name() = "url"]'$obj_dom_nodelist_entry->item($ii));
                
$str_link '';
                if (
$obj_dom_nodelist_link->length)
                {
                    
$indice 0;
                    if (
$obj_dom_nodelist_link->length 1)
                    {
                        for (
$jj 0$jj $obj_dom_nodelist_link->length$jj++)
                        {
                            
//echo '<li>'.htmlspecialchars($obj_dom_document->saveXml($obj_dom_nodelist_link->item($jj))).'</li>';
                            
if ($obj_dom_nodelist_link->item($jj)->hasAttribute('rel') && $obj_dom_nodelist_link->item($jj)->getAttribute('rel') == 'alternate')
                            {
                                
$indice $jj;
                                break;
                            }
                        }
                    }
                    
// Problème 2: le lien peut être dans un attribut ou dans le noeud.
                    
if ($obj_dom_nodelist_link->item($indice)->hasAttribute('href'))
                        { 
$str_link $obj_dom_nodelist_link->item($indice)->getAttribute('href'); }
                    else
                        { 
$str_link $obj_dom_nodelist_link->item($indice)->nodeValue; }
                }
                if (!
$str_title) { $str_title $str_link; } // On affichage les liens même sans titre.
                
if ($str_title)
                {
                    echo 
"\n".'<li><a href="'.htmlspecialchars($str_link).'" target="_blank">'.htmlspecialchars(html_entity_decode($str_title)).'</a></li>';
                }
            }
            echo 
"\n".'</ul>';
        }

        
// source
        
echo "\n".'<p>(source: <a href="'.htmlspecialchars($str_url).'" target="_blank">'.htmlspecialchars($str_url).'</a> à '.date('d/m/Y H:i:s'$int_derniere_modification).') </p>';
        echo 
"\n".'<hr />';        
    }
    else
    {
        echo 
"\n".'<p>(feed en erreur: <a href="'.htmlspecialchars(strip_tags($str_url)).'" target="_blank">'.htmlspecialchars(strip_tags($str_url)).'</a>)</p>';
        if (
is_file($str_chemin_cache))
        {
            
unlink($str_chemin_cache);
        }
        if (
$str_xml)
        {
            
//echo htmlspecialchars($str_xml);
        
}
        echo 
"\n".'<hr />';
    }
    
$arr_debug[$str_url] = time() - $arr_debug[$str_url];
}

echo 
"\n".'<p>Page générée en '.strval(time() - $int_time).' s. le '.date('Y-m-d').' à '.date('H:i:s').' - <a href="'.htmlspecialchars($_SERVER['SCRIPT_NAME'].'?source').'" target="_blank">Code source de la page</a></p>';

//asort($arr_debug);
//echo '<pre>'; var_dump($arr_debug); echo '</pre>';

echo "\n".'<hr />';

echo 
"\n".'</body></html>';