]> git.immae.eu Git - github/wallabag/wallabag.git/blame - readityourself.php
ajout favicon + icone ios
[github/wallabag/wallabag.git] / readityourself.php
CommitLineData
1a268ba7
NL
1<?php
2
3define("VERSION", "0.0.3");
4
5header('Content-type:text/html; charset=utf-8');
6// Set locale to French
7setlocale(LC_ALL, 'fr_FR');
8
9// set timezone to Europe/Paris
10date_default_timezone_set('Europe/Paris');
11
12// set charset to utf-8 important since all pages will be transform to utf-8
13header('Content-Type: text/html;charset=utf-8');
14
15// get readability library
16require_once dirname(__FILE__).'/inc/Readability.php';
17
18// get Encoding library.
19require_once dirname(__FILE__).'/inc/Encoding.php';
20
21// appel de la libraire RainTPL.
22require_once dirname(__FILE__).'/inc/rain.tpl.class.php';
23
24619534 24include dirname(__FILE__).'/inc/functions.php';
1a268ba7
NL
25
26// EXUCUTION CODE
27
28
29if(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);
24619534 38
1a268ba7
NL
39 // if url use https protocol change it to http
40 if (!preg_match('!^https?://!i', $url)) $url = 'http://'.$url;
24619534 41
1a268ba7
NL
42 // convert page to utf-8
43 $html = Encoding::toUTF8(get_external_file($url,15));
24619534 44
1a268ba7 45 if(isset($html) and strlen($html) > 0) {
24619534 46
1a268ba7
NL
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}
24619534 61?>