]> git.immae.eu Git - github/wallabag/wallabag.git/blob - readityourself.php
mise en page
[github/wallabag/wallabag.git] / readityourself.php
1 <?php
2
3 define("VERSION", "0.0.3");
4
5 header('Content-type:text/html; charset=utf-8');
6 // Set locale to French
7 setlocale(LC_ALL, 'fr_FR');
8
9 // set timezone to Europe/Paris
10 date_default_timezone_set('Europe/Paris');
11
12 // set charset to utf-8 important since all pages will be transform to utf-8
13 header('Content-Type: text/html;charset=utf-8');
14
15 // get readability library
16 require_once dirname(__FILE__).'/inc/Readability.php';
17
18 // get Encoding library.
19 require_once dirname(__FILE__).'/inc/Encoding.php';
20
21 // appel de la libraire RainTPL.
22 require_once dirname(__FILE__).'/inc/rain.tpl.class.php';
23
24 include dirname(__FILE__).'/inc/functions.php';
25
26 // EXUCUTION CODE
27
28
29 if(isset($_GET['url']) && $_GET['url'] != null && trim($_GET['url']) != "") {
30 // get url link
31 if(strlen(trim($_GET['url'])) > 2048) {
32 echo "Error URL is too large !!";
33 } else {
34 $url = trim($_GET['url']);
35
36 // decode it
37 $url = html_entity_decode($url);
38
39 // if url use https protocol change it to http
40 if (!preg_match('!^https?://!i', $url)) $url = 'http://'.$url;
41
42 // convert page to utf-8
43 $html = Encoding::toUTF8(get_external_file($url,15));
44
45 if(isset($html) and strlen($html) > 0) {
46
47 // send result to readability library
48 $r = new Readability($html, $url);
49
50 if($r->init()) {
51 generate_page($url,$r->articleTitle->innerHTML,$r->articleContent->innerHTML);
52 } else {
53 // return data into an iframe
54 echo "<iframe id='readabilityframe'>".$html."</iframe>";
55 }
56 } else {
57 echo "Error unable to get link : ".$url;
58 }
59 }
60 }
61 ?>