diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-05 15:54:37 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-05 15:54:37 +0200 |
commit | 55821e04c188997d258645975220828e195d0df4 (patch) | |
tree | 9a85831aa55c35c2fa69122220f7c873d73a9143 /inc/poche | |
parent | b161295d0b53a5ae194e236b0a7c662e9ac2ff9a (diff) | |
download | wallabag-55821e04c188997d258645975220828e195d0df4.tar.gz wallabag-55821e04c188997d258645975220828e195d0df4.tar.zst wallabag-55821e04c188997d258645975220828e195d0df4.zip |
share email +twitter / class messages
Diffstat (limited to 'inc/poche')
-rw-r--r-- | inc/poche/Poche.class.php | 27 | ||||
-rw-r--r-- | inc/poche/Tools.class.php | 11 | ||||
-rw-r--r-- | inc/poche/config.inc.php | 5 |
3 files changed, 37 insertions, 6 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index f9bcf85b..80bf6919 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -12,6 +12,7 @@ class Poche | |||
12 | { | 12 | { |
13 | public $store; | 13 | public $store; |
14 | public $tpl; | 14 | public $tpl; |
15 | public $messages; | ||
15 | 16 | ||
16 | function __construct($storage_type) | 17 | function __construct($storage_type) |
17 | { | 18 | { |
@@ -41,6 +42,9 @@ class Poche | |||
41 | 'cache' => CACHE, | 42 | 'cache' => CACHE, |
42 | )); | 43 | )); |
43 | $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); | 44 | $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); |
45 | # filter to display domain name of an url | ||
46 | $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); | ||
47 | $this->tpl->addFilter($filter); | ||
44 | 48 | ||
45 | Tools::initPhp(); | 49 | Tools::initPhp(); |
46 | Session::init(); | 50 | Session::init(); |
@@ -113,10 +117,12 @@ class Poche | |||
113 | case 'toggle_fav' : | 117 | case 'toggle_fav' : |
114 | $this->store->favoriteById($id); | 118 | $this->store->favoriteById($id); |
115 | Tools::logm('mark as favorite link #' . $id); | 119 | Tools::logm('mark as favorite link #' . $id); |
120 | Tools::redirect(); | ||
116 | break; | 121 | break; |
117 | case 'toggle_archive' : | 122 | case 'toggle_archive' : |
118 | $this->store->archiveById($id); | 123 | $this->store->archiveById($id); |
119 | Tools::logm('archive link #' . $id); | 124 | Tools::logm('archive link #' . $id); |
125 | Tools::redirect(); | ||
120 | break; | 126 | break; |
121 | default: | 127 | default: |
122 | break; | 128 | break; |
@@ -174,16 +180,21 @@ class Poche | |||
174 | 180 | ||
175 | public function updatePassword() | 181 | public function updatePassword() |
176 | { | 182 | { |
177 | if (isset($_POST['password']) && isset($_POST['password_repeat'])) { | 183 | if (MODE_DEMO) { |
178 | if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { | 184 | $this->messages->add('i', 'in demo mode, you can\'t update your password'); |
179 | if (!MODE_DEMO) { | 185 | Tools::logm('in demo mode, you can\'t do this'); |
186 | } | ||
187 | else { | ||
188 | if (isset($_POST['password']) && isset($_POST['password_repeat'])) { | ||
189 | if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { | ||
180 | Tools::logm('password updated'); | 190 | Tools::logm('password updated'); |
191 | $this->messages->add('s', 'your password has been updated'); | ||
181 | $this->store->updatePassword(Tools::encodeString($_POST['password'] . $_SESSION['login'])); | 192 | $this->store->updatePassword(Tools::encodeString($_POST['password'] . $_SESSION['login'])); |
182 | Session::logout(); | 193 | Session::logout(); |
183 | Tools::redirect(); | 194 | Tools::redirect(); |
184 | } | 195 | } |
185 | else { | 196 | else { |
186 | Tools::logm('in demo mode, you can\'t do this'); | 197 | $this->messages->add('e', 'the two fields have to be filled & the password must be the same in the two fields'); |
187 | } | 198 | } |
188 | } | 199 | } |
189 | } | 200 | } |
@@ -194,7 +205,7 @@ class Poche | |||
194 | if (!empty($_POST['login']) && !empty($_POST['password'])) { | 205 | if (!empty($_POST['login']) && !empty($_POST['password'])) { |
195 | if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) { | 206 | if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) { |
196 | Tools::logm('login successful'); | 207 | Tools::logm('login successful'); |
197 | 208 | $this->messages->add('s', 'login successful, welcome to your poche'); | |
198 | if (!empty($_POST['longlastingsession'])) { | 209 | if (!empty($_POST['longlastingsession'])) { |
199 | $_SESSION['longlastingsession'] = 31536000; | 210 | $_SESSION['longlastingsession'] = 31536000; |
200 | $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession']; | 211 | $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession']; |
@@ -205,9 +216,11 @@ class Poche | |||
205 | session_regenerate_id(true); | 216 | session_regenerate_id(true); |
206 | Tools::redirect($referer); | 217 | Tools::redirect($referer); |
207 | } | 218 | } |
219 | $this->messages->add('e', 'login failed, bad login or password'); | ||
208 | Tools::logm('login failed'); | 220 | Tools::logm('login failed'); |
209 | Tools::redirect(); | 221 | Tools::redirect(); |
210 | } else { | 222 | } else { |
223 | $this->messages->add('e', 'login failed, you have to fill all fields'); | ||
211 | Tools::logm('login failed'); | 224 | Tools::logm('login failed'); |
212 | Tools::redirect(); | 225 | Tools::redirect(); |
213 | } | 226 | } |
@@ -215,6 +228,7 @@ class Poche | |||
215 | 228 | ||
216 | public function logout() | 229 | public function logout() |
217 | { | 230 | { |
231 | $this->messages->add('s', 'logout successful, see you soon!'); | ||
218 | Tools::logm('logout'); | 232 | Tools::logm('logout'); |
219 | Session::logout(); | 233 | Session::logout(); |
220 | Tools::redirect(); | 234 | Tools::redirect(); |
@@ -244,6 +258,7 @@ class Poche | |||
244 | # the second <ol> is for read links | 258 | # the second <ol> is for read links |
245 | $read = 1; | 259 | $read = 1; |
246 | } | 260 | } |
261 | $this->messages->add('s', 'import from instapaper completed'); | ||
247 | Tools::logm('import from instapaper completed'); | 262 | Tools::logm('import from instapaper completed'); |
248 | Tools::redirect(); | 263 | Tools::redirect(); |
249 | } | 264 | } |
@@ -272,6 +287,7 @@ class Poche | |||
272 | # the second <ul> is for read links | 287 | # the second <ul> is for read links |
273 | $read = 1; | 288 | $read = 1; |
274 | } | 289 | } |
290 | $this->messages->add('s', 'import from pocket completed'); | ||
275 | Tools::logm('import from pocket completed'); | 291 | Tools::logm('import from pocket completed'); |
276 | Tools::redirect(); | 292 | Tools::redirect(); |
277 | } | 293 | } |
@@ -300,6 +316,7 @@ class Poche | |||
300 | if ($url->isCorrect()) | 316 | if ($url->isCorrect()) |
301 | $this->action('add', $url); | 317 | $this->action('add', $url); |
302 | } | 318 | } |
319 | $this->messages->add('s', 'import from Readability completed'); | ||
303 | Tools::logm('import from Readability completed'); | 320 | Tools::logm('import from Readability completed'); |
304 | Tools::redirect(); | 321 | Tools::redirect(); |
305 | } | 322 | } |
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 834940ff..7bc8830a 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php | |||
@@ -210,4 +210,15 @@ class Tools | |||
210 | { | 210 | { |
211 | return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default); | 211 | return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default); |
212 | } | 212 | } |
213 | |||
214 | public static function getDomain($url) | ||
215 | { | ||
216 | $pieces = parse_url($url); | ||
217 | $domain = isset($pieces['host']) ? $pieces['host'] : ''; | ||
218 | if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) { | ||
219 | return $regs['domain']; | ||
220 | } | ||
221 | |||
222 | return FALSE; | ||
223 | } | ||
213 | } \ No newline at end of file | 224 | } \ No newline at end of file |
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php index 27be1857..d49df190 100644 --- a/inc/poche/config.inc.php +++ b/inc/poche/config.inc.php | |||
@@ -15,6 +15,7 @@ define ('CONVERT_LINKS_FOOTNOTES', FALSE); | |||
15 | define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); | 15 | define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); |
16 | define ('DOWNLOAD_PICTURES', FALSE); | 16 | define ('DOWNLOAD_PICTURES', FALSE); |
17 | define ('SHARE_TWITTER', TRUE); | 17 | define ('SHARE_TWITTER', TRUE); |
18 | define ('SHARE_MAIL', TRUE); | ||
18 | define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX'); | 19 | define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX'); |
19 | define ('ABS_PATH', 'assets/'); | 20 | define ('ABS_PATH', 'assets/'); |
20 | define ('TPL', './tpl'); | 21 | define ('TPL', './tpl'); |
@@ -34,9 +35,11 @@ require_once './inc/store/store.class.php'; | |||
34 | require_once './inc/store/' . $storage_type . '.class.php'; | 35 | require_once './inc/store/' . $storage_type . '.class.php'; |
35 | require_once './vendor/autoload.php'; | 36 | require_once './vendor/autoload.php'; |
36 | require_once './inc/3rdparty/simple_html_dom.php'; | 37 | require_once './inc/3rdparty/simple_html_dom.php'; |
38 | require_once './inc/3rdparty/class.messages.php'; | ||
37 | 39 | ||
38 | if (DOWNLOAD_PICTURES) { | 40 | if (DOWNLOAD_PICTURES) { |
39 | require_once './inc/poche/pochePictures.php'; | 41 | require_once './inc/poche/pochePictures.php'; |
40 | } | 42 | } |
41 | 43 | ||
42 | $poche = new Poche($storage_type); \ No newline at end of file | 44 | $poche = new Poche($storage_type); |
45 | $poche->messages = new Messages(); \ No newline at end of file | ||