X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=294620d1ebcc4136bc0f3c10d860a200a3bd283d;hb=e4ed594d8246ba5877b86e61f7f85c1b3010f62c;hp=d56c19410d4f530bb02f069a5c1d027ed604502d;hpb=3c8d80aec5f5ba15910014bb4dcb48e948041ec9;p=github%2Fwallabag%2Fwallabag.git diff --git a/index.php b/index.php old mode 100755 new mode 100644 index d56c1941..294620d1 --- a/index.php +++ b/index.php @@ -8,159 +8,59 @@ * @license http://www.wtfpl.net/ see COPYING file */ -include dirname(__FILE__).'/inc/config.php'; -$db = new db(DB_PATH); +include dirname(__FILE__).'/inc/poche/config.inc.php'; -$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'] : ''; +#XSRF protection with token +// if (!empty($_POST)) { +// if (!Session::isToken($_POST['token'])) { +// die(_('Wrong token')); +// // TODO remettre le test +// } +// unset($_SESSION['tokens']); +// } -switch ($action) -{ - case 'add': +$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; +$view = Tools::checkVar('view'); +$action = Tools::checkVar('action'); +$id = Tools::checkVar('id'); +$_SESSION['sort'] = Tools::checkVar('sort'); +$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); - 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; +if (isset($_GET['login'])) { + # hello you + $poche->login($referer); } - -try -{ - # action query - if (isset($sql_action)) - { - $query = $db->getHandle()->prepare($sql_action); - $query->execute($params_action); - } +elseif (isset($_GET['logout'])) { + # see you soon ! + $poche->logout(); } -catch (Exception $e) -{ - die('action query error : '.$e->getMessage()); +elseif (isset($_GET['config'])) { + # Update password + $poche->updatePassword(); } - -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; +elseif (isset($_GET['import'])) { + $poche->import($_GET['from']); } - -# view query -try -{ - $query = $db->getHandle()->prepare($sql); - $query->execute($params); - $entries = $query->fetchAll(); -} -catch (Exception $e) -{ - die('view query error : '.$e->getMessage()); +elseif (isset($_GET['export'])) { + $poche->export(); } -?> - - - - - - - - - - - poche, a read it later open source system - - - - - - - - -
-

logo pochepoche

-
-
- -
- -
- -

- -

-
- - - -
-
-
- -
-
- - - - - - - +# Aaaaaaand action ! +echo $poche->tpl->render($tpl_file, $tpl_vars); \ No newline at end of file