Showing 15 changed files with 2059 additions and 0 deletions
+19
sources/create-json.php
... ...
@@ -0,0 +1,19 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$numNews = count($array_title);
5
+$cpt = 1;
6
+echo '['.PHP_EOL;
7
+foreach ($array_title as $key => $value) {
8
+  echo '{"name": "'.$value.'", "image": "'.$key.'", "html": "sources/'.$key.'.html"}';
9
+  if($cpt<$numNews) {
10
+    echo ','.PHP_EOL;
11
+  } else {
12
+    echo PHP_EOL;
13
+  }
14
+
15
+  $cpt=$cpt+1;
16
+}
17
+echo ']'.PHP_EOL;
18
+
19
+?>
+15
sources/gennews.sh
... ...
@@ -0,0 +1,15 @@
1
+#!/bin/bash
2
+cd /var/www/html/news2/sources
3
+php create-json.php > news.json 2> /dev/null
4
+exit 0
5
+php news-lemonde.fr.php > lemonde.html 2> /dev/null
6
+php news-liberation.fr.php > liberation.html 2> /dev/null
7
+php news-slate.fr.php > slatefr.html 2> /dev/null
8
+php news-vice.fr.php > vicefr.html 2> /dev/null
9
+php news-lesinrocks.fr.php > lesinrocks.html 2> /dev/null
10
+php news-numerama.fr.php > numerama.html 2> /dev/null
11
+php news-huffingtonpost.fr.php > huffingtonpostfr.html 2> /dev/null
12
+php news-lepoint.fr.php > lepointfr.html 2> /dev/null
13
+php news-lexpress.fr.php > lexpressfr.html 2> /dev/null
14
+php news-franceinfo.php > franceinfo.html 2> /dev/null
15
+php news-conspiracy.php > conspiracy.html 2> /dev/null
+94
sources/news-conspiracy.php
... ...
@@ -0,0 +1,94 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = http_get_contents(NEWS_RSS_CONSPIRACY);
5
+$rss_content = str_replace("<content:encoded>","<contentEncoded>",$rss_content);
6
+$rss_content = str_replace("</content:encoded>","</contentEncoded>",$rss_content);
7
+$articles = array();
8
+$xml = simplexml_load_string($rss_content);
9
+if ($xml === false) {
10
+  echo 'Failed to read RSS';
11
+} else {
12
+  $channel = array();
13
+  $channel['title'] = $xml->channel->title;
14
+  $channel['link'] = $xml->channel->link;
15
+  $channel['description'] = $xml->channel->description;
16
+  $channel['pubDate'] = $xml->channel->pubDate;
17
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
18
+  echo '<h4>' . $channel['title'] . '</h4>';
19
+  $cpt=0;
20
+  foreach ($xml->channel->item as $item) {
21
+    $article = array();
22
+    $article['title'] = $item->title;
23
+    $article['link'] = $item->link;
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $article['content'] = $item->contentEncoded;
28
+    //Extract image
29
+    $re = '/<img class="size-medium wp-image-(.+?)" src="(.+?)" alt=(.+?)>/';
30
+    preg_match($re, $article['content'], $matches);
31
+    if( isset($matches[2]) ) {
32
+      $article['image'] = $matches[2];
33
+      if ( 0 == strlen($article['image']) ) {
34
+        $re = '/<img class="aligncenter wp-image-(.+?)" src="(.+?)" alt=(.+?)>/';
35
+        preg_match($re, $article['content'], $matches);
36
+        $article['image'] = $matches[2];
37
+      }
38
+    } else {
39
+      $article['image'] = "";
40
+    }
41
+
42
+    $articles[$cpt]=$article;
43
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
44
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>';
45
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;';
46
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
47
+    echo $article['title'].'&nbsp;&nbsp;';
48
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>';
49
+    $cpt++;
50
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
51
+      break;
52
+    }
53
+  }
54
+}
55
+echo '</div><!-- ./col-4 -->';
56
+echo '<div class="col-6">';
57
+echo '<a name="article-top"></a><div id="article-current"></div>';
58
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
59
+$cpt=0;
60
+foreach ($articles as $article ) {
61
+  $cpt_prev=$cpt-1;
62
+  $cpt_next=$cpt+1;
63
+  echo '<!-- ==================== article '.$cpt.'============== -->';
64
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
65
+  echo "<hr>";
66
+  echo "<a name=\"article-$cpt\">";
67
+  $article_only = $article['content'];
68
+
69
+  $article_only = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
70
+  $article_only = preg_replace('/\s\s+/', ' ', $article_only);
71
+  $article_only = preg_replace('/<div (.+?) class="wp-video">/', '<div class="wp-video">', $article_only);
72
+  $article_only = preg_replace('/<video class="wp-video-shortcode" id="(.+?)" (.+?) preload="metadata" controls="controls">/', '<video class="wp-video-shortcode" id="\1" preload="metadata" controls="controls">', $article_only);
73
+  $article_only = preg_replace('/<iframe (.+?) src="(.+?)" (.+?)><\/iframe>/', '<iframe src="\2"></iframe>', $article_only);
74
+  $article_only = preg_replace('/<img (.+?) width="(.+?)" height="(.+?)" (.+?)>/', '<img \1 \4>', $article_only);
75
+  $article_only = preg_replace('/<img (.+?) srcset="(.+?)" sizes="(.+?)" \/>/', '<img \1>', $article_only);
76
+  $article_only = preg_replace('/<div id="(.+?)" style="width: (.+?)" (.+?)>/', '<div id="\1" \3>', $article_only);
77
+  $article_only = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
78
+
79
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
80
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
81
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
82
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
83
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>';
84
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> ';
85
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
86
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
87
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
88
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
89
+  $cpt++;
90
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
91
+      break;
92
+  }
93
+}
94
+?>
+47
sources/news-constants.php
... ...
@@ -0,0 +1,47 @@
1
+<?php
2
+include_once( 'rss.php' );
3
+$NEWS_RSS_MAX_ITEMS = 10;
4
+
5
+function DOMinnerHTML(DOMNode $element) 
6
+{ 
7
+    $innerHTML = ""; 
8
+    $children  = $element->childNodes;
9
+
10
+    foreach ($children as $child) 
11
+    { 
12
+        $innerHTML .= $element->ownerDocument->saveHTML($child);
13
+    }
14
+
15
+    return $innerHTML; 
16
+}
17
+
18
+function http_get_contents($url, $opts = [])
19
+{
20
+  $ch = curl_init();
21
+  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
22
+  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
23
+  curl_setopt($ch, CURLOPT_USERAGENT, "Wget 1");
24
+  curl_setopt($ch, CURLOPT_URL, $url);
25
+  if(is_array($opts) && $opts) {
26
+    foreach($opts as $key => $val) {
27
+      curl_setopt($ch, $key, $val);
28
+    }
29
+  }
30
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
31
+  if(FALSE === ($retval = curl_exec($ch))) {
32
+    error_log(curl_error($ch));
33
+  } else {
34
+    return $retval;
35
+  }
36
+}
37
+
38
+function re_remove($source, $regex) {
39
+    return preg_replace($regex, '', $source);
40
+}
41
+
42
+function add_https($source, $seed) {
43
+    $orgStrings = array( "http://$seed/" );
44
+    $newStrings = array( "https://$seed/" );
45
+    return str_replace($orgStrings, $newStrings, $source);
46
+}
47
+?>
+136
sources/news-franceinfo.php
... ...
@@ -0,0 +1,136 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = file_get_contents(NEWS_RSS_FRANCEINFO);
5
+$xml = simplexml_load_string($rss_content);
6
+if ($xml === false) {
7
+  echo 'Failed to read RSS';
8
+} else {
9
+  $channel = array();
10
+  $channel['title'] = $xml->channel->title;
11
+  $channel['link'] = $xml->channel->link;
12
+  $channel['description'] = $xml->channel->description;
13
+  $channel['pubDate'] = $xml->channel->pubDate;
14
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
15
+  echo '<h4>' . $channel['title'] . '</h4>';
16
+  $cpt=0;
17
+  foreach ($xml->channel->item as $item) {
18
+    $article = array();
19
+    $article['title'] = $item->title;
20
+    $article['link'] = $item->link;
21
+    $orgStrings = array('?xtor=RSS-3208');
22
+    $newStrings = array('');
23
+    $article['link']  = str_replace($orgStrings, $newStrings, $article['link']);
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $article['image'] = $item->enclosure['url'];
28
+    $articles[$cpt] = $article;
29
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
30
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>';
31
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;';
32
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
33
+    echo $article['title'].'&nbsp;&nbsp;';
34
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>';
35
+    $cpt++;
36
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
37
+      break;
38
+    }
39
+  }
40
+}
41
+echo '</div><!-- ./col-4 -->';
42
+echo '<div class="col-6">';
43
+echo '<a name="article-top"></a><div id="article-current"></div>';
44
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
45
+$cpt=0;
46
+foreach ($articles as $article ) {
47
+  $cpt_prev=$cpt-1;
48
+  $cpt_next=$cpt+1;
49
+  echo '<!-- ==================== article '.$cpt.'============== -->';
50
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
51
+  echo "<hr>";
52
+  echo "<a name=\"article-$cpt\">";
53
+  $article_content = file_get_contents($article['link']);
54
+  $doc = new DOMDocument();
55
+  $doc->preserveWhiteSpace = false;
56
+  $doc->formatOutput       = true;
57
+  $libxml_previous_state = libxml_use_internal_errors(true);
58
+  $doc->loadHTML($article_content);
59
+  libxml_clear_errors();
60
+  libxml_use_internal_errors($libxml_previous_state);
61
+  $articles = $doc->getElementsByTagName('article');
62
+  $article_only="";
63
+  foreach ( $articles as $node) {
64
+    $article_only = DOMinnerHTML($node);
65
+  }
66
+ 
67
+  $orgStrings = array(' href="/');
68
+  $newStrings = array(' href="https://www.francetvinfo.fr/');
69
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
70
+  
71
+  $orgStrings = array( 
72
+      '<p class="txt3 description-article" itemprop="description">',
73
+      '<p class="bloc_signature">',
74
+      '<span id="publisher" itemprop="Publisher" data-source="LE MONDE">',
75
+      '<div class="toolbar"></div>',
76
+      '<div id="articleBody" class="contenu_article js_article_body" itemprop="articleBody">',
77
+      '<h4>',
78
+      '</h4>',
79
+      '<h1 class="tt2" itemprop="Headline">',
80
+      '</h1>',
81
+      '<h2 class="taille_courante">',
82
+      '<h2 class="intertitre">',
83
+      '</h2>',
84
+      '<span>Le Monde</span>',
85
+      '<figure class="illustration_haut   " style="width: 534px">',
86
+      '<img width="534" data-lazyload="false" src="',
87
+      ' onload="lmd.pic(this);" onerror="lmd.pic(this);" class="lazy-retina"' );
88
+  $newStrings = array( 
89
+      '<p>',
90
+      '<p>',
91
+      '<span>',
92
+      '',
93
+      '<div>',
94
+      '<h5>',
95
+      '</h5>',
96
+      '<h3>',
97
+      '</h3>',
98
+      '<h4>',
99
+      '<h4>',
100
+      '</h4>',
101
+      'Le Monde',
102
+      '<figure>',
103
+      '<img width="100%" src="',
104
+      '' );
105
+
106
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
107
+
108
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
109
+  $article_only = $temp;
110
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
111
+  $article_only = $temp;
112
+  $re = '/<a class="lien_interne rub"(.+?)>(.+?)<\/a>/';
113
+  $temp = preg_replace($re, '\\2', $article_only);
114
+  $article_only = $temp;
115
+  $re = '/<img (.+?)data-src="(.+?)"(.+?)data-lazyload="true"(.+?)>/';
116
+  $temp = preg_replace($re, '<img width="100%" src="\\2">', $article_only); 
117
+  $article_only = $temp;
118
+  $re = '/<a href="http:\/\/ad.apsalar.com\/api\/v1\/ad(.+?)target="_blank(.+?)<\/a>/';
119
+  $temp = preg_replace($re, '', $article_only); 
120
+  $article_only = $temp;
121
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
122
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
123
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
124
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
125
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>';
126
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
127
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-upi fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
128
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
129
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
130
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
131
+  $cpt++;
132
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
133
+      break;
134
+  }
135
+}
136
+?>
+200
sources/news-huffingtonpost.fr.php
... ...
@@ -0,0 +1,200 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = file_get_contents(NEWS_RSS_HUFFINGTONPOSTFR);
5
+$orgStrings = array( 'media:content');
6
+$newStrings = array( 'mediacontent');
7
+$rss_content  = str_replace($orgStrings, $newStrings, $rss_content);
8
+$xml = simplexml_load_string($rss_content);
9
+if ($xml === false) {
10
+  echo 'Failed to read RSS';
11
+} else {
12
+  $channel = array();
13
+  $channel['title'] = $xml->channel->title;
14
+  $channel['link'] = $xml->channel->link;
15
+  $channel['description'] = $xml->channel->description;
16
+  $channel['pubDate'] = $xml->channel->pubDate;
17
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
18
+  echo '<h4>' . $channel['title'] . '</h4>';
19
+  $cpt=0;
20
+  foreach ($xml->channel->item as $item) {
21
+    $article = array();
22
+    $article['title'] = $item->title;
23
+    $article['link'] = $item->link;
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $SEARCH_SUB1='<p><img width="1024" height="';
28
+    $pos_start = strpos($item->description, $SEARCH_SUB1);
29
+    $pos_start += strlen($SEARCH_SUB1);
30
+    $SEARCH_SUB2="\"";
31
+    $pos_stop = strpos($item->description, $SEARCH_SUB2, $pos_start);
32
+    $height=substr($item->description, $pos_start, $pos_stop - $pos_start);
33
+    $article['width']=1024;
34
+    $article['height']=$height;
35
+    $SEARCH_SUB1='src="';
36
+    $pos_start = strpos($item->description, $SEARCH_SUB1);
37
+    $pos_start += strlen($SEARCH_SUB1);
38
+    $SEARCH_SUB2="\"";
39
+    $pos_stop = strpos($item->description, $SEARCH_SUB2, $pos_start);
40
+    $article['image']=$item->mediacontent['url'];
41
+    $articles[$cpt] = $article;  
42
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">'.PHP_EOL;
43
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>'.PHP_EOL;
44
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;'.PHP_EOL;
45
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
46
+    echo $article['title'].'&nbsp;&nbsp;'.PHP_EOL;
47
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>'.PHP_EOL;
48
+    $cpt++;
49
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
50
+      break;
51
+    }
52
+  }
53
+}
54
+echo '</div><!-- ./col-4 -->';
55
+echo '<div class="col-6">';
56
+echo '<a name="article-top"></a><div id="article-current"></div>';
57
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
58
+$cpt=0;
59
+foreach ($articles as $article ) {
60
+  $cpt_prev=$cpt-1;
61
+  $cpt_next=$cpt+1;
62
+  echo PHP_EOL.PHP_EOL."<!-- ==================== article '.$cpt.'============== -->".PHP_EOL;
63
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
64
+  echo "<hr>";
65
+  echo "<a name=\"article-$cpt\">\n";
66
+  $article_content = file_get_contents($article['link']);
67
+  $doc = new DOMDocument();
68
+  $doc->preserveWhiteSpace = false;
69
+  $doc->formatOutput       = true;
70
+  $libxml_previous_state = libxml_use_internal_errors(true);
71
+  $doc->loadHTML($article_content);
72
+  libxml_clear_errors();
73
+  libxml_use_internal_errors($libxml_previous_state);
74
+  $articles = $doc->getElementsByTagName('article');
75
+  foreach ( $articles as $node) {
76
+    $article_only = DOMinnerHTML($node);
77
+  }
78
+  
79
+  $orgStrings = array( '<img src="',
80
+    'style="width: 680px"',
81
+    '<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>',
82
+    ' width="500" height="281" frameborder="0" ');
83
+  $newStrings = array( '<img width="100%" src="',
84
+    'style="width: 100%"',
85
+    '',
86
+    ' width="100%" frameborder="0" ');
87
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
88
+  
89
+  $SEARCH_SUB1='<p><strong>Lire aussi :</strong></p>';
90
+  $pos_stop = strpos($article_only, $SEARCH_SUB1);
91
+  if($pos_stop) {
92
+    $temp = substr($article_only, 0, $pos_stop);
93
+    $article_only = $temp."</blockquote>";
94
+  } else {
95
+    //End of article cleanup
96
+    $SEARCHSUB='<h3 class="related-entries__title">LIRE AUSSI</h3>';
97
+    $pos_stop=false;
98
+    $pos_stop = strpos($article_only, $SEARCHSUB);
99
+    if($pos_stop) {
100
+      $temp = substr($article_only, 0, $pos_stop);
101
+      $article_only = $temp;
102
+    } else {
103
+      $SEARCHSUB='<h3 class="recirc__title trending">';
104
+      $pos_stop=false;
105
+      $pos_stop = strpos($article_only, $SEARCHSUB);
106
+      if($pos_stop) {
107
+        $temp = substr($article_only, 0, $pos_stop);
108
+        $article_only = $temp;
109
+      } else {
110
+        DEBUG("Article($cpt) : No Match");
111
+      }
112
+    }
113
+  }
114
+
115
+  $re = '/alt="(.+?)" width="(.+?)" height="(.+?)"/';
116
+  $temp = preg_replace($re, 'width="100%"', $article_only);
117
+  $article_only = $temp;
118
+  $re = '/alt="" width="(.+?)" height="(.+?)"/';
119
+  $temp = preg_replace($re, 'width="100%"', $article_only);
120
+  $article_only = $temp;
121
+  $re = '/<iframe width="500" height="(.+?)"/';
122
+  $temp = preg_replace($re, '<iframe width="100%"', $article_only);
123
+  $article_only = $temp;
124
+  $re = '/sizes="\(max-width: (.+?)\) 100vw, (.+?)"/';
125
+  $temp = preg_replace($re, 'sizes="(max-width: 100%) 100vw,100%"', $article_only);
126
+  $article_only = $temp;
127
+  $re = '/<figure id="attachment_(.+?)" style="width: (.+?)" class="wp-caption aligncenter">/';
128
+  $temp = preg_replace($re, '<figure id="attachment_\\1" style="width: 100%" class="wp-caption aligncenter">', $article_only);
129
+  $article_only = $temp;
130
+  $re = '/<img class="aligncenter size-full wp-image-(.+?)"/';
131
+  $temp = preg_replace($re, '<img ', $article_only);
132
+  $article_only = $temp;
133
+  $re = '/<iframe (.+?) height="(.+?)" (.+?) width="(.+?)">/';
134
+  $temp = preg_replace($re, '<iframe \\1 \\3 width="100%">', $article_only);
135
+  $article_only = $temp;
136
+  $re = '/<img class="image__src"/';
137
+  $temp = preg_replace($re, '<img class="image__src" width="100%"', $article_only);
138
+  $article_only = $temp;
139
+
140
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
141
+  $article_only = $temp;
142
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
143
+  $article_only = $temp;
144
+  $orgStrings = array( 
145
+    '<div id="entry_paragraph_1" class="entry-body--paragraph-ad"> <div class="ad_spot "> </div> </div>',
146
+    '<div id="entry_paragraph_2" class="entry-body--paragraph-ad"> <div class="ad_spot "> </div> </div>',
147
+    '<div id="entry_paragraph_3" class="entry-body--paragraph-ad"> <div class="ad_spot "> </div> </div>',
148
+    '<div id="entry_paragraph_4" class="entry-body--paragraph-ad"> <div class="ad_spot "> </div> </div>');
149
+  $newStrings = array( 
150
+    '',
151
+    '',
152
+    '',
153
+    '');
154
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
155
+
156
+  // Cleanup "Social"
157
+  $re='/<script id="share-bar__social-mob" (.+)<\/script>/';
158
+  $article_only = preg_replace($re, '', $article_only);
159
+  $re='/<li class="(facebook|twitter|gplus|pinterest|linkedin|email) share-bar__item">(.+)<\/a><\/li>/';
160
+  $article_only = preg_replace($re, '', $article_only);
161
+  $re='/<li class="(facebook|twitter|snapchat|instagram) follow-us-networks-item " (.+?)<\/span> <\/a> <\/li>/';
162
+  $article_only = preg_replace($re, '', $article_only);
163
+  $re='/<div class="social-overlay__qr">(.+)<\/a><\/div>/';
164
+  $article_only = preg_replace($re, '', $article_only);
165
+  $re='/<script type="text\/javascript"> \(function\(\)\{ var dfp_placement_slug(.+)<\/script>/';
166
+  $article_only = preg_replace($re, '', $article_only);
167
+  $re='/<form class="newsletter-signup" method="POST">(.+)<\/form>/';
168
+  $article_only = preg_replace($re, '', $article_only);
169
+  $re='/<div class="follow-us__header"> <h3>SUIVEZ-NOUS<\/h3> <\/div>/';
170
+  $article_only = preg_replace($re, '', $article_only);
171
+  $re='/<div class="follow-us__description"> <p>Avec la newsletter quotidienne du HuffPost(.+) target="_blank">En savoir plus<\/a> <\/p> <\/div>/';
172
+  $article_only = preg_replace($re, '', $article_only);
173
+  $re='/<li class="(facebook|instagram) follow-us-networks-item even" (.+) <\/a> <\/li>/';
174
+  $article_only = preg_replace($re, '', $article_only);
175
+  //Clean Empty lines
176
+  $article_only = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
177
+  $article_only = preg_replace('/\s\s+/', ' ', $article_only);
178
+
179
+
180
+
181
+  
182
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
183
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
184
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
185
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>'.PHP_EOL;
186
+  echo '<div class="extract-content" id="'.$cpt.'">';
187
+  echo '<h4>'.$article['title'].'</h4>';
188
+  echo $article_only.'</div>'.PHP_EOL;
189
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
190
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-upi fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
191
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
192
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
193
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>'.PHP_EOL;
194
+  echo '<!-- ENDOF ==================== article '.$cpt.'============== -->'.PHP_EOL;
195
+  $cpt++;
196
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
197
+      break;
198
+  }
199
+}
200
+?>
+249
sources/news-lemonde.fr.php
... ...
@@ -0,0 +1,249 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = file_get_contents(NEWS_RSS_LEMONDE);
5
+$xml = simplexml_load_string($rss_content);
6
+if ($xml === false) {
7
+  echo 'Failed to read RSS';
8
+} else {
9
+  $channel = array();
10
+  $channel['title'] = $xml->channel->title;
11
+  $channel['link'] = $xml->channel->link;
12
+  $channel['description'] = $xml->channel->description;
13
+  $channel['pubDate'] = $xml->channel->pubDate;
14
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
15
+  echo '<h4>' . $channel['title'] . '</h4>';
16
+  $cpt=0;
17
+  foreach ($xml->channel->item as $item) {
18
+    $article = array();
19
+    $article['title'] = $item->title;
20
+    $article['link'] = $item->link;
21
+    $orgStrings = array('?xtor=RSS-3208');
22
+    $newStrings = array('');
23
+    $article['link']  = str_replace($orgStrings, $newStrings, $article['link']);
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $article['image'] = $item->enclosure['url'];
28
+    $articles[$cpt] = $article;
29
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">'.PHP_EOL;
30
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>'.PHP_EOL;
31
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;'.PHP_EOL;
32
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
33
+    echo $article['title'].'&nbsp;&nbsp;'.PHP_EOL;
34
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>'.PHP_EOL;
35
+    $cpt++;
36
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
37
+      break;
38
+    }
39
+  }
40
+}
41
+echo '</div><!-- ./col-4 -->'.PHP_EOL;
42
+echo '<div class="col-6">'.PHP_EOL;
43
+echo '<a name="article-top"></a><div id="article-current"></div>'.PHP_EOL;
44
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
45
+
46
+$cpt=0;
47
+foreach ($articles as $article ) {
48
+  $cpt_prev=$cpt-1;
49
+  $cpt_next=$cpt+1;
50
+  echo PHP_EOL.PHP_EOL.'<!-- ==================== article '.$cpt.'============== -->'.PHP_EOL;
51
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
52
+  echo "<hr>";
53
+  echo "<a name=\"article-$cpt\">";
54
+  $article_content = file_get_contents($article['link']);
55
+  $doc = new DOMDocument();
56
+  $doc->preserveWhiteSpace = false;
57
+  $doc->formatOutput       = true;
58
+  $libxml_previous_state = libxml_use_internal_errors(true);
59
+  $doc->loadHTML($article_content);
60
+  libxml_clear_errors();
61
+  libxml_use_internal_errors($libxml_previous_state);
62
+  $articles = $doc->getElementsByTagName('article');
63
+  $article_only="";
64
+  if( isset($articles[0]) ) {
65
+    $article_only=DOMinnerHTML($articles[0]);
66
+  } else {
67
+    $article_only = "Extraction Failed";
68
+    break;
69
+  }
70
+  $figure="";
71
+  
72
+  $SEARCH_SUB='<span class="ea_article">édition abonné</span>';
73
+  $pos_start=strpos($article_content, $SEARCH_SUB);
74
+  if(!$pos_start) {
75
+    //Second Test
76
+    DEBUG("article($cpt) : Non Abonne 1");
77
+    $SEARCH_SUB='<p class="article__status"><span class="icon__premium"></span>Article réservé aux abonnés</p>';
78
+    $pos_start=strpos($article_content, $SEARCH_SUB);
79
+    if(!$pos_start) {
80
+      DEBUG("article($cpt) : Non Abonne 2");
81
+    } else {
82
+      DEBUG("article($cpt) : Abonne 2");
83
+    }
84
+  }
85
+  if($pos_start) {
86
+    try {
87
+      $figures = $doc->getElementsByTagName('figure');
88
+      if( NULL === $figures[0] ) {
89
+        DEBUG("article($cpt) : No Image");
90
+      } else {
91
+        $figure = DOMinnerHTML($figures[0]);
92
+        $re = '/<img (.+?) class="illu lazy-retina" data-src="(.+?)" (.+?) data-lazyload="true" alt="(.+?)" title="(.+?)" (.+?)>/';
93
+        preg_match($re, $figure, $array);
94
+        if(count($array) >= 5 ) {
95
+          $figure = '<img width="100%" src="'.$array[2].'"><figcaption>'.$array[4].'<br>&nbsp;<em>('.$array[5].')</em></figcaption>';
96
+        }
97
+      }
98
+    } catch(Exception $e) {
99
+      ERROR("article($cpt) : Exception".$e->getMessage());
100
+    }
101
+
102
+    $article_abonne = str_replace("www.lemonde.fr", "abonnes.lemonde.fr", $article['link']);
103
+    $article_content = file_get_contents($article_abonne);
104
+    $doc = new DOMDocument();
105
+    $doc->preserveWhiteSpace = false;
106
+    $doc->formatOutput       = true;
107
+    $libxml_previous_state = libxml_use_internal_errors(true);
108
+    $doc->loadHTML($article_content);
109
+    libxml_clear_errors();
110
+    libxml_use_internal_errors($libxml_previous_state);
111
+    $articles = $doc->getElementsByTagName('article');
112
+    $article_only="";
113
+    if( isset($articles[0]) ) {
114
+      $article_only=DOMinnerHTML($articles[0]);
115
+    } else {
116
+      $article_only = "Extraction Failed for Subscribed Article";
117
+      break;
118
+    }
119
+  }
120
+
121
+  $orgStrings = array(' href="/');
122
+  $newStrings = array(' href="https://www.lemonde.fr/');
123
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
124
+
125
+  //Remove Blank lines
126
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
127
+  $article_only = $temp;
128
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
129
+  $article_only = $temp;
130
+
131
+  //Remove Social section
132
+  $re = '/<li class="meta__icon"> <a class="js-social"(.+)<\/span> <\/li>/s';
133
+  $temp = preg_replace($re, '', $article_only);
134
+  $article_only = $temp;
135
+
136
+  //Cleanup end-of-article extraction
137
+  $re = '/<section class="article__comments">(.+)commentaires <\/a> <\/section>/';
138
+  $temp = preg_replace($re, '', $article_only);
139
+  $article_only = $temp;
140
+  $re = '/<li><a class="insert__teaser" (.+)<\/a><\/li>/';
141
+  $temp = preg_replace($re, '', $article_only);
142
+  $article_only = $temp;
143
+  $re = '/<p class="insert__title">Les plus lus<\/p>/';
144
+  $temp = preg_replace($re, '', $article_only);
145
+  $article_only = $temp;
146
+  $re = '/<li> <a href="http(.+)Recherche<\/a> <\/li>/';
147
+  $temp = preg_replace($re, '', $article_only);
148
+  $article_only = $temp;
149
+  $re = '/<div class="bd__header"> <span>Annonces automobiles<\/span> <span>avec La Centrale<\/span> <\/div>/';
150
+  $temp = preg_replace($re, '', $article_only);
151
+  $article_only = $temp;
152
+  $re = '/<div class="bd__header"> <span>Annonces immobilières<\/span> <span>avec Logic-Immo<\/span> <\/div>/';
153
+  $temp = preg_replace($re, '', $article_only);
154
+  $article_only = $temp;
155
+  $re = '/<div class="bd__header"> <span>Codes promos<\/span> <span>avec Global Savings Group<\/span> <\/div>/';
156
+  $article_only = preg_replace($re, '', $article_only);
157
+  $re = '/<div class="bd__footer"> <a class="bd__btn" href="https:\/\/codepromo\.lemonde\.fr\/">Toutes les offres<\/a> <\/div>/';
158
+  $article_only = preg_replace($re, '', $article_only);
159
+  $re = '/<li><a href="https:\/\/codepromo(.+?)<\/a><\/li>/';
160
+  $article_only = preg_replace($re, '', $article_only);
161
+  $re = '/<p class="article__siblings-title">Dans la même rubrique<\/p>/';
162
+  $temp = preg_replace($re, '', $article_only);
163
+  $article_only = $temp;
164
+  $re = '/<footer class=" old__article-footer">(.+)<\/footer>/';
165
+  $temp = preg_replace($re, '', $article_only);
166
+  $article_only = $temp;
167
+  $re = '/<a href="https:\/\/www.lemonde.fr\/services\/"><h4 class="area__title area__title--bd">Services<\/h4><\/a>/';
168
+  $temp = preg_replace($re, '', $article_only);
169
+  $article_only = $temp;
170
+  $re = '/<a class="insert__action button button--dark" target="_blank" data-target="jelec-sidebar" href="https:\/\/journal.lemonde.fr\/">Lire le journal numérique<\/a>/';
171
+  $temp = preg_replace($re, '', $article_only);
172
+  $article_only = $temp;
173
+  $re = '/<section class="friend"><div (.+?)<\/div> <\/section>/';
174
+  $article_only = preg_replace($re, '', $article_only);
175
+  $re = '/<aside class="aside__article old__aside"><section class="friend"><div class=""> <div id="pave_haut" class="dfp-slot dfp__slot friend--around dfp__sticky dfp__slot--pave dfp__slot--desktop dfp-unloaded" data-format="pave_haut" aria-hidden="true"><\/div> <\/div> <\/section><section class="friend"><div id="lig_lemonde_article_teaser_side"><\/div> <\/section><\/aside>/';
176
+  $article_only = preg_replace($re, '', $article_only);
177
+
178
+  //Remove Thumbnail
179
+  $re = '/<img src="\/thumbnail\/journal\/(.+) class="insert__media" alt="">/';
180
+  $temp = preg_replace($re, '', $article_only);
181
+  $article_only = $temp;
182
+
183
+  $orgStrings = array( 
184
+      '<p class="txt3 description-article" itemprop="description">',
185
+      '<p class="bloc_signature">',
186
+      '<span id="publisher" itemprop="Publisher" data-source="LE MONDE">',
187
+      '<div class="toolbar"></div>',
188
+      '<div id="articleBody" class="contenu_article js_article_body" itemprop="articleBody">',
189
+      '<h4>',
190
+      '</h4>',
191
+      '<h1 class="tt2" itemprop="Headline">',
192
+      '</h1>',
193
+      '<h2 class="taille_courante">',
194
+      '<h2 class="intertitre">',
195
+      '</h2>',
196
+      '<span>Le Monde</span>',
197
+      '<figure class="illustration_haut   " style="width: 534px">',
198
+      '<img width="534" data-lazyload="false" src="',
199
+      ' onload="lmd.pic(this);" onerror="lmd.pic(this);" class="lazy-retina"' );
200
+  $newStrings = array( 
201
+      '<p>',
202
+      '<p>',
203
+      '<span>',
204
+      '',
205
+      '<div>',
206
+      '<h5>',
207
+      '</h5>',
208
+      '<h3>',
209
+      '</h3>',
210
+      '<h4>',
211
+      '<h4>',
212
+      '</h4>',
213
+      'Le Monde',
214
+      '<figure>',
215
+      '<img width="100%" src="',
216
+      '' );
217
+
218
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
219
+
220
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
221
+  $article_only = $temp;
222
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
223
+  $article_only = $temp;
224
+  $re = '/<a class="lien_interne rub"(.+?)>(.+?)<\/a>/';
225
+  $temp = preg_replace($re, '\\2', $article_only);
226
+  $article_only = $temp;
227
+  $re = '/<img (.+?)data-src="(.+?)"(.+?)data-lazyload="true"(.+?)>/';
228
+  $temp = preg_replace($re, '<img width="100%" src="\\2">', $article_only); 
229
+  $article_only = $temp;
230
+  $re = '/<a href="http:\/\/ad.apsalar.com\/api\/v1\/ad(.+?)target="_blank(.+?)<\/a>/';
231
+  $temp = preg_replace($re, '', $article_only); 
232
+  $article_only = $temp;
233
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
234
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
235
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
236
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>'.PHP_EOL;
237
+  echo '<div class="extract-content" id="'.$cpt.'">'.$figure.$article_only.'</div>'.PHP_EOL;
238
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
239
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
240
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
241
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
242
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>'.PHP_EOL;
243
+  echo '<!-- ENDOF ==================== article '.$cpt.'============== -->'.PHP_EOL;
244
+  $cpt++;
245
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
246
+      break;
247
+  }
248
+}
249
+?>
+170
sources/news-lepoint.fr.php
... ...
@@ -0,0 +1,170 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = http_get_contents(NEWS_RSS_LEPOINTFR);
5
+$xml = simplexml_load_string($rss_content);
6
+if ($xml === false) {
7
+  echo 'Failed to read RSS';
8
+  exit(0);
9
+} else {
10
+  $channel = array();
11
+  $channel['title'] = $xml->channel->title;
12
+  $channel['link'] = $xml->channel->link;
13
+  $channel['description'] = $xml->channel->description;
14
+  $channel['pubDate'] = $xml->channel->pubDate;
15
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
16
+  echo '<h4>' . $channel['title'] . '</h4>';
17
+  $cpt=0;
18
+  foreach ($xml->channel->item as $item) {
19
+    $article = array();
20
+    $article['title'] = $item->title;
21
+    $article['link'] = $item->link;
22
+    $orgStrings = array('#xtor=RSS-221');
23
+    $newStrings = array('');
24
+    $article['link']  = str_replace($orgStrings, $newStrings, $article['link']);
25
+    $article['pubDate'] = $item->pubDate;
26
+    $article['timestamp'] = strtotime($item->pubDate);
27
+    $article['description'] = $item->description;
28
+    $article['image'] = $item->enclosure['url'];
29
+    $articles[$cpt] = $article;  
30
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
31
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>';
32
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;';
33
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
34
+    echo $article['title'].'&nbsp;&nbsp;';
35
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>';
36
+    $cpt++;
37
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
38
+      break;
39
+    }
40
+  }
41
+}
42
+echo '</div><!-- ./col-4 -->';
43
+echo '<div class="col-6">';
44
+echo '<a name="article-top"></a><div id="article-current"></div>';
45
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
46
+$cpt=0;
47
+foreach ($articles as $article ) {
48
+  $cpt_prev=$cpt-1;
49
+  $cpt_next=$cpt+1;
50
+  echo '<!-- ==================== article '.$cpt.'============== -->';
51
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
52
+  echo "<hr>";
53
+  echo "<a name=\"article-$cpt\">";
54
+  $article_content = http_get_contents($article['link']);
55
+
56
+  $SEARCH_SUB1='<h1 class="art-titre list-view">';
57
+  $pos_start = strpos($article_content, $SEARCH_SUB1);
58
+  $pos_stop = false;
59
+  if(!$pos_start) {
60
+    $SEARCH_SUB1='<h2 class="art-chapeau">';
61
+    $pos_start = strpos($article_content, $SEARCH_SUB1);
62
+  }
63
+  if($pos_start) {
64
+    $SEARCH_SUB1='<h3 class="header-meme-sujet">';
65
+    $pos_stop = strpos($article_content, $SEARCH_SUB1);
66
+    if(!$pos_stop) {
67
+      $SEARCH_SUB1='<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>';
68
+      $pos_stop = strpos($article_content, $SEARCH_SUB1);
69
+      if(!$pos_stop) {
70
+        $SEARCH_SUB1='</article>';
71
+        $pos_stop = strpos($article_content, $SEARCH_SUB1);
72
+      }
73
+    }
74
+  }
75
+
76
+  if( $pos_start && $pos_stop ) {
77
+    $article_only = substr($article_content, $pos_start, $pos_stop - $pos_start);
78
+  } else {
79
+    $article_only="";
80
+  }
81
+  
82
+  $orgStrings = array( ' href="/',
83
+    ' src="/sites/',
84
+    '<img src=',
85
+    ' data-src="/');
86
+  $newStrings = array( ' href="https://www.lepoint.fr/',
87
+    ' src="https://www.lepoint.fr/sites/',
88
+    '<img width="100%" src=',
89
+    ' data-src="https://www.lepoint.fr/' );
90
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
91
+  
92
+  $orgStrings = array( '<div class="row">',
93
+    '<div class="col-md-2">',
94
+    '<div class="col-md-8">',
95
+    '<div class="container width_wrap">',
96
+    '<div class="col-left">',
97
+    '<h3> </h3>',
98
+    '<h1>',
99
+    '</h1>',
100
+    '<p style="text-align:center">',
101
+    '<div class="image-wrap panoramique bg-undefined">',
102
+    '<div class="placement-left">' );
103
+  $newStrings = array('<div>',
104
+    '<div>',
105
+    '<div>',
106
+    '<div>',
107
+    '<div>',
108
+    '',
109
+    '<h4>',
110
+    '</h4>',
111
+    '<p>',
112
+    '<div>',
113
+    '<div>');
114
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
115
+  
116
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
117
+  $article_only = $temp;
118
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
119
+  $article_only = $temp;
120
+  $re = '/<a class="cboxElement" (.+?)><img (.+?)><\/a>/';
121
+  $temp = preg_replace($re, '<img \\2>', $article_only);
122
+  $article_only = $temp;
123
+  $re = '/<noscript>(.+?)<\/noscript>/ms';
124
+  $temp = preg_replace($re, '', $article_only);
125
+  $article_only = $temp;
126
+  
127
+  $orgStrings = array( 'http://www.lepoint.fr/' );
128
+  $newStrings = array( 'https://www.lepoint.fr/' );
129
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
130
+
131
+  $re = '/<img class="w100" alt="(.+?)" data-lazyload="loading" onclick="(.+?)" src="(.+?)" title="(.+?)" data-src="(.+?)" \/>/';
132
+  $temp = preg_replace($re, '<img width="100%" src="\\5">', $article_only);
133
+  $article_only = $temp;
134
+
135
+  $re = '/<img class="" src data-lazyload="loading" data-src="(.+?)" data-alt="(.+?)" width="(.+?)" height="(.+?)" alt title="(.+?)"\/>/ms';
136
+  $temp = preg_replace($re, '<img width="100%" src="\\1">', $article_only);
137
+  $article_only = $temp;
138
+
139
+  $re = '/<img src data-lazyload="loading" data-src="(.+?)" data-alt="(.+?)" alt="(.+?)" width="(.+?)" height="(.+?)" \/>/';
140
+  $temp = preg_replace($re, '<img width="100%" src="\\1">', $article_only);
141
+  $article_only = $temp;
142
+
143
+  $re = '/<img class="w100" alt="" data-lazyload="loading" onclick="(.+?)" src="(.+?)" title="" data-src="(.+?)" \/>/';
144
+  $temp = preg_replace($re, '<img width="100%" src="\\3">', $article_only);
145
+  $article_only = $temp;
146
+
147
+  $re = '/<a href="(.+?)" class="button-type pat little-button-mob" onclick="(.+?)">Abonnez-vous<\/a>/';
148
+  $temp = preg_replace($re, '', $article_only);
149
+  $article_only = $temp;
150
+  
151
+  $re = '/<a onclick="(.+?)" data-shadowbox="#authform" href="(.+?)" id="connect_viafreemium" class="w100 block txtcenter br-4-all bg-grey-medium-blue pas font-black bold br-4-all upper">Identifiez-vous<\/a>/';
152
+  $temp = preg_replace($re, '', $article_only);
153
+  $article_only = $temp;
154
+  
155
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
156
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
157
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
158
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
159
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>';
160
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
161
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
162
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
163
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
164
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
165
+  $cpt++;
166
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
167
+      break;
168
+  }
169
+}
170
+?>
+165
sources/news-lesinrocks.fr.php
... ...
@@ -0,0 +1,165 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = file_get_contents(NEWS_RSS_LESINROCKS);
5
+$xml = simplexml_load_string($rss_content);
6
+if ($xml === false) {
7
+  echo 'Failed to read RSS';
8
+} else {
9
+  $channel = array();
10
+  $channel['title'] = $xml->channel->title;
11
+  $channel['link'] = $xml->channel->link;
12
+  $channel['description'] = $xml->channel->description;
13
+  $channel['pubDate'] = $xml->channel->pubDate;
14
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
15
+  echo '<h4>' . $channel['title'] . '</h4>';
16
+  $cpt=0;
17
+  foreach ($xml->channel->item as $item) {
18
+    $article = array();
19
+    $article['title'] = $item->title;
20
+    $article['link'] = $item->link;
21
+    $orgStrings = array('?xtor=RSS-3208');
22
+    $newStrings = array('');
23
+    $article['link']  = str_replace($orgStrings, $newStrings, $article['link']);
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $article['image'] = $item->enclosure['url'];
28
+    $articles[$cpt] = $article; 
29
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
30
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>';
31
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;';
32
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
33
+    echo $article['title'].'&nbsp;&nbsp;';
34
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>';
35
+    $cpt++;
36
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
37
+      break;
38
+    }
39
+  }
40
+}
41
+echo '</div><!-- ./col-4 -->';
42
+echo '<div class="col-6">';
43
+echo '<a name="article-top"></a><div id="article-current"></div>';
44
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
45
+$cpt=0;
46
+foreach ($articles as $article ) {
47
+  $cpt_prev=$cpt-1;
48
+  $cpt_next=$cpt+1;
49
+  echo '<!-- ==================== article '.$cpt.'============== -->';
50
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
51
+  echo "<hr>";
52
+  echo "<a name=\"article-$cpt\">";
53
+  $article_content = file_get_contents($article['link']);
54
+  $article_content_utf8 = mb_convert_encoding($article_content, 'HTML-ENTITIES', "UTF-8");
55
+  $doc = new DOMDocument();
56
+  $doc->preserveWhiteSpace = false;
57
+  $doc->formatOutput       = true;
58
+  $libxml_previous_state = libxml_use_internal_errors(true);
59
+  $doc->loadHTML($article_content_utf8);
60
+  libxml_clear_errors();
61
+  libxml_use_internal_errors($libxml_previous_state);
62
+  $articles = $doc->getElementsByTagName('article');
63
+  $article_only="";
64
+  foreach ( $articles as $node) {
65
+    $article_only = DOMinnerHTML($node);
66
+  }
67
+
68
+  $orgStrings = array( ' href="/',
69
+    '<img src=');
70
+  $newStrings = array( ' href="http://www.lesinrocks.com/',
71
+    '<img width="100%" src=' );
72
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
73
+  
74
+  $orgStrings = array( '<div class="row">',
75
+    '<div class="col-md-2">',
76
+    '<div class="col-md-8">',
77
+    '<div class="container width_wrap">',
78
+    '<div class="col-left">',
79
+    '<h3> </h3>',
80
+    '<span>PAR</span>',
81
+    '<span>Par</span>',
82
+    '<p></p>',
83
+    '<div style="padding-top: 56.25% ">',
84
+    '<h1>',
85
+    '</h1>',
86
+    '<img width="100%" src="/img/auteur.png'
87
+    /*
88
+    '<div style="padding-top: 73.170731707317% ">'*/ );
89
+  $newStrings = array('<div>',
90
+    '<div>',
91
+    '<div>',
92
+    '<div>',
93
+    '<div>',
94
+    '',
95
+    'par ',
96
+    'par ',
97
+    '',
98
+    '<div>',
99
+    '<h4>',
100
+    '</h4>',
101
+    '<img width="5%" src="img/lesinrocks.png'
102
+    /*
103
+    '<div>'*/);
104
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
105
+  
106
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
107
+  $article_only = $temp;
108
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
109
+  $article_only = $temp;
110
+  $re='/<img class="alignnone size-full(.+?)" src="(.+?)"(.+?)>/';
111
+  $temp = preg_replace($re, '<img width="100%" src="\\2">', $article_only);
112
+  $article_only = $temp;
113
+  $re='/<img class="aligncenter size-full(.+?)" src="(.+?)"(.+?)>/';
114
+  $temp = preg_replace($re, '<img width="100%" src="\\2">', $article_only);
115
+  $article_only = $temp;
116
+  $re='/<div class="OUTBRAIN"(.+?)data-ob-template="lesinrocks"><\/div>/';
117
+  $temp = preg_replace($re, '', $article_only);
118
+  $article_only = $temp;
119
+  $re='/<div style="padding-top:(.+?)">/';
120
+  $temp = preg_replace($re, '<div>', $article_only);
121
+  $article_only = $temp;
122
+  $re='/<iframe width="(.+?)" height="(.+?)" /';
123
+  $temp = preg_replace($re, '<iframe width="100%" ', $article_only);
124
+  $article_only = $temp;
125
+  $re='/ width="(.+?)" height="(.+?)" frameborder="0" /';
126
+  $temp = preg_replace($re, ' width="100%" frameborder="0" ', $article_only);
127
+  $article_only = $temp;
128
+  $SEARCH='Prolongez votre lecture !';
129
+  $posend = strpos($article_only,$SEARCH);
130
+  if($posend) {
131
+    $temp = substr( $article_only, 0, $posend );
132
+    $article_only = $temp;
133
+  }
134
+  $SEARCH='<div class="native-ad-in-content">';
135
+  $posend = strpos($article_only,$SEARCH);
136
+  if($posend) {
137
+    $temp = substr( $article_only, 0, $posend );
138
+    $article_only = $temp;
139
+  }
140
+  $re='/<a href="(.+?)" class="inner_(.+?)"> <svg(.+?)><\/use><\/svg><\/a>/';
141
+  $temp = preg_replace($re, '', $article_only);
142
+  $article_only = $temp;
143
+  $orgStrings = array( '<div class="author"> <img width="100%"',
144
+    'par <br>',
145
+    '<div class="single-cta"> <a href="http://abonnement.lesinrocks.com/" class="cta-header cta-abonnement" onclick="return trackClick(this, \'abonnement_article_avatar\');">Abonnez-vous<br>à partir de <span>1€</span></a> </div>' );
146
+  $newStrings = array( '<div class="author"> <img width="5%"',
147
+    'par ',
148
+    '' );
149
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
150
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
151
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
152
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
153
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
154
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>';
155
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
156
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
157
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
158
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
159
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
160
+  $cpt++;
161
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
162
+      break;
163
+  }
164
+}
165
+?>
+123
sources/news-lexpress.fr.php
... ...
@@ -0,0 +1,123 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = http_get_contents(NEWS_RSS_LEXPRESSFR);
5
+$xml = simplexml_load_string($rss_content);
6
+if ($xml === false) {
7
+  echo 'Failed to read RSS';
8
+} else {
9
+  $channel = array();
10
+  $channel['title'] = $xml->channel->title;
11
+  $channel['link'] = $xml->channel->link;
12
+  $channel['description'] = $xml->channel->description;
13
+  $channel['pubDate'] = $xml->channel->pubDate;
14
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
15
+  echo '<h4>' . $channel['title'] . '</h4>';
16
+  $cpt=0;
17
+  foreach ($xml->channel->item as $item) {
18
+    $article = array();
19
+    $article['title'] = $item->title;
20
+    $article['link'] = $item->link;
21
+    $orgStrings = array('#xtor=RSS-221');
22
+    $newStrings = array('');
23
+    $article['link']  = str_replace($orgStrings, $newStrings, $article['link']);
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $orgStrings = array( 'w_200,h_134,' );
28
+    $newStrings = array( 'w_2000,h_1125,' );
29
+    $article['image'] = str_replace($orgStrings, $newStrings, $item->enclosure['url']);
30
+
31
+    $articles[$cpt] = $article;  
32
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
33
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>';
34
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;';
35
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
36
+    echo $article['title'].'&nbsp;&nbsp;';
37
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>';
38
+    $cpt++;
39
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
40
+      break;
41
+    }
42
+  }
43
+}
44
+echo '</div><!-- ./col-4 -->';
45
+echo '<div class="col-6">';
46
+echo '<a name="article-top"></a><div id="article-current"></div>';
47
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
48
+$cpt=0;
49
+foreach ($articles as $article ) {
50
+  $cpt_prev=$cpt-1;
51
+  $cpt_next=$cpt+1;
52
+  echo '<!-- ==================== article '.$cpt.'============== -->';
53
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
54
+  echo "<hr>";
55
+  echo "<a name=\"article-$cpt\">";
56
+  $article_content = http_get_contents($article['link']);
57
+  $doc = new DOMDocument();
58
+  $doc->preserveWhiteSpace = false;
59
+  $doc->formatOutput       = true;
60
+  $libxml_previous_state = libxml_use_internal_errors(true);
61
+  $doc->loadHTML($article_content);
62
+  libxml_clear_errors();
63
+  libxml_use_internal_errors($libxml_previous_state);
64
+  $articles = $doc->getElementsByTagName('div');
65
+  $article_only="";
66
+  foreach ( $articles as $node) {
67
+    if(0==strcmp("article_container",$node->getAttribute('class'))) {
68
+      $article_only = DOMinnerHTML($node);
69
+    }
70
+  }
71
+  
72
+  $orgStrings = array( ' href="/',
73
+    ' src="/sites/',
74
+    '<img src=',
75
+    ' data-src="/');
76
+  $newStrings = array( ' href="https://www.lexpress.fr/',
77
+    ' src="https://www.lexpress.fr/sites/',
78
+    '<img width="100%" src=',
79
+    ' data-src="https://www.lexpress.fr/' );
80
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
81
+  
82
+  $orgStrings = array( '<div class="row">',
83
+    '<div class="col-md-2">',
84
+    '<div class="col-md-8">',
85
+    '<div class="container width_wrap">',
86
+    '<div class="col-left">',
87
+    '<h3> </h3>',
88
+    '<h1>',
89
+    '</h1>',
90
+    '<p style="text-align:center">',
91
+    '<div class="image-wrap panoramique bg-undefined">',
92
+    '<div class="placement-left">' );
93
+  $newStrings = array('<div>',
94
+    '<div>',
95
+    '<div>',
96
+    '<div>',
97
+    '<div>',
98
+    '',
99
+    '<h4>',
100
+    '</h4>',
101
+    '<p>',
102
+    '<div>',
103
+    '<div>');
104
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
105
+  $orgStrings = array( 'http://www.lexpress.fr/' );
106
+  $newStrings = array( 'https://www.lexpress.fr/' );
107
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
108
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
109
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
110
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
111
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
112
+  echo '<div class="extract-content" id="'.$cpt.'"><h3>'.$article['title'].'</h3><img width="100%" src="'.$article['image'].'">'.$article_only.'</div>';
113
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
114
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
115
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
116
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
117
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
118
+  $cpt++;
119
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
120
+      break;
121
+  }
122
+}
123
+?>
+269
sources/news-liberation.fr.php
... ...
@@ -0,0 +1,269 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = file_get_contents(NEWS_RSS_LIBERATION);
5
+$xml = simplexml_load_string($rss_content);
6
+if ($xml === false) {
7
+  echo 'Failed to read RSS';
8
+} else {
9
+  $channel = array();
10
+  $channel['title'] = $xml->title;
11
+  $channel['pubDate'] = $xml->updated;
12
+  $channel['timestamp'] = strtotime($xml->updated);
13
+  echo '<h4>' . $channel['title'] . '</h4>';
14
+  $cpt=0;
15
+  foreach ($xml->entry as $item)
16
+  {
17
+    $article = array();
18
+    $article['title'] = $item->title;
19
+    $article['link'] = $item->link['href'];
20
+    $orgStrings = array('?xtor=rss-450');
21
+    $newStrings = array('');
22
+    $article['link']  = str_replace($orgStrings, $newStrings, $article['link']);
23
+    $article['pubDate'] = $item->updated;
24
+    $article['timestamp'] = strtotime($item->updated);
25
+    $article['description'] = $item->summary;
26
+    $article['image']="img/liberation.png";
27
+    foreach ($item->link as $item2 )
28
+    {
29
+      if( ( 0 == strcmp( $item2['type'], "image/jpeg") ) ||
30
+          ( 0 == strcmp( $item2['type'], "image/png") ) ) {
31
+        $pos_start=strpos($item2['href'],"?modified_at");
32
+        if( $pos_start ) {
33
+          $image_link=substr($item2['href'],0,$pos_start);
34
+          $article['image']=substr($item2['href'],0,$pos_start);
35
+        }
36
+      }
37
+    }
38
+
39
+    $articles[$cpt] = $article;
40
+    echo "<div onclick=\"onArticle($cpt)\" style=\"display:inline;\">".PHP_EOL;
41
+    echo '<img width="100%" src="'.$article['image'].'" style="display:inline;"><br>'.PHP_EOL;
42
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>'.PHP_EOL;
43
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>';
44
+    echo $article['title'].PHP_EOL;
45
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>'.PHP_EOL;
46
+    $cpt++;
47
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
48
+      break;
49
+    }
50
+  }
51
+}
52
+echo '</div><!-- ./col-4 -->';
53
+echo '<div class="col-6">';
54
+echo '<a name="article-top"></a><div id="article-current"></div>';
55
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
56
+$cpt=0;
57
+foreach ($articles as $article ) {
58
+  $cpt_prev=$cpt-1;
59
+  $cpt_next=$cpt+1;
60
+  echo PHP_EOL.PHP_EOL.'<!-- ==================== article '.$cpt.'============== -->'.PHP_EOL;
61
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
62
+  echo "<hr>";
63
+  echo "<a name=\"article-$cpt\"></a>";
64
+  $article_content = file_get_contents($article['link']);
65
+  $article_content_utf8 = mb_convert_encoding($article_content, 'HTML-ENTITIES', "UTF-8");
66
+  $doc = new DOMDocument();
67
+  $doc->preserveWhiteSpace = false;
68
+  $doc->formatOutput       = true;
69
+  $libxml_previous_state = libxml_use_internal_errors(true);
70
+  $doc->loadHTML($article_content_utf8);
71
+  libxml_clear_errors();
72
+  libxml_use_internal_errors($libxml_previous_state);
73
+  $articles = $doc->getElementsByTagName('article');
74
+  $article_only="";
75
+  foreach ( $articles as $node) {
76
+    $article_only = DOMinnerHTML($node);
77
+  }
78
+
79
+
80
+  $SEARCH_SUB='<aside class="aside-column side-flow-bloc width-padded">';
81
+  $pos_stop = strpos($article_only, $SEARCH_SUB);
82
+  $article_only = substr($article_only, 0, $pos_stop);
83
+ 
84
+  if(0==strcmp($article_only,"")) {
85
+    $SEARCH_SUB='itemtype="http://schema.org/NewsArticle">';
86
+    $pos_start=strpos($article_content_utf8, $SEARCH_SUB);
87
+    if($pos_start) {
88
+      $article_only = substr($article_content_utf8, $pos_start + strlen($SEARCH_SUB));
89
+      $SEARCH_SUB='<aside class="outbrain">';
90
+      $pos_stop=strpos($article_only, $SEARCH_SUB);
91
+      if($pos_stop) {
92
+        $article_only = substr($article_only, 0, $pos_stop);
93
+      } else {
94
+        $article_only = "Oups";
95
+      }
96
+    } else {
97
+      $article_only = "";
98
+      $articles = $doc->getElementsByTagName('div');
99
+      foreach ( $articles as $node) {
100
+        if(0==strcmp("answer-body",$node->getAttribute('class'))) {
101
+          $article_only = "<h3>".$article['title']."</h3>".DOMinnerHTML($node);
102
+        }else if(0==strcmp("live-content",$node->getAttribute('class'))) {
103
+          //$article_only = "<h3>".$article['title']."</h3>".DOMinnerHTML($node);
104
+          $temp = DOMinnerHTML($node);
105
+          $article_only = $article_only.$temp;
106
+        }
107
+      }
108
+    }
109
+  }
110
+  DEBUG("Article($cpt) : length = ".strlen($article_only));
111
+  $isCheckNews=false;
112
+  if( 0 == strlen($article_only)) {
113
+    $articles = $doc->getElementsByTagName('article');
114
+    $article_only="";
115
+    foreach ( $articles as $node) {
116
+      $article_only = DOMinnerHTML($node);
117
+    }
118
+    $isCheckNews=true;
119
+  }
120
+
121
+  $orgStrings = array( ' href="/' );
122
+  $newStrings = array( ' href="https://www.liberation.fr/' );
123
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
124
+  
125
+  $orgStrings = array( '<p lang="en" dir="ltr">',
126
+      '<p dir="ltr">',
127
+      '<h4>',
128
+      '</h4>',
129
+      '<h1 class="article-headline">',
130
+      '</h1>',
131
+      '<h2 class="article-standfirst read-left-padding">',
132
+      '<h2 class="article-standfirst">',
133
+      '<h2 class="intertitre">',
134
+      '</h2>',
135
+      '<figure class="article-image article-header-image"><a role="button" class="figure-zoom">',
136
+      '<figure class="article-image article-header-image"><a role="button" class="figure-zoom js-figure-zoom">',
137
+      '<img width="534" data-lazyload="false" src="',
138
+      '<i class="zoom-icon"> <svg class="icon " role="img" width="22" height="22"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-zoom"></use></svg></i>',
139
+      ' onload="lmd.pic(this);" onerror="lmd.pic(this);" class="lazy-retina"',
140
+      ' width="960">',
141
+      '<img class="live-image"',
142
+      '<a class="slug"',
143
+      '<figcaption class="legende" data-caption="',
144
+      '<figcaption class="read-left-padding caption">',
145
+      '</figcaption>' );
146
+  $newStrings = array( '<p>',
147
+      '<p>',
148
+      '<h5>',
149
+      '</h5>',
150
+      '<h3>',
151
+      '</h3>',
152
+      '<h4>',
153
+      '<h4>',
154
+      '<h4>',
155
+      '</h4>',
156
+      '<figure>',
157
+      '<figure>',
158
+      '<img width="100%" src="',
159
+      '',
160
+      '',
161
+      ' width="100%">',
162
+      '<img width="100%"',
163
+      '<a',
164
+      '<em>',
165
+      '<em>',
166
+      '</em>' );
167
+
168
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
169
+
170
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
171
+  $article_only = $temp;
172
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
173
+  $article_only = $temp;
174
+  $re = '/<a class="lien_interne rub"(.+)>(.+)<\/a>/';
175
+  $temp = preg_replace($re, '\\2', $article_only);
176
+  $article_only = $temp;
177
+  $re = '/<img (.+)data-src="(.+?)"(.+?)data-lazyload="true"(.+?)>/';
178
+  $temp = preg_replace($re, '<img width="100%" src="\\2">', $article_only); 
179
+  $article_only = $temp;
180
+  $re = '/<a href="http:\/\/ad.apsalar.com\/api\/v1\/ad(.+?)target="_blank(.+?)<\/a>/';
181
+  $temp = preg_replace($re, '', $article_only); 
182
+  $article_only = $temp;
183
+  $re = '/<span class="share">(.+?)<\/span>/';
184
+  $temp = preg_replace($re, '', $article_only); 
185
+  $article_only = $temp;
186
+  $orgStrings = array( '<ul class="article-rel-list">','<li class="article-rel-item">  </li>','</ul>', '<a href=');
187
+  $newStrings = array( '','','', '<a target="new" href=' );
188
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
189
+
190
+  //Checknews Specific
191
+  if($isCheckNews) {
192
+    $re='/<\/form>/';
193
+    $temp = preg_replace($re, "", $article_only);
194
+    $article_only = $temp;
195
+    $re='/<form class="checknews-form" method="GET" action="\/checknews\/search\/" name="checknews_box">(.+)<\/a>/';
196
+    $temp = preg_replace($re, "", $article_only);
197
+    $article_only = $temp;
198
+    /*
199
+    $re='//';
200
+    $temp = preg_replace($re, "", $article_only);
201
+    $article_only = $temp;
202
+     */
203
+    $re='/<li class="answer no-tags">(.+?)<\/li>/';
204
+    $temp = preg_replace($re, "", $article_only);
205
+    $article_only = $temp;
206
+    $re='/<li class="answer no-tags">(.+)<ul class="checknews-tags">/';
207
+    $temp = preg_replace($re, "<li><ul>", $article_only);
208
+    $article_only = $temp;
209
+    $re='/<p class="btn" href="https:\/\/www\.liberation\.fr\/checknews\/(.+)Voir la réponse<br><span>(.+)<\/span> <\/p> <\/div> <\/a> <\/li>/';
210
+    $article_only = preg_replace($re, "</div></a></li>", $article_only);
211
+    $re='/<a class="btn about-button" href="https:\/\/www\.liberation\.fr\/checknews\/voter\/"> Accédez à toutes les questions <\/a>/';
212
+    $article_only = preg_replace($re, "", $article_only);
213
+    $re='/<script type="text\/javascript" src="https:\/\/statics\.liberation\.fr\/newsite\/(.+)<\/script>/';
214
+    $article_only = preg_replace($re, "", $article_only);
215
+    $re='/<div class="checknews-header"> <div class="title"> <h3>(Nos dernières réponses|Le vote des lecteurs)<\/h3> <\/div> <\/div>/';
216
+    $article_only = preg_replace($re, "", $article_only);
217
+    $re='/<p> Voici les cinq questions qui sont en tête des votes.<br> Vous aussi, donnez votre avis et choisissez les sujets que la rédaction va traiter. <\/p>/';
218
+    $article_only = preg_replace($re, "", $article_only);
219
+    $re='/<\/div><\/a><\/li> <li><ul>/';
220
+    $article_only = preg_replace($re, "", $article_only);
221
+    $re='/<ul id="question" class="checknews-answers vote">/';
222
+    $article_only = preg_replace($re, "", $article_only);
223
+    $re='/<ul class="checknews-answers">/';
224
+    $article_only = preg_replace($re, "", $article_only);
225
+    $re='/<div class="checknews-box last-content"> <li><ul>/';
226
+    $article_only = preg_replace($re, "<div><li>", $article_only);
227
+    $re='/ target="_blank">/';
228
+    $article_only = preg_replace($re, ">", $article_only);
229
+    $re='/<\/div><\/a><\/li>/';
230
+    $article_only = preg_replace($re, "", $article_only);
231
+    $article_only = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
232
+    $article_only = preg_replace('/\s\s+/', ' ', $article_only);
233
+    $re='/<div class="checknews-box last-content"> <li><ul>/';
234
+    $article_only = preg_replace($re, "<div>", $article_only);
235
+
236
+  }
237
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
238
+  $article_only = $temp;
239
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
240
+  $article_only = $temp;
241
+
242
+  //Force HTTPS
243
+  $article_only = add_https($article_only, 'www.twitter.com');
244
+  $article_only = add_https($article_only, 'www.facebook.com');
245
+  $article_only = add_https($article_only, 'pbs.twimg.com');
246
+  $article_only = add_https($article_only, 'schema.org');
247
+  //$article_only = add_https($article_only, 'www.w3.org');
248
+  $article_only = add_https($article_only, 'videos.senat.fr');
249
+  $article_only = add_https($article_only, '9w4t.mjt.lu');
250
+  $article_only = add_https($article_only, 'www.lefigaro.fr');
251
+  $article_only = add_https($article_only, 'www.leparisien.fr');
252
+  $article_only = add_https($article_only, 'www.lepoint.fr');
253
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
254
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
255
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
256
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>'.PHP_EOL;
257
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>'.PHP_EOL;
258
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
259
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
260
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
261
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
262
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>'.PHP_EOL;
263
+  echo '<!-- ENDOF ==================== article '.$cpt.'============== -->'.PHP_EOL;
264
+  $cpt++;
265
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
266
+      break;
267
+  }
268
+}
269
+?>
+130
sources/news-numerama.fr.php
... ...
@@ -0,0 +1,130 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = file_get_contents(NEWS_RSS_NUMERAMA);
5
+$xml = simplexml_load_string($rss_content);
6
+if ($xml === false) {
7
+  echo 'Failed to read RSS';
8
+} else {
9
+  $channel = array();
10
+  $channel['title'] = $xml->channel->title;
11
+  $channel['link'] = $xml->channel->link;
12
+  $channel['description'] = $xml->channel->description;
13
+  $channel['pubDate'] = $xml->channel->pubDate;
14
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
15
+  echo '<h4>' . $channel['title'] . '</h4>';
16
+  $cpt=0;
17
+  foreach ($xml->channel->item as $item) {
18
+    $article = array();
19
+    $article['title'] = $item->title;
20
+    $article['link'] = $item->link;
21
+    $article['pubDate'] = $item->pubDate;
22
+    $article['timestamp'] = strtotime($item->pubDate);
23
+    $article['description'] = $item->description;
24
+    $SEARCH_SUB1='<p><img width="1024" height="';
25
+    $pos_start = strpos($item->description, $SEARCH_SUB1);
26
+    $pos_start += strlen($SEARCH_SUB1);
27
+    $SEARCH_SUB2="\"";
28
+    $pos_stop = strpos($item->description, $SEARCH_SUB2, $pos_start);
29
+    $height=substr($item->description, $pos_start, $pos_stop - $pos_start);
30
+    $article['width']=1024;
31
+    $article['height']=$height;
32
+    $SEARCH_SUB1='src="';
33
+    $pos_start = strpos($item->description, $SEARCH_SUB1);
34
+    $pos_start += strlen($SEARCH_SUB1);
35
+    $SEARCH_SUB2="\"";
36
+    $pos_stop = strpos($item->description, $SEARCH_SUB2, $pos_start);
37
+    $article['image']=substr($item->description, $pos_start, $pos_stop - $pos_start);
38
+    $articles[$cpt] = $article;  
39
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
40
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>';
41
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;';
42
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
43
+    echo $article['title'].'&nbsp;&nbsp;';
44
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>';
45
+    $cpt++;
46
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
47
+      break;
48
+    }
49
+  }
50
+}
51
+echo '</div><!-- ./col-4 -->';
52
+echo '<div class="col-6">';
53
+echo '<a name="article-top"></a><div id="article-current"></div>';
54
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
55
+$cpt=0;
56
+foreach ($articles as $article ) {
57
+  $cpt_prev=$cpt-1;
58
+  $cpt_next=$cpt+1;
59
+  echo '<!-- ==================== article '.$cpt.'============== -->';
60
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
61
+  echo "<hr>";
62
+  echo "<a name=\"article-$cpt\">";
63
+  $article_content = file_get_contents($article['link']);
64
+  $SEARCH_SUB1='<article class="post-content span8 tablet12 phone12">';
65
+  $pos_start = strpos($article_content, $SEARCH_SUB1);
66
+  $pos_start += strlen($SEARCH_SUB1);
67
+  $SEARCH_SUB2='<div id="bottom_ad"';
68
+  $pos_stop = strpos($article_content, $SEARCH_SUB2);
69
+  $article_only = substr($article_content, $pos_start, $pos_stop - $pos_start);
70
+
71
+  $orgStrings = array(' src="//www.numerama.com/');
72
+  $newStrings = array(' src="https://www.numerama.com/');
73
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
74
+  $orgStrings = array(' srcset="//www.numerama.com/');
75
+  $newStrings = array(' srcset="https://www.numerama.com/');
76
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
77
+  $orgStrings = array(' href="/');
78
+  $newStrings = array(' href="https://www.numerama.com/');
79
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
80
+
81
+  $orgStrings = array( ' width="500" height="281" frameborder="0" ');
82
+  $newStrings = array( ' width="100%" frameborder="0" ');
83
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
84
+  $orgStrings = array( 'style="width: 680px"');
85
+  $newStrings = array( 'style="width: 100%"');
86
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
87
+  $orgStrings = array( '<img src="');
88
+  $newStrings = array( '<img width="100%" src="');
89
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
90
+  $re = '/alt="(.+?)" width="(.+?)" height="(.+?)"/';
91
+  $temp = preg_replace($re, 'width="100%"', $article_only);
92
+  $article_only = $temp;
93
+  $re = '/alt="" width="(.+?)" height="(.+?)"/';
94
+  $temp = preg_replace($re, 'width="100%"', $article_only);
95
+  $article_only = $temp;
96
+  $re = '/<iframe width="500" height="(.+?)"/';
97
+  $temp = preg_replace($re, '<iframe width="100%"', $article_only);
98
+  $article_only = $temp;
99
+  $re = '/sizes="\(max-width: (.+?)\) 100vw, (.+?)"/';
100
+  $temp = preg_replace($re, 'sizes="(max-width: 100%) 100vw,100%"', $article_only);
101
+  $article_only = $temp;
102
+  $re = '/<figure id="attachment_(.+?)" style="width: (.+?)" class="wp-caption aligncenter">/';
103
+  $temp = preg_replace($re, '<figure id="attachment_\\1" style="width: 100%" class="wp-caption aligncenter">', $article_only);
104
+  $article_only = $temp;
105
+  $re = '/<img class="aligncenter size-full wp-image-(.+?)"/';
106
+  $temp = preg_replace($re, '<img ', $article_only);
107
+  $article_only = $temp;
108
+
109
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
110
+  $article_only = $temp;
111
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
112
+  $article_only = $temp;
113
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
114
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
115
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
116
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
117
+  echo '<div class="extract-content" id="'.$cpt.'">';
118
+  echo '<h4>'.$article['title'].'</h4><img width="100%" src="'.$article['image'].'" style="display:inline;"><br>';
119
+  echo $article_only.'</div>';
120
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
121
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-upi fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
122
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
123
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
124
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
125
+  $cpt++;
126
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
127
+      break;
128
+  }
129
+}
130
+?>
+250
sources/news-slate.fr.php
... ...
@@ -0,0 +1,250 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = http_get_contents(NEWS_RSS_SLATEFR);
5
+$xml = simplexml_load_string($rss_content);
6
+if ($xml === false) {
7
+  echo 'Failed to read RSS';
8
+} else {
9
+  $channel = array();
10
+  $channel['title'] = $xml->channel->title;
11
+  $channel['link'] = $xml->channel->link;
12
+  $channel['description'] = $xml->channel->description;
13
+  $channel['pubDate'] = $xml->channel->pubDate;
14
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
15
+  echo '<h4>' . $channel['title'] . '</h4>';
16
+  $cpt=0;
17
+  foreach ($xml->channel->item as $item) {
18
+    $article = array();
19
+    $article['title'] = $item->title;
20
+    $article['link'] = $item->link;
21
+    $orgStrings = array('?xtor=RSS-3208');
22
+    $newStrings = array('');
23
+    $article['link']  = str_replace($orgStrings, $newStrings, $article['link']);
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $article['image'] = $item->enclosure['url'];
28
+    $articles[$cpt] = $article; 
29
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">'.PHP_EOL;
30
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>'.PHP_EOL;
31
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;'.PHP_EOL;
32
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
33
+    echo $article['title'].'&nbsp;&nbsp;'.PHP_EOL;
34
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>'.PHP_EOL;
35
+    $cpt++;
36
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
37
+      break;
38
+    }
39
+  }
40
+}
41
+echo '</div><!-- ./col-4 -->';
42
+echo '<div class="col-6">';
43
+echo '<a name="article-top"></a><div id="article-current"></div>';
44
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
45
+$cpt=0;
46
+foreach ($articles as $article ) {
47
+  $cpt_prev=$cpt-1;
48
+  $cpt_next=$cpt+1;
49
+  echo PHP_EOL.PHP_EOL."<!-- ==================== article '.$cpt.'============== -->".PHP_EOL;
50
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
51
+  echo "<hr><a name=\"article-$cpt\">\n";
52
+  $article_content = file_get_contents($article['link']);
53
+  $doc = new DOMDocument();
54
+  $doc->preserveWhiteSpace = false;
55
+  $doc->formatOutput       = true;
56
+  $libxml_previous_state = libxml_use_internal_errors(true);
57
+  $doc->loadHTML($article_content);
58
+  libxml_clear_errors();
59
+  libxml_use_internal_errors($libxml_previous_state);
60
+  $articles = $doc->getElementsByTagName('article');
61
+  $article_only="";
62
+  foreach ( $articles as $node) {
63
+    $article_only = DOMinnerHTML($node);
64
+  }
65
+  DEBUG("Article($cpt) : length = ".strlen($article_only));
66
+  $isPortfolio=false;
67
+  if( 0 == strlen($article_only) ) {
68
+    //<div class="layout layout--portfolio">
69
+    $node = getElementByClass($doc, 'div', 'layout layout--portfolio', $offset = 0);
70
+    if( false !== $node ) {
71
+      //Article is a portfolio
72
+      $article_only = DOMinnerHTML($node);
73
+      $isPortfolio=true;
74
+    }
75
+  }
76
+
77
+  $orgStrings = array( ' href="/',
78
+    ' src="/sites/',
79
+    '-src="/sites/',
80
+    '<img src=');
81
+  $newStrings = array( ' href="http://www.slate.fr/',
82
+    ' src="http://www.slate.fr/sites/',
83
+    '-src="http://www.slate.fr/sites/',
84
+    '<img width="100%" src=' );
85
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
86
+  
87
+  $orgStrings = array( '<div class="row">',
88
+    '<div class="col-md-2">',
89
+    '<div class="col-md-8">',
90
+    '<div class="container width_wrap">',
91
+    '<div class="col-left">',
92
+    '<div class="article-header__inner col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">',
93
+    '<div class="content-left col-md-8 col-auto">',
94
+    '<p class="article-header__infos article-infos">',
95
+    '<div class="article-thumb-wrapper">',
96
+    '<div class="article-thumb">',
97
+    '<figure class="preload article-image">',
98
+    '<div class="article-content row">',
99
+    '<h3> </h3>',
100
+    '<h1>',
101
+    '</h1>',
102
+    '<p style="text-align:center">' );
103
+  $newStrings = array('<div>',
104
+    '<div>',
105
+    '<div>',
106
+    '<div>',
107
+    '<div>',
108
+    '<div>',
109
+    '<div>',
110
+    '<p>',
111
+    '<div>',
112
+    '<div>',
113
+    '<figure>',
114
+    '<div>',
115
+    '',
116
+    '<h4>',
117
+    '</h4>',
118
+    '<p>');
119
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
120
+  
121
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
122
+  $article_only = $temp;
123
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
124
+  $article_only = $temp;
125
+  $re = '/ style="height:(.+?)width: 640px;">/';
126
+  $temp = preg_replace($re, '>', $article_only); 
127
+  $article_only = $temp;
128
+  $re = '/<script>\(function \(\) \{var sasCallOptions = \{ siteId: 59629(.+?)<\/script>/';
129
+  $temp = preg_replace($re, '', $article_only); 
130
+  $article_only = $temp;
131
+  $re = '/<img data-file-id=(.+?)src="(.+?)"(.+?)>/';
132
+  $temp = preg_replace($re, '<img width="100%" src="\\2">', $article_only); 
133
+  $article_only = $temp;
134
+  $re='/<div class="media_embed" height="(.+?)" width="(.+?)">/';
135
+  $temp = preg_replace($re, '<div>', $article_only); 
136
+  $article_only = $temp;
137
+  $re='/<iframe allowfullscreen="" frameborder="0" height="(.+?)" src="(.+?)" width="(.+?)"><\/iframe>/';
138
+  $temp = preg_replace($re, '<iframe frameborder="0" width="100%" src="\\2"></iframe>', $article_only); 
139
+  $article_only = $temp;
140
+  $re='/<img width="100%" src="(.+?)" style="height:(.+?)width: (.+?)">/';
141
+  $temp = preg_replace($re, '<img width="100%" src="\\1">', $article_only); 
142
+  $article_only = $temp;
143
+  $re='/<div class="icon icon--(.+?)"> (.+)/';
144
+  $temp = preg_replace($re, '<div>', $article_only); 
145
+  $article_only = $temp;
146
+  $re='/<div class="article-header__breadcrumb">/';
147
+  $temp = preg_replace($re, '<div>', $article_only); 
148
+  $article_only = $temp;
149
+
150
+  $re='/<img class="image image--full lazyload" data-full-src=/';
151
+  $temp = preg_replace($re, '<img width="100%" src=', $article_only); 
152
+  $article_only = $temp;
153
+
154
+  $re='/<span class="sharing-btn__numbers">(.+)<\/span>/';
155
+  $temp = preg_replace($re, '', $article_only); 
156
+  $article_only = $temp;
157
+  
158
+  $re='/<span class="sharing-btn__bg"><\/span>/';
159
+  $temp = preg_replace($re, '', $article_only); 
160
+  $article_only = $temp;
161
+
162
+  $re='/<script data-cfasync="false" src=(.+)<\/script><script>(.+?)<\/script>/';
163
+  $temp = preg_replace($re, '', $article_only); 
164
+  $article_only = $temp;
165
+
166
+  //Clean so called social
167
+  $re='/<a data-share="(fb|li|tw)" data-url="(.+)">  <div>/';
168
+  $temp = preg_replace($re, '<a><div>', $article_only); 
169
+  $article_only = $temp;
170
+  $re='/<a class="sharing-btn sharing-btn--circle sharing-btn--whatsapp" href="whatsapp:(.+)>  <div>/';
171
+  $temp = preg_replace($re, '<a><div>', $article_only); 
172
+  $article_only = $temp;
173
+  $re='/<a href="fb-messenger:(.+) class="sharing-btn sharing-btn--circle sharing-btn--messenger" target="_blank">  <div>/';
174
+  $temp = preg_replace($re, '<a><div>', $article_only); 
175
+  $article_only = $temp;
176
+  $re='/<a href="https:\/\/www\.facebook\.com\/dialog\/send(.+)target="_blank">  <div>/';
177
+  $temp = preg_replace($re, '<a><div>', $article_only); 
178
+  $article_only = $temp;
179
+  $re='/<div id="inreadbis" class="ad-wrapper"><span id="wrapper_inread"><div(.+)<\/div><\/span><\/div>/';
180
+  $temp = preg_replace($re, '', $article_only); 
181
+  $article_only = $temp;
182
+  $re='/<\/div> <\/a> <a><div>/';
183
+  $temp = preg_replace($re, '',$article_only);
184
+  $article_only = $temp;
185
+
186
+  //Remove Emptylines
187
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
188
+  $article_only = $temp;
189
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
190
+  $article_only = $temp;
191
+
192
+  
193
+  $re='/<iframe allow="autoplay; encrypted-media" allowfullscreen="" frameborder="0" height="(.+?)" src="https:\/\/www\.youtube\.com\/embed\/(.+?)" width="(.+?)"><\/iframe>/';
194
+  $temp = preg_replace($re, '<iframe allow="autoplay; encrypted-media" allowfullscreen="" frameborder="0" width="100%" src="https://www.youtube.com/embed/\\2"></iframe>', $article_only); 
195
+  $article_only = $temp;
196
+
197
+  $SEARCH='<div class="sharing-tools sharing-tools--align-center">';
198
+  $posend = strpos($article_only,$SEARCH);
199
+  if($posend) {
200
+    $temp = substr( $article_only, 0, $posend );
201
+    $article_only = $temp;
202
+  }
203
+
204
+  //Portfolio specific
205
+  if($isPortfolio) {
206
+    $re = '/<img class="cover parallax-enable fit lazyload" data-speed="2" data-full-src="(.+?)" alt="(.+?)">/';
207
+    $temp = preg_replace($re, '<img src="\\1" alt="\\2">', $article_only );
208
+    $article_only = $temp;
209
+    $re = '/" width="(.+)" height="(.+)">/';
210
+    $temp = preg_replace($re, '>', $article_only );
211
+    $article_only = $temp;
212
+  }
213
+  //Force HTTPS
214
+  $article_only = add_https($article_only, 'www.twitter.com');
215
+  $article_only = add_https($article_only, 'www.facebook.com');
216
+  $article_only = add_https($article_only, 'pbs.twimg.com');
217
+  $article_only = add_https($article_only, 'schema.org');
218
+  $article_only = add_https($article_only, 'www.w3.org');
219
+  $article_only = add_https($article_only, 'www.slate.fr');
220
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
221
+  echo "\n";
222
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
223
+  echo "\n";
224
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
225
+  echo "\n";
226
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
227
+  echo "\n";
228
+  echo '<div class="extract-content" id="'.$cpt.'">';
229
+  echo "\n";
230
+  echo $article_only;
231
+  echo "\n";
232
+  echo '</div>';
233
+  echo "\n";
234
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
235
+  echo "\n";
236
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
237
+  echo "\n";
238
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
239
+  echo "\n";
240
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
241
+  echo "\n";
242
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
243
+  echo "\n";
244
+  $cpt++;
245
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
246
+      break;
247
+  }
248
+}
249
+?>
250
+
+115
sources/news-vice.fr.php
... ...
@@ -0,0 +1,115 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = http_get_contents(NEWS_RSS_VICEFR);
5
+$rss_content = str_replace("<content:encoded>","<contentEncoded>",$rss_content);
6
+$rss_content = str_replace("</content:encoded>","</contentEncoded>",$rss_content);
7
+$articles = array();
8
+$xml = simplexml_load_string($rss_content);
9
+if ($xml === false) {
10
+  echo 'Failed to read RSS';
11
+} else {
12
+  $channel = array();
13
+  $channel['title'] = $xml->channel->title;
14
+  $channel['link'] = $xml->channel->link;
15
+  $channel['description'] = $xml->channel->description;
16
+  $channel['pubDate'] = $xml->channel->pubDate;
17
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
18
+  echo '<h4>' . $channel['title'] . '</h4>';
19
+  $cpt=0;
20
+  foreach ($xml->channel->item as $item) {
21
+    $article = array();
22
+    $article['title'] = $item->title;
23
+    $article['link'] = $item->link;
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $article['content'] = $item->contentEncoded;
28
+    $article['image'] = $item->enclosure['url'];
29
+    $articles[$cpt]=$article;
30
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">'.PHP_EOL;
31
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>'.PHP_EOL;
32
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;'.PHP_EOL;
33
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
34
+    echo $article['title'].'&nbsp;&nbsp;'.PHP_EOL;
35
+    echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>'.PHP_EOL;
36
+    $cpt++;
37
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
38
+      break;
39
+    }
40
+  }
41
+}
42
+echo '</div><!-- ./col-4 -->';
43
+echo '<div class="col-6">';
44
+echo '<a name="article-top"></a><div id="article-current"></div>';
45
+echo '</div><!-- ./col-6 -->'.PHP_EOL;
46
+$cpt=0;
47
+foreach ($articles as $article ) {
48
+  $cpt_prev=$cpt-1;
49
+  $cpt_next=$cpt+1;
50
+  echo PHP_EOL.PHP_EOL.'<!-- ==================== article '.$cpt.'============== -->'.PHP_EOL;
51
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
52
+  echo "<hr>";
53
+  echo "<a name=\"article-$cpt\">";
54
+  $article_only = $article['content'];
55
+		
56
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
57
+  $article_only = $temp;
58
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
59
+  $article_only = $temp;
60
+  $re='/<div data-iframely-id="(.+?)" data-embedded-url="https:\/\/www.youtube.com\/watch\?v=(.+?)"(.+?)>/';
61
+  $newre='<div><iframe width="100%" src="https://www.youtube.com/embed/\\2?feature=oembed" frameborder="0" gesture="media" allowfullscreen></iframe>';
62
+  $temp = preg_replace($re, $newre, $article_only);
63
+  $article_only = $temp;
64
+  $re='/<div data-iframely-id="(.+?)" data-embedded-url="https:\/\/www.youtube.com\/watch\?time_continue=(.+?)&v=(.+?)"(.+?)>/';
65
+  $newre='<div><iframe width="100%" src="https://www.youtube.com/embed/\\3?feature=oembed&start=\\2" frameborder="0" gesture="media" allowfullscreen></iframe>';
66
+  $temp = preg_replace($re, $newre, $article_only);
67
+  $article_only = $temp;
68
+  $re='/><iframe data-img="" data-iframely-url="(.+?)" style="(.+?)"><\/iframe>/';
69
+  $newre='<a href="\\1" target="new">Video</a><iframe width="100%" src="https:\\1" frameborder="0" gesture="media" allowfullscreen></iframe>';
70
+  $article_only = preg_replace($re, $newre, $article_only);
71
+  $re = '/<div style="left:0;width:100%;height:0;position:relative;padding-bottom:56.2493%;" data-iframely-smart-iframe="true"/';
72
+  $article_only = preg_replace($re, '<div>', $article_only);
73
+
74
+  $re='/<div style="max-width: (.+?)px;"/';
75
+  $newre='<div ';
76
+  $temp = preg_replace($re, $newre, $article_only);
77
+  $article_only = $temp;
78
+  $re='/<div style="left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.(.+?)" data-iframely-smart-iframe="true">/';
79
+  $newre='<div>';
80
+  $temp = preg_replace($re, $newre, $article_only);
81
+  $article_only = $temp;
82
+  $re='/<div data-iframely-id="(.+?)" data-embedded-url="https:\/\/www.youtube.com\/embed\/(.+?)"(.+?)>/';
83
+  $newre='<div><iframe width="100%" src="https://www.youtube.com/embed/\\2" frameborder="0" gesture="media" allowfullscreen></iframe>';
84
+  $temp = preg_replace($re, $newre, $article_only);
85
+  $article_only = $temp;
86
+  $re='/<div  data-iframely-id="(.+?)" data-embedded-url="https:\/\/twitter.com\/(.+?)"(.+?)>/';
87
+  $newre='<div><iframe width="100%" src="https://publish.twitter.com/oembed?https://twitter.com/\\2"></iframe>';
88
+  $temp = preg_replace($re, $newre, $article_only);
89
+  $article_only = $temp;
90
+  $re='/<source media="\(max-width: (.+?)\)" /';
91
+  $temp = preg_replace($re, '<source media="(max-width: 100%)" ', $article_only);
92
+  $article_only = $temp;
93
+  $re='/<source media="\(min-width: (.+?)\)" /';
94
+  $temp = preg_replace($re, '<source media="(min-width: 100%)" ', $article_only);
95
+  $article_only = $temp;
96
+  $re='/<img src="(.+?)" alt="">/';
97
+  $temp = preg_replace($re, '<img width="100%" src="\\1" alt="">" ', $article_only);
98
+  $article_only = $temp;
99
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
100
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
101
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
102
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>'.PHP_EOL;
103
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>'.PHP_EOL;
104
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '.PHP_EOL;
105
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
106
+  echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
107
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.PHP_EOL;
108
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>'.PHP_EOL;
109
+  echo '<!-- ENDOF ==================== article '.$cpt.'============== -->'.PHP_EOL;
110
+  $cpt++;
111
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
112
+      break;
113
+  }
114
+}
115
+?>
+77
sources/rss.php
... ...
@@ -0,0 +1,77 @@
1
+<?php
2
+$DEBUG=0;
3
+define('NEWS_RSS_LEMONDE', 'https://www.lemonde.fr/rss/une.xml');
4
+define('NEWS_RSS_LIBERATION', 'http://rss.liberation.fr/rss/latest/');
5
+define('NEWS_RSS_SLATEFR', 'https://www.slate.fr/rss.xml');
6
+define('NEWS_RSS_VICEFR', 'https://www.vice.com/fr/rss');
7
+define('NEWS_RSS_LESINROCKS', 'https://www.lesinrocks.com/feeds/feed-a-la-une/');
8
+define('NEWS_RSS_NUMERAMA', 'https://www.numerama.com/rss/news.rss');
9
+define('NEWS_RSS_HUFFINGTONPOSTFR', 'https://www.huffingtonpost.fr/feeds/index.xml');
10
+define('NEWS_RSS_LEPOINTFR', 'http://www.lepoint.fr/24h-infos/rss.xml');
11
+define('NEWS_RSS_LEXPRESSFR', 'https://www.lexpress.fr/rss/alaune.xml');
12
+define('NEWS_RSS_FRANCEINFO', 'https://www.francetvinfo.fr/titres.rss');
13
+define('NEWS_RSS_CONSPIRACY', 'http://www.conspiracywatch.info/feed');
14
+
15
+$array_title=array(
16
+  "lemonde" => "LeMonde.fr",
17
+  "liberation" => "Liberation.fr",
18
+  "slatefr" => "Slate.fr",
19
+  "numerama" => "Numerama",
20
+  "huffingtonpostfr" => "HuffingtonPost.fr",
21
+  "lepointfr" => "LePoint.fr",
22
+  "lexpressfr" => "L'Express.fr",
23
+  "vicefr" => "Vice.fr",
24
+  "franceinfo" => "FranceInfo",
25
+  "lesinrocks" => "LesInrocks.fr",
26
+  "conspiracy" => "Conspiracy Watch"
27
+);
28
+$array_url=array(
29
+  "lemonde" => NEWS_RSS_LEMONDE,
30
+  "liberation" => NEWS_RSS_LIBERATION,
31
+  "slatefr" => NEWS_RSS_SLATEFR,
32
+  "numerama" => NEWS_RSS_NUMERAMA,
33
+  "huffingtonpostfr" => NEWS_RSS_HUFFINGTONPOSTFR,
34
+  "lepointfr" => NEWS_RSS_LEPOINTFR,
35
+  "lexpressfr" => NEWS_RSS_LEXPRESSFR,
36
+  "vicefr" => NEWS_RSS_VICEFR,
37
+  "franceinfo" => NEWS_RSS_FRANCEINFO,
38
+  "lesinrocks" => NEWS_RSS_LESINROCKS,
39
+  "conspiracy" => NEWS_RSS_CONSPIRACY
40
+);
41
+
42
+function DEBUG($Message) {
43
+  global $DEBUG;
44
+  if($DEBUG) {
45
+    $stderr = fopen('php://stderr', 'w'); 
46
+    fwrite($stderr,"[DEBUG]".$Message.PHP_EOL); 
47
+    fclose($stderr); 
48
+  }
49
+}
50
+function WARNING($Message) {
51
+  $stderr = fopen('php://stderr', 'w'); 
52
+  fwrite($stderr,"[WARNING]".$Message.PHP_EOL); 
53
+  fclose($stderr); 
54
+}
55
+function ERROR($Message) {
56
+  $stderr = fopen('php://stderr', 'w'); 
57
+  fwrite($stderr,"[ERROR]".$Message.PHP_EOL); 
58
+  fclose($stderr); 
59
+}
60
+
61
+function getElementByClass(&$parentNode, $tagName, $className, $offset = 0) {
62
+    $response = false;
63
+    $childNodeList = $parentNode->getElementsByTagName($tagName);
64
+    $tagCount = 0;
65
+    for ($i = 0; $i < $childNodeList->length; $i++) {
66
+        $temp = $childNodeList->item($i);
67
+        if (stripos($temp->getAttribute('class'), $className) !== false) {
68
+            if ($tagCount == $offset) {
69
+                $response = $temp;
70
+                break;
71
+            }
72
+            $tagCount++;
73
+        }
74
+    }
75
+    return $response;
76
+}
77
+?>