...
|
...
|
@@ -1,200 +0,0 @@
|
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> '.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> ';
|
46
|
|
- echo $article['title'].' '.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> '.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> '.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> '.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> '.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> '.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> '.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> '.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
|
|
-?>
|