Merge branch 'dev'
@ -25,7 +25,7 @@ You can :
|
|||||||
## Requirements & installation
|
## Requirements & installation
|
||||||
You have to install [sqlite for php](http://www.php.net/manual/en/book.sqlite.php) on your server.
|
You have to install [sqlite for php](http://www.php.net/manual/en/book.sqlite.php) on your server.
|
||||||
|
|
||||||
Get the [latest version](https://github.com/nicosomb/poche) of poche on github. Unzip it and upload it on your server. poche must have write access on assets, cache and db directories.
|
Get the [latest version](https://github.com/inthepoche/poche) of poche on github. Unzip it and upload it on your server. poche must have write access on assets, cache and db directories.
|
||||||
|
|
||||||
That's all, **poche works** !
|
That's all, **poche works** !
|
||||||
|
|
||||||
|
0
img/messages/close.png
Executable file → Normal file
Before Width: | Height: | Size: 662 B After Width: | Height: | Size: 662 B |
0
img/messages/cross.png
Executable file → Normal file
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
0
img/messages/help.png
Executable file → Normal file
Before Width: | Height: | Size: 786 B After Width: | Height: | Size: 786 B |
0
img/messages/tick.png
Executable file → Normal file
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 537 B |
0
img/messages/warning.png
Executable file → Normal file
Before Width: | Height: | Size: 666 B After Width: | Height: | Size: 666 B |
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* This class extends PHP's DOMElement to allow
|
* This class extends PHP's DOMElement to allow
|
||||||
* users to get and set the innerHTML property of
|
* users to get and set the innerHTML property of
|
||||||
* HTML elements in the same way it's done in
|
* HTML elements in the same way it's done in
|
||||||
* JavaScript.
|
* JavaScript.
|
||||||
*
|
*
|
||||||
* Example usage:
|
* Example usage:
|
||||||
@ -15,16 +15,16 @@
|
|||||||
* $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
|
* $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
|
||||||
* $doc->loadHTML('<div><p>Para 1</p><p>Para 2</p></div>');
|
* $doc->loadHTML('<div><p>Para 1</p><p>Para 2</p></div>');
|
||||||
* $elem = $doc->getElementsByTagName('div')->item(0);
|
* $elem = $doc->getElementsByTagName('div')->item(0);
|
||||||
*
|
*
|
||||||
* // print innerHTML
|
* // print innerHTML
|
||||||
* echo $elem->innerHTML; // prints '<p>Para 1</p><p>Para 2</p>'
|
* echo $elem->innerHTML; // prints '<p>Para 1</p><p>Para 2</p>'
|
||||||
* echo "\n\n";
|
* echo "\n\n";
|
||||||
*
|
*
|
||||||
* // set innerHTML
|
* // set innerHTML
|
||||||
* $elem->innerHTML = '<a href="http://fivefilters.org">FiveFilters.org</a>';
|
* $elem->innerHTML = '<a href="http://fivefilters.org">FiveFilters.org</a>';
|
||||||
* echo $elem->innerHTML; // prints '<a href="http://fivefilters.org">FiveFilters.org</a>'
|
* echo $elem->innerHTML; // prints '<a href="http://fivefilters.org">FiveFilters.org</a>'
|
||||||
* echo "\n\n";
|
* echo "\n\n";
|
||||||
*
|
*
|
||||||
* // print document (with our changes)
|
* // print document (with our changes)
|
||||||
* echo $doc->saveXML();
|
* echo $doc->saveXML();
|
||||||
* @endcode
|
* @endcode
|
||||||
@ -59,7 +59,7 @@ class JSLikeHTMLElement extends DOMElement
|
|||||||
$value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
|
$value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
|
||||||
// Using <htmlfragment> will generate a warning, but so will bad HTML
|
// Using <htmlfragment> will generate a warning, but so will bad HTML
|
||||||
// (and by this point, bad HTML is what we've got).
|
// (and by this point, bad HTML is what we've got).
|
||||||
// We use it (and suppress the warning) because an HTML fragment will
|
// We use it (and suppress the warning) because an HTML fragment will
|
||||||
// be wrapped around <html><body> tags which we don't really want to keep.
|
// be wrapped around <html><body> tags which we don't really want to keep.
|
||||||
// Note: despite the warning, if loadHTML succeeds it will return true.
|
// Note: despite the warning, if loadHTML succeeds it will return true.
|
||||||
$result = @$f->loadHTML('<htmlfragment>'.$value.'</htmlfragment>');
|
$result = @$f->loadHTML('<htmlfragment>'.$value.'</htmlfragment>');
|
||||||
@ -86,7 +86,7 @@ class JSLikeHTMLElement extends DOMElement
|
|||||||
* @code
|
* @code
|
||||||
* $string = $div->innerHTML;
|
* $string = $div->innerHTML;
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
public function __get($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
if ($name == 'innerHTML') {
|
if ($name == 'innerHTML') {
|
||||||
@ -106,5 +106,4 @@ class JSLikeHTMLElement extends DOMElement
|
|||||||
{
|
{
|
||||||
return '['.$this->tagName.']';
|
return '['.$this->tagName.']';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
2164
inc/Readability.php
@ -93,7 +93,7 @@ class Session
|
|||||||
// Force logout
|
// Force logout
|
||||||
public static function logout()
|
public static function logout()
|
||||||
{
|
{
|
||||||
unset($_SESSION['uid'],$_SESSION['info'],$_SESSION['expires_on'],$_SESSION['tokens']);
|
unset($_SESSION['uid'],$_SESSION['info'],$_SESSION['expires_on'],$_SESSION['tokens'], $_SESSION['login'], $_SESSION['pass']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure user is logged in.
|
// Make sure user is logged in.
|
||||||
|
@ -14,9 +14,12 @@ if (!is_dir('db/')) {
|
|||||||
@mkdir('db/',0705);
|
@mkdir('db/',0705);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define ('MODE_DEMO', FALSE);
|
||||||
define ('ABS_PATH', 'assets/');
|
define ('ABS_PATH', 'assets/');
|
||||||
define ('CONVERT_LINKS_FOOTNOTES', TRUE);
|
define ('CONVERT_LINKS_FOOTNOTES', TRUE);
|
||||||
|
define ('REVERT_FORCED_PARAGRAPH_ELEMENTS',FALSE);
|
||||||
define ('DOWNLOAD_PICTURES', TRUE);
|
define ('DOWNLOAD_PICTURES', TRUE);
|
||||||
|
define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX');
|
||||||
$storage_type = 'sqlite'; # sqlite or file
|
$storage_type = 'sqlite'; # sqlite or file
|
||||||
|
|
||||||
include 'functions.php';
|
include 'functions.php';
|
||||||
@ -32,9 +35,7 @@ require_once 'class.messages.php';
|
|||||||
|
|
||||||
Session::init();
|
Session::init();
|
||||||
|
|
||||||
$store = new $storage_type();
|
$store = new $storage_type();
|
||||||
$msg = new Messages();
|
|
||||||
|
|
||||||
# initialisation de RainTPL
|
# initialisation de RainTPL
|
||||||
raintpl::$tpl_dir = './tpl/';
|
raintpl::$tpl_dir = './tpl/';
|
||||||
raintpl::$cache_dir = './cache/';
|
raintpl::$cache_dir = './cache/';
|
||||||
@ -42,4 +43,24 @@ raintpl::$base_url = get_poche_url();
|
|||||||
raintpl::configure('path_replace', false);
|
raintpl::configure('path_replace', false);
|
||||||
raintpl::configure('debug', false);
|
raintpl::configure('debug', false);
|
||||||
$tpl = new raintpl();
|
$tpl = new raintpl();
|
||||||
|
|
||||||
|
if(!$store->isInstalled())
|
||||||
|
{
|
||||||
|
logm('poche still not installed');
|
||||||
|
$tpl->draw('install');
|
||||||
|
if (isset($_GET['install'])) {
|
||||||
|
if (($_POST['password'] == $_POST['password_repeat'])
|
||||||
|
&& $_POST['password'] != "" && $_POST['login'] != "") {
|
||||||
|
$store->install($_POST['login'], encode_string($_POST['password'] . $_POST['login']));
|
||||||
|
Session::logout();
|
||||||
|
MyTool::redirect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin();
|
||||||
|
$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword();
|
||||||
|
|
||||||
|
$msg = new Messages();
|
||||||
$tpl->assign('msg', $msg);
|
$tpl->assign('msg', $msg);
|
@ -23,6 +23,11 @@ function get_poche_url()
|
|||||||
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encode_string($string)
|
||||||
|
{
|
||||||
|
return sha1($string . SALT);
|
||||||
|
}
|
||||||
|
|
||||||
// function define to retrieve url content
|
// function define to retrieve url content
|
||||||
function get_external_file($url)
|
function get_external_file($url)
|
||||||
{
|
{
|
||||||
@ -39,6 +44,10 @@ function get_external_file($url)
|
|||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||||
|
|
||||||
|
// FOR SSL do not verified certificate
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||||
|
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE );
|
||||||
|
|
||||||
// FeedBurner requires a proper USER-AGENT...
|
// FeedBurner requires a proper USER-AGENT...
|
||||||
curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
|
curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
|
||||||
curl_setopt($curl, CURLOPT_ENCODING, "gzip, deflate");
|
curl_setopt($curl, CURLOPT_ENCODING, "gzip, deflate");
|
||||||
@ -54,7 +63,15 @@ function get_external_file($url)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// create http context and add timeout and user-agent
|
// create http context and add timeout and user-agent
|
||||||
$context = stream_context_create(array('http'=>array('timeout' => $timeout,'header'=> "User-Agent: ".$useragent,/*spoot Mozilla Firefox*/'follow_location' => true)));
|
$context = stream_context_create(array(
|
||||||
|
'http'=>array('timeout' => $timeout,
|
||||||
|
'header'=> "User-Agent: ".$useragent, /*spoot Mozilla Firefox*/
|
||||||
|
'follow_location' => true),
|
||||||
|
// FOR SSL do not verified certificate
|
||||||
|
'ssl' => array('verify_peer' => false,
|
||||||
|
'allow_self_signed' => true)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// only download page lesser than 4MB
|
// only download page lesser than 4MB
|
||||||
$data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source.
|
$data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source.
|
||||||
@ -108,14 +125,26 @@ function prepare_url($url)
|
|||||||
$i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i);
|
$i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i);
|
||||||
|
|
||||||
$title = $url;
|
$title = $url;
|
||||||
if (!preg_match('!^https?://!i', $url))
|
|
||||||
$url = 'http://' . $url;
|
|
||||||
|
|
||||||
$html = Encoding::toUTF8(get_external_file($url,15));
|
$html = Encoding::toUTF8(get_external_file($url,15));
|
||||||
|
// If get_external_file if not able to retrieve HTTPS content try the same URL with HTTP protocol
|
||||||
|
if (!preg_match('!^https?://!i', $url) && (!isset($html) || strlen($html) <= 0)) {
|
||||||
|
$url = 'http://' . $url;
|
||||||
|
$html = Encoding::toUTF8(get_external_file($url,15));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function_exists('tidy_parse_string')) {
|
||||||
|
$tidy = tidy_parse_string($html, array(), 'UTF8');
|
||||||
|
$tidy->cleanRepair();
|
||||||
|
$html = $tidy->value;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($html) and strlen($html) > 0)
|
if (isset($html) and strlen($html) > 0)
|
||||||
{
|
{
|
||||||
$r = new Readability($html, $url);
|
$r = new Readability($html, $url);
|
||||||
|
|
||||||
$r->convertLinksToFootnotes = CONVERT_LINKS_FOOTNOTES;
|
$r->convertLinksToFootnotes = CONVERT_LINKS_FOOTNOTES;
|
||||||
|
$r->revertForcedParagraphElements = REVERT_FORCED_PARAGRAPH_ELEMENTS;
|
||||||
|
|
||||||
if($r->init())
|
if($r->init())
|
||||||
{
|
{
|
||||||
$content = $r->articleContent->innerHTML;
|
$content = $r->articleContent->innerHTML;
|
||||||
@ -125,8 +154,6 @@ function prepare_url($url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg->add('e', 'error during url preparation');
|
|
||||||
logm('error during url preparation');
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +290,13 @@ function display_view($view, $id = 0, $full_head = 'yes')
|
|||||||
$tpl->assign('id', $entry['id']);
|
$tpl->assign('id', $entry['id']);
|
||||||
$tpl->assign('url', $entry['url']);
|
$tpl->assign('url', $entry['url']);
|
||||||
$tpl->assign('title', $entry['title']);
|
$tpl->assign('title', $entry['title']);
|
||||||
$tpl->assign('content', $entry['content']);
|
$content = $entry['content'];
|
||||||
|
if (function_exists('tidy_parse_string')) {
|
||||||
|
$tidy = tidy_parse_string($content, array('indent'=>true, 'show-body-only' => true), 'UTF8');
|
||||||
|
$tidy->cleanRepair();
|
||||||
|
$content = $tidy->value;
|
||||||
|
}
|
||||||
|
$tpl->assign('content', $content);
|
||||||
$tpl->assign('is_fav', $entry['is_fav']);
|
$tpl->assign('is_fav', $entry['is_fav']);
|
||||||
$tpl->assign('is_read', $entry['is_read']);
|
$tpl->assign('is_read', $entry['is_read']);
|
||||||
$tpl->assign('load_all_js', 0);
|
$tpl->assign('load_all_js', 0);
|
||||||
@ -311,35 +344,46 @@ function action_to_do($action, $url, $id = 0)
|
|||||||
|
|
||||||
if (MyTool::isUrl($url)) {
|
if (MyTool::isUrl($url)) {
|
||||||
if($parametres_url = prepare_url($url)) {
|
if($parametres_url = prepare_url($url)) {
|
||||||
$store->add($url, $parametres_url['title'], $parametres_url['content']);
|
if ($store->add($url, $parametres_url['title'], $parametres_url['content'])) {
|
||||||
$last_id = $store->getLastId();
|
$last_id = $store->getLastId();
|
||||||
if (DOWNLOAD_PICTURES) {
|
if (DOWNLOAD_PICTURES) {
|
||||||
$content = filtre_picture($parametres_url['content'], $url, $last_id);
|
$content = filtre_picture($parametres_url['content'], $url, $last_id);
|
||||||
|
}
|
||||||
|
$msg->add('s', 'the link has been added successfully');
|
||||||
}
|
}
|
||||||
$msg->add('s', 'the link has been added successfully');
|
else {
|
||||||
|
$msg->add('e', 'error during insertion : the link wasn\'t added');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$msg->add('e', 'error during url preparation : the link wasn\'t added');
|
||||||
|
logm('error during url preparation');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$msg->add('e', 'the link has been added successfully');
|
$msg->add('e', 'error during url preparation : the link is not valid');
|
||||||
logm($url . ' is not a valid url');
|
logm($url . ' is not a valid url');
|
||||||
}
|
}
|
||||||
|
|
||||||
logm('add link ' . $url);
|
logm('add link ' . $url);
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
remove_directory(ABS_PATH . $id);
|
if ($store->deleteById($id)) {
|
||||||
$store->deleteById($id);
|
remove_directory(ABS_PATH . $id);
|
||||||
$msg->add('s', 'the link has been deleted successfully');
|
$msg->add('s', 'the link has been deleted successfully');
|
||||||
logm('delete link #' . $id);
|
logm('delete link #' . $id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$msg->add('e', 'the link wasn\'t deleted');
|
||||||
|
logm('error : can\'t delete link #' . $id);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'toggle_fav' :
|
case 'toggle_fav' :
|
||||||
$store->favoriteById($id);
|
$store->favoriteById($id);
|
||||||
$msg->add('s', 'the favorite toggle has been done successfully');
|
|
||||||
logm('mark as favorite link #' . $id);
|
logm('mark as favorite link #' . $id);
|
||||||
break;
|
break;
|
||||||
case 'toggle_archive' :
|
case 'toggle_archive' :
|
||||||
$store->archiveById($id);
|
$store->archiveById($id);
|
||||||
$msg->add('s', 'the archive toggle has been done successfully');
|
|
||||||
logm('archive link #' . $id);
|
logm('archive link #' . $id);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -351,4 +395,4 @@ function logm($message)
|
|||||||
{
|
{
|
||||||
$t = strval(date('Y/m/d_H:i:s')).' - '.$_SERVER["REMOTE_ADDR"].' - '.strval($message)."\n";
|
$t = strval(date('Y/m/d_H:i:s')).' - '.$_SERVER["REMOTE_ADDR"].' - '.strval($message)."\n";
|
||||||
file_put_contents('./log.txt',$t,FILE_APPEND);
|
file_put_contents('./log.txt',$t,FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ class Sqlite extends Store {
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->handle = new PDO(self::$db_path);
|
$this->handle = new PDO(self::$db_path);
|
||||||
$this->handle->exec('CREATE TABLE IF NOT EXISTS "entries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "title" VARCHAR, "url" VARCHAR UNIQUE , "is_read" INTEGER DEFAULT 0, "is_fav" INTEGER DEFAULT 0, "content" BLOB)');
|
|
||||||
$this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +24,63 @@ class Sqlite extends Store {
|
|||||||
return $this->handle;
|
return $this->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isInstalled() {
|
||||||
|
$sql = "SELECT name FROM sqlite_sequence WHERE name=?";
|
||||||
|
$query = $this->executeQuery($sql, array('config'));
|
||||||
|
$hasConfig = $query->fetchAll();
|
||||||
|
|
||||||
|
if (count($hasConfig) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!$this->getLogin() || !$this->getPassword())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function install($login, $password) {
|
||||||
|
$this->getHandle()->exec('CREATE TABLE IF NOT EXISTS "config" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "name" VARCHAR UNIQUE, "value" BLOB)');
|
||||||
|
|
||||||
|
$this->handle->exec('CREATE TABLE IF NOT EXISTS "entries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "title" VARCHAR, "url" VARCHAR UNIQUE , "is_read" INTEGER DEFAULT 0, "is_fav" INTEGER DEFAULT 0, "content" BLOB)');
|
||||||
|
|
||||||
|
if (!$this->getLogin()) {
|
||||||
|
$sql_login = 'INSERT INTO config ( name, value ) VALUES (?, ?)';
|
||||||
|
$params_login = array('login', $login);
|
||||||
|
$query = $this->executeQuery($sql_login, $params_login);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->getPassword()) {
|
||||||
|
$sql_pass = 'INSERT INTO config ( name, value ) VALUES (?, ?)';
|
||||||
|
$params_pass = array('password', $password);
|
||||||
|
$query = $this->executeQuery($sql_pass, $params_pass);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLogin() {
|
||||||
|
$sql = "SELECT value FROM config WHERE name=?";
|
||||||
|
$query = $this->executeQuery($sql, array('login'));
|
||||||
|
$login = $query->fetchAll();
|
||||||
|
|
||||||
|
return isset($login[0]['value']) ? $login[0]['value'] : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPassword() {
|
||||||
|
$sql = "SELECT value FROM config WHERE name=?";
|
||||||
|
$query = $this->executeQuery($sql, array('password'));
|
||||||
|
$pass = $query->fetchAll();
|
||||||
|
|
||||||
|
return isset($pass[0]['value']) ? $pass[0]['value'] : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatePassword($password)
|
||||||
|
{
|
||||||
|
$sql_update = "UPDATE config SET value=? WHERE name='password'";
|
||||||
|
$params_update = array($password);
|
||||||
|
$query = $this->executeQuery($sql_update, $params_update);
|
||||||
|
}
|
||||||
|
|
||||||
private function executeQuery($sql, $params) {
|
private function executeQuery($sql, $params) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -107,6 +163,7 @@ class Sqlite extends Store {
|
|||||||
$sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
|
$sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
|
||||||
$params_action = array($url, $title, $content);
|
$params_action = array($url, $title, $content);
|
||||||
$query = $this->executeQuery($sql_action, $params_action);
|
$query = $this->executeQuery($sql_action, $params_action);
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteById($id) {
|
public function deleteById($id) {
|
||||||
@ -114,6 +171,7 @@ class Sqlite extends Store {
|
|||||||
$sql_action = "DELETE FROM entries WHERE id=?";
|
$sql_action = "DELETE FROM entries WHERE id=?";
|
||||||
$params_action = array($id);
|
$params_action = array($id);
|
||||||
$query = $this->executeQuery($sql_action, $params_action);
|
$query = $this->executeQuery($sql_action, $params_action);
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function favoriteById($id) {
|
public function favoriteById($id) {
|
||||||
|
@ -13,6 +13,14 @@ class Store {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLogin() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPassword() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function add() {
|
public function add() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
20
index.php
@ -25,9 +25,9 @@ $ref = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
|||||||
if (isset($_GET['login'])) {
|
if (isset($_GET['login'])) {
|
||||||
// Login
|
// Login
|
||||||
if (!empty($_POST['login']) && !empty($_POST['password'])) {
|
if (!empty($_POST['login']) && !empty($_POST['password'])) {
|
||||||
if (Session::login('poche', 'poche', $_POST['login'], $_POST['password'])) {
|
if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) {
|
||||||
logm('login successful');
|
logm('login successful');
|
||||||
$msg->add('s', 'welcome in your pocket!');
|
$msg->add('s', 'welcome in your poche!');
|
||||||
if (!empty($_POST['longlastingsession'])) {
|
if (!empty($_POST['longlastingsession'])) {
|
||||||
$_SESSION['longlastingsession'] = 31536000;
|
$_SESSION['longlastingsession'] = 31536000;
|
||||||
$_SESSION['expires_on'] = time() + $_SESSION['longlastingsession'];
|
$_SESSION['expires_on'] = time() + $_SESSION['longlastingsession'];
|
||||||
@ -50,6 +50,22 @@ elseif (isset($_GET['logout'])) {
|
|||||||
Session::logout();
|
Session::logout();
|
||||||
MyTool::redirect();
|
MyTool::redirect();
|
||||||
}
|
}
|
||||||
|
elseif (isset($_GET['config'])) {
|
||||||
|
if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
|
||||||
|
if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
|
||||||
|
logm('password updated');
|
||||||
|
if (!DEMO) {
|
||||||
|
$store->updatePassword(encode_string($_POST['password'] . $_SESSION['login']));
|
||||||
|
$msg->add('s', 'your password has been updated');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$msg->add('i', 'in demo mode, you can\'t update password');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$msg->add('e', 'your password can\'t be empty and you have to repeat it in the second field');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Traitement des paramètres et déclenchement des actions
|
# Traitement des paramètres et déclenchement des actions
|
||||||
$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'index';
|
$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'index';
|
||||||
|
@ -3,6 +3,25 @@
|
|||||||
<p>Thanks to the bookmarklet, you will be able to easily add a link to your poche. If you don't know how use a bookmarklet, <a href="http://support.mozilla.org/en-US/kb/bookmarklets-perform-common-web-page-tasks">have a look here</a>.</p>
|
<p>Thanks to the bookmarklet, you will be able to easily add a link to your poche. If you don't know how use a bookmarklet, <a href="http://support.mozilla.org/en-US/kb/bookmarklets-perform-common-web-page-tasks">have a look here</a>.</p>
|
||||||
<p>Drag & drop this link to your bookmarks bar and have fun with poche.</p>
|
<p>Drag & drop this link to your bookmarks bar and have fun with poche.</p>
|
||||||
<p><a style="cursor: move; border: 1px dashed grey; background: white;" title="i am a bookmarklet, use me !" href="javascript:(function(){var%20url%20=%20location.href%20||%20url;window.open('{$poche_url}?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></p>
|
<p><a style="cursor: move; border: 1px dashed grey; background: white;" title="i am a bookmarklet, use me !" href="javascript:(function(){var%20url%20=%20location.href%20||%20url;window.open('{$poche_url}?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></p>
|
||||||
|
|
||||||
|
<h2>Password</h2>
|
||||||
|
<form method="post" action="?config" name="loginform">
|
||||||
|
<fieldset class="w500p">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="password">New password</label>
|
||||||
|
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="password_repeat">Repeat your new password</label>
|
||||||
|
<input class="col" type="password" id="password_repeat" name="password_repeat" placeholder="Password" tabindex="3">
|
||||||
|
</div>
|
||||||
|
<div class="row mts txtcenter">
|
||||||
|
<button class="bouton" type="submit" tabindex="4">Update</button>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<input type="hidden" name="returnurl" value="<?php echo htmlspecialchars($referer);?>">
|
||||||
|
<input type="hidden" name="token" value="<?php echo Session::getToken(); ?>">
|
||||||
|
</form>
|
||||||
<h2>Export</h2>
|
<h2>Export</h2>
|
||||||
<p><a href="?view=export" target="_blank">Click here</a> to export your poche datas.</p>
|
<p><a href="?view=export" target="_blank">Click here</a> to export your poche datas.</p>
|
||||||
</div>
|
</div>
|
30
tpl/install.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{include="head"}
|
||||||
|
<body class="light-style">
|
||||||
|
<header>
|
||||||
|
<h1><a href="index.php"><img src="./img/logo.png" alt="logo poche" /></a>poche</h1>
|
||||||
|
</header>
|
||||||
|
<div id="main">
|
||||||
|
<form method="post" action="?install" name="loginform">
|
||||||
|
<fieldset class="w500p center">
|
||||||
|
<h2 class="mbs txtcenter">install your poche</h2>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="login">Login</label>
|
||||||
|
<input class="col" type="text" id="login" name="login" placeholder="Login" tabindex="1" autofocus />
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="password">Password</label>
|
||||||
|
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="password_repeat">Repeat your password</label>
|
||||||
|
<input class="col" type="password" id="password_repeat" name="password_repeat" placeholder="Password" tabindex="3">
|
||||||
|
</div>
|
||||||
|
<div class="row mts txtcenter">
|
||||||
|
<button class="bouton" type="submit" tabindex="4">Install</button>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<input type="hidden" name="returnurl" value="<?php echo htmlspecialchars($referer);?>">
|
||||||
|
<input type="hidden" name="token" value="<?php echo Session::getToken(); ?>">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{include="footer"}
|
@ -12,7 +12,7 @@
|
|||||||
<input class="col" type="text" id="login" name="login" placeholder="Login" tabindex="1" autofocus />
|
<input class="col" type="text" id="login" name="login" placeholder="Login" tabindex="1" autofocus />
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col w150p" for="password" >Password</label>
|
<label class="col w150p" for="password">Password</label>
|
||||||
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
|
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<h1><a href="{$url}">{$title}</a></h1>
|
<h1><a href="{$url}">{$title}</a></h1>
|
||||||
<div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="original : {$title}">view original</a></div>
|
<div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="original : {$title}">view original</a></div>
|
||||||
</header>
|
</header>
|
||||||
|
{include="messages"}
|
||||||
<article>
|
<article>
|
||||||
<div id="readityourselfcontent">
|
<div id="readityourselfcontent">
|
||||||
{$content}
|
{$content}
|
||||||
|