aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche')
-rwxr-xr-xinc/poche/Database.class.php12
-rwxr-xr-xinc/poche/Poche.class.php5
-rw-r--r--inc/poche/WallabagEpub.class.php8
3 files changed, 13 insertions, 12 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index dfd7ae34..f6ba4708 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -24,15 +24,17 @@ class Database {
24 switch (STORAGE) { 24 switch (STORAGE) {
25 case 'sqlite': 25 case 'sqlite':
26 // Check if /db is writeable 26 // Check if /db is writeable
27 if ( !is_writable(STORAGE_SQLITE) || !is_writable(dirname(STORAGE_SQLITE))) { 27 if ( !is_writable(STORAGE_SQLITE) || !is_writable(dirname(STORAGE_SQLITE))) {
28 die('An error occured: "db" directory must be writeable for your web server user!'); 28 die('An error occured: "db" directory must be writeable for your web server user!');
29 } 29 }
30 $db_path = 'sqlite:' . STORAGE_SQLITE; 30 $db_path = 'sqlite:' . STORAGE_SQLITE;
31 $this->handle = new PDO($db_path); 31 $this->handle = new PDO($db_path);
32 break; 32 break;
33 case 'mysql': 33 case 'mysql':
34 $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; 34 $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4';
35 $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD); 35 $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD, array(
36 PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
37 ));
36 break; 38 break;
37 case 'postgres': 39 case 'postgres':
38 $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; 40 $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB;
@@ -117,10 +119,10 @@ class Database {
117 $query = $this->executeQuery($sql, array()); 119 $query = $this->executeQuery($sql, array());
118 } 120 }
119 121
120 public function install($login, $password) 122 public function install($login, $password, $email = '')
121 { 123 {
122 $sql = 'INSERT INTO users ( username, password, name, email) VALUES (?, ?, ?, ?)'; 124 $sql = 'INSERT INTO users ( username, password, name, email) VALUES (?, ?, ?, ?)';
123 $params = array($login, $password, $login, ' '); 125 $params = array($login, $password, $login, $email);
124 $query = $this->executeQuery($sql, $params); 126 $query = $this->executeQuery($sql, $params);
125 127
126 $sequence = ''; 128 $sequence = '';
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index c80e5d2a..8cebafa3 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -74,12 +74,13 @@ class Poche
74 /** 74 /**
75 * Creates a new user 75 * Creates a new user
76 */ 76 */
77 public function createNewUser($username, $password) 77 public function createNewUser($username, $password, $email = "")
78 { 78 {
79 if (!empty($username) && !empty($password)){ 79 if (!empty($username) && !empty($password)){
80 $newUsername = filter_var($username, FILTER_SANITIZE_STRING); 80 $newUsername = filter_var($username, FILTER_SANITIZE_STRING);
81 $email = filter_var($email, FILTER_SANITIZE_STRING);
81 if (!$this->store->userExists($newUsername)){ 82 if (!$this->store->userExists($newUsername)){
82 if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername))) { 83 if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) {
83 Tools::logm('The new user ' . $newUsername . ' has been installed'); 84 Tools::logm('The new user ' . $newUsername . ' has been installed');
84 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername)); 85 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername));
85 Tools::redirect(); 86 Tools::redirect();
diff --git a/inc/poche/WallabagEpub.class.php b/inc/poche/WallabagEpub.class.php
index b81d9bfd..9c4d3566 100644
--- a/inc/poche/WallabagEpub.class.php
+++ b/inc/poche/WallabagEpub.class.php
@@ -12,14 +12,12 @@ class WallabagEpub
12{ 12{
13 protected $wallabag; 13 protected $wallabag;
14 protected $method; 14 protected $method;
15 protected $id;
16 protected $value; 15 protected $value;
17 16
18 public function __construct(Poche $wallabag, $method, $id, $value) 17 public function __construct(Poche $wallabag, $method, $value)
19 { 18 {
20 $this->wallabag = $wallabag; 19 $this->wallabag = $wallabag;
21 $this->method = $method; 20 $this->method = $method;
22 $this->id = $id;
23 $this->value = $value; 21 $this->value = $value;
24 } 22 }
25 23
@@ -30,7 +28,7 @@ class WallabagEpub
30 { 28 {
31 switch ($this->method) { 29 switch ($this->method) {
32 case 'id': 30 case 'id':
33 $entryID = filter_var($this->id, FILTER_SANITIZE_NUMBER_INT); 31 $entryID = filter_var($this->value, FILTER_SANITIZE_NUMBER_INT);
34 $entry = $this->wallabag->store->retrieveOneById($entryID, $this->wallabag->user->getId()); 32 $entry = $this->wallabag->store->retrieveOneById($entryID, $this->wallabag->user->getId());
35 $entries = array($entry); 33 $entries = array($entry);
36 $bookTitle = $entry['title']; 34 $bookTitle = $entry['title'];
@@ -87,7 +85,7 @@ class WallabagEpub
87 $log->logLine("getCurrentServerURL: " . $book->getCurrentServerURL()); 85 $log->logLine("getCurrentServerURL: " . $book->getCurrentServerURL());
88 $log->logLine("getCurrentPageURL..: " . $book->getCurrentPageURL()); 86 $log->logLine("getCurrentPageURL..: " . $book->getCurrentPageURL());
89 87
90 $book->setTitle(_('wallabag\'s articles')); 88 $book->setTitle($bookTitle);
91 $book->setIdentifier("http://$_SERVER[HTTP_HOST]", EPub::IDENTIFIER_URI); // Could also be the ISBN number, prefered for published books, or a UUID. 89 $book->setIdentifier("http://$_SERVER[HTTP_HOST]", EPub::IDENTIFIER_URI); // Could also be the ISBN number, prefered for published books, or a UUID.
92 //$book->setLanguage("en"); // Not needed, but included for the example, Language is mandatory, but EPub defaults to "en". Use RFC3066 Language codes, such as "en", "da", "fr" etc. 90 //$book->setLanguage("en"); // Not needed, but included for the example, Language is mandatory, but EPub defaults to "en". Use RFC3066 Language codes, such as "en", "da", "fr" etc.
93 $book->setDescription(_("Some articles saved on my wallabag")); 91 $book->setDescription(_("Some articles saved on my wallabag"));