From 311baf86befde0557faea614ca4d13bb2bd2cc66 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 7 Dec 2014 23:36:35 +0100 Subject: implemented random button --- inc/poche/Poche.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 27d6f4a6..2a8037cc 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -445,6 +445,7 @@ class Poche $tpl_vars['entries'] = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit(), $id); $tpl_vars['page_links'] = $page_links; $tpl_vars['nb_results'] = $count; + $tpl_vars['random'] = rand(1,$count); } Tools::logm('display ' . $view . ' view'); break; @@ -812,4 +813,4 @@ class Poche } -} \ No newline at end of file +} -- cgit v1.2.3 From 44b95cb81deae35f58e0058910afde2f2ffb9a60 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 13 Dec 2014 22:56:30 +0100 Subject: added reload function --- inc/poche/Poche.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 27d6f4a6..f5262a8e 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -303,6 +303,15 @@ class Poche $this->messages->add('s', _('The tag has been successfully deleted')); Tools::redirect(); break; + case 'reload_article' : + Tools::logm('reload article'); + $id = $_GET['id']; + $entry = $this->store->retrieveOneById($id, $this->user->getId()); + Tools::logm('reload url ' . $entry['url']); + $url = new Url(base64_encode($entry['url'])); + $this->action('add', $url); + break; + default: break; } @@ -812,4 +821,4 @@ class Poche } -} \ No newline at end of file +} -- cgit v1.2.3 From e51487f93265521cf04d8752b0554bb1f05dd189 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 22 Dec 2014 16:19:29 +0100 Subject: implemented ?random url --- inc/poche/Poche.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 2a8037cc..3c7a2c5a 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -303,6 +303,14 @@ class Poche $this->messages->add('s', _('The tag has been successfully deleted')); Tools::redirect(); break; + /* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */ + case 'random': + $count = $this->store->getEntriesByViewCount($view, $this->user->getId()); + $id = rand(1,$count); + Tools::logm('get a random article'); + Tools::redirect('?view=view&id=' . $id); + //$this->displayView('view', $id); + break; default: break; } @@ -445,7 +453,6 @@ class Poche $tpl_vars['entries'] = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit(), $id); $tpl_vars['page_links'] = $page_links; $tpl_vars['nb_results'] = $count; - $tpl_vars['random'] = rand(1,$count); } Tools::logm('display ' . $view . ' view'); break; -- cgit v1.2.3 From 3e1daa4c9016944b444829151334ab87cd3d3dcb Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 24 Jan 2015 15:09:18 +0100 Subject: allow to send confirmation emails when creating a new user --- inc/poche/Poche.class.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 81a18c86..adb335c9 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -74,16 +74,35 @@ class Poche /** * Creates a new user */ - public function createNewUser($username, $password, $email = "") + public function createNewUser($username, $password, $email = "", $internalRegistration = false) { if (!empty($username) && !empty($password)){ $newUsername = filter_var($username, FILTER_SANITIZE_STRING); $email = filter_var($email, FILTER_SANITIZE_STRING); if (!$this->store->userExists($newUsername)){ if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) { - Tools::logm('The new user ' . $newUsername . ' has been installed'); - $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to logout ?'), $newUsername)); - Tools::redirect(); + if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) { + // if internal registration + $body_internal = "Hi,\r\n\r\nSomeone just created an account for you on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; + // if external (public) registration + $body = "Hi, \r\n\r\nYou've just created an account on " . Tools::getPocheUrl() . . ".\r\nHave fun with it !"; + $body = $internalRegistration ? $body_internal : $body; + $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) + if (mail($email, sprintf(_('Your new wallabag account on '), Tools::getPocheUrl()), $body, 'From: {$email}')) { + Tools::logm('The user ' . $newUsername . ' has been emailed'); + $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s.'), $newUsername, $email)); + + } else { + Tools::logm('A problem has been encountered while sending an email'); + $this->messages->add('e', _('A problem has been encountered while sending an email'); + } + } else { + Tools::logm('The user has been created, but the server did not authorize sending emails'); + $this->messages->add('i', _('The server did not authorize sending an email'); + } + Tools::logm('The new user ' . $newUsername . ' has been installed'); + $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to logout ?'), $newUsername)); + Tools::redirect(); } else { Tools::logm('error during adding new user'); -- cgit v1.2.3 From 1be071f9f0fba7c93f114a886ff19199955a3f02 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 24 Jan 2015 15:43:45 +0100 Subject: fix syntax errors --- inc/poche/Poche.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index adb335c9..e89e9d30 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -85,20 +85,20 @@ class Poche // if internal registration $body_internal = "Hi,\r\n\r\nSomeone just created an account for you on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; // if external (public) registration - $body = "Hi, \r\n\r\nYou've just created an account on " . Tools::getPocheUrl() . . ".\r\nHave fun with it !"; + $body = "Hi, \r\n\r\nYou've just created an account on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; $body = $internalRegistration ? $body_internal : $body; $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) - if (mail($email, sprintf(_('Your new wallabag account on '), Tools::getPocheUrl()), $body, 'From: {$email}')) { + if (mail($email, sprintf(_('Your new wallabag account on '), Tools::getPocheUrl()), $body, 'X-Mailer: PHP/' . phpversion())) { Tools::logm('The user ' . $newUsername . ' has been emailed'); $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s.'), $newUsername, $email)); } else { Tools::logm('A problem has been encountered while sending an email'); - $this->messages->add('e', _('A problem has been encountered while sending an email'); + $this->messages->add('e', _('A problem has been encountered while sending an email')); } } else { Tools::logm('The user has been created, but the server did not authorize sending emails'); - $this->messages->add('i', _('The server did not authorize sending an email'); + $this->messages->add('i', _('The server did not authorize sending an email')); } Tools::logm('The new user ' . $newUsername . ' has been installed'); $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to logout ?'), $newUsername)); -- cgit v1.2.3 From 89637c2a1dcc114b17a8f7eef493b51315e1a6ac Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 1 Feb 2015 12:22:14 +0100 Subject: added reload icon and fixed a bug where random could redirect to deleted articles --- inc/poche/Poche.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index fb74ab9a..f9928145 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -349,8 +349,11 @@ class Poche /* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */ case 'random': - $count = $this->store->getEntriesByViewCount($view, $this->user->getId()); - $id = rand(1,$count); + $id = 0; + while ($this->store->retrieveOneById($id,$this->user->getId()) == null) { + $count = $this->store->getEntriesByViewCount($view, $this->user->getId()); + $id = rand(1,$count); + } Tools::logm('get a random article'); Tools::redirect('?view=view&id=' . $id); //$this->displayView('view', $id); -- cgit v1.2.3 From 1c91178932cd5b48d793261c6631697186853a93 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 4 Feb 2015 23:37:37 +0100 Subject: fix autoclose (#984) and bookmarklet mode --- inc/poche/Poche.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index f9928145..a601f0a8 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -195,9 +195,9 @@ class Poche } if ($autoclose == TRUE) { - Tools::redirect('?view=home'); + Tools::redirect('?view=home&closewin=true'); } else { - Tools::redirect('?view=home&closewin=true'); + Tools::redirect('?view=home'); } return $last_id; break; -- cgit v1.2.3 From fde4cf0616e68d7b94f0991c1fcb434de4567c17 Mon Sep 17 00:00:00 2001 From: Eric Priou aka erixtekila Date: Thu, 5 Feb 2015 14:19:03 +0100 Subject: Fix fetched entries when localized --- inc/poche/Poche.class.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index a601f0a8..d096de91 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -740,17 +740,23 @@ class Poche $purifier = $this->_getPurifier(); foreach($items as $item) { $url = new Url(base64_encode($item['url'])); - Tools::logm('Fetching article ' . $item['id']); - $content = Tools::getPageContent($url); - $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled')); - $body = (($content['rss']['channel']['item']['description'] != '') ? $content['rss']['channel']['item']['description'] : _('Undefined')); - - // clean content to prevent xss attack - - $title = $purifier->purify($title); - $body = $purifier->purify($body); - $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId()); - Tools::logm('Article ' . $item['id'] . ' updated.'); + if( $url->isCorrect() ) + { + Tools::logm('Fetching article ' . $item['id']); + $content = Tools::getPageContent($url); + $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled')); + $body = (($content['rss']['channel']['item']['description'] != '') ? $content['rss']['channel']['item']['description'] : _('Undefined')); + + // clean content to prevent xss attack + + $title = $purifier->purify($title); + $body = $purifier->purify($body); + $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId()); + Tools::logm('Article ' . $item['id'] . ' updated.'); + } else + { + Tools::logm('Unvalid URL (' . $item['url'] .') to fetch for article ' . $item['id']); + } } } } -- cgit v1.2.3 From 6cb5e1c9f511996d52b45b459bb26047f0dead38 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 13 Feb 2015 19:10:22 +0100 Subject: improvements to internal registration and translations --- inc/poche/Poche.class.php | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index b26826f1..8ade91b4 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -81,25 +81,40 @@ class Poche $email = filter_var($email, FILTER_SANITIZE_STRING); if (!$this->store->userExists($newUsername)){ if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) { - if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) { - // if internal registration - $body_internal = "Hi,\r\n\r\nSomeone just created an account for you on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; - // if external (public) registration - $body = "Hi, \r\n\r\nYou've just created an account on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; - $body = $internalRegistration ? $body_internal : $body; - $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) - if (mail($email, sprintf(_('Your new wallabag account on '), Tools::getPocheUrl()), $body, 'X-Mailer: PHP/' . phpversion())) { - Tools::logm('The user ' . $newUsername . ' has been emailed'); - $this->messages->add('i', sprintf(_('The new user %1$s has been sent an email at %2$s.'), $newUsername, $email)); + if ($email != "") { // if email is filled + if (SEND_CONFIRMATION_EMAIL && function_exists('mail')) { + + // if internal registration + $body_internal = _('Hi,') . "\r\n\r\n" . sprintf(_('Someone just created a wallabag account for you on %1$s.'), Tools::getPocheUrl()) . + "\r\n\r\n" . sprintf(_('Your login is %1$s.'), $newUsername) ."\r\n\r\n" . + _('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" . + _('Have fun with it !') . "\r\n\r\n" . + _('This is an automatically generated message, no one will answer if you respond to it.'); + // if external (public) registration + $body = "Hi, " . $newUsername . "\r\n\r\nYou've just created a wallabag account on " . Tools::getPocheUrl() . ".\r\nHave fun with it !"; + $body = $internalRegistration ? $body_internal : $body; + + $body = wordwrap($body, 70, "\r\n"); // cut lines with more than 70 caracters (MIME standard) + if (mail($email, sprintf(_('Your new wallabag account on %1$s'), Tools::getPocheUrl()), $body, + 'X-Mailer: PHP/' . phpversion() . "\r\n" . + 'Content-type: text/plain; charset=UTF-8' . "\r\n" . + "From: " . $newUsername . "@" . gethostname() . "\r\n")) { + Tools::logm('The user ' . $newUsername . ' has been emailed'); + $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)); + + } else { + Tools::logm('A problem has been encountered while sending an email'); + $this->messages->add('e', _('A problem has been encountered while sending an email')); + } } else { - Tools::logm('A problem has been encountered while sending an email'); - $this->messages->add('e', _('A problem has been encountered while sending an email')); + Tools::logm('The user has been created, but the server did not authorize sending emails'); + $this->messages->add('i', _('The server did not authorize sending a confirmation email')); } - } else { - Tools::logm('The user has been created, but the server did not authorize sending emails'); - $this->messages->add('i', _('The server did not authorize sending an email')); - } + } else { + Tools::logm('The user has been created, but no email was saved, so no confimation email was sent'); + $this->messages->add('i', _('The user was created, but no email was sent because email was not filled in')); + } Tools::logm('The new user ' . $newUsername . ' has been installed'); $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to logout ?'), $newUsername)); Tools::redirect(); -- cgit v1.2.3