Example #1
0
     $errors[] = 'Invalid Board Name';
 }
 if (preg_match('/^[A-Za-z0-9-_]+$/', $_POST['keyword'])) {
     $keyword = trim($_POST['keyword']);
 } else {
     $errors[] = 'Invalid Keyword';
 }
 if (empty($errors)) {
     // initate objects
     $spider = new spider();
     $threadFinder = new threadFinder();
     // parameters
     $board = $boardname;
     $searchkeyword = $keyword;
     // get threads from specified board
     $threadFinder->threads = $spider->getThreads($board);
     $threadsFound = $threadFinder->getBySubject($searchkeyword);
     if ($threadsFound) {
         // processing
         if (count($threadsFound) == 1) {
             // just one, we got what we need!
             $threadID = $threadsFound[0];
             $threadLink = 'http://boards.4chan.org/' . $board . '/thread/' . $threadID;
         } else {
             if (count($threadsFound) > 1) {
                 // multiple threads
                 // ID => UNIX time
                 $findLatest = array();
                 foreach ($threadsFound as $tid) {
                     $td = $threadFinder->getById($tid);
                     if (isset($td->last_replies) && !empty($td->last_replies)) {