]> git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
167c4401cc792774b1210646281b7cee54539680
[github/wallabag/wallabag.git] / index.php
1 <?php
2 /**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <nicolas@loeuillet.org>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11 /**
12 * TODO
13 * gestion des erreurs sqlite (duplicate tout ça)
14 * gérer si url vide
15 * traiter les variables passées en get
16 * récupérer le titre de la page pochée (cf readityourself.php)
17 * actions archive, fav et delete à traiter
18 * bookmarklet
19 * améliorer présentation des liens
20 * améliorer présentation d'un article
21 * aligner verticalement les icones d'action
22 * afficher liens mis en favoris et archivés
23 * tri des liens
24 */
25
26 try
27 {
28 $db_handle = new PDO('sqlite:poche.sqlite');
29 $db_handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
30 }
31 catch (Exception $e)
32 {
33 die('error : '.$e->getMessage());
34 }
35
36 $action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : '';
37
38 switch ($action) {
39 case 'add':
40 $url = (isset ($_GET['url'])) ? htmlspecialchars($_GET['url']) : '';
41 $title = $url;
42 $query = $db_handle->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)');
43 $query->execute(array($url, $title));
44 break;
45 case 'archive':
46 break;
47 case 'fav' :
48 break;
49 case 'delete':
50 break;
51 default:
52 break;
53 }
54
55 function url(){
56 $protocol = "http";
57 if(isset($_SERVER['HTTPS']))
58 if($_SERVER['HTTPS'] != "off")
59 $protocol = "https";
60
61 return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
62 }
63 ?>
64 <!DOCTYPE html>
65 <!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]-->
66 <!--[if lte IE 7]> <html class="no-js ie7 ie67 ie678" lang="en"> <![endif]-->
67 <!--[if IE 8]> <html class="no-js ie8 ie678" lang="en"> <![endif]-->
68 <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
69 <html>
70 <head>
71 <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
72 <meta charset="utf-8">
73 <meta http-equiv="X-UA-Compatible" content="IE=10">
74 <title>poche : queue</title>
75 <link rel="stylesheet" href="css/knacss.css" media="all">
76 <link rel="stylesheet" href="css/style.css" media="all">
77 </head>
78 <body>
79 <header>
80 <h1>poche, a read it later open source system</h1>
81 </header>
82 <div id="main" class="w800p">
83 <ul id="links">
84 <li><a href="index.php">home</a></li>
85 <li><a href="#">favorites</a></li>
86 <li><a href="#">archive</a></li>
87 <li><a href="javascript:(function(){var%20url%20=%20location.href;var%20title%20=%20document.title%20||%20url;window.open('<?php echo url()?>index.php?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></li>
88 </ul>
89 <?php
90 $query = $db_handle->prepare("SELECT * FROM entries WHERE read=?");
91 $query->execute(array('FALSE'));
92 $entries = $query->fetchAll();
93 ?>
94 <ul id="entries">
95 <?php
96 foreach ($entries as $entry) {
97 echo '<li><a href="readityourself.php?url='.urlencode($entry['url']).'">' . $entry['title'] . '</a> <a href="#" title="toggle delete" class="tool">&#10003;</a> <a href="#" title="toggle favorite" class="tool">&#9734;</a> <a href="#" title="toggle mark as read" class="tool">&#10799;</a></li>';
98 }
99 ?>
100 </ul>
101 </div>
102 <footer class="mr2 mt3">
103 <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>. poche is developed by <a href="http://nicolas.loeuillet.org">Nicolas Lœuillet</a> under the <a href="http://www.wtfpl.net/">Do What the Fuck You Want to Public License</a></p>
104 </footer>
105 </body>
106 </html>