aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xinc/poche/Poche.class.php27
-rwxr-xr-xinc/poche/Routing.class.php2
2 files changed, 24 insertions, 5 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index d096de91..b26826f1 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -74,16 +74,35 @@ class Poche
74 /** 74 /**
75 * Creates a new user 75 * Creates a new user
76 */ 76 */
77 public function createNewUser($username, $password, $email = "") 77 public function createNewUser($username, $password, $email = "", $internalRegistration = false)
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 $email = filter_var($email, FILTER_SANITIZE_STRING);
82 if (!$this->store->userExists($newUsername)){ 82 if (!$this->store->userExists($newUsername)){
83 if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) { 83 if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) {
84 Tools::logm('The new user ' . $newUsername . ' has been installed'); 84 if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) {
85 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername)); 85 // if internal registration
86 Tools::redirect(); 86 $body_internal = "Hi,\r\n\r\nSomeone just created an account for you on " . Tools::getPocheUrl() . ".\r\nHave fun with it !";
87 // if external (public) registration
88 $body = "Hi, \r\n\r\nYou've just created an account on " . Tools::getPocheUrl() . ".\r\nHave fun with it !";
89 $body = $internalRegistration ? $body_internal : $body;
90 $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard)
91 if (mail($email, sprintf(_('Your new wallabag account on '), Tools::getPocheUrl()), $body, 'X-Mailer: PHP/' . phpversion())) {
92 Tools::logm('The user ' . $newUsername . ' has been emailed');
93 $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s.'), $newUsername, $email));
94
95 } else {
96 Tools::logm('A problem has been encountered while sending an email');
97 $this->messages->add('e', _('A problem has been encountered while sending an email'));
98 }
99 } else {
100 Tools::logm('The user has been created, but the server did not authorize sending emails');
101 $this->messages->add('i', _('The server did not authorize sending an email'));
102 }
103 Tools::logm('The new user ' . $newUsername . ' has been installed');
104 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername));
105 Tools::redirect();
87 } 106 }
88 else { 107 else {
89 Tools::logm('error during adding new user'); 108 Tools::logm('error during adding new user');
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php
index 709831d5..82ff20d6 100755
--- a/inc/poche/Routing.class.php
+++ b/inc/poche/Routing.class.php
@@ -117,7 +117,7 @@ class Routing
117 // update password 117 // update password
118 $this->wallabag->updatePassword($_POST['password'], $_POST['password_repeat']); 118 $this->wallabag->updatePassword($_POST['password'], $_POST['password_repeat']);
119 } elseif (isset($_GET['newuser'])) { 119 } elseif (isset($_GET['newuser'])) {
120 $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail']); 120 $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail'], true);
121 } elseif (isset($_GET['deluser'])) { 121 } elseif (isset($_GET['deluser'])) {
122 $this->wallabag->deleteUser($_POST['password4deletinguser']); 122 $this->wallabag->deleteUser($_POST['password4deletinguser']);
123 } elseif (isset($_GET['epub'])) { 123 } elseif (isset($_GET['epub'])) {