aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authornicosomb <nicolas@loeuillet.org>2013-04-15 09:58:34 +0200
committernicosomb <nicolas@loeuillet.org>2013-04-15 09:58:34 +0200
commit263d6c6756a2549100ae186042f157ff64944bfa (patch)
treedc7a9e874438584ab809393d88b41050b75cff34 /index.php
parent8046748b424f95a92ab599ecc973f57eb05246ce (diff)
downloadwallabag-263d6c6756a2549100ae186042f157ff64944bfa.tar.gz
wallabag-263d6c6756a2549100ae186042f157ff64944bfa.tar.zst
wallabag-263d6c6756a2549100ae186042f157ff64944bfa.zip
factorisation code
Diffstat (limited to 'index.php')
-rwxr-xr-xindex.php64
1 files changed, 3 insertions, 61 deletions
diff --git a/index.php b/index.php
index ef18254a..1cb32f58 100755
--- a/index.php
+++ b/index.php
@@ -11,70 +11,12 @@
11include dirname(__FILE__).'/inc/config.php'; 11include dirname(__FILE__).'/inc/config.php';
12 12
13$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; 13$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : '';
14$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : ''; 14$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : 'index';
15$id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : ''; 15$id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : '';
16$url = (isset ($_GET['url'])) ? $_GET['url'] : ''; 16$url = (isset ($_GET['url'])) ? $_GET['url'] : '';
17 17
18switch ($action) 18action_to_do($action, $id);
19{ 19$entries = display_view($view);
20 case 'add':
21 if ($url == '')
22 continue;
23
24 $parametres_url = prepare_url($url);
25 $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
26 $params_action = array($url, $parametres_url['title'], $parametres_url['content']);
27 break;
28 case 'delete':
29 $sql_action = "DELETE FROM entries WHERE id=?";
30 $params_action = array($id);
31 break;
32 default:
33 break;
34}
35
36try
37{
38 # action query
39 if (isset($sql_action))
40 {
41 $query = $db->getHandle()->prepare($sql_action);
42 $query->execute($params_action);
43 }
44}
45catch (Exception $e)
46{
47 die('action query error : '.$e->getMessage());
48}
49
50switch ($view)
51{
52 case 'archive':
53 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
54 $params = array(-1);
55 break;
56 case 'fav' :
57 $sql = "SELECT * FROM entries WHERE is_fav=? ORDER BY id desc";
58 $params = array(-1);
59 break;
60 default:
61 $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
62 $params = array(0);
63 $view = 'index';
64 break;
65}
66
67# view query
68try
69{
70 $query = $db->getHandle()->prepare($sql);
71 $query->execute($params);
72 $entries = $query->fetchAll();
73}
74catch (Exception $e)
75{
76 die('view query error : '.$e->getMessage());
77}
78 20
79$tpl->assign('title', 'poche, a read it later open source system'); 21$tpl->assign('title', 'poche, a read it later open source system');
80$tpl->assign('view', $view); 22$tpl->assign('view', $view);