* @copyright 2013 * @license http://www.wtfpl.net/ see COPYING file */ include dirname(__FILE__).'/inc/config.php'; $db = new db(DB_PATH); $action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; $view = (isset ($_GET['view'])) ? htmlspecialchars($_GET['view']) : ''; $id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : ''; $url = (isset ($_GET['url'])) ? $_GET['url'] : ''; switch ($action) { case 'add': if ($url == '') continue; $parametres_url = prepare_url($url); try { # insert query $query = $db->getHandle()->prepare('INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'); $query->execute(array($url, $parametres_url['title'], $parametres_url['content'])); } catch (Exception $e) { error_log('insert query error : '.$e->getMessage()); } break; case 'delete': $sql_action = "DELETE FROM entries WHERE id=?"; $params_action = array($id); break; default: break; } try { # action query if (isset($sql_action)) { $query = $db->getHandle()->prepare($sql_action); $query->execute($params_action); } } catch (Exception $e) { die('action query error : '.$e->getMessage()); } switch ($view) { case 'archive': $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc"; $params = array(-1); break; case 'fav' : $sql = "SELECT * FROM entries WHERE is_fav=? ORDER BY id desc"; $params = array(-1); break; default: $sql = "SELECT * FROM entries WHERE is_read=? ORDER BY id desc"; $params = array(0); $view = 'index'; break; } # view query try { $query = $db->getHandle()->prepare($sql); $query->execute($params); $entries = $query->fetchAll(); } catch (Exception $e) { die('view query error : '.$e->getMessage()); } ?>