]>
Commit | Line | Data |
---|---|---|
1a268ba7 | 1 | <?php |
1a268ba7 | 2 | header('Content-type:text/html; charset=utf-8'); |
1a268ba7 | 3 | |
1ff23336 | 4 | setlocale(LC_ALL, 'fr_FR'); |
1a268ba7 NL |
5 | date_default_timezone_set('Europe/Paris'); |
6 | ||
1a268ba7 | 7 | require_once dirname(__FILE__).'/inc/Readability.php'; |
1a268ba7 | 8 | require_once dirname(__FILE__).'/inc/Encoding.php'; |
1a268ba7 | 9 | require_once dirname(__FILE__).'/inc/rain.tpl.class.php'; |
24619534 | 10 | include dirname(__FILE__).'/inc/functions.php'; |
1a268ba7 | 11 | |
1a268ba7 NL |
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); | |
24619534 | 21 | |
1a268ba7 NL |
22 | // if url use https protocol change it to http |
23 | if (!preg_match('!^https?://!i', $url)) $url = 'http://'.$url; | |
24619534 | 24 | |
1a268ba7 NL |
25 | // convert page to utf-8 |
26 | $html = Encoding::toUTF8(get_external_file($url,15)); | |
24619534 | 27 | |
1a268ba7 | 28 | if(isset($html) and strlen($html) > 0) { |
24619534 | 29 | |
1a268ba7 NL |
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 | } | |
1ff23336 | 43 | } |