Exemple #1
0
 private static function fuukaFormat(Post $post) : array
 {
     $fuukaData = ['doc_id' => $post->getDocId(), 'num' => $post->getNo(), 'subnum' => 0, 'thread_num' => $post->getThreadId(), 'op' => $post->getNo() == $post->getThreadId() ? 1 : 0, 'fourchan_date' => $post->getChanTime(), 'timestamp' => $post->getTime(), 'name' => $post->name, 'name_processed' => $post->getName(), 'email' => $post->email, 'email_processed' => $post->getEmail(), 'trip' => $post->trip, 'trip_processed' => $post->getTripcode(), 'poster_hash_processed' => $post->getID(), 'poster_hash' => $post->id, 'comment_sanitized' => Yotsuba::toBBCode($post->getComment()), 'comment' => Yotsuba::toBBCode($post->getComment()), 'comment_processed' => $post->getComment(), 'title' => $post->sub, 'title_processed' => $post->getSubject()];
     if ($post->hasImage()) {
         $fuukaData['media'] = ['op' => $post->getThreadId() == $post->getNo() ? 1 : 0, 'preview_w' => $post->getThumbWidth(), 'preview_h' => $post->getThumbHeight(), 'media_filename' => $post->getFullFilename(), 'media_filename_processed' => $post->getFullFilename(), 'media_w' => $post->getWidth(), 'media_h' => $post->getHeight(), 'media_size' => $post->getFilesize(), 'media_hash' => base64_encode($post->getMD5Bin()), 'media_orig' => $post->getTim() . $post->getExtension(), 'media' => $post->getTim() . $post->getExtension(), 'preview_reply' => $post->getTim() . "s.jpg", 'remote_media_link' => $post->getImgUrl(), 'media_link' => $post->getImgUrl(), 'thumb_link' => $post->getThumbUrl()];
     } else {
         $fuukaData['media'] = null;
     }
     return $fuukaData;
 }
Exemple #2
0
 private function renderSwfBoard(int $page)
 {
     $threads = $this->board->getPage($page);
     $pages = $this->renderPageNumbers($page);
     $main = div('', 'board');
     $main->append($pages);
     $main->append("<table class='flashListing' style='border:none;'>" . "<tbody>" . "<tr>" . "<td class='postblock'>No.</td><td class='postblock'>Name</td>" . "<td class='postblock'>File</td><td class='postblock'></td>" . "<td class='postblock'>Tag</td><td class='postblock'>Subject</td>" . "<td class='postblock'>Size</td><td class='postblock'>Date</td>" . "<td class='postblock'>Replies</td><td class='postblock'></td>" . "</tr>");
     $nums = array_map(function (Thread $thread) {
         return $thread->getThreadId();
     }, $threads);
     sort($nums);
     $nums = array_slice($nums, 0, 5);
     foreach ($threads as $thread) {
         $thread->loadOP();
         $op = $thread->getPost(0);
         $preview = $op->getSubject() != "" ? $op->getSubject() : ($op->hasComment() ? Yotsuba::toBBCode($op->com) : "");
         $highlight = array_search($thread->getThreadId(), $nums) ? " class='highlightPost'" : "";
         $repostSearch = "/" . $this->board->getName() . "/search/md5/" . $op->getMD5Hex();
         $tr = "<tr{$highlight}>" . "<td>{$op->getNo()}</td>" . "<td class='name-col'><span class='name'>{$op->getName()}</span>" . ($op->getTripcode() != '' ? " <span class='postertrip'>{$op->getTripcode()}</span>" : "") . "</td>" . "<td>[<a href='" . $op->getSwfUrl() . "' title='" . str_replace("'", "&#39;", $op->getFilename()) . "' data-width='{$op->getWidth()}' data-height='{$op->getHeight()}' target='_blank'>" . (mb_strlen($op->getFilename()) > 30 ? mb_substr($op->getFilename(), 0, 25) . "(...)" : $op->getFilename()) . "</a>]</td>" . "<td>[<a href='{$repostSearch}'>Reposts</a>]</td>" . "<td>[" . str_replace("O", "?", substr($thread->getTag(), 0, 1)) . "]</td>" . "<td class='subject'><span title='" . str_replace("'", "&#39;", $preview) . "'>" . (mb_strlen($preview) > 30 ? mb_substr($preview, 0, 30) . "(...)" : $preview) . "</span></td>" . "<td>" . human_filesize($op->getFilesize(), 2) . "</td>" . "<td>" . date("Y-m-d(D)H:i", $op->getTime()) . "</td>" . "<td>{$thread->getChanPosts()}</td>" . "<td>[<a href='thread/{$op->getNo()}'>View</a>]</td>" . "</tr>";
         $main->append($tr);
     }
     $main->append("</tbody></table><br>");
     $main->append($pages);
     $this->appendToBody($main);
 }
Exemple #3
0
 /**
  * Naiive attempt at making an imageboard.
  *
  * @todo: Make this not as spaghetti
  *
  * @return string
  * @throws Exception
  * @throws \NotFoundException
  */
 static function post() : string
 {
     srand((int) (microtime(true) * 1000));
     if (post('captcha') != $_SESSION['captcha']) {
         $_SESSION['captcha'] = rand(100000, 999999);
         throw new Exception("Invalid Captcha");
     }
     $_SESSION['captcha'] = rand(100000, 999999);
     $model = Model::get();
     if (post('mode') != 'regist') {
         throw new Exception("invalid mode");
     }
     $board = $model->getBoard(post('board'));
     if ($board->isArchive()) {
         throw new Exception("Board is an archive");
     }
     $name = post('name', 'Anonymous');
     if ($name == '') {
         $name = 'Anonymous';
     }
     $trip = Yotsuba::parseTripcode($name);
     if ($trip == false) {
         $trip = null;
     } else {
         $trip = '!' . $trip;
     }
     $name = strtok($name, '#');
     $com = post('com');
     if ($com == '') {
         $com = null;
     }
     $file = self::checkUploadedFile();
     if ($com == null && $file == null) {
         throw new Exception("Post must contain image");
     }
     $post = $model->addPost($board, post('resto', 0), htmlspecialchars($name), $trip, htmlspecialchars(post('email')), htmlspecialchars(post('sub')), $com, $file);
     // auto-noko
     return "/{$board->getName()}/thread/{$post->getThreadId()}";
 }
Exemple #4
0
 private static function transformHtml(Post $p) : string
 {
     return Yotsuba::parseBBCode($p);
 }