+ // -------- Thumbnails Update
+ if ($targetPage == Router::$PAGE_THUMBS_UPDATE) {
+ $ids = [];
+ foreach ($LINKSDB as $link) {
+ // A note or not HTTP(S)
+ if ($link['url'][0] === '?' || ! startsWith(strtolower($link['url']), 'http')) {
+ continue;
+ }
+ $ids[] = $link['id'];
+ }
+ $PAGE->assign('ids', $ids);
+ $PAGE->assign('pagetitle', t('Thumbnails update') .' - '. $conf->get('general.title', 'Shaarli'));
+ $PAGE->renderPage('thumbnails');
+ exit;
+ }
+
+ // -------- Single Thumbnail Update
+ if ($targetPage == Router::$AJAX_THUMB_UPDATE) {
+ if (! isset($_POST['id']) || ! ctype_digit($_POST['id'])) {
+ http_response_code(400);
+ exit;
+ }
+ $id = (int) $_POST['id'];
+ if (empty($LINKSDB[$id])) {
+ http_response_code(404);
+ exit;
+ }
+ $thumbnailer = new Thumbnailer($conf);
+ $link = $LINKSDB[$id];
+ $link['thumbnail'] = $thumbnailer->get($link['url']);
+ $LINKSDB[$id] = $link;
+ $LINKSDB->save($conf->get('resource.page_cache'));
+
+ echo json_encode($link);
+ exit;
+ }
+