2013-04-03 13:14:01 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* poche, a read it later open source system
|
|
|
|
*
|
|
|
|
* @category poche
|
2013-04-13 09:08:31 +00:00
|
|
|
* @author Nicolas Lœuillet <support@inthepoche.com>
|
2013-04-03 13:14:01 +00:00
|
|
|
* @copyright 2013
|
|
|
|
* @license http://www.wtfpl.net/ see COPYING file
|
|
|
|
*/
|
|
|
|
|
2013-04-09 13:18:39 +00:00
|
|
|
include dirname(__FILE__).'/inc/config.php';
|
2013-04-03 13:14:01 +00:00
|
|
|
|
|
|
|
$action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : '';
|
2013-04-05 07:41:34 +00:00
|
|
|
$view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : '';
|
2013-04-05 13:30:50 +00:00
|
|
|
$id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : '';
|
2013-04-15 07:04:23 +00:00
|
|
|
$url = (isset ($_GET['url'])) ? $_GET['url'] : '';
|
2013-04-03 13:14:01 +00:00
|
|
|
|
2013-04-05 07:41:34 +00:00
|
|
|
switch ($action)
|
|
|
|
{
|
2013-04-03 13:14:01 +00:00
|
|
|
case 'add':
|
2013-04-05 07:41:34 +00:00
|
|
|
if ($url == '')
|
|
|
|
continue;
|
|
|
|
|
2013-04-15 07:04:23 +00:00
|
|
|
$parametres_url = prepare_url($url);
|
2013-04-15 07:38:41 +00:00
|
|
|
$sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
|
2013-04-15 07:11:48 +00:00
|
|
|
$params_action = array($url, $parametres_url['title'], $parametres_url['content']);
|
2013-04-03 13:14:01 +00:00
|
|
|
break;
|
|
|
|
case 'delete':
|
2013-04-05 07:41:34 +00:00
|
|
|
$sql_action = "DELETE FROM entries WHERE id=?";
|
|
|
|
$params_action = array($id);
|
2013-04-03 13:14:01 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-04-03 13:22:19 +00:00
|
|
|
|
2013-04-04 17:51:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
# action query
|
2013-04-05 07:41:34 +00:00
|
|
|
if (isset($sql_action))
|
|
|
|
{
|
2013-04-09 13:18:39 +00:00
|
|
|
$query = $db->getHandle()->prepare($sql_action);
|
2013-04-04 17:51:24 +00:00
|
|
|
$query->execute($params_action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception $e)
|
|
|
|
{
|
2013-04-12 10:25:58 +00:00
|
|
|
die('action query error : '.$e->getMessage());
|
2013-04-04 17:51:24 +00:00
|
|
|
}
|
|
|
|
|
2013-04-05 07:41:34 +00:00
|
|
|
switch ($view)
|
|
|
|
{
|
2013-04-04 17:51:24 +00:00
|
|
|
case 'archive':
|
2013-04-08 08:54:30 +00:00
|
|
|
$sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
|
2013-04-04 17:51:24 +00:00
|
|
|
$params = array(-1);
|
|
|
|
break;
|
|
|
|
case 'fav' :
|
2013-04-08 08:54:30 +00:00
|
|
|
$sql = "SELECT * FROM entries WHERE is_fav=? ORDER BY id desc";
|
2013-04-04 17:51:24 +00:00
|
|
|
$params = array(-1);
|
|
|
|
break;
|
|
|
|
default:
|
2013-04-08 08:54:30 +00:00
|
|
|
$sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc";
|
2013-04-04 17:51:24 +00:00
|
|
|
$params = array(0);
|
2013-04-09 09:49:22 +00:00
|
|
|
$view = 'index';
|
2013-04-04 17:51:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
# view query
|
|
|
|
try
|
|
|
|
{
|
2013-04-09 13:18:39 +00:00
|
|
|
$query = $db->getHandle()->prepare($sql);
|
2013-04-04 17:51:24 +00:00
|
|
|
$query->execute($params);
|
|
|
|
$entries = $query->fetchAll();
|
|
|
|
}
|
|
|
|
catch (Exception $e)
|
|
|
|
{
|
2013-04-12 10:25:58 +00:00
|
|
|
die('view query error : '.$e->getMessage());
|
2013-04-04 17:51:24 +00:00
|
|
|
}
|
|
|
|
|
2013-04-15 07:38:41 +00:00
|
|
|
$tpl->assign('title', 'poche, a read it later open source system');
|
|
|
|
$tpl->assign('view', $view);
|
|
|
|
$tpl->assign('poche_url', get_poche_url());
|
|
|
|
$tpl->assign('entries', $entries);
|
|
|
|
$tpl->assign('load_all_js', 1);
|
|
|
|
$tpl->draw('home');
|