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 if (!preg_match('!^https?://!i', $url))
39 $url = 'http://' . $url;
41 $html = Encoding
::toUTF8(get_external_file($url,15));
42 if (isset($html) and strlen($html) > 0)
44 $r = new Readability($html, $url);
47 $title = $r->articleTitle
->innerHTML
;
51 $query = $db_handle->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)');
52 $query->execute(array($url, $title));
55 $sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?";
56 $params_action = array($id);
58 case 'toggle_archive' :
59 $sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?";
60 $params_action = array($id);
63 $sql_action = "DELETE FROM entries WHERE id=?";
64 $params_action = array($id);
73 if (isset($sql_action))
75 $query = $db_handle->prepare($sql_action);
76 $query->execute($params_action);
81 die('query error : '.$e->getMessage());
87 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
91 $sql = "SELECT * FROM entries WHERE is_fav=? ORDER BY id desc";
95 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
103 $query = $db_handle->prepare($sql);
104 $query->execute($params);
105 $entries = $query->fetchAll();
109 die('query error : '.$e->getMessage());
114 <!--[if lte IE
6]> <html
class="no-js ie6 ie67 ie678" lang
="en"> <![endif]-->
115 <!--[if lte IE
7]> <html
class="no-js ie7 ie67 ie678" lang
="en"> <![endif]-->
116 <!--[if IE
8]> <html
class="no-js ie8 ie678" lang
="en"> <![endif]-->
117 <!--[if gt IE
8]><!--> <html
class="no-js" lang
="en"> <!--<![endif]-->
120 <meta name
="viewport" content
="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
121 <meta charset
="utf-8">
122 <meta http
-equiv
="X-UA-Compatible" content
="IE=10">
123 <title
>poche
, a read it later open source system
</title
>
124 <link rel
="stylesheet" href
="css/knacss.css" media
="all">
125 <link rel
="stylesheet" href
="css/style.css" media
="all">
129 <h1
><img src
="img/logo.png" alt
="logo poche" />poche
</h1
>
131 <div id
="main" class="w960p">
133 <li
><a href
="index.php">home
</a
></li
>
134 <li
><a href
="?view=fav">favorites
</a
></li
>
135 <li
><a href
="?view=archive">archive
</a
></li
>
136 <li
><a 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
>
141 foreach ($entries as $entry)
144 echo '<section class="line grid3">';
146 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" class="tool">⨯</a></div></aside>';
157 <footer
class="mr2 mt3">
158 <p
class="smaller"><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
>. <a href
="https://twitter.com/getpoche" title
="follow us on twitter">@getpoche
</a
>. Logo by
<a href
="http://www.iconfinder.com/icondetails/43256/128/jeans_monotone_pocket_icon">Brightmix
</a
>. 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
>