aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php64
1 files changed, 27 insertions, 37 deletions
diff --git a/index.php b/index.php
index 1e402896..f46ddf10 100755
--- a/index.php
+++ b/index.php
@@ -8,19 +8,8 @@
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
10 10
11require_once dirname(__FILE__).'/inc/Readability.php'; 11include dirname(__FILE__).'/inc/config.php';
12require_once dirname(__FILE__).'/inc/Encoding.php'; 12$db = new db(DB_PATH);
13include dirname(__FILE__).'/inc/functions.php';
14
15try
16{
17 $db_handle = new PDO('sqlite:db/poche.sqlite');
18 $db_handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
19}
20catch (Exception $e)
21{
22 die('database error : '.$e->getMessage());
23}
24 13
25$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; 14$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : '';
26$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : ''; 15$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : '';
@@ -55,17 +44,9 @@ switch ($action)
55 } 44 }
56 } 45 }
57 46
58 $query = $db_handle->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)'); 47 $query = $db->getHandle()->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)');
59 $query->execute(array($url, $title)); 48 $query->execute(array($url, $title));
60 break; 49 break;
61 case 'toggle_fav' :
62 $sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?";
63 $params_action = array($id);
64 break;
65 case 'toggle_archive' :
66 $sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?";
67 $params_action = array($id);
68 break;
69 case 'delete': 50 case 'delete':
70 $sql_action = "DELETE FROM entries WHERE id=?"; 51 $sql_action = "DELETE FROM entries WHERE id=?";
71 $params_action = array($id); 52 $params_action = array($id);
@@ -79,7 +60,7 @@ try
79 # action query 60 # action query
80 if (isset($sql_action)) 61 if (isset($sql_action))
81 { 62 {
82 $query = $db_handle->prepare($sql_action); 63 $query = $db->getHandle()->prepare($sql_action);
83 $query->execute($params_action); 64 $query->execute($params_action);
84 } 65 }
85} 66}
@@ -108,7 +89,7 @@ switch ($view)
108# view query 89# view query
109try 90try
110{ 91{
111 $query = $db_handle->prepare($sql); 92 $query = $db->getHandle()->prepare($sql);
112 $query->execute($params); 93 $query->execute($params);
113 $entries = $query->fetchAll(); 94 $entries = $query->fetchAll();
114} 95}
@@ -140,30 +121,37 @@ catch (Exception $e)
140 <header> 121 <header>
141 <h1><img src="img/logo.png" alt="logo poche" />poche</h1> 122 <h1><img src="img/logo.png" alt="logo poche" />poche</h1>
142 </header> 123 </header>
143 <div id="main" class="w960p"> 124 <div id="main">
144 <ul id="links"> 125 <ul id="links">
145 <li><a href="index.php" <?php echo (($view == 'index') ? 'class="current"' : ''); ?>>home</a></li> 126 <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> 127 <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> 128 <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> 129 <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>
149 </ul> 130 </ul>
150 <div id="entries"> 131 <div id="content">
132 <ul id="entries">
151 <?php 133 <?php
152 $i = 0; 134 $i = 1;
153 foreach ($entries as $entry) 135 foreach ($entries as $entry)
154 { 136 {
155 if ($i == 0) { 137 ?>
156 echo '<section class="line grid3">'; 138 <li id="entry-<?php echo $entry['id']; ?>" class="entrie mb2">
157 } 139 <span class="content">
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">&#10003;</a> <a href="?action=toggle_fav&id='.$entry['id'].'" title="toggle favorite" class="tool">'.(($entry['is_fav'] == 0) ? '&#9734;' : '&#9733;' ).'</a> <a href="?action=delete&id='.$entry['id'].'" title="toggle delete" onclick="return confirm(\'Are you sure?\')" class="tool">&#10799;</a></div></aside>'; 140 <h2 class="h6-like">
159 141 <a href="readityourself.php?url=<?php echo urlencode($entry['url']); ?>"><?php echo $entry['title']; ?>
160 $i++; 142 </h2>
161 if ($i == 3) { 143 <div class="tools">
162 echo '</section>'; 144 <a title="toggle mark as read" class="tool archive <?php echo ( ($entry['is_read'] == '0') ? 'archive-off' : '' ); ?>" onclick="toggle_archive(<?php echo $entry['id']; ?>)"><span></span></a>
163 $i = 0; 145 <a title="toggle favorite" class="tool fav <?php echo ( ($entry['is_fav'] == '0') ? 'fav-off' : '' ); ?>" onclick="toggle_favorite(this, <?php echo $entry['id']; ?>)"><span></span></a>
164 } 146 <a href="?action=delete&id=<?php echo $entry['id']; ?>" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
147 </div>
148 </span>
149 </li>
150 <?php
151 $i++;
165 } 152 }
166 ?> 153 ?>
154 </ul>
167 </div> 155 </div>
168 </div> 156 </div>
169 <footer class="mr2 mt3 smaller"> 157 <footer class="mr2 mt3 smaller">
@@ -172,5 +160,7 @@ catch (Exception $e)
172 Logo by <a href="http://www.iconfinder.com/icondetails/43256/128/jeans_monotone_pocket_icon">Brightmix</a>.<br /> 160 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> 161 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>
174 </footer> 162 </footer>
163 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
164 <script type="text/javascript" src="js/poche.js"></script>
175 </body> 165 </body>
176</html> 166</html>