]> git.immae.eu Git - github/wallabag/wallabag.git/blob - readityourself.php
ajout de flattr dans le readme
[github/wallabag/wallabag.git] / readityourself.php
1 <?php
2 header('Content-type:text/html; charset=utf-8');
3
4 setlocale(LC_ALL, 'fr_FR');
5 date_default_timezone_set('Europe/Paris');
6
7 require_once dirname(__FILE__).'/inc/Readability.php';
8 require_once dirname(__FILE__).'/inc/Encoding.php';
9 require_once dirname(__FILE__).'/inc/rain.tpl.class.php';
10 include dirname(__FILE__).'/inc/functions.php';
11
12 if(isset($_GET['url']) && $_GET['url'] != null && trim($_GET['url']) != "") {
13 // get url link
14 if(strlen(trim($_GET['url'])) > 2048) {
15 echo "Error URL is too large !!";
16 } else {
17 $url = trim($_GET['url']);
18
19 // decode it
20 $url = html_entity_decode($url);
21
22 // if url use https protocol change it to http
23 if (!preg_match('!^https?://!i', $url)) $url = 'http://'.$url;
24
25 // convert page to utf-8
26 $html = Encoding::toUTF8(get_external_file($url,15));
27
28 if(isset($html) and strlen($html) > 0) {
29
30 // send result to readability library
31 $r = new Readability($html, $url);
32
33 if($r->init()) {
34 generate_page($url,$r->articleTitle->innerHTML,$r->articleContent->innerHTML);
35 } else {
36 // return data into an iframe
37 echo "<iframe id='readabilityframe'>".$html."</iframe>";
38 }
39 } else {
40 echo "Error unable to get link : ".$url;
41 }
42 }
43 }