aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php27
1 files changed, 4 insertions, 23 deletions
diff --git a/index.php b/index.php
index d40a6c95..d56c1941 100755
--- a/index.php
+++ b/index.php
@@ -14,41 +14,22 @@ $db = new db(DB_PATH);
14$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; 14$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : '';
15$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : ''; 15$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : '';
16$id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : ''; 16$id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : '';
17$url = (isset ($_GET['url'])) ? $_GET['url'] : '';
17 18
18switch ($action) 19switch ($action)
19{ 20{
20 case 'add': 21 case 'add':
21 $url = (isset ($_GET['url'])) ? $_GET['url'] : ''; 22
22 if ($url == '') 23 if ($url == '')
23 continue; 24 continue;
24 25
25 $url = html_entity_decode(trim($url)); 26 $parametres_url = prepare_url($url);
26
27 // We remove the annoying parameters added by FeedBurner and GoogleFeedProxy (?utm_source=...)
28 // from shaarli, by sebsauvage
29 $i=strpos($url,'&utm_source='); if ($i!==false) $url=substr($url,0,$i);
30 $i=strpos($url,'?utm_source='); if ($i!==false) $url=substr($url,0,$i);
31 $i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i);
32
33 $title = $url;
34 if (!preg_match('!^https?://!i', $url))
35 $url = 'http://' . $url;
36
37 $html = Encoding::toUTF8(get_external_file($url,15));
38 if (isset($html) and strlen($html) > 0)
39 {
40 $r = new Readability($html, $url);
41 if($r->init())
42 {
43 $title = $r->articleTitle->innerHTML;
44 }
45 }
46 27
47 try 28 try
48 { 29 {
49 # insert query 30 # insert query
50 $query = $db->getHandle()->prepare('INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'); 31 $query = $db->getHandle()->prepare('INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)');
51 $query->execute(array($url, $title, $r->articleContent->innerHTML)); 32 $query->execute(array($url, $parametres_url['title'], $parametres_url['content']));
52 } 33 }
53 catch (Exception $e) 34 catch (Exception $e)
54 { 35 {