page_matches("post/list") && isset($_GET['search'])) { $trigger = $config->get_string("link_scan_trigger", "https?://"); if (preg_match("#.*{$trigger}.*#", $_GET['search'])) { $ids = $this->scan($_GET['search']); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(search_link(["id=".implode(",", $ids)])); $event->stop_processing = true; } } } private function scan(string $text): array { $ids = []; $matches = []; preg_match_all("/post\/view\/(\d+)/", $text, $matches); foreach($matches[1] as $match) { $ids[] = $match; } preg_match_all("/\b([0-9a-fA-F]{32})\b/", $text, $matches); foreach($matches[1] as $match) { $ids[] = Image::by_hash($match)->id; } return array_unique($ids); } }