]> git.immae.eu Git - github/wallabag/wallabag.git/blame - index.php
suppression doublon du code pour la requête
[github/wallabag/wallabag.git] / index.php
CommitLineData
1a268ba7
NL
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
421b65eb 6 * @author Nicolas Lœuillet <support@inthepoche.com>
1a268ba7
NL
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
c594aedf 11include dirname(__FILE__).'/inc/config.php';
12$db = new db(DB_PATH);
1a268ba7
NL
13
14$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : '';
386407c1 15$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : '';
7eca3552 16$id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : '';
3c8d80ae 17$url = (isset ($_GET['url'])) ? $_GET['url'] : '';
1a268ba7 18
386407c1 19switch ($action)
20{
1a268ba7 21 case 'add':
3c8d80ae 22
386407c1 23 if ($url == '')
24 continue;
25
3c8d80ae 26 $parametres_url = prepare_url($url);
24619534 27
3e188a7c 28 $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
29 $params_action = array($url, $parametres_url['title'], $parametres_url['content']);
67e79104 30
1a268ba7 31 break;
1a268ba7 32 case 'delete':
386407c1 33 $sql_action = "DELETE FROM entries WHERE id=?";
34 $params_action = array($id);
1a268ba7
NL
35 break;
36 default:
37 break;
38}
c4fb6f01 39
5917f419 40try
41{
42 # action query
386407c1 43 if (isset($sql_action))
44 {
c594aedf 45 $query = $db->getHandle()->prepare($sql_action);
5917f419 46 $query->execute($params_action);
47 }
48}
49catch (Exception $e)
50{
67e79104 51 die('action query error : '.$e->getMessage());
5917f419 52}
53
386407c1 54switch ($view)
55{
5917f419 56 case 'archive':
0772c48b 57 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
5917f419 58 $params = array(-1);
59 break;
60 case 'fav' :
0772c48b 61 $sql = "SELECT * FROM entries WHERE is_fav=? ORDER BY id desc";
5917f419 62 $params = array(-1);
63 break;
64 default:
0772c48b 65 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
5917f419 66 $params = array(0);
8784f095 67 $view = 'index';
5917f419 68 break;
69}
70
71# view query
72try
73{
c594aedf 74 $query = $db->getHandle()->prepare($sql);
5917f419 75 $query->execute($params);
76 $entries = $query->fetchAll();
77}
78catch (Exception $e)
79{
67e79104 80 die('view query error : '.$e->getMessage());
5917f419 81}
82
1a268ba7
NL
83?>
84<!DOCTYPE html>
85<!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]-->
86<!--[if lte IE 7]> <html class="no-js ie7 ie67 ie678" lang="en"> <![endif]-->
87<!--[if IE 8]> <html class="no-js ie8 ie678" lang="en"> <![endif]-->
88<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
89<html>
90 <head>
91 <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
92 <meta charset="utf-8">
93 <meta http-equiv="X-UA-Compatible" content="IE=10">
386407c1 94 <title>poche, a read it later open source system</title>
d6353f75 95 <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
5a862b08 96 <link rel="apple-touch-icon-precomposed" sizes="144x144" href="img/apple-touch-icon-144x144-precomposed.png">
97 <link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
98 <link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-precomposed.png">
1a268ba7
NL
99 <link rel="stylesheet" href="css/knacss.css" media="all">
100 <link rel="stylesheet" href="css/style.css" media="all">
101 </head>
102 <body>
5917f419 103 <header>
386407c1 104 <h1><img src="img/logo.png" alt="logo poche" />poche</h1>
5917f419 105 </header>
c594aedf 106 <div id="main">
5917f419 107 <ul id="links">
8784f095 108 <li><a href="index.php" <?php echo (($view == 'index') ? 'class="current"' : ''); ?>>home</a></li>
109 <li><a href="?view=fav" <?php echo (($view == 'fav') ? 'class="current"' : ''); ?>>favorites</a></li>
110 <li><a href="?view=archive" <?php echo (($view == 'archive') ? 'class="current"' : ''); ?>>archive</a></li>
ee55d616 111 <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>
5917f419 112 </ul>
c594aedf 113 <div id="content">
5917f419 114 <?php
386407c1 115 foreach ($entries as $entry)
116 {
c594aedf 117 ?>
b70971e0 118 <div id="entry-<?php echo $entry['id']; ?>" class="entrie mb2">
c594aedf 119 <span class="content">
120 <h2 class="h6-like">
67e79104 121 <a href="view.php?id=<?php echo $entry['id']; ?>"><?php echo $entry['title']; ?>
c594aedf 122 </h2>
123 <div class="tools">
c8bbe19b 124 <a title="toggle mark as read" class="tool archive <?php echo ( ($entry['is_read'] == '0') ? 'archive-off' : '' ); ?>" onclick="toggle_archive(this, <?php echo $entry['id']; ?>)"><span></span></a>
c594aedf 125 <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>
126 <a href="?action=delete&id=<?php echo $entry['id']; ?>" title="toggle delete" onclick="return confirm('Are you sure?')" class="tool delete"><span></span></a>
127 </div>
128 </span>
b70971e0 129 </div>
c594aedf 130 <?php
5917f419 131 }
132 ?>
7eca3552 133 </div>
5917f419 134 </div>
d08318e4 135 <footer class="mr2 mt3 smaller">
421b65eb 136 <p>powered by <a href="http://inthepoche.com">poche</a><br />follow us on <a href="https://twitter.com/getpoche" title="follow us on twitter">twitter</a></p>
1a268ba7 137 </footer>
c594aedf 138 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
b70971e0 139 <script type="text/javascript" src="js/jquery.masonry.min.js"></script>
c594aedf 140 <script type="text/javascript" src="js/poche.js"></script>
b70971e0 141 <script type="text/javascript">
142 $( window ).load( function()
143 {
144 var columns = 3,
145 setColumns = function() { columns = $( window ).width() > 640 ? 3 : $( window ).width() > 320 ? 2 : 1; };
146
147 setColumns();
148 $( window ).resize( setColumns );
149
150 $( '#content' ).masonry(
151 {
152 itemSelector: '.entrie',
153 columnWidth: function( containerWidth ) { return containerWidth / columns; }
154 });
155 });
156 </script>
5917f419 157 </body>
d08318e4 158</html>