aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rwxr-xr-xinc/poche/Poche.class.php18
-rwxr-xr-xinc/poche/Routing.class.php10
-rwxr-xr-xinc/poche/Tools.class.php2
-rwxr-xr-xinc/poche/config.inc.default.php3
4 files changed, 26 insertions, 7 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 8ade91b4..6d4ce137 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -76,6 +76,7 @@ class Poche
76 */ 76 */
77 public function createNewUser($username, $password, $email = "", $internalRegistration = false) 77 public function createNewUser($username, $password, $email = "", $internalRegistration = false)
78 { 78 {
79 Tools::logm('Trying to create a new user...');
79 if (!empty($username) && !empty($password)){ 80 if (!empty($username) && !empty($password)){
80 $newUsername = filter_var($username, FILTER_SANITIZE_STRING); 81 $newUsername = filter_var($username, FILTER_SANITIZE_STRING);
81 $email = filter_var($email, FILTER_SANITIZE_STRING); 82 $email = filter_var($email, FILTER_SANITIZE_STRING);
@@ -84,7 +85,7 @@ class Poche
84 if ($email != "") { // if email is filled 85 if ($email != "") { // if email is filled
85 if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) { 86 if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) {
86 87
87 // if internal registration 88 // if internal registration from config screen
88 $body_internal = _('Hi,') . "\r\n\r\n" . sprintf(_('Someone just created a wallabag account for you on %1$s.'), Tools::getPocheUrl()) . 89 $body_internal = _('Hi,') . "\r\n\r\n" . sprintf(_('Someone just created a wallabag account for you on %1$s.'), Tools::getPocheUrl()) .
89 "\r\n\r\n" . sprintf(_('Your login is %1$s.'), $newUsername) ."\r\n\r\n" . 90 "\r\n\r\n" . sprintf(_('Your login is %1$s.'), $newUsername) ."\r\n\r\n" .
90 _('Note : The password has been chosen by the person who created your account. Get in touch with that person to know your password and change it as soon as possible') . "\r\n\r\n" . 91 _('Note : The password has been chosen by the person who created your account. Get in touch with that person to know your password and change it as soon as possible') . "\r\n\r\n" .
@@ -92,7 +93,10 @@ class Poche
92 _('This is an automatically generated message, no one will answer if you respond to it.'); 93 _('This is an automatically generated message, no one will answer if you respond to it.');
93 94
94 // if external (public) registration 95 // if external (public) registration
95 $body = "Hi, " . $newUsername . "\r\n\r\nYou've just created a wallabag account on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; 96 $body = sprintf(_('Hi, %1$s'), $newUsername) . "\r\n\r\n" .
97 sprintf(_('You\'ve just created a wallabag account on %1$s.'), Tools::getPocheUrl()) .
98 "\r\n\r\n" . _("Have fun with it !");
99
96 $body = $internalRegistration ? $body_internal : $body; 100 $body = $internalRegistration ? $body_internal : $body;
97 101
98 $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) 102 $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard)
@@ -102,6 +106,7 @@ class Poche
102 "From: " . $newUsername . "@" . gethostname() . "\r\n")) { 106 "From: " . $newUsername . "@" . gethostname() . "\r\n")) {
103 Tools::logm('The user ' . $newUsername . ' has been emailed'); 107 Tools::logm('The user ' . $newUsername . ' has been emailed');
104 $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s. You may have to check spam folder.'), $newUsername, $email)); 108 $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s. You may have to check spam folder.'), $newUsername, $email));
109 Tools::redirect('?');
105 110
106 } else { 111 } else {
107 Tools::logm('A problem has been encountered while sending an email'); 112 Tools::logm('A problem has been encountered while sending an email');
@@ -109,14 +114,16 @@ class Poche
109 } 114 }
110 } else { 115 } else {
111 Tools::logm('The user has been created, but the server did not authorize sending emails'); 116 Tools::logm('The user has been created, but the server did not authorize sending emails');
112 $this->messages->add('i', _('The server did not authorize sending a confirmation email')); 117 $this->messages->add('i', _('The server did not authorize sending a confirmation email, but the user was created.'));
113 } 118 }
114 } else { 119 } else {
115 Tools::logm('The user has been created, but no email was saved, so no confimation email was sent'); 120 Tools::logm('The user has been created, but no email was saved, so no confimation email was sent');
116 $this->messages->add('i', _('The user was created, but no email was sent because email was not filled in')); 121 $this->messages->add('i', _('The user was created, but no email was sent because email was not filled in'));
117 } 122 }
118 Tools::logm('The new user ' . $newUsername . ' has been installed'); 123 Tools::logm('The new user ' . $newUsername . ' has been installed');
119 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername)); 124 if (\Session::isLogged()) {
125 $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername));
126 }
120 Tools::redirect(); 127 Tools::redirect();
121 } 128 }
122 else { 129 else {
@@ -130,6 +137,9 @@ class Poche
130 Tools::redirect(); 137 Tools::redirect();
131 } 138 }
132 } 139 }
140 else {
141 Tools::logm('Password or username were empty');
142 }
133 } 143 }
134 144
135 /** 145 /**
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php
index 82ff20d6..177b74d5 100755
--- a/inc/poche/Routing.class.php
+++ b/inc/poche/Routing.class.php
@@ -68,6 +68,12 @@ class Routing
68 $this->wallabag->action($this->action, $this->url, $this->id, FALSE, $this->autoclose); 68 $this->wallabag->action($this->action, $this->url, $this->id, FALSE, $this->autoclose);
69 $tplFile = Tools::getTplFile($this->view); 69 $tplFile = Tools::getTplFile($this->view);
70 $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id)); 70 $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id));
71 } elseif(ALLOW_REGISTER && isset($_GET['registerform'])) {
72 Tools::logm('register');
73 $tplFile = Tools::getTplFile('register');
74 } elseif (ALLOW_REGISTER && isset($_GET['register'])){
75 $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail']);
76 Tools::redirect();
71 } elseif(isset($_SERVER['PHP_AUTH_USER'])) { 77 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
72 if($this->wallabag->store->userExists($_SERVER['PHP_AUTH_USER'])) { 78 if($this->wallabag->store->userExists($_SERVER['PHP_AUTH_USER'])) {
73 $this->wallabag->login($this->referer); 79 $this->wallabag->login($this->referer);
@@ -105,7 +111,9 @@ class Routing
105 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); 111 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
106 $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0); 112 $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0);
107 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit); 113 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit);
108 } 114 } //elseif (ALLOW_REGISTER && isset($_GET['register'])) {
115 //$this->wallabag->register
116 //}
109 117
110 //allowed ONLY to logged in user 118 //allowed ONLY to logged in user
111 if (\Session::isLogged() === true) 119 if (\Session::isLogged() === true)
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index 7ccfc069..d0b31d4f 100755
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -117,7 +117,7 @@ final class Tools
117 { 117 {
118 $views = array( 118 $views = array(
119 'install', 'import', 'export', 'config', 'tags', 119 'install', 'import', 'export', 'config', 'tags',
120 'edit-tags', 'view', 'login', 'error', 'about' 120 'edit-tags', 'view', 'login', 'error', 'about', 'register'
121 ); 121 );
122 122
123 return (in_array($view, $views) ? $view . '.twig' : 'home.twig'); 123 return (in_array($view, $views) ? $view . '.twig' : 'home.twig');
diff --git a/inc/poche/config.inc.default.php b/inc/poche/config.inc.default.php
index fbf4ae9a..6750383e 100755
--- a/inc/poche/config.inc.default.php
+++ b/inc/poche/config.inc.default.php
@@ -60,7 +60,8 @@
60@define ('PDF', FALSE); 60@define ('PDF', FALSE);
61 61
62// registration 62// registration
63@define ('SEND_CONFIRMATION_EMAIL', TRUE); 63@define ('SEND_CONFIRMATION_EMAIL', FALSE);
64@define ('ALLOW_REGISTER', TRUE);
64 65
65// display or not print link in article view 66// display or not print link in article view
66@define ('SHOW_PRINTLINK', '1'); 67@define ('SHOW_PRINTLINK', '1');