| ... | ... |
@@ -1,170 +0,0 @@ |
| 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> '; |
|
| 33 |
- echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div> '; |
|
| 34 |
- echo $article['title'].' '; |
|
| 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 id="article-display" class="col-6">'.PHP_EOL; |
|
| 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> '; |
|
| 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> '; |
|
| 157 |
- echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div> ';
|
|
| 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> '; |
|
| 161 |
- echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div> '; |
|
| 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> '; |
|
| 163 |
- echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div> ';
|
|
| 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 |
-?> |
| ... | ... |
@@ -1,123 +0,0 @@ |
| 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> '; |
|
| 35 |
- echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div> '; |
|
| 36 |
- echo $article['title'].' '; |
|
| 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 id="article-display" class="col-6">'.PHP_EOL; |
|
| 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> '; |
|
| 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> '; |
|
| 110 |
- echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div> ';
|
|
| 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> '; |
|
| 114 |
- echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div> '; |
|
| 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> '; |
|
| 116 |
- echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div> ';
|
|
| 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 |
-?> |