3 * poche, a read it later open source system
6 * @author Nicolas LÅ“uillet <nicolas@loeuillet.org>
8 * @license http://www.wtfpl.net/ see COPYING file
11 require_once dirname(__FILE__
).'/inc/Readability.php';
12 require_once dirname(__FILE__
).'/inc/Encoding.php';
13 include dirname(__FILE__
).'/inc/functions.php';
17 $db_handle = new PDO('sqlite:db/poche.sqlite');
18 $db_handle->setAttribute(PDO
::ATTR_ERRMODE
, PDO
::ERRMODE_EXCEPTION
);
22 die('database error : '.$e->getMessage());
25 $action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : '';
26 $view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : '';
27 $id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : '';
32 $url = (isset ($_GET['url'])) ? $_GET['url'] : '';
36 $url = html_entity_decode(trim($url));
38 // We remove the annoying parameters added by FeedBurner and GoogleFeedProxy (?utm_source=...)
39 // from shaarli, by sebsauvage
40 $i=strpos($url,'&utm_source='); if ($i!==false) $url=substr($url,0,$i);
41 $i=strpos($url,'?utm_source='); if ($i!==false) $url=substr($url,0,$i);
42 $i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i);
45 if (!preg_match('!^https?://!i', $url))
46 $url = 'http://' . $url;
48 $html = Encoding
::toUTF8(get_external_file($url,15));
49 if (isset($html) and strlen($html) > 0)
51 $r = new Readability($html, $url);
54 $title = $r->articleTitle
->innerHTML
;
58 $query = $db_handle->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)');
59 $query->execute(array($url, $title));
62 $sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?";
63 $params_action = array($id);
65 case 'toggle_archive' :
66 $sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?";
67 $params_action = array($id);
70 $sql_action = "DELETE FROM entries WHERE id=?";
71 $params_action = array($id);
80 if (isset($sql_action))
82 $query = $db_handle->prepare($sql_action);
83 $query->execute($params_action);
88 die('query error : '.$e->getMessage());
94 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
98 $sql = "SELECT * FROM entries WHERE is_fav=? ORDER BY id desc";
102 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
111 $query = $db_handle->prepare($sql);
112 $query->execute($params);
113 $entries = $query->fetchAll();
117 die('query error : '.$e->getMessage());
122 <!--[if lte IE
6]> <html
class="no-js ie6 ie67 ie678" lang
="en"> <![endif]-->
123 <!--[if lte IE
7]> <html
class="no-js ie7 ie67 ie678" lang
="en"> <![endif]-->
124 <!--[if IE
8]> <html
class="no-js ie8 ie678" lang
="en"> <![endif]-->
125 <!--[if gt IE
8]><!--> <html
class="no-js" lang
="en"> <!--<![endif]-->
128 <meta name
="viewport" content
="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
129 <meta charset
="utf-8">
130 <meta http
-equiv
="X-UA-Compatible" content
="IE=10">
131 <title
>poche
, a read it later open source system
</title
>
132 <link rel
="shortcut icon" type
="image/x-icon" href
="img/favicon.ico" />
133 <link rel
="apple-touch-icon-precomposed" sizes
="144x144" href
="img/apple-touch-icon-144x144-precomposed.png">
134 <link rel
="apple-touch-icon-precomposed" sizes
="72x72" href
="img/apple-touch-icon-72x72-precomposed.png">
135 <link rel
="apple-touch-icon-precomposed" href
="img/apple-touch-icon-precomposed.png">
136 <link rel
="stylesheet" href
="css/knacss.css" media
="all">
137 <link rel
="stylesheet" href
="css/style.css" media
="all">
141 <h1
><img src
="img/logo.png" alt
="logo poche" />poche
</h1
>
143 <div id
="main" class="w960p">
145 <li
><a href
="index.php" <?php
echo (($view == 'index') ? 'class="current"' : ''); ?>>home
</a
></li
>
146 <li
><a href
="?view=fav" <?php
echo (($view == 'fav') ? 'class="current"' : ''); ?>>favorites
</a
></li
>
147 <li
><a href
="?view=archive" <?php
echo (($view == 'archive') ? 'class="current"' : ''); ?>>archive
</a
></li
>
148 <li
><a style
="cursor: move" title
="i am a bookmarklet, use me !" href
="javascript:(function(){var%20url%20=%20location.href;var%20title%20=%20document.title%20||%20url;window.open('<?php echo url()?>?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it
!</a
></li
>
153 foreach ($entries as $entry)
156 echo '<section class="line grid3">';
158 echo '<aside class="mod entrie mb2"><h2 class="h6-like"><a href="readityourself.php?url='.urlencode($entry['url']).'">' . $entry['title'] . '</h2><div class="tools"><a href="?action=toggle_archive&id='.$entry['id'].'" title="toggle mark as read" class="tool">✓</a> <a href="?action=toggle_fav&id='.$entry['id'].'" title="toggle favorite" class="tool">'.(($entry['is_fav'] == 0) ? '☆' : '★' ).'</a> <a href="?action=delete&id='.$entry['id'].'" title="toggle delete" onclick="return confirm(\'Are you sure?\')" class="tool">⨯</a></div></aside>';
169 <footer
class="mr2 mt3 smaller">
170 <p
><a href
="http://github.com/nicosomb/poche">poche
</a
> is a read it later open source system
, based on
<a href
="http://www.memiks.fr/readityourself/">ReadItYourself
</a
>.<br
/>
171 Follow us on
<a href
="https://twitter.com/getpoche" title
="follow us on twitter">@getpoche
</a
>.</<br
/>
172 Logo by
<a href
="http://www.iconfinder.com/icondetails/43256/128/jeans_monotone_pocket_icon">Brightmix
</a
>.<br
/>
173 poche is developed by
<a href
="http://nicolas.loeuillet.org">Nicolas LÅ“uillet
</a
> under the
<a href
="http://www.wtfpl.net/">WTFPL
</a
>.</p
>