diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/poche/Poche.class.php | 108 | ||||
-rw-r--r-- | inc/poche/config.inc.php | 1 |
2 files changed, 108 insertions, 1 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 973ae3e2..9e407d41 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -73,7 +73,7 @@ class Poche | |||
73 | /** | 73 | /** |
74 | * Call action (mark as fav, archive, delete, etc.) | 74 | * Call action (mark as fav, archive, delete, etc.) |
75 | */ | 75 | */ |
76 | public function action($action, Url $url, $id) | 76 | public function action($action, Url $url, $id = 0) |
77 | { | 77 | { |
78 | switch ($action) | 78 | switch ($action) |
79 | { | 79 | { |
@@ -118,6 +118,8 @@ class Poche | |||
118 | $this->store->archiveById($id); | 118 | $this->store->archiveById($id); |
119 | Tools::logm('archive link #' . $id); | 119 | Tools::logm('archive link #' . $id); |
120 | break; | 120 | break; |
121 | case 'import': | ||
122 | break; | ||
121 | default: | 123 | default: |
122 | break; | 124 | break; |
123 | } | 125 | } |
@@ -173,4 +175,108 @@ class Poche | |||
173 | 175 | ||
174 | return $tpl_vars; | 176 | return $tpl_vars; |
175 | } | 177 | } |
178 | |||
179 | public function updatePassword() | ||
180 | { | ||
181 | if (isset($_POST['password']) && isset($_POST['password_repeat'])) { | ||
182 | if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { | ||
183 | if (!MODE_DEMO) { | ||
184 | Tools::logm('password updated'); | ||
185 | $this->store->updatePassword(Tools::encodeString($_POST['password'] . $_SESSION['login'])); | ||
186 | Session::logout(); | ||
187 | Tools::redirect(); | ||
188 | } | ||
189 | else { | ||
190 | Tools::logm('in demo mode, you can\'t do this'); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | |||
196 | public function login($referer) | ||
197 | { | ||
198 | if (!empty($_POST['login']) && !empty($_POST['password'])) { | ||
199 | if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) { | ||
200 | Tools::logm('login successful'); | ||
201 | |||
202 | if (!empty($_POST['longlastingsession'])) { | ||
203 | $_SESSION['longlastingsession'] = 31536000; | ||
204 | $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession']; | ||
205 | session_set_cookie_params($_SESSION['longlastingsession']); | ||
206 | } else { | ||
207 | session_set_cookie_params(0); | ||
208 | } | ||
209 | session_regenerate_id(true); | ||
210 | Tools::redirect($referer); | ||
211 | } | ||
212 | Tools::logm('login failed'); | ||
213 | Tools::redirect(); | ||
214 | } else { | ||
215 | Tools::logm('login failed'); | ||
216 | Tools::redirect(); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | public function logout() | ||
221 | { | ||
222 | Tools::logm('logout'); | ||
223 | Session::logout(); | ||
224 | Tools::redirect(); | ||
225 | } | ||
226 | |||
227 | public function import($from) | ||
228 | { | ||
229 | if ($from == 'pocket') { | ||
230 | $html = new simple_html_dom(); | ||
231 | $html->load_file('./ril_export.html'); | ||
232 | |||
233 | $read = 0; | ||
234 | $errors = array(); | ||
235 | foreach($html->find('ul') as $ul) | ||
236 | { | ||
237 | foreach($ul->find('li') as $li) | ||
238 | { | ||
239 | $a = $li->find('a'); | ||
240 | $url = new Url($a[0]->href); | ||
241 | $this->action('add', $url); | ||
242 | if ($read == '1') { | ||
243 | $last_id = $this->store->lastInsertId(); | ||
244 | $sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?"; | ||
245 | $params_update = array($last_id); | ||
246 | $query_update = $this->store->prepare($sql_update); | ||
247 | $query_update->execute($params_update); | ||
248 | } | ||
249 | } | ||
250 | # Pocket génère un fichier HTML avec deux <ul> | ||
251 | # Le premier concerne les éléments non lus | ||
252 | # Le second concerne les éléments archivés | ||
253 | $read = 1; | ||
254 | } | ||
255 | logm('import from pocket completed'); | ||
256 | Tools::redirect(); | ||
257 | } | ||
258 | else if ($from == 'readability') { | ||
259 | # TODO finaliser tout ça ici | ||
260 | $str_data = file_get_contents("readability"); | ||
261 | $data = json_decode($str_data,true); | ||
262 | |||
263 | foreach ($data as $key => $value) { | ||
264 | $url = ''; | ||
265 | foreach ($value as $key2 => $value2) { | ||
266 | if ($key2 == 'article__url') { | ||
267 | $url = new Url($value2); | ||
268 | } | ||
269 | } | ||
270 | if ($url != '') | ||
271 | action_to_do('add', $url); | ||
272 | } | ||
273 | logm('import from Readability completed'); | ||
274 | Tools::redirect(); | ||
275 | } | ||
276 | } | ||
277 | |||
278 | public function export() | ||
279 | { | ||
280 | |||
281 | } | ||
176 | } \ No newline at end of file | 282 | } \ No newline at end of file |
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php index 81297e0c..98a9ee6b 100644 --- a/inc/poche/config.inc.php +++ b/inc/poche/config.inc.php | |||
@@ -32,6 +32,7 @@ require_once './inc/3rdparty/Session.class.php'; | |||
32 | require_once './inc/store/store.class.php'; | 32 | require_once './inc/store/store.class.php'; |
33 | require_once './inc/store/' . $storage_type . '.class.php'; | 33 | require_once './inc/store/' . $storage_type . '.class.php'; |
34 | require_once './vendor/autoload.php'; | 34 | require_once './vendor/autoload.php'; |
35 | require_once './inc/3rdparty/simple_html_dom.php'; | ||
35 | 36 | ||
36 | if (DOWNLOAD_PICTURES) { | 37 | if (DOWNLOAD_PICTURES) { |
37 | require_once './inc/poche/pochePicture.php'; | 38 | require_once './inc/poche/pochePicture.php'; |