From 67e7910439d364f1f7a4dac1d233a7c1055fb933 Mon Sep 17 00:00:00 2001 From: nicosomb Date: Fri, 12 Apr 2013 12:25:58 +0200 Subject: changement de la structure de la bdd sqlite : on stocke le contenu maintenant issue #17 --- db/poche.sqlite | Bin 163840 -> 294912 bytes index.php | 19 ++++++++++++++----- process.php | 1 - readityourself.php | 43 ------------------------------------------- view.php | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 49 deletions(-) delete mode 100755 readityourself.php create mode 100755 view.php diff --git a/db/poche.sqlite b/db/poche.sqlite index 6847e957..2aee61f4 100755 Binary files a/db/poche.sqlite and b/db/poche.sqlite differ diff --git a/index.php b/index.php index 27144de3..7ae2fb6f 100755 --- a/index.php +++ b/index.php @@ -44,8 +44,17 @@ switch ($action) } } - $query = $db->getHandle()->prepare('INSERT INTO entries ( url, title ) VALUES (?, ?)'); - $query->execute(array($url, $title)); + try + { + # insert query + $query = $db->getHandle()->prepare('INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'); + $query->execute(array($url, $title, $r->articleContent->innerHTML)); + } + catch (Exception $e) + { + error_log('insert query error : '.$e->getMessage()); + } + break; case 'delete': $sql_action = "DELETE FROM entries WHERE id=?"; @@ -66,7 +75,7 @@ try } catch (Exception $e) { - die('query error : '.$e->getMessage()); + die('action query error : '.$e->getMessage()); } switch ($view) @@ -95,7 +104,7 @@ try } catch (Exception $e) { - die('query error : '.$e->getMessage()); + die('view query error : '.$e->getMessage()); } ?> @@ -136,7 +145,7 @@ catch (Exception $e)

- +

diff --git a/process.php b/process.php index ef258308..0bd20e5d 100644 --- a/process.php +++ b/process.php @@ -14,7 +14,6 @@ $db = new db(DB_PATH); $action = (isset ($_GET['action'])) ? htmlspecialchars($_GET['action']) : ''; $id = (isset ($_GET['id'])) ? htmlspecialchars($_GET['id']) : ''; - switch ($action) { case 'toggle_fav' : diff --git a/readityourself.php b/readityourself.php deleted file mode 100755 index 588baeca..00000000 --- a/readityourself.php +++ /dev/null @@ -1,43 +0,0 @@ - 2048) { - echo "Error URL is too large !!"; - } else { - $url = trim($_GET['url']); - - // decode it - $url = html_entity_decode($url); - - // if url use https protocol change it to http - if (!preg_match('!^https?://!i', $url)) $url = 'http://'.$url; - - // convert page to utf-8 - $html = Encoding::toUTF8(get_external_file($url,15)); - - if(isset($html) and strlen($html) > 0) { - - // send result to readability library - $r = new Readability($html, $url); - - if($r->init()) { - generate_page($url,$r->articleTitle->innerHTML,$r->articleContent->innerHTML); - } else { - // return data into an iframe - echo ""; - } - } else { - echo "Error unable to get link : ".$url; - } - } -} \ No newline at end of file diff --git a/view.php b/view.php new file mode 100755 index 00000000..aba1b7ec --- /dev/null +++ b/view.php @@ -0,0 +1,35 @@ + + * @copyright 2013 + * @license http://www.wtfpl.net/ see COPYING file + */ + +header('Content-type:text/html; charset=utf-8'); + +include dirname(__FILE__).'/inc/config.php'; +require_once dirname(__FILE__).'/inc/rain.tpl.class.php'; +$db = new db(DB_PATH); + +if(isset($_GET['id']) && $_GET['id'] != '') { + + $sql = "SELECT * FROM entries WHERE id=?"; + $params = array(intval($_GET['id'])); + + # view article query + try + { + $query = $db->getHandle()->prepare($sql); + $query->execute($params); + $entry = $query->fetchAll(); + } + catch (Exception $e) + { + die('query error : '.$e->getMessage()); + } + + generate_page($entry[0]['url'], $entry[0]['title'], $entry[0]['content']); +} \ No newline at end of file -- cgit v1.2.3