diff options
author | Arthur <arthur@hoa.ro> | 2017-01-04 16:35:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-04 16:35:29 +0100 |
commit | fc11ab2f290a3712b766d78fdbcd354625a35d0a (patch) | |
tree | b0c045269ae900ad131bb6762a56c0d13369f6cb /index.php | |
parent | 061f04fba06d2a78246de747e2bdd5625fc22400 (diff) | |
parent | f4ebd5fed20b29c4fb580983b4be7bd0a52151b9 (diff) | |
download | Shaarli-fc11ab2f290a3712b766d78fdbcd354625a35d0a.tar.gz Shaarli-fc11ab2f290a3712b766d78fdbcd354625a35d0a.tar.zst Shaarli-fc11ab2f290a3712b766d78fdbcd354625a35d0a.zip |
Merge pull request #682 from ArthurHoaro/delete-button
Bugfixes on link deletion, and use a GET form
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -1316,21 +1316,21 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | // -------- User clicked the "Delete" button when editing a link: Delete link from database. | 1318 | // -------- User clicked the "Delete" button when editing a link: Delete link from database. |
1319 | if (isset($_POST['delete_link'])) | 1319 | if ($targetPage == Router::$PAGE_DELETELINK) |
1320 | { | 1320 | { |
1321 | if (!tokenOk($_POST['token'])) die('Wrong token.'); | ||
1322 | |||
1323 | // We do not need to ask for confirmation: | 1321 | // We do not need to ask for confirmation: |
1324 | // - confirmation is handled by JavaScript | 1322 | // - confirmation is handled by JavaScript |
1325 | // - we are protected from XSRF by the token. | 1323 | // - we are protected from XSRF by the token. |
1326 | 1324 | ||
1327 | // FIXME! We keep `lf_linkdate` for consistency before a proper API. To be removed. | 1325 | if (! tokenOk($_GET['token'])) { |
1328 | $id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : intval(escape($_POST['lf_linkdate'])); | 1326 | die('Wrong token.'); |
1329 | 1327 | } | |
1330 | $pluginManager->executeHooks('delete_link', $LINKSDB[$id]); | ||
1331 | 1328 | ||
1329 | $id = intval(escape($_GET['lf_linkdate'])); | ||
1330 | $link = $LINKSDB[$id]; | ||
1331 | $pluginManager->executeHooks('delete_link', $link); | ||
1332 | unset($LINKSDB[$id]); | 1332 | unset($LINKSDB[$id]); |
1333 | $LINKSDB->save('resource.page_cache'); // save to disk | 1333 | $LINKSDB->save($conf->get('resource.page_cache')); // save to disk |
1334 | 1334 | ||
1335 | // If we are called from the bookmarklet, we must close the popup: | 1335 | // If we are called from the bookmarklet, we must close the popup: |
1336 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } | 1336 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } |