diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 146 |
1 files changed, 43 insertions, 103 deletions
@@ -412,13 +412,13 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
412 | 412 | ||
413 | // -------- Tag cloud | 413 | // -------- Tag cloud |
414 | if ($targetPage == Router::$PAGE_TAGCLOUD) { | 414 | if ($targetPage == Router::$PAGE_TAGCLOUD) { |
415 | header('Location: ./tag-cloud'); | 415 | header('Location: ./tags/cloud'); |
416 | exit; | 416 | exit; |
417 | } | 417 | } |
418 | 418 | ||
419 | // -------- Tag list | 419 | // -------- Tag list |
420 | if ($targetPage == Router::$PAGE_TAGLIST) { | 420 | if ($targetPage == Router::$PAGE_TAGLIST) { |
421 | header('Location: ./tag-list'); | 421 | header('Location: ./tags/list'); |
422 | exit; | 422 | exit; |
423 | } | 423 | } |
424 | 424 | ||
@@ -433,7 +433,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
433 | if ($targetPage == Router::$PAGE_FEED_ATOM || $targetPage == Router::$PAGE_FEED_RSS) { | 433 | if ($targetPage == Router::$PAGE_FEED_ATOM || $targetPage == Router::$PAGE_FEED_RSS) { |
434 | $feedType = $targetPage == Router::$PAGE_FEED_RSS ? FeedBuilder::$FEED_RSS : FeedBuilder::$FEED_ATOM; | 434 | $feedType = $targetPage == Router::$PAGE_FEED_RSS ? FeedBuilder::$FEED_RSS : FeedBuilder::$FEED_ATOM; |
435 | 435 | ||
436 | header('Location: ./feed-'. $feedType .'?'. http_build_query($_GET)); | 436 | header('Location: ./feed/'. $feedType .'?'. http_build_query($_GET)); |
437 | exit; | 437 | exit; |
438 | } | 438 | } |
439 | 439 | ||
@@ -501,31 +501,31 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
501 | 501 | ||
502 | // -------- Display the Tools menu if requested (import/export/bookmarklet...) | 502 | // -------- Display the Tools menu if requested (import/export/bookmarklet...) |
503 | if ($targetPage == Router::$PAGE_TOOLS) { | 503 | if ($targetPage == Router::$PAGE_TOOLS) { |
504 | header('Location: ./tools'); | 504 | header('Location: ./admin/tools'); |
505 | exit; | 505 | exit; |
506 | } | 506 | } |
507 | 507 | ||
508 | // -------- User wants to change his/her password. | 508 | // -------- User wants to change his/her password. |
509 | if ($targetPage == Router::$PAGE_CHANGEPASSWORD) { | 509 | if ($targetPage == Router::$PAGE_CHANGEPASSWORD) { |
510 | header('Location: ./password'); | 510 | header('Location: ./admin/password'); |
511 | exit; | 511 | exit; |
512 | } | 512 | } |
513 | 513 | ||
514 | // -------- User wants to change configuration | 514 | // -------- User wants to change configuration |
515 | if ($targetPage == Router::$PAGE_CONFIGURE) { | 515 | if ($targetPage == Router::$PAGE_CONFIGURE) { |
516 | header('Location: ./configure'); | 516 | header('Location: ./admin/configure'); |
517 | exit; | 517 | exit; |
518 | } | 518 | } |
519 | 519 | ||
520 | // -------- User wants to rename a tag or delete it | 520 | // -------- User wants to rename a tag or delete it |
521 | if ($targetPage == Router::$PAGE_CHANGETAG) { | 521 | if ($targetPage == Router::$PAGE_CHANGETAG) { |
522 | header('Location: ./manage-tags'); | 522 | header('Location: ./admin/tags'); |
523 | exit; | 523 | exit; |
524 | } | 524 | } |
525 | 525 | ||
526 | // -------- User wants to add a link without using the bookmarklet: Show form. | 526 | // -------- User wants to add a link without using the bookmarklet: Show form. |
527 | if ($targetPage == Router::$PAGE_ADDLINK) { | 527 | if ($targetPage == Router::$PAGE_ADDLINK) { |
528 | header('Location: ./shaare'); | 528 | header('Location: ./admin/shaare'); |
529 | exit; | 529 | exit; |
530 | } | 530 | } |
531 | 531 | ||
@@ -538,56 +538,10 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
538 | 538 | ||
539 | // -------- User clicked the "Delete" button when editing a link: Delete link from database. | 539 | // -------- User clicked the "Delete" button when editing a link: Delete link from database. |
540 | if ($targetPage == Router::$PAGE_DELETELINK) { | 540 | if ($targetPage == Router::$PAGE_DELETELINK) { |
541 | if (! $sessionManager->checkToken($_GET['token'])) { | 541 | $ids = $_GET['lf_linkdate'] ?? ''; |
542 | die(t('Wrong token.')); | 542 | $token = $_GET['token'] ?? ''; |
543 | } | ||
544 | |||
545 | $ids = trim($_GET['lf_linkdate']); | ||
546 | if (strpos($ids, ' ') !== false) { | ||
547 | // multiple, space-separated ids provided | ||
548 | $ids = array_values(array_filter( | ||
549 | preg_split('/\s+/', escape($ids)), | ||
550 | function ($item) { | ||
551 | return $item !== ''; | ||
552 | } | ||
553 | )); | ||
554 | } else { | ||
555 | // only a single id provided | ||
556 | $shortUrl = $bookmarkService->get($ids)->getShortUrl(); | ||
557 | $ids = [$ids]; | ||
558 | } | ||
559 | // assert at least one id is given | ||
560 | if (!count($ids)) { | ||
561 | die('no id provided'); | ||
562 | } | ||
563 | $factory = new FormatterFactory($conf, $loginManager->isLoggedIn()); | ||
564 | $formatter = $factory->getFormatter('raw'); | ||
565 | foreach ($ids as $id) { | ||
566 | $id = (int) escape($id); | ||
567 | $bookmark = $bookmarkService->get($id); | ||
568 | $data = $formatter->format($bookmark); | ||
569 | $pluginManager->executeHooks('delete_link', $data); | ||
570 | $bookmarkService->remove($bookmark, false); | ||
571 | } | ||
572 | $bookmarkService->save(); | ||
573 | |||
574 | // If we are called from the bookmarklet, we must close the popup: | ||
575 | if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { | ||
576 | echo '<script>self.close();</script>'; | ||
577 | exit; | ||
578 | } | ||
579 | 543 | ||
580 | $location = '?'; | 544 | header('Location: ./admin/shaare/delete?id=' . $ids . '&token=' . $token); |
581 | if (isset($_SERVER['HTTP_REFERER'])) { | ||
582 | // Don't redirect to where we were previously if it was a permalink or an edit_link, because it would 404. | ||
583 | $location = generateLocation( | ||
584 | $_SERVER['HTTP_REFERER'], | ||
585 | $_SERVER['HTTP_HOST'], | ||
586 | ['delete_link', 'edit_link', ! empty($shortUrl) ? $shortUrl : null] | ||
587 | ); | ||
588 | } | ||
589 | |||
590 | header('Location: ' . $location); // After deleting the link, redirect to appropriate location | ||
591 | exit; | 545 | exit; |
592 | } | 546 | } |
593 | 547 | ||
@@ -646,13 +600,13 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
646 | // -------- User clicked the "EDIT" button on a link: Display link edit form. | 600 | // -------- User clicked the "EDIT" button on a link: Display link edit form. |
647 | if (isset($_GET['edit_link'])) { | 601 | if (isset($_GET['edit_link'])) { |
648 | $id = (int) escape($_GET['edit_link']); | 602 | $id = (int) escape($_GET['edit_link']); |
649 | header('Location: ./shaare-' . $id); | 603 | header('Location: ./admin/shaare/' . $id); |
650 | exit; | 604 | exit; |
651 | } | 605 | } |
652 | 606 | ||
653 | // -------- User want to post a new link: Display link edit form. | 607 | // -------- User want to post a new link: Display link edit form. |
654 | if (isset($_GET['post'])) { | 608 | if (isset($_GET['post'])) { |
655 | header('Location: ./shaare?' . http_build_query($_GET)); | 609 | header('Location: ./admin/shaare?' . http_build_query($_GET)); |
656 | exit; | 610 | exit; |
657 | } | 611 | } |
658 | 612 | ||
@@ -1160,7 +1114,7 @@ if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do= | |||
1160 | exit; | 1114 | exit; |
1161 | } | 1115 | } |
1162 | 1116 | ||
1163 | $containerBuilder = new ContainerBuilder($conf, $sessionManager, $loginManager, WEB_PATH); | 1117 | $containerBuilder = new ContainerBuilder($conf, $sessionManager, $loginManager); |
1164 | $container = $containerBuilder->build(); | 1118 | $container = $containerBuilder->build(); |
1165 | $app = new App($container); | 1119 | $app = new App($container); |
1166 | 1120 | ||
@@ -1183,51 +1137,37 @@ $app->group('/api/v1', function () { | |||
1183 | 1137 | ||
1184 | $app->group('', function () { | 1138 | $app->group('', function () { |
1185 | /* -- PUBLIC --*/ | 1139 | /* -- PUBLIC --*/ |
1186 | $this->get('/login', '\Shaarli\Front\Controller\Visitor\LoginController:index')->setName('login'); | 1140 | $this->get('/login', '\Shaarli\Front\Controller\Visitor\LoginController:index'); |
1187 | $this->get('/picture-wall', '\Shaarli\Front\Controller\Visitor\PictureWallController:index')->setName('picwall'); | 1141 | $this->get('/picture-wall', '\Shaarli\Front\Controller\Visitor\PictureWallController:index'); |
1188 | $this->get('/tag-cloud', '\Shaarli\Front\Controller\Visitor\TagCloudController:cloud')->setName('tagcloud'); | 1142 | $this->get('/tags/cloud', '\Shaarli\Front\Controller\Visitor\TagCloudController:cloud'); |
1189 | $this->get('/tag-list', '\Shaarli\Front\Controller\Visitor\TagCloudController:list')->setName('taglist'); | 1143 | $this->get('/tags/list', '\Shaarli\Front\Controller\Visitor\TagCloudController:list'); |
1190 | $this->get('/daily', '\Shaarli\Front\Controller\Visitor\DailyController:index')->setName('daily'); | 1144 | $this->get('/daily', '\Shaarli\Front\Controller\Visitor\DailyController:index'); |
1191 | $this->get('/daily-rss', '\Shaarli\Front\Controller\Visitor\DailyController:rss')->setName('dailyrss'); | 1145 | $this->get('/daily-rss', '\Shaarli\Front\Controller\Visitor\DailyController:rss'); |
1192 | $this->get('/feed-atom', '\Shaarli\Front\Controller\Visitor\FeedController:atom')->setName('feedatom'); | 1146 | $this->get('/feed/atom', '\Shaarli\Front\Controller\Visitor\FeedController:atom'); |
1193 | $this->get('/feed-rss', '\Shaarli\Front\Controller\Visitor\FeedController:rss')->setName('feedrss'); | 1147 | $this->get('/feed/rss', '\Shaarli\Front\Controller\Visitor\FeedController:rss'); |
1194 | $this->get('/open-search', '\Shaarli\Front\Controller\Visitor\OpenSearchController:index')->setName('opensearch'); | 1148 | $this->get('/open-search', '\Shaarli\Front\Controller\Visitor\OpenSearchController:index'); |
1195 | 1149 | ||
1196 | $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\Visitor\TagController:addTag')->setName('add-tag'); | 1150 | $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\Visitor\TagController:addTag'); |
1197 | $this->get('/remove-tag/{tag}', '\Shaarli\Front\Controller\Visitor\TagController:removeTag')->setName('remove-tag'); | 1151 | $this->get('/remove-tag/{tag}', '\Shaarli\Front\Controller\Visitor\TagController:removeTag'); |
1198 | 1152 | ||
1199 | /* -- LOGGED IN -- */ | 1153 | /* -- LOGGED IN -- */ |
1200 | $this->get('/logout', '\Shaarli\Front\Controller\Admin\LogoutController:index')->setName('logout'); | 1154 | $this->get('/logout', '\Shaarli\Front\Controller\Admin\LogoutController:index'); |
1201 | $this->get('/tools', '\Shaarli\Front\Controller\Admin\ToolsController:index')->setName('tools'); | 1155 | $this->get('/admin/tools', '\Shaarli\Front\Controller\Admin\ToolsController:index'); |
1202 | $this->get('/password', '\Shaarli\Front\Controller\Admin\PasswordController:index')->setName('password'); | 1156 | $this->get('/admin/password', '\Shaarli\Front\Controller\Admin\PasswordController:index'); |
1203 | $this->post('/password', '\Shaarli\Front\Controller\Admin\PasswordController:change')->setName('changePassword'); | 1157 | $this->post('/admin/password', '\Shaarli\Front\Controller\Admin\PasswordController:change'); |
1204 | $this->get('/configure', '\Shaarli\Front\Controller\Admin\ConfigureController:index')->setName('configure'); | 1158 | $this->get('/admin/configure', '\Shaarli\Front\Controller\Admin\ConfigureController:index'); |
1205 | $this->post('/configure', '\Shaarli\Front\Controller\Admin\ConfigureController:save')->setName('saveConfigure'); | 1159 | $this->post('/admin/configure', '\Shaarli\Front\Controller\Admin\ConfigureController:save'); |
1206 | $this->get('/manage-tags', '\Shaarli\Front\Controller\Admin\ManageTagController:index')->setName('manageTag'); | 1160 | $this->get('/admin/tags', '\Shaarli\Front\Controller\Admin\ManageTagController:index'); |
1207 | $this->post('/manage-tags', '\Shaarli\Front\Controller\Admin\ManageTagController:save')->setName('saveManageTag'); | 1161 | $this->post('/admin/tags', '\Shaarli\Front\Controller\Admin\ManageTagController:save'); |
1208 | $this->get('/add-shaare', '\Shaarli\Front\Controller\Admin\PostBookmarkController:addShaare')->setName('addShaare'); | 1162 | $this->get('/admin/add-shaare', '\Shaarli\Front\Controller\Admin\PostBookmarkController:addShaare'); |
1209 | $this | 1163 | $this->get('/admin/shaare', '\Shaarli\Front\Controller\Admin\PostBookmarkController:displayCreateForm'); |
1210 | ->get('/shaare', '\Shaarli\Front\Controller\Admin\PostBookmarkController:displayCreateForm') | 1164 | $this->get('/admin/shaare/{id:[0-9]+}', '\Shaarli\Front\Controller\Admin\PostBookmarkController:displayEditForm'); |
1211 | ->setName('newShaare'); | 1165 | $this->post('/admin/shaare', '\Shaarli\Front\Controller\Admin\PostBookmarkController:save'); |
1212 | $this | 1166 | $this->get('/admin/shaare/delete', '\Shaarli\Front\Controller\Admin\PostBookmarkController:deleteBookmark'); |
1213 | ->get('/shaare-{id}', '\Shaarli\Front\Controller\Admin\PostBookmarkController:displayEditForm') | 1167 | |
1214 | ->setName('editShaare'); | 1168 | $this->get('/links-per-page', '\Shaarli\Front\Controller\Admin\SessionFilterController:linksPerPage'); |
1215 | $this | 1169 | $this->get('/visibility/{visibility}', '\Shaarli\Front\Controller\Admin\SessionFilterController:visibility'); |
1216 | ->post('/shaare', '\Shaarli\Front\Controller\Admin\PostBookmarkController:save') | 1170 | $this->get('/untagged-only', '\Shaarli\Front\Controller\Admin\SessionFilterController:untaggedOnly'); |
1217 | ->setName('saveShaare'); | ||
1218 | $this | ||
1219 | ->get('/delete-shaare', '\Shaarli\Front\Controller\Admin\PostBookmarkController:deleteBookmark') | ||
1220 | ->setName('deleteShaare'); | ||
1221 | |||
1222 | $this | ||
1223 | ->get('/links-per-page', '\Shaarli\Front\Controller\Admin\SessionFilterController:linksPerPage') | ||
1224 | ->setName('filter-links-per-page'); | ||
1225 | $this | ||
1226 | ->get('/visibility/{visibility}', '\Shaarli\Front\Controller\Admin\SessionFilterController:visibility') | ||
1227 | ->setName('visibility'); | ||
1228 | $this | ||
1229 | ->get('/untagged-only', '\Shaarli\Front\Controller\Admin\SessionFilterController:untaggedOnly') | ||
1230 | ->setName('untagged-only'); | ||
1231 | })->add('\Shaarli\Front\ShaarliMiddleware'); | 1171 | })->add('\Shaarli\Front\ShaarliMiddleware'); |
1232 | 1172 | ||
1233 | $response = $app->run(true); | 1173 | $response = $app->run(true); |