Showing 1 changed files with 0 additions and 135 deletions
-135
sources/news-lobs.php
... ...
@@ -1,135 +0,0 @@
1
-<?php
2
-include_once( 'news-constants.php' );
3
-
4
-$rss_content = http_get_contents(NEWS_RSS_LOBS);
5
-$xml = simplexml_load_string($rss_content);
6
-if ($xml === false) {
7
-  echo 'Failed to read RSS';
8
-} else {
9
-  $channel = array();
10
-  $channel['name'] = "lobs";
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'].PHP_EOL;
17
-  echo '<button id="html-btn" onclick="printHTMLAll(\''.$channel['name'].'.html\')" style="display:inline;"><img src="img/html5.png" width="24px" height="24px"></button>'.PHP_EOL;
18
-  echo '<button id="pdf-btn" onclick="printPDFAll(\''.$channel['name'].'.pdf\')" style="display:inline;"><img src="img/pdf.png" width="24px" height="24px"></button>'.PHP_EOL;
19
-  echo '<button id="epub-btn" onclick="printEPUBAll(\''.$channel['name'].'.epub\')" style="display:inline;"><img src="img/epub.png" width="24px" height="24px"></button>'.PHP_EOL;
20
-  echo '</h4>'.PHP_EOL;
21
-  $cpt=0;
22
-  foreach ($xml->channel->item as $item) {
23
-    $article = array();
24
-    $article['title'] = $item->title;
25
-    $article['link'] = $item->link;
26
-    $article['link']  = re_remove($article['link'], '/\?xtor=RSS-(.+)/');
27
-    $article['pubDate'] = $item->pubDate;
28
-    $article['timestamp'] = strtotime($item->pubDate);
29
-    $article['description'] = $item->description;
30
-    $articles[$cpt] = $article; 
31
-
32
-    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">'.PHP_EOL;
33
-    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;
34
-    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
35
-    echo $article['title'].'&nbsp;&nbsp;'.PHP_EOL;
36
-    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;
37
-    $cpt++;
38
-    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
39
-      break;
40
-    }
41
-  }
42
-}
43
-echo '</div><!-- ./col-4 -->';
44
-echo '<div id="article-display" class="col-6">'.PHP_EOL;
45
-echo '<a name="article-top"></a><div id="article-current"></div>';
46
-echo '</div><!-- ./col-6 -->'.PHP_EOL;
47
-$cpt=0;
48
-foreach ($articles as $article ) {
49
-  $cpt_prev=$cpt-1;
50
-  $cpt_next=$cpt+1;
51
-  echo PHP_EOL.PHP_EOL."<!-- ==================== article '.$cpt.'============== -->".PHP_EOL;
52
-  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
53
-  echo "<hr><a name=\"article-$cpt\">\n";
54
-  $article_content = file_get_contents($article['link']);
55
-  $article_content_utf8 = mb_convert_encoding($article_content, 'HTML-ENTITIES', "UTF-8");
56
-  $article_content = $article_content_utf8;
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
-    $classname = $node->getAttribute('id');
68
-    if($classname == 'ObsArticle-body' ) {
69
-      $article_only = DOMinnerHTML($node);
70
-      break;
71
-    }
72
-  }
73
-  if( 0 == strlen($article_only)) {
74
-    $article_only = "Extraction failed";
75
-  }
76
-
77
-  $metas = $doc->getElementsByTagName('meta');
78
-  $chapo = "";
79
-  foreach ( $metas as $node) {
80
-    $classname = $node->getAttribute('property');
81
-    if(0==strcmp($classname,'og:description') ) {
82
-      $chapo = $node->getAttribute('content');
83
-    }else if(0==strcmp($classname,'og:image') ) {
84
-      $article['image'] = $node->getAttribute('content');
85
-    }
86
-  }
87
-  $orgStrings = array(' href="/');
88
-  $newStrings = array(' href="https://www.nouvelobs.com/');
89
-  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
90
-
91
-  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
92
-  $article_only = $temp;
93
-  $temp = preg_replace('/\s\s+/', ' ', $article_only);
94
-  $article_only = $temp;
95
-
96
-  $article_only = re_remove($article_only, '/ <footer class="ObsArticle-footer(.+?)">(.+?)<\/footer>/');
97
-
98
-  //Remove Emptylines
99
-  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
100
-  $article_only = $temp;
101
-  $temp = preg_replace('/\s\s+/', ' ', $article_only);
102
-  $article_only = $temp;
103
-
104
-  
105
-  //Force HTTPS
106
-  $article_only = add_https($article_only, 'www.twitter.com');
107
-  $article_only = add_https($article_only, 'www.facebook.com');
108
-  $article_only = add_https($article_only, 'pbs.twimg.com');
109
-  $article_only = add_https($article_only, 'schema.org');
110
-  $article_only = add_https($article_only, 'www.w3.org');
111
-  $article_only = add_https($article_only, 'www.nouvelobs.com');
112
-  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;
113
-  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;
114
-  echo '<button id="html-btn" onclick="printHTML()" style="display:inline;"><img src="img/html5.png" width="24px" height="24px"></button>'.PHP_EOL;
115
-  echo '<button id="pdf-btn" onclick="printPDF()" style="display:inline;"><img src="img/pdf.png" width="24px" height="24px"></button>'.PHP_EOL;
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;'.PHP_EOL;
117
-  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>'.PHP_EOL;
118
-  echo '<div class="extract-content" id="'.$cpt.'">'.PHP_EOL;
119
-  echo '<h1>'.$article['title'].'</h1>'.PHP_EOL;
120
-  echo '<img src="'.$article['image'].'">'.PHP_EOL;
121
-  echo '<p><em>'.$chapo.'</em></p>'.PHP_EOL;
122
-  echo $article_only;
123
-  echo '</div>'.PHP_EOL;
124
-  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;
125
-  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;
126
-  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;
127
-  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;
128
-  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;
129
-  $cpt++;
130
-  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
131
-      break;
132
-  }
133
-}
134
-?>
135
-