コード例 #1
0
ファイル: controller.php プロジェクト: procod3R/FoolFuuka
 /**
  * @return bool
  */
 public function radix_submit()
 {
     // adapter
     if (!$this->getPost()) {
         return $this->error(_i('You aren\'t sending the required fields for creating a new message.'));
     }
     if (!$this->checkCsrfToken()) {
         return $this->error(_i('The security token wasn\'t found. Try resubmitting.'));
     }
     if ($this->getPost('reply_delete')) {
         foreach ($this->getPost('delete') as $idx => $doc_id) {
             try {
                 $comments = Board::forge($this->getContext())->getPost()->setOptions('doc_id', $doc_id)->setRadix($this->radix)->getComments();
                 $comment = current($comments);
                 $comment = new Comment($this->getContext(), $comment);
                 $comment->delete($this->getPost('delpass'));
             } catch (\Foolz\Foolfuuka\Model\BoardException $e) {
                 return $this->error($e->getMessage(), 404);
             } catch (\Foolz\Foolfuuka\Model\CommentDeleteWrongPassException $e) {
                 return $this->error($e->getMessage(), 404);
             }
         }
         $this->builder->createLayout('redirect')->getParamManager()->setParam('url', $this->uri->create([$this->radix->shortname, 'thread', $comment->comment->thread_num]));
         $this->builder->getProps()->addTitle(_i('Redirecting'));
         return new Response($this->builder->build());
     }
     if ($this->getPost('reply_report')) {
         foreach ($this->getPost('delete') as $idx => $doc_id) {
             try {
                 $this->getContext()->getService('foolfuuka.report_collection')->add($this->radix, $doc_id, $this->getPost('KOMENTO'), Inet::ptod($this->getRequest()->getClientIp()));
             } catch (\Foolz\Foolfuuka\Model\ReportException $e) {
                 return $this->error($e->getMessage(), 404);
             }
         }
         $this->builder->createLayout('redirect')->getParamManager()->setParam('url', $this->uri->create($this->radix->shortname . '/thread/' . $this->getPost('parent')));
         $this->builder->getProps()->addTitle(_i('Redirecting'));
         return new Response($this->builder->build());
     }
     // Determine if the invalid post fields are populated by bots.
     if (isset($post['name']) && mb_strlen($post['name'], 'utf-8') > 0) {
         return $this->error();
     }
     if (isset($post['reply']) && mb_strlen($post['reply'], 'utf-8') > 0) {
         return $this->error();
     }
     if (isset($post['email']) && mb_strlen($post['email'], 'utf-8') > 0) {
         return $this->error();
     }
     $data = [];
     $post = $this->getPost();
     if (isset($post['parent'])) {
         $data['thread_num'] = $post['parent'];
     }
     if (isset($post['NAMAE'])) {
         $data['name'] = $post['NAMAE'];
         $this->response->headers->setCookie(new Cookie($this->getContext(), 'reply_name', $data['name'], 60 * 60 * 24 * 30));
     }
     if (isset($post['MERU'])) {
         $data['email'] = $post['MERU'];
         $this->response->headers->setCookie(new Cookie($this->getContext(), 'reply_email', $data['email'], 60 * 60 * 24 * 30));
     }
     if (isset($post['subject'])) {
         $data['title'] = $post['subject'];
     }
     if (isset($post['KOMENTO'])) {
         $data['comment'] = $post['KOMENTO'];
     }
     if (isset($post['delpass'])) {
         // get the password needed for the reply field if it's not set yet
         if (!$post['delpass'] || strlen($post['delpass']) < 3) {
             $post['delpass'] = Util::randomString(7);
         }
         $data['delpass'] = $post['delpass'];
     }
     if (isset($post['reply_spoiler'])) {
         $data['spoiler'] = true;
     }
     if (isset($post['reply_postas'])) {
         $data['capcode'] = $post['reply_postas'];
     }
     if (isset($post['recaptcha_challenge_field']) && isset($post['recaptcha_response_field'])) {
         $data['recaptcha_challenge'] = $post['recaptcha_challenge_field'];
         $data['recaptcha_response'] = $post['recaptcha_response_field'];
     }
     $media = null;
     if ($this->getRequest()->files->count()) {
         try {
             $media = $this->media_factory->forgeFromUpload($this->getRequest(), $this->radix);
             $media->spoiler = isset($data['spoiler']) && $data['spoiler'];
         } catch (\Foolz\Foolfuuka\Model\MediaUploadNoFileException $e) {
             $media = null;
         } catch (\Foolz\Foolfuuka\Model\MediaUploadException $e) {
             return $this->error($e->getMessage());
         }
     }
     return $this->submit($data, $media);
 }
コード例 #2
0
ファイル: Gallery.php プロジェクト: voh/FoolFuuka
    public function toString()
    {
        $board = $this->getParamManager()->getParam('board');
        $radix = $this->getBuilderParamManager()->getParam('radix');
        ?>
        <div id="thread_o_matic" class="clearfix">
        <?php 
        $separator = 0;
        foreach ($board as $k => $p_bulk) {
            $p = new Comment($this->getContext(), $p_bulk);
            if ($p_bulk->media !== null) {
                $p_media = new Media($this->getContext(), $p_bulk);
            } else {
                $p_media = null;
            }
            $separator++;
            ?>
        <article id="<?php 
            echo $p->num;
            ?>
" class="thread doc_id_<?php 
            echo $p->doc_id;
            ?>
">
            <header>
                <div class="post_data">
                    <h2 class="post_title"><?php 
            echo $p->getTitleProcessed();
            ?>
</h2>
                    <span class="post_author"><?php 
            echo $p->email && $p->email !== 'noko' ? '<a href="mailto:' . rawurlencode($p->email) . '">' . $p->getNameProcessed() . '</a>' : $p->getNameProcessed();
            ?>
</span>
                    <span class="post_trip"><?php 
            echo $p->getTripProcessed();
            ?>
</span>
                    <span class="poster_hash"><?php 
            echo $p->getPosterHashProcessed() ? 'ID:' . $p->getPosterHashProcessed() : '';
            ?>
</span>
                    <?php 
            if ($p->capcode == 'M') {
                ?>
                    <span class="post_level post_level_moderator">## <?php 
                echo _i('Mod');
                ?>
</span>
                    <?php 
            }
            ?>
                    <?php 
            if ($p->capcode == 'A') {
                ?>
                    <span class="post_level post_level_administrator">## <?php 
                echo _i('Admin');
                ?>
</span>
                    <?php 
            }
            ?>
                    <?php 
            if ($p->capcode == 'D') {
                ?>
                    <span class="post_level post_level_developer">## <?php 
                echo _i('Developer');
                ?>
</span>
                    <?php 
            }
            ?>
<br/>
                    <time datetime="<?php 
            echo gmdate(DATE_W3C, $p->timestamp);
            ?>
"><?php 
            echo gmdate('D M d H:i:s Y', $p->timestamp);
            ?>
</time>
                    <span class="post_number"><a href="<?php 
            echo $this->getUri()->create($radix->shortname . '/thread/' . $p->num) . '#' . $p->num;
            ?>
" data-function="highlight" data-post="<?php 
            echo $p->num;
            ?>
">No.</a><a href="<?php 
            echo $this->getUri()->create($radix->shortname . '/thread/' . $p->num) . '#q' . $p->num;
            ?>
" data-function="quote" data-post="<?php 
            echo $p->num;
            ?>
"><?php 
            echo $p->num;
            ?>
</a></span>
                    <?php 
            if ($p->poster_country !== null) {
                ?>
<span class="post_type"><span title="<?php 
                echo e($p->poster_country_name);
                ?>
" class="flag flag-<?php 
                echo strtolower($p->poster_country);
                ?>
"></span></span><?php 
            }
            ?>
                    <span class="post_controls"><a href="<?php 
            echo $this->getUri()->create($radix->shortname . '/thread/' . $p->num);
            ?>
" class="btnr parent"><?php 
            echo _i('View');
            ?>
</a><a href="<?php 
            echo $this->getUri()->create($radix->shortname . '/thread/' . $p->num) . '#reply';
            ?>
" class="btnr parent"><?php 
            echo _i('Reply');
            ?>
</a><?php 
            echo isset($p->count_all) && $p->count_all > 50 ? '<a href="' . $this->getUri()->create($radix->shortname . '/last50/' . $p->num) . '" class="btnr parent">' . _i('Last 50') . '</a>' : '';
            if ($radix->archive == 1) {
                ?>
<a href="http://boards.4chan.org/<?php 
                echo $radix->shortname . '/thread/' . $p->num;
                ?>
" class="btnr parent"><?php 
                echo _i('Original');
                ?>
</a><?php 
            }
            ?>
<a href="<?php 
            echo $this->getUri()->create($radix->shortname . '/report/' . $p->doc_id);
            ?>
" class="btnr parent" data-function="report" data-post="<?php 
            echo $p->doc_id;
            ?>
" data-post-id="<?php 
            echo $p->num;
            ?>
" data-board="<?php 
            echo htmlspecialchars($p->radix->shortname);
            ?>
" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true"><?php 
            echo _i('Report');
            ?>
</a><?php 
            if ($this->getAuth()->hasAccess('maccess.mod')) {
                ?>
<a href="<?php 
                echo $this->getUri()->create($radix->shortname . '/delete/' . $p->doc_id);
                ?>
" class="btnr parent" data-function="delete" data-post="<?php 
                echo $p->doc_id;
                ?>
" data-post-id="<?php 
                echo $p->num;
                ?>
" data-board="<?php 
                echo htmlspecialchars($p->radix->shortname);
                ?>
" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true"><?php 
                echo _i('Delete');
                ?>
</a><?php 
            }
            ?>
</span>
                </div>
            </header>
            <?php 
            if ($p_media !== null) {
                ?>
            <div class="thread_image_box" title="<?php 
                echo $p->getCommentProcessed() ? htmlspecialchars(strip_tags($p->getCommentProcessed())) : '';
                ?>
">
                <?php 
                if ($p_media->getMediaStatus($this->getRequest()) === 'banned') {
                    ?>
                <img src="<?php 
                    echo $this->getAssetManager()->getAssetLink('images/banned-image.png');
                    ?>
" width="150" height="150" />
                <?php 
                } elseif ($p_media->getMediaStatus($this->getRequest()) !== 'normal') {
                    ?>
                <a href="<?php 
                    echo $p_media->getMediaLink($this->getRequest()) ? $p_media->getMediaLink($this->getRequest()) : $p_media->getRemoteMediaLink($this->getRequest());
                    ?>
" target="_blank" rel="noreferrer" class="thread_image_link">
                    <img src="<?php 
                    echo $this->getAssetManager()->getAssetLink('images/missing-image.jpg');
                    ?>
" width="150" height="150" />
                </a>
                <?php 
                } else {
                    ?>
                <a href="<?php 
                    echo $this->getUri()->create($radix->shortname . '/thread/' . $p->num);
                    ?>
" rel="noreferrer" target="_blank" class="thread_image_link"<?php 
                    echo $p_media->getMediaLink($this->getRequest()) ? ' data-expand="true"' : '';
                    ?>
>
                    <?php 
                    if (!$this->getAuth()->hasAccess('maccess.mod') && !$radix->getValue('transparent_spoiler') && $p_media->spoiler) {
                        ?>
                    <div class="spoiler_box"><span class="spoiler_box_text"><?php 
                        echo _i('Spoiler');
                        ?>
<span class="spoiler_box_text_help"><?php 
                        echo _i('Click to view');
                        ?>
</span></div>
                    <?php 
                    } else {
                        ?>
                    <img src="<?php 
                        echo $p_media->getThumbLink($this->getRequest());
                        ?>
" width="<?php 
                        echo $p_media->preview_w;
                        ?>
" height="<?php 
                        echo $p_media->preview_h;
                        ?>
" data-width="<?php 
                        echo $p_media->media_w;
                        ?>
" data-height="<?php 
                        echo $p_media->media_h;
                        ?>
" data-md5="<?php 
                        echo $p_media->media_hash;
                        ?>
" class="thread_image<?php 
                        echo $p_media->spoiler ? ' is_spoiler_image' : '';
                        ?>
" />
                    <?php 
                    }
                    ?>
                </a>
                <?php 
                }
                ?>
                <?php 
                if ($p_media->getMediaStatus($this->getRequest()) !== 'banned' || $this->getAuth()->hasAccess('media.see_banned')) {
                    ?>
                <div class="post_file" style="padding-left: 2px"><?php 
                    echo \Rych\ByteSize\ByteSize::formatBinary($p_media->media_size, 0) . ', ' . $p_media->media_w . 'x' . $p_media->media_h . ', ' . $p_media->media_filename;
                    ?>
</div>
                <div class="post_file_controls">
                    <a href="<?php 
                    echo $p_media->getMediaLink($this->getRequest()) ? $p_media->getMediaLink($this->getRequest()) : $p_media->getRemoteMediaLink($this->getRequest());
                    ?>
" class="btnr" target="_blank">Full</a><a href="<?php 
                    echo $this->getUri()->create($radix->shortname . '/search/image/' . urlencode(substr($p_media->media_hash, 0, -2)));
                    ?>
" class="btnr parent"><?php 
                    echo _i('View Same');
                    ?>
</a><a target="_blank" href="http://iqdb.org/?url=<?php 
                    echo $p_media->getThumbLink($this->getRequest());
                    ?>
" class="btnr parent">iqdb</a><a target="_blank" href="http://saucenao.com/search.php?url=<?php 
                    echo $p_media->getThumbLink($this->getRequest());
                    ?>
" class="btnr parent">SauceNAO</a><a target="_blank" href="http://google.com/searchbyimage?image_url=<?php 
                    echo $p_media->getThumbLink($this->getRequest());
                    ?>
" class="btnr parent">Google</a>
                </div>
                <?php 
                }
                ?>
            </div>
            <?php 
            }
            ?>
            <div class="thread_tools_bottom">
                <?php 
            if (isset($p->comment->nreplies)) {
                ?>
                <?php 
                echo _i('Replies');
                ?>
 : <?php 
                echo $p->nreplies - 1;
                ?>
 | <?php 
                echo _i('Images');
                ?>
: <?php 
                echo $p->nimages - ($p_media !== null ? 1 : 0);
                ?>
                <?php 
            }
            ?>
                <?php 
            if ($p->deleted == 1) {
                ?>
<span class="post_type"><img src="<?php 
                echo $this->getAssetManager()->getAssetLink('images/icons/file-delete-icon.png');
                ?>
" title="<?php 
                echo htmlspecialchars(_i('This post was deleted from 4chan manually'));
                ?>
"/></span><?php 
            }
            ?>
                <?php 
            if (isset($p_media) && $p_media->spoiler == 1) {
                ?>
<span class="post_type"><img src="<?php 
                echo $this->getAssetManager()->getAssetLink('images/icons/spoiler-icon.png');
                ?>
" title="<?php 
                echo htmlspecialchars(_i('This post contains a spoiler image'));
                ?>
"/></span><?php 
            }
            ?>
            </div>
        </article>
        <?php 
            if ($separator % 4 == 0) {
                echo '<div class="clearfix"></div>';
            }
        }
        ?>
        </div>
        <article class="thread">
            <div id="backlink" class="thread_o_matic" style="position: absolute; top: 0; left: 0; z-index: 5;"></div>
        </article>
        <?php 
    }
コード例 #3
0
ファイル: Comment.php プロジェクト: voh/FoolFuuka
 /**
  * Delete the post and eventually the entire thread if it's OP
  * Also deletes the images when it's the only post with that image
  *
  * @param null $password
  * @param bool $force
  * @param bool $thread
  * @throws CommentSendingDatabaseException
  * @throws CommentDeleteWrongPassException
  * @return array|bool
  */
 protected function p_delete($password = null, $force = false, $thread = false)
 {
     if (!$this->getAuth()->hasAccess('comment.passwordless_deletion') && $force !== true) {
         if (!password_verify($password, $this->comment->getDelpass())) {
             throw new CommentDeleteWrongPassException(_i('You did not provide the correct deletion password.'));
         }
     }
     try {
         $this->dc->getConnection()->beginTransaction();
         // check that the post isn't already in deleted
         $has_deleted = $this->dc->qb()->select('COUNT(*) as found')->from($this->radix->getTable('_deleted'), 'd')->where('doc_id = :doc_id')->setParameter(':doc_id', $this->comment->doc_id)->execute()->fetch();
         if (!$has_deleted['found']) {
             // throw into _deleted table
             $this->dc->getConnection()->executeUpdate('INSERT INTO ' . $this->radix->getTable('_deleted') . ' ' . $this->dc->qb()->select('*')->from($this->radix->getTable(), 't')->where('doc_id = ' . $this->dc->getConnection()->quote($this->comment->doc_id))->getSQL());
         }
         // delete post
         $this->dc->qb()->delete($this->radix->getTable())->where('doc_id = :doc_id')->setParameter(':doc_id', $this->comment->doc_id)->execute();
         // purge reports
         $this->dc->qb()->delete($this->dc->p('reports'))->where('board_id = :board_id')->andWhere('doc_id = :doc_id')->setParameter(':board_id', $this->radix->id)->setParameter(':doc_id', $this->comment->doc_id)->execute();
         // clear cache
         $this->radix_coll->clearCache();
         // remove image file
         if (isset($this->media)) {
             $media_sql = $this->dc->qb()->select('COUNT(*)')->from($this->radix->getTable(), 't')->where('media_id = :media_id')->setParameter(':media_id', $this->media->media_id)->getSQL();
             $this->dc->qb()->update($this->radix->getTable('_images'))->set('total', '(' . $media_sql . ')')->where('media_id = :media_id')->setParameter(':media_id', $this->media->media_id)->execute();
             $has_image = $this->dc->qb()->select('total')->from($this->radix->getTable('_images'), 'ti')->where('media_id = :media_id')->setParameter(':media_id', $this->media->media_id)->execute()->fetch();
             if (!$has_image || !$has_image['total']) {
                 $media = new Media($this->getContext(), $this->bulk);
                 $media->delete();
             }
         }
         // if this is OP, delete replies too
         if ($this->comment->op) {
             // delete thread data
             $this->dc->qb()->delete($this->radix->getTable('_threads'))->where('thread_num = :thread_num')->setParameter(':thread_num', $this->comment->thread_num)->execute();
             // process each comment
             $comments = $this->dc->qb()->select('doc_id')->from($this->radix->getTable(), 'b')->where('thread_num = :thread_num')->setParameter(':thread_num', $this->comment->thread_num)->execute()->fetchAll();
             foreach ($comments as $comment) {
                 $post = Board::forge($this->getContext())->getPost()->setOptions('doc_id', $comment['doc_id'])->setRadix($this->radix)->getComments();
                 $post = current($post);
                 $post = new Comment($this->getContext(), $post);
                 $post->delete(null, true, true);
             }
         } else {
             // if this is not triggered by a thread deletion, update the thread table
             if ($thread === false && !$this->radix->archive) {
                 $time_last = '
                 (
                     COALESCE(GREATEST(
                         time_op,
                         (
                             SELECT MAX(timestamp) FROM ' . $this->radix->getTable() . ' xr
                             WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . ' AND subnum = 0
                         )
                     ), time_op)
                 )';
                 $time_bump = '
                 (
                     COALESCE(GREATEST(
                         time_op,
                         (
                             SELECT MAX(timestamp) FROM ' . $this->radix->getTable() . ' xr
                             WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . ' AND subnum = 0
                                 AND (email <> \'sage\' OR email IS NULL)
                         )
                     ), time_op)
                 )';
                 $time_ghost = '
                 (
                     SELECT MAX(timestamp) FROM ' . $this->radix->getTable() . ' xr
                     WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . ' AND subnum <> 0
                 )';
                 $time_ghost_bump = '
                 (
                     SELECT MAX(timestamp) FROM ' . $this->radix->getTable() . ' xr
                     WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . ' AND subnum <> 0
                         AND (email <> \'sage\' OR email IS NULL)
                 )';
                 // update thread information
                 $this->dc->qb()->update($this->radix->getTable('_threads'))->set('time_last', $time_last)->set('time_bump', $time_bump)->set('time_ghost', $time_ghost)->set('time_ghost_bump', $time_ghost_bump)->set('time_last_modified', ':time')->set('nreplies', 'nreplies - 1')->set('nimages', $this->media === null ? 'nimages' : 'nimages - 1')->where('thread_num = :thread_num')->setParameter(':time', $this->getRadixTime())->setParameter(':thread_num', $this->comment->thread_num)->execute();
             }
         }
         $this->dc->getConnection()->commit();
         $this->clearCache();
         if ($thread === false) {
             $this->audit->log(Audit::AUDIT_DEL_POST, ['radix' => $this->radix->id, 'doc_id' => $this->comment->doc_id, 'thread_num' => $this->comment->thread_num, 'num' => $this->comment->num, 'subnum' => $this->comment->subnum]);
         }
     } catch (\Doctrine\DBAL\DBALException $e) {
         $this->logger->error('\\Foolz\\FoolFuuka\\Model\\CommentInsert: ' . $e->getMessage());
         $this->dc->getConnection()->rollBack();
         throw new CommentSendingDatabaseException(_i('Something went wrong when deleting the post in the database. Try again.'));
     }
     return $this;
 }
コード例 #4
0
ファイル: Chan.php プロジェクト: procod3R/FoolFuuka
 public function submit($data, $media)
 {
     // some beginners' validation, while through validation will happen in the Comment model
     $validator = new Validator();
     $validator->add('thread_num', _i('Thread Number'), [new Assert\NotBlank()])->add('name', _i('Name'), [new Assert\Length(['max' => 64])])->add('email', _i('Email'), [new Assert\Length(['max' => 64])])->add('title', _i('Title'), [new Assert\Length(['max' => 64])])->add('delpass', _i('Deletion pass'), [new Assert\Length(['min' => 3, 'max' => 32])]);
     // no empty posts without images
     if ($media === null) {
         $validator->add('comment', _i('Comment'), [new Assert\NotBlank(), new Assert\Length(['min' => 3])]);
     }
     // this is for redirecting, not for the database
     $limit = false;
     if (isset($data['last_limit'])) {
         $limit = intval($data['last_limit']);
         unset($data['last_limit']);
     }
     $validator->validate($data);
     if (!$validator->getViolations()->count()) {
         try {
             $data['poster_ip'] = Inet::ptod($this->getRequest()->getClientIp());
             $bulk = new CommentBulk();
             $bulk->import($data, $this->radix);
             $comment = new CommentInsert($this->getContext(), $bulk);
             $comment->insert($media, $data);
         } catch (\Foolz\Foolfuuka\Model\CommentSendingRequestCaptchaException $e) {
             if ($this->getRequest()->isXmlHttpRequest()) {
                 return $this->response->setData(['captcha' => true]);
             } else {
                 return $this->error(_i('Your message looked like spam. Make sure you have JavaScript enabled to display the reCAPTCHA to submit the comment.'));
             }
         } catch (\Foolz\Foolfuuka\Model\CommentSendingException $e) {
             if ($this->getRequest()->isXmlHttpRequest()) {
                 return $this->response->setData(['error' => $e->getMessage()]);
             } else {
                 return $this->error($e->getMessage());
             }
         }
     } else {
         if ($this->getRequest()->isXmlHttpRequest()) {
             return $this->response->setData(['error' => $validator->getViolations()->getText()]);
         } else {
             return $this->error($validator->getViolations()->getHtml());
         }
     }
     if ($this->request->isXmlHttpRequest()) {
         $latest_doc_id = $this->getPost('latest_doc_id');
         if ($latest_doc_id && ctype_digit((string) $latest_doc_id)) {
             try {
                 $board = Board::forge($this->getContext())->getThread($comment->comment->thread_num)->setRadix($this->radix)->setOptions(['type' => 'from_doc_id', 'latest_doc_id' => $latest_doc_id]);
                 $comments = $board->getComments();
             } catch (\Foolz\Foolfuuka\Model\BoardThreadNotFoundException $e) {
                 return $this->error(_i('Thread not found.'));
             } catch (\Foolz\Foolfuuka\Model\BoardException $e) {
                 return $this->error(_i('Unknown error.'));
             }
             $comment_obj = new Comment($this->getContext());
             $comment_obj->setControllerMethod($limit ? 'last/' . $limit : 'thread');
             $media_obj = new Media($this->getContext());
             $m = null;
             foreach ($board->getCommentsUnsorted() as $bulk) {
                 $comment_obj->setBulk($bulk, $this->radix);
                 if ($bulk->media) {
                     $media_obj->setBulk($bulk, $this->radix);
                     $m = $media_obj;
                 } else {
                     $m = null;
                 }
                 if ($this->builder) {
                     $this->param_manager->setParam('controller_method', $limit ? 'last/' . $limit : 'thread');
                     $partial = $this->builder->createPartial('board_comment', 'board_comment');
                     $partial->getParamManager()->setParam('p', $comment_obj)->setParam('p_media', $m);
                     $bulk->comment->formatted = $partial->build();
                     $partial->clearBuilt();
                 }
             }
             $this->response->setData(['success' => _i('Message sent.')] + $comments);
         } else {
             if ($this->builder) {
                 $this->param_manager->setParam('controller_method', $limit ? 'last/' . $limit : 'thread');
                 $partial = $this->builder->createPartial('board_comment', 'board_comment');
                 $partial->getParamManager()->setParam('p', new Comment($this->getContext(), $comment->bulk))->setParam('p_media', new Media($this->getContext(), $comment->bulk));
                 $bulk->comment->formatted = $partial->build();
                 $partial->clearBuilt();
             }
             $this->response->setData(['success' => _i('Message sent.'), 'thread_num' => $comment->comment->thread_num, $comment->comment->thread_num => ['posts' => [$comment->bulk]]]);
         }
     } else {
         $this->builder->createLayout('redirect')->getParamManager()->setParam('url', $this->uri->create([$this->radix->shortname, !$limit ? 'thread' : 'last/' . $limit, $comment->comment->thread_num]) . '#' . $comment->comment->num);
         $this->builder->getProps()->addTitle(_i('Redirecting'));
         $this->response->setContent($this->builder->build());
     }
     return $this->response;
 }
コード例 #5
0
ファイル: Board.php プロジェクト: voh/FoolFuuka
    public function toString()
    {
        $radix = $this->getBuilderParamManager()->getParam('radix');
        $board = $this->getParamManager()->getParam('board');
        $controller_method = $this->getBuilderParamManager()->getParam('controller_method', 'thread');
        $thread_id = $this->getBuilderParamManager()->getParam('thread_id', 0);
        $form = $this->getForm();
        if ($thread_id > 0) {
            echo $form->open(['enctype' => 'multipart/form-data', 'onsubmit' => 'fuel_set_csrf_token(this);', 'action' => $radix->shortname . '/submit', 'id' => 'postform']);
            echo $form->hidden('csrf_token', $this->getSecurity()->getCsrfToken());
            echo $form->hidden('id', 'postform');
            echo isset($backend_vars['last_limit']) ? $form->hidden('reply_last_limit', $backend_vars['last_limit']) : '';
        }
        ?>

        <div class="content">
        <?php 
        foreach ($board as $key => $post) {
            if (isset($post['op'])) {
                $op_bulk = $post['op'];
                $op = new Comment($this->getContext(), $op_bulk);
                $op->setControllerMethod($controller_method);
                if ($op_bulk->media !== null) {
                    $op_media = new Media($this->getContext(), $op_bulk);
                } else {
                    $op_media = null;
                }
                ?>
            <div id="<?php 
                echo $op->num;
                ?>
">
                <?php 
                if ($op_media !== null) {
                    ?>
                    <?php 
                    if ($op_media->getMediaStatus($this->getRequest()) !== 'banned') {
                        ?>
                    <span><?php 
                        echo _i('File:') . ' ' . ByteSize::formatBinary($op_media->media_size, 0) . ', ' . $op_media->media_w . 'x' . $op_media->media_h . ', ' . $op_media->getMediaFilenameProcessed();
                        ?>
 <?php 
                        echo '<!-- ' . substr($op_media->media_hash, 0, -2) . '-->';
                        ?>
</span>
                        <?php 
                        if (!$op->radix->hide_thumbnails || $this->getAuth()->hasAccess('maccess.mod')) {
                            ?>
                            [<a href="<?php 
                            echo $this->getUri()->create($op->radix->shortname . '/search/image/' . $op_media->getSafeMediaHash());
                            ?>
"><?php 
                            echo _i('View Same');
                            ?>
</a>]
                            [<a href="http://google.com/searchbyimage?image_url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
">Google</a>]
                            [<a href="http://iqdb.org/?url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
">iqdb</a>]
                            [<a href="http://saucenao.com/search.php?url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
">SauceNAO</a>]
                        <?php 
                        }
                        ?>
                    <br />
                    <?php 
                    }
                    ?>
                    <?php 
                    if ($op_media->getMediaStatus($this->getRequest()) === 'banned') {
                        ?>
                        <img src="<?php 
                        echo $this->getAssetManager()->getAssetLink('images/banned-image.png');
                        ?>
" width="150" height="150" class="thumb"/>
                    <?php 
                    } elseif ($op_media->getMediaStatus($this->getRequest()) !== 'normal') {
                        ?>
                        <a href="<?php 
                        echo $op_media->getMediaLink($this->getRequest()) ? $op_media->getMediaLink($this->getRequest()) : $op_media->getRemoteMediaLink($this->getRequest());
                        ?>
" rel="noreferrer">
                            <img src="<?php 
                        echo $this->getAssetManager()->getAssetLink('images/missing-image.jpg');
                        ?>
" width="150" height="150" class="thumb"/>
                        </a>
                    <?php 
                    } else {
                        ?>
                        <a href="<?php 
                        echo $op_media->getMediaLink($this->getRequest()) ? $op_media->getMediaLink($this->getRequest()) : $op_media->getRemoteMediaLink($this->getRequest());
                        ?>
" rel="noreferrer">
                            <?php 
                        if (!$this->getAuth()->hasAccess('maccess.mod') && $op_media->spoiler) {
                            ?>
                            <img src="<?php 
                            echo $this->getAssetManager()->getAssetLink('images/spoiler.png');
                            ?>
" width="100" height="100" class="thumb" alt="[SPOILER]" />
                            <?php 
                        } else {
                            ?>
                            <img src="<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" width="<?php 
                            echo $op_media->preview_w;
                            ?>
" height="<?php 
                            echo $op_media->preview_h;
                            ?>
" class="thumb" alt="<?php 
                            echo $op->num;
                            ?>
" />
                            <?php 
                        }
                        ?>
                        </a>
                    <?php 
                    }
                    ?>
                <?php 
                }
                ?>

                <label>
                    <input type="checkbox" name="delete[]" value="<?php 
                echo $op->doc_id;
                ?>
" />
                    <span class="filetitle"><?php 
                echo $op->getTitleProcessed();
                ?>
</span>
                    <span class="postername<?php 
                echo $op->capcode == 'M' ? ' mod' : '';
                echo $op->capcode == 'A' ? ' admin' : '';
                echo $op->capcode == 'D' ? ' developer' : '';
                ?>
"><?php 
                echo $op->email && $op->email !== 'noko' ? '<a href="mailto:' . rawurlencode($op->email) . '">' . $op->getNameProcessed() . '</a>' : $op->getNameProcessed();
                ?>
</span>
                    <span class="postertrip<?php 
                echo $op->capcode == 'M' ? ' mod' : '';
                echo $op->capcode == 'A' ? ' admin' : '';
                echo $op->capcode == 'D' ? ' developer' : '';
                ?>
"><?php 
                echo $op->getTripProcessed();
                ?>
</span>
                    <span class="poster_hash"><?php 
                if ($op->getPosterHashProcessed()) {
                    ?>
ID:<?php 
                    echo $op->getPosterHashProcessed();
                }
                ?>
</span>
                    <?php 
                if ($op->capcode == 'M') {
                    ?>
                        <span class="postername mod">## <?php 
                    echo _i('Mod');
                    ?>
</span>
                    <?php 
                }
                ?>
                    <?php 
                if ($op->capcode == 'A') {
                    ?>
                        <span class="postername admin">## <?php 
                    echo _i('Admin');
                    ?>
</span>
                    <?php 
                }
                ?>
                    <?php 
                if ($op->capcode == 'D') {
                    ?>
                        <span class="postername admin">## <?php 
                    echo _i('Developer');
                    ?>
</span>
                    <?php 
                }
                ?>
                    <?php 
                echo gmdate('D d M H:i:s Y', $op->getOriginalTimestamp());
                ?>
                    <?php 
                if ($op->poster_country !== null) {
                    ?>
<span class="poster_country"><span title="<?php 
                    echo e($op->poster_country_name);
                    ?>
" class="flag flag-<?php 
                    echo strtolower($op->poster_country);
                    ?>
"></span></span><?php 
                }
                ?>
                </label>

                <?php 
                if ($thread_id == 0) {
                    ?>
                    <a class="js" href="<?php 
                    echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $op->num)) . '#' . $op->num;
                    ?>
">No.<?php 
                    echo $op->num;
                    ?>
</a>
                <?php 
                } else {
                    ?>
                    <a class="js" href="<?php 
                    echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $op->num)) . '#' . $op->num;
                    ?>
">No.</a><a class="js" href="javascript:replyQuote('>><?php 
                    echo $op->num;
                    ?>
\n')"><?php 
                    echo $op->num;
                    ?>
</a>
                <?php 
                }
                ?>

                <?php 
                if (isset($op_media) && $op_media->spoiler == 1) {
                    ?>
<img class="inline" src="<?php 
                    echo $this->getAssetManager()->getAssetLink('images/icons/spoiler-icon.png');
                    ?>
" alt="[SPOILER]" title="<?php 
                    echo _i('The image in this post has been marked spoiler.');
                    ?>
"><?php 
                }
                ?>
                <?php 
                if ($op->deleted == 1 && $op->timestamp_expired == 0) {
                    ?>
<img class="inline" src="<?php 
                    echo $this->getAssetManager()->getAssetLink('images/icons/file-delete-icon.png');
                    ?>
" alt="[DELETED]" title="<?php 
                    echo _i('This thread was prematurely deleted.');
                    ?>
"><?php 
                }
                ?>
                <?php 
                if ($op->deleted == 1 && $op->timestamp_expired != 0) {
                    ?>
<img class="inline" src="<?php 
                    echo $this->getAssetManager()->getAssetLink('images/icons/file-delete-icon.png');
                    ?>
" alt="[DELETED]" title="<?php 
                    echo _i('This thread was deleted on %s.', gmdate('M d, Y \\a\\t H:i:s e', $op->timestamp_expired));
                    ?>
"><?php 
                }
                ?>
                <?php 
                if ($op->sticky == 1) {
                    ?>
<img class="inline" src="<?php 
                    echo $this->getAssetManager()->getAssetLink('images/icons/sticky-icon.png');
                    ?>
" alt="[STICKY]" title="<?php 
                    echo _i('This thread has been stickied.');
                    ?>
"><?php 
                }
                ?>
                <?php 
                if ($op->locked == 1) {
                    ?>
<img class="inline" src="<?php 
                    echo $this->getAssetManager()->getAssetLink('images/icons/locked-icon.png');
                    ?>
" alt="[LOCKED]" title="<?php 
                    echo _i('This thread has been locked.');
                    ?>
"><?php 
                }
                ?>

                [<a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, 'thread', $op->num));
                ?>
"><?php 
                echo _i('Reply');
                ?>
</a>]
                <?php 
                if (isset($post['omitted']) && $post['omitted'] > 50) {
                    ?>
 [<a href="<?php 
                    echo $this->getUri()->create($op->radix->shortname . '/last/50/' . $op->num);
                    ?>
"><?php 
                    echo _i('Last 50');
                    ?>
</a>]<?php 
                }
                ?>
                <?php 
                if ($op->radix->archive) {
                    ?>
 [<a href="//boards.4chan.org/<?php 
                    echo $op->radix->shortname . '/thread/' . $op->num;
                    ?>
"><?php 
                    echo _i('Original');
                    ?>
</a>]<?php 
                }
                ?>

                <div class="quoted-by" style="display: <?php 
                echo $op->getBacklinks() ? 'block' : 'none';
                ?>
">
                    <?php 
                echo _i('Quoted By:');
                ?>
 <?php 
                echo $op->getBacklinks() ? implode(' ', $op->getBacklinks()) : '';
                ?>
                </div>

                <blockquote><p><?php 
                echo $op->getCommentProcessed();
                ?>
</p></blockquote>
                <?php 
                if (isset($post['omitted']) && $post['omitted'] > 0) {
                    ?>
                <span class="omitted">
                    <?php 
                    if (isset($post['images_omitted']) && $post['images_omitted'] > 0) {
                        ?>
                    <?php 
                        echo $post['omitted'] + $post['images_omitted'] . ' ' . _n('post', 'posts', $post['omitted'] + $post['images_omitted']);
                        ?>
                    <?php 
                        echo ' ' . _n('omitted', 'omitted', $post['omitted'] + $post['images_omitted']);
                        ?>
.
                    <?php 
                    } else {
                        ?>
                    <?php 
                        echo $post['omitted'] . ' ' . _n('post', 'posts', $post['omitted']);
                        ?>
                    <?php 
                        echo ' ' . _n('omitted', 'omitted', $post['omitted'] + $post['images_omitted']);
                        ?>
.
                    <?php 
                    }
                    ?>
                </span>
                <?php 
                }
                ?>
            </div>
            <?php 
            }
            ?>

            <?php 
            if (isset($post['posts'])) {
                $post_counter = 0;
                $image_counter = 0;
                $board_comment_view = $this->getBuilder()->createPartial('post', 'board_comment');
                // reusable Comment object not to create one every loop
                $comment = new Comment($this->getContext());
                $comment->setControllerMethod($controller_method);
                $media_obj = new Media($this->getContext());
                foreach ($post['posts'] as $p) {
                    /** @var CommentBulk $p */
                    $post_counter++;
                    if ($p->media !== null) {
                        $image_counter++;
                    }
                    $comment->setBulk($p);
                    // set the $media to null and leave the Media object in existence
                    if ($p->media !== null) {
                        $media_obj->setBulk($p);
                        $media = $media_obj;
                    } else {
                        $media = null;
                    }
                    $board_comment_view->getParamManager()->setParams(['p' => $comment, 'p_media' => $media, 'modifiers' => $this->getBuilderParamManager()->getParam('modifiers', false), 'post_counter' => $post_counter, 'image_counter' => $image_counter]);
                    // refreshes the string
                    $board_comment_view->doBuild();
                    echo $board_comment_view->build();
                    // remove extra strings from the objects
                    $board_comment_view->clearBuilt();
                    $p->comment->clean();
                    if ($p->media !== null) {
                        $p->media->clean();
                    }
                }
            }
            ?>

            <?php 
            if ($thread_id > 0) {
                ?>
            <?php 
                echo $this->getBuilder()->isPartial('tools_reply_box') ? $this->getBuilder()->getPartial('tools_reply_box')->build() : '';
                ?>
            <?php 
            }
            ?>

            <br class="newthr" />
            <hr />
        <?php 
        }
        ?>
        </div>

        <?php 
        if ($thread_id > 0) {
            echo $form->close();
        }
        ?>
    <?php 
    }
コード例 #6
0
ファイル: Chan.php プロジェクト: procod3R/FoolFuuka
 public function post_mod_actions()
 {
     if (!$this->checkCsrfToken()) {
         return $this->response->setData(['error' => _i('The security token was not found. Please try again.')]);
     }
     if (!$this->getAuth()->hasAccess('comment.mod_capcode')) {
         return $this->response->setData(['error' => _i('Access Denied.')])->setStatusCode(403);
     }
     if (!$this->check_board()) {
         return $this->response->setData(['error' => _i('No board was selected.')])->setStatusCode(422);
     }
     if ($this->getPost('action') === 'delete_report') {
         try {
             $this->report_coll->delete($this->getPost('id'));
         } catch (\Foolz\Foolfuuka\Model\ReportException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('The report was deleted.')]);
     }
     if ($this->getPost('action') === 'delete_post') {
         try {
             $comments = Board::forge($this->getContext())->getPost()->setOptions('doc_id', $this->getPost('id'))->setRadix($this->radix)->getComments();
             $comment = current($comments);
             $comment = new Comment($this->getContext(), $comment);
             $comment->delete();
         } catch (\Foolz\Foolfuuka\Model\BoardException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('This post was deleted.')]);
     }
     if ($this->getPost('action') === 'delete_image') {
         try {
             $media = $this->media_factory->getByMediaId($this->radix, $this->getPost('id'));
             $media = new Media($this->getContext(), CommentBulk::forge($this->radix, null, $media));
             $media->delete(true, true, true);
         } catch (\Foolz\Foolfuuka\Model\MediaNotFoundException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('This image was deleted.')]);
     }
     if ($this->getPost('action') === 'ban_image_local' || $this->getPost('action') === 'ban_image_global') {
         $global = false;
         if ($this->getPost('action') === 'ban_image_global') {
             $global = true;
         }
         try {
             $media = $this->media_factory->getByMediaId($this->radix, $this->getPost('id'));
             $media = new Media($this->getContext(), CommentBulk::forge($this->radix, null, $media));
             $media->ban($global);
         } catch (\Foolz\Foolfuuka\Model\MediaNotFoundException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('This image was banned.')]);
     }
     if ($this->getPost('action') === 'ban_user') {
         try {
             $this->ban_factory->add(Inet::ptod($this->getPost('ip')), $this->getPost('reason'), $this->getPost('length'), $this->getPost('board_ban') === 'global' ? array() : array($this->radix->id));
         } catch (\Foolz\Foolfuuka\Model\BanException $e) {
             return $this->response->setData(['error' => $e->getMessage()])->setStatusCode(404);
         }
         return $this->response->setData(['success' => _i('This user was banned.')]);
     }
 }
コード例 #7
0
ファイル: Board.php プロジェクト: procod3R/FoolFuuka
    public function toString()
    {
        $board = $this->getParamManager()->getParam('board');
        $controller_method = $this->getBuilderParamManager()->getParam('controller_method', 'thread');
        $thread_id = $this->getBuilderParamManager()->getParam('thread_id', 0);
        foreach ($board as $key => $post) {
            if (isset($post['op'])) {
                $op_bulk = $post['op'];
                $op = new Comment($this->getContext(), $op_bulk);
                $op->setControllerMethod($controller_method);
                if ($op_bulk->media !== null) {
                    $op_media = new Media($this->getContext(), $op_bulk);
                } else {
                    $op_media = null;
                }
                $num = $op->num . ($op->subnum ? '_' . $op->subnum : '');
                ?>
        <?php 
                if ($thread_id === 0) {
                    ?>
        <div class="thread stub stub_doc_id_<?php 
                    echo $op->doc_id;
                    ?>
">
            <button class="btn-toggle-post" data-function="showThread" data-board="<?php 
                    echo $op->radix->shortname;
                    ?>
" data-doc-id="<?php 
                    echo $op->doc_id;
                    ?>
" data-thread-num="<?php 
                    echo $op->thread_num;
                    ?>
"><i class="icon-plus"></i></button>
            <?php 
                    if ($op->email && $op->email !== 'noko') {
                        ?>
<a href="mailto:<?php 
                        echo rawurlencode($op->email);
                        ?>
"><?php 
                    }
                    ?>
<span class="post_author"><?php 
                    echo $op->getNameProcessed();
                    ?>
</span><?php 
                    echo $op->getNameProcessed() && $op->getTripProcessed() ? ' ' : '';
                    ?>
<span class="post_tripcode"><?php 
                    echo $op->getTripProcessed();
                    ?>
</span><?php 
                    if ($op->email && $op->email !== 'noko') {
                        ?>
</a><?php 
                    }
                    ?>
            (<?php 
                    echo $post['omitted'] + 5 . ' ' . _i('replies');
                    ?>
)
        </div>
        <?php 
                }
                ?>
        <article id="<?php 
                echo $num;
                ?>
" class="clearfix thread doc_id_<?php 
                echo $op->doc_id;
                ?>
 board_<?php 
                echo $op->radix->shortname;
                ?>
" data-doc-id="<?php 
                echo $op->doc_id;
                ?>
" data-thread-num="<?php 
                echo $op->thread_num;
                ?>
">
                <?php 
                if ($thread_id === 0) {
                    ?>
                <div class="stub pull-left">
                    <button class="btn-toggle-post" data-function="hideThread" data-board="<?php 
                    echo $op->radix->shortname;
                    ?>
" data-doc-id="<?php 
                    echo $op->doc_id;
                    ?>
"><i class="icon-minus"></i></button>
                </div>
                <?php 
                }
                ?>
                <?php 
                \Foolz\Plugin\Hook::forge('foolfuuka.themes.default_after_op_open')->setObject($this)->setParam('board', $op->radix)->execute();
                ?>
                <?php 
                if ($op_media !== null) {
                    ?>
                <div class="thread_image_box">
                    <?php 
                    if ($op_media->getMediaStatus($this->getRequest()) === 'banned') {
                        ?>
                    <img src="<?php 
                        echo $this->getAssetManager()->getAssetLink('images/banned-image.png');
                        ?>
" width="150" height="150" />
                    <?php 
                    } elseif ($op_media->getMediaStatus($this->getRequest()) !== 'normal') {
                        ?>
                    <a href="<?php 
                        echo $op_media->getMediaLink($this->getRequest()) ? $op_media->getMediaLink($this->getRequest()) : $op_media->getRemoteMediaLink($this->getRequest());
                        ?>
" target="_blank" rel="noreferrer" class="thread_image_link">
                        <img src="<?php 
                        echo $this->getAssetManager()->getAssetLink('images/missing-image.jpg');
                        ?>
" width="150" height="150" />
                    </a>
                    <?php 
                    } else {
                        ?>
                    <a href="<?php 
                        echo $op_media->getMediaLink($this->getRequest()) ? $op_media->getMediaLink($this->getRequest()) : $op_media->getRemoteMediaLink($this->getRequest());
                        ?>
" target="_blank" rel="noreferrer" class="thread_image_link">
                        <?php 
                        if (!$this->getAuth()->hasAccess('maccess.mod') && !$op->radix->getValue('transparent_spoiler') && $op_media->spoiler) {
                            ?>
                        <div class="spoiler_box"><span class="spoiler_box_text"><?php 
                            echo _i('Spoiler');
                            ?>
<span class="spoiler_box_text_help"><?php 
                            echo _i('Click to view');
                            ?>
</span></div>
                        <?php 
                        } else {
                            ?>
                        <img src="<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" width="<?php 
                            echo $op_media->preview_w;
                            ?>
" height="<?php 
                            echo $op_media->preview_h;
                            ?>
" class="thread_image<?php 
                            echo $op_media->spoiler ? ' is_spoiler_image' : '';
                            ?>
" data-md5="<?php 
                            echo $op_media->media_hash;
                            ?>
" />
                        <?php 
                        }
                        ?>
                    </a>
                    <?php 
                    }
                    ?>
                    <?php 
                    if ($op_media->getMediaStatus($this->getRequest()) !== 'banned') {
                        ?>
                    <div class="post_file" style="padding-left: 2px;<?php 
                        if ($op_media->preview_w > 149) {
                            echo 'max-width:' . $op_media->preview_w . 'px;';
                        }
                        ?>
">
                        <?php 
                        echo ByteSize::formatBinary($op_media->media_size, 0) . ', ' . $op_media->media_w . 'x' . $op_media->media_h . ', ';
                        ?>
<a class="post_file_filename" href="<?php 
                        echo $op_media->getMediaLink($this->getRequest()) ? $op_media->getMediaLink($this->getRequest()) : $op_media->getRemoteMediaLink($this->getRequest());
                        ?>
" target="_blank"><?php 
                        echo $op_media->getMediaFilenameProcessed();
                        ?>
</a>
                    </div>
                    <?php 
                    }
                    ?>
                    <div class="post_file_controls">
                        <?php 
                    if ($op_media->getMediaStatus($this->getRequest()) !== 'banned' || $this->getAuth()->hasAccess('media.see_banned')) {
                        ?>
                        <?php 
                        if (!$op->radix->hide_thumbnails || $this->getAuth()->hasAccess('maccess.mod')) {
                            ?>
                            <a href="<?php 
                            echo $this->getUri()->create($op->radix->shortname . '/search/image/' . $op_media->getSafeMediaHash());
                            ?>
" class="btnr parent"><?php 
                            echo _i('View Same');
                            ?>
</a><a
                                href="http://google.com/searchbyimage?image_url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" target="_blank"
                                class="btnr parent">Google</a><a
                                href="http://iqdb.org/?url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" target="_blank"
                                class="btnr parent">iqdb</a><a
                                href="http://saucenao.com/search.php?url=<?php 
                            echo $op_media->getThumbLink($this->getRequest());
                            ?>
" target="_blank"
                                class="btnr parent">SauceNAO</a><?php 
                            if (!$op->radix->archive || $op->radix->getValue('archive_full_images')) {
                                ?>
<a
                                href="<?php 
                                echo $op_media->getMediaDownloadLink($this->getRequest());
                                ?>
" download="<?php 
                                echo $op_media->getMediaFilenameProcessed();
                                ?>
"
                                class="btnr parent"><i class="icon-download-alt"></i></a><?php 
                            }
                            ?>
                            <?php 
                        }
                        ?>
                        <?php 
                    }
                    ?>
                    </div>
                </div>
                <?php 
                }
                ?>
                <header>
                    <div class="post_data">
                        <?php 
                if ($op->getTitleProcessed() !== '') {
                    ?>
<h2 class="post_title"><?php 
                    echo $op->getTitleProcessed();
                    ?>
</h2><?php 
                }
                ?>
                        <span class="post_poster_data">
                            <?php 
                if ($op->email && $op->email !== 'noko') {
                    ?>
<a href="mailto:<?php 
                    echo rawurlencode($op->email);
                    ?>
"><?php 
                }
                ?>
<span class="post_author"><?php 
                echo $op->getNameProcessed();
                ?>
</span><?php 
                echo $op->getNameProcessed() && $op->getTripProcessed() ? ' ' : '';
                ?>
<span class="post_tripcode"><?php 
                echo $op->getTripProcessed();
                ?>
</span><?php 
                if ($op->email && $op->email !== 'noko') {
                    ?>
</a><?php 
                }
                ?>

                            <?php 
                if ($op->getPosterHashProcessed()) {
                    ?>
<span class="poster_hash">ID:<?php 
                    echo $op->getPosterHashProcessed();
                    ?>
</span><?php 
                }
                ?>
                            <?php 
                if ($op->capcode !== 'N') {
                    ?>
                            <?php 
                    if ($op->capcode === 'M') {
                        ?>
<span class="post_level post_level_moderator">## <?php 
                        echo _i('Mod');
                        ?>
</span><?php 
                    }
                    ?>
                            <?php 
                    if ($op->capcode === 'A') {
                        ?>
<span class="post_level post_level_administrator">## <?php 
                        echo _i('Admin');
                        ?>
</span><?php 
                    }
                    ?>
                            <?php 
                    if ($op->capcode === 'D') {
                        ?>
<span class="post_level post_level_developer">## <?php 
                        echo _i('Developer');
                        ?>
</span><?php 
                    }
                    ?>
                            <?php 
                }
                ?>
                        </span>
                        <span class="time_wrap">
                            <time datetime="<?php 
                echo gmdate(DATE_W3C, $op->timestamp);
                ?>
" class="show_time" <?php 
                if ($op->radix->archive) {
                    ?>
 title="<?php 
                    echo _i('4chan Time') . ': ' . $op->getFourchanDate();
                    ?>
"<?php 
                }
                ?>
><?php 
                echo gmdate('D d M H:i:s Y', $op->timestamp);
                ?>
</time>
                        </span>
                        <a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $op->thread_num)) . '#' . $num;
                ?>
" data-post="<?php 
                echo $num;
                ?>
" data-function="highlight">No.</a><a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $op->thread_num)) . '#q' . $num;
                ?>
" data-post="<?php 
                echo $num;
                ?>
" data-function="quote"><?php 
                echo $num;
                ?>
</a>

                        <span class="post_type">
                            <?php 
                if ($op->poster_country !== null) {
                    ?>
<span title="<?php 
                    echo e($op->poster_country_name);
                    ?>
" class="flag flag-<?php 
                    echo strtolower($op->poster_country);
                    ?>
"></span><?php 
                }
                ?>
                            <?php 
                if (isset($op_media) && $op_media->spoiler) {
                    ?>
<i class="icon-eye-close" title="<?php 
                    echo htmlspecialchars(_i('The image in this post has been marked spoiler.'));
                    ?>
"></i><?php 
                }
                ?>
                            <?php 
                if ($op->deleted && !$op->timestamp_expired) {
                    ?>
<i class="icon-trash" title="<?php 
                    echo htmlspecialchars(_i('This thread was prematurely deleted.'));
                    ?>
"></i><?php 
                }
                ?>
                            <?php 
                if ($op->deleted && $op->timestamp_expired) {
                    ?>
<i class="icon-trash" title="<?php 
                    echo htmlspecialchars(_i('This thread was deleted on %s.', gmdate('M d, Y \\a\\t H:i:s e', $op->timestamp_expired)));
                    ?>
"></i><?php 
                }
                ?>
                            <?php 
                if ($op->sticky) {
                    ?>
<i class="icon-pushpin" title="<?php 
                    echo _i('This thread has been stickied.');
                    ?>
"></i><?php 
                }
                ?>
                            <?php 
                if ($op->locked) {
                    ?>
<i class="icon-lock" title="<?php 
                    echo _i('This thread has been locked.');
                    ?>
"></i><?php 
                }
                ?>
                        </span>

                        <span class="post_controls">
                <a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, 'thread', $num));
                ?>
" class="btnr parent"><?php 
                echo _i('View');
                ?>
</a><a href="<?php 
                echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $num)) . '#reply';
                ?>
" class="btnr parent"><?php 
                echo _i('Reply');
                ?>
</a><?php 
                echo isset($post['omitted']) && $post['omitted'] > 50 ? '<a href="' . $this->getUri()->create($op->radix->shortname . '/last/50/' . $num) . '" class="btnr parent">' . _i('Last 50') . '</a>' : '';
                echo $op->radix->archive ? '<a href="//boards.4chan.org/' . $op->radix->shortname . '/thread/' . $num . '" class="btnr parent">' . _i('Original') . '</a>' : '';
                ?>
<a href="#" class="btnr parent" data-post="<?php 
                echo $op->doc_id;
                ?>
" data-post-id="<?php 
                echo $num;
                ?>
" data-board="<?php 
                echo htmlspecialchars($op->radix->shortname);
                ?>
" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true" data-function="report"><?php 
                echo _i('Report');
                ?>
</a><?php 
                if ($this->getAuth()->hasAccess('maccess.mod') || !$op->radix->archive) {
                    ?>
<a href="#" class="btnr parent" data-post="<?php 
                    echo $op->doc_id;
                    ?>
" data-post-id="<?php 
                    echo $num;
                    ?>
" data-board="<?php 
                    echo htmlspecialchars($op->radix->shortname);
                    ?>
" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true" data-function="delete"><?php 
                    echo _i('Delete');
                    ?>
</a><?php 
                }
                ?>
            </span>

                        <div class="backlink_list"<?php 
                echo $op->getBacklinks() ? ' style="display:block"' : '';
                ?>
>
                            <?php 
                echo _i('Quoted By:');
                ?>
 <span class="post_backlink" data-post="<?php 
                echo $num;
                ?>
"><?php 
                echo $op->getBacklinks() ? implode(' ', $op->getBacklinks()) : '';
                ?>
</span>
                        </div>

                        <?php 
                if ($this->getAuth()->hasAccess('maccess.mod')) {
                    ?>
                        <div class="btn-group" style="clear:both; padding:5px 0 0 0;">
                            <button class="btn btn-mini" data-function="activateModeration"><?php 
                    echo _i('Mod');
                    if ($op->poster_ip) {
                        echo ' ' . Inet::dtop($op->poster_ip);
                    }
                    ?>
</button>
                        </div>
                        <div class="btn-group post_mod_controls" style="clear:both; padding:5px 0 0 0;">
                            <button class="btn btn-mini" data-function="mod" data-board="<?php 
                    echo $op->radix->shortname;
                    ?>
" data-id="<?php 
                    echo $op->doc_id;
                    ?>
" data-action="delete_post"><?php 
                    echo _i('Delete Thread');
                    ?>
</button>
                            <?php 
                    if (!is_null($op_media)) {
                        ?>
                            <button class="btn btn-mini" data-function="mod" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-id="<?php 
                        echo $op_media->media_id;
                        ?>
" data-doc-id="<?php 
                        echo $op->doc_id;
                        ?>
" data-action="delete_image"><?php 
                        echo _i('Delete Image');
                        ?>
</button>
                            <button class="btn btn-mini" data-function="mod" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-id="<?php 
                        echo $op_media->media_id;
                        ?>
" data-doc-id="<?php 
                        echo $op->doc_id;
                        ?>
" data-action="ban_image_local"><?php 
                        echo _i('Ban Image');
                        ?>
</button>
                            <button class="btn btn-mini" data-function="mod" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-id="<?php 
                        echo $op_media->media_id;
                        ?>
" data-doc-id="<?php 
                        echo $op->doc_id;
                        ?>
" data-action="ban_image_global"><?php 
                        echo _i('Ban Image Globally');
                        ?>
</button>
                            <?php 
                    }
                    ?>
                            <?php 
                    if ($op->poster_ip) {
                        ?>
                            <button class="btn btn-mini" data-function="ban" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-ip="<?php 
                        echo Inet::dtop($op->poster_ip);
                        ?>
" data-action="ban_user"><?php 
                        echo _i('Ban IP:') . ' ' . Inet::dtop($op->poster_ip);
                        ?>
</button>
                            <button class="btn btn-mini" data-function="searchUser" data-board="<?php 
                        echo $op->radix->shortname;
                        ?>
" data-board-url="<?php 
                        echo $this->getUri()->create(array($op->radix->shortname));
                        ?>
" data-id="<?php 
                        echo $op->doc_id;
                        ?>
" data-poster-ip="<?php 
                        echo Inet::dtop($op->poster_ip);
                        ?>
"><?php 
                        echo _i('Search IP');
                        ?>
</button>
                            <?php 
                        if ($this->getPreferences()->get('foolfuuka.sphinx.global')) {
                            ?>
                                <button class="btn btn-mini" data-function="searchUserGlobal" data-board="<?php 
                            echo $op->radix->shortname;
                            ?>
" data-board-url="<?php 
                            echo $this->getUri()->create(array($op->radix->shortname));
                            ?>
" data-id="<?php 
                            echo $op->doc_id;
                            ?>
" data-poster-ip="<?php 
                            echo Inet::dtop($op->poster_ip);
                            ?>
"><?php 
                            echo _i('Search IP Globally');
                            ?>
</button>
                                <?php 
                        }
                        ?>
                            <?php 
                    }
                    ?>
                        </div>
                        <?php 
                }
                ?>
                    </div>
                </header>

                <div class="text<?php 
                if (preg_match('/[\\x{4E00}-\\x{9FBF}\\x{3040}-\\x{309F}\\x{30A0}-\\x{30FF}]/u', $op->getCommentProcessed())) {
                    echo ' shift-jis';
                }
                ?>
">
                    <?php 
                echo $op->getCommentProcessed();
                ?>
                </div>
                <div class="thread_tools_bottom">
                    <?php 
                if (isset($post['omitted']) && $post['omitted'] > 0) {
                    ?>
        <span class="omitted">
            <a style="display:inline-block" href="<?php 
                    echo $this->getUri()->create(array($op->radix->shortname, $controller_method, $op->thread_num));
                    ?>
" data-function="expandThread" data-thread-num="<?php 
                    echo $op->thread_num;
                    ?>
"><i class="icon icon-resize-full"></i></a>
                    <span class="omitted_text">
                <span class="omitted_posts"><?php 
                    echo $post['omitted'];
                    ?>
</span> <?php 
                    echo _n('post', 'posts', $post['omitted']);
                    ?>
                        <?php 
                    if (isset($post['images_omitted']) && $post['images_omitted'] > 0) {
                        ?>
                        <?php 
                        echo _i('and');
                        ?>
 <span class="omitted_images"><?php 
                        echo $post['images_omitted'];
                        ?>
</span> <?php 
                        echo _n('image', 'images', $post['images_omitted']);
                        ?>
                        <?php 
                    }
                    ?>
                        <?php 
                    echo _n('omitted', 'omitted', $post['omitted'] + $post['images_omitted']);
                    ?>
        </span>
                    <?php 
                }
                ?>
                </div>

                <?php 
                if ($op->getReports()) {
                    ?>
                <?php 
                    foreach ($op->getReports() as $report) {
                        ?>
                    <div class="report_reason"><?php 
                        echo '<strong>' . _i('Reported Reason:') . '</strong> ' . $report->getReasonProcessed();
                        ?>
                        <br/>
                        <div class="ip_reporter">
                            <strong><?php 
                        echo _i('Info:');
                        ?>
</strong>
                            <?php 
                        echo Inet::dtop($report->ip_reporter);
                        ?>
, <?php 
                        echo _i('Type:');
                        ?>
 <?php 
                        echo $report->media_id !== null ? _i('media') : _i('post');
                        ?>
, <?php 
                        echo _i('Time:');
                        ?>
 <?php 
                        echo gmdate('D M d H:i:s Y', $report->created);
                        ?>
                            <button class="btn btn-mini" data-function="mod" data-id="<?php 
                        echo $report->id;
                        ?>
" data-board="<?php 
                        echo htmlspecialchars($op->radix->shortname);
                        ?>
" data-action="delete_report"><?php 
                        echo _i('Delete Report');
                        ?>
</button>
                        </div>
                    </div>
                    <?php 
                    }
                    ?>
                <?php 
                }
                ?>
                <?php 
            } elseif (isset($post['posts'])) {
                ?>
        <article class="clearfix thread">
                    <?php 
                \Foolz\Plugin\Hook::forge('foolfuuka.themes.default_after_headless_open')->setObject($this)->setParam('board', array(isset($radix) ? $radix : null))->execute();
                ?>
                <?php 
            }
            ?>

            <aside class="posts">
                <?php 
            if (isset($post['posts'])) {
                $post_counter = 0;
                $image_counter = 0;
                $board_comment_view = $this->getBuilder()->createPartial('post', 'board_comment');
                // reusable Comment object not to create one every loop
                $comment = new Comment($this->getContext());
                $comment->setControllerMethod($controller_method);
                $media_obj = new Media($this->getContext());
                $search = array('/\\>[^\\S ]+/s', '/[^\\S ]+\\</s', '/(\\s)+/s');
                $replace = array('>', '<', '\\1');
                foreach ($post['posts'] as $p) {
                    /** @var CommentBulk $p */
                    $post_counter++;
                    if ($p->media !== null) {
                        $image_counter++;
                    }
                    if ($image_counter == 150) {
                        $modifiers['lazyload'] = true;
                    }
                    $comment->setBulk($p);
                    // set the $media to null and leave the Media object in existence
                    if ($p->media !== null) {
                        $media_obj->setBulk($p);
                        $media = $media_obj;
                    } else {
                        $media = null;
                    }
                    $board_comment_view->getParamManager()->setParams(['p' => $comment, 'p_media' => $media, 'modifiers' => $this->getBuilderParamManager()->getParam('modifiers', false), 'post_counter' => $post_counter, 'image_counter' => $image_counter]);
                    // refreshes the string
                    $board_comment_view->doBuild();
                    echo preg_replace($search, $replace, $board_comment_view->build());
                    // remove extra strings from the objects
                    $board_comment_view->clearBuilt();
                    $p->comment->clean();
                    if ($p->media !== null) {
                        $p->media->clean();
                    }
                    $this->flush();
                }
            }
            ?>
            </aside>

            <?php 
            if ($thread_id !== 0) {
                ?>
            <div class="js_hook_realtimethread"></div>
            <?php 
                echo $this->getBuilder()->isPartial('tools_reply_box') ? $this->getBuilder()->getPartial('tools_reply_box')->build() : '';
                ?>
            <?php 
            }
            ?>
            <?php 
            if (isset($post['op']) || isset($post['posts'])) {
                ?>
        </article>
        <?php 
            }
            ?>
            <?php 
        }
        ?>
        <article class="clearfix thread backlink_container">
            <div id="backlink" style="position: absolute; top: 0; left: 0; z-index: 5;"></div>
        </article>
        <?php 
    }
コード例 #8
0
ファイル: Board.php プロジェクト: voh/FoolFuuka
 /**
  * Loops over the unsorted comments to fetch all the backlinks
  */
 protected function loadBacklinks()
 {
     if ($this->comments_unsorted === null) {
         return;
     }
     $c = new Comment($this->getContext());
     foreach ($this->comments_unsorted as $bulk) {
         $c->setBulk($bulk);
         $c->processComment(true);
         $bulk->clean();
     }
 }