예제 #1
0
 public function blockCountryComment(Result $result)
 {
     /** @var Comment $obj */
     $obj = $result->getObject();
     // globally allowed and disallowed
     $allow = $this->preferences->get('foolfuuka.plugins.geoip_region_lock.allow_comment');
     $disallow = $this->preferences->get('foolfuuka.plugins.geoip_region_lock.disallow_comment');
     $board_allow = trim($obj->radix->getValue('plugin_geo_ip_region_lock_allow_comment'), " ,");
     $board_disallow = trim($obj->radix->getValue('plugin_geo_ip_region_lock_disallow_comment'), " ,");
     // allow board settings to override global
     if ($board_allow || $board_disallow) {
         $allow = $board_allow;
         $disallow = $board_disallow;
     }
     if ($allow || $disallow) {
         $ip = Inet::dtop($obj->comment->poster_ip);
         $reader = new Reader($this->preferences->get('foolframe.maxmind.geoip2_db_path'));
         $country = null;
         try {
             $record = $reader->country($ip);
             $country = strtolower($record->country->isoCode);
         } catch (AddressNotFoundException $e) {
             $country = 'xx';
         }
         if ($allow) {
             $allow = array_filter(explode(',', $allow));
             foreach ($allow as $al) {
                 if (strtolower(trim($al)) === $country) {
                     return;
                 }
             }
             throw new CommentSendingException(_i('Your nation has been blocked from posting.') . '<br/><br/>This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com/');
         }
         if ($disallow) {
             $disallow = array_filter(explode(',', $disallow));
             foreach ($disallow as $disal) {
                 if (strtolower(trim($disal)) == $country) {
                     throw new CommentSendingException(_i('Your nation has been blocked from posting.') . '<br/><br/>This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com/');
                 }
             }
         }
     }
 }
예제 #2
0
    public function toString()
    {
        $controller_method = $this->getBuilderParamManager()->getParam('controller_method', 'thread');
        $p = $this->getParamManager()->getParam('p');
        $p_media = $this->getParamManager()->getParam('p_media');
        if ($this->getParamManager()->getParam('modifiers', false)) {
            $modifiers = $this->getParamManager()->getParam('modifiers');
        }
        $num = $p->num . ($p->subnum ? '_' . $p->subnum : '');
        ?>
        <div class="post stub stub_doc_id_<?php 
        echo $p->doc_id;
        ?>
">
                <button class="btn-toggle-post" data-function="showPost" data-board="<?php 
        echo $p->radix->shortname;
        ?>
"  data-doc-id="<?php 
        echo $p->doc_id;
        ?>
" data-thread-num="<?php 
        echo $p->thread_num;
        ?>
"><i class="icon-plus"></i></button>
                <?php 
        if ($p->email && $p->email !== 'noko') {
            ?>
<a href="mailto:<?php 
            echo rawurlencode($p->email);
            ?>
"><?php 
        }
        ?>
<span class="post_author"><?php 
        echo $p->getNameProcessed();
        ?>
</span><?php 
        echo $p->getNameProcessed() && $p->getTripProcessed() ? ' ' : '';
        ?>
<span class="post_tripcode"><?php 
        echo $p->getTripProcessed();
        ?>
</span><?php 
        if ($p->email && $p->email !== 'noko') {
            ?>
</a><?php 
        }
        ?>
        </div>
        <article class="post doc_id_<?php 
        echo $p->doc_id;
        if ($p->subnum > 0) {
            ?>
 post_ghost<?php 
        }
        if ($p->thread_num === $p->num) {
            ?>
 post_is_op<?php 
        }
        if (!is_null($p_media)) {
            ?>
 has_image<?php 
        }
        ?>
" id="<?php 
        echo $num;
        ?>
">
            <div class="stub pull-left">
                <button class="btn-toggle-post" data-function="hidePost" data-board="<?php 
        echo $p->radix->shortname;
        ?>
" data-doc-id="<?php 
        echo $p->doc_id;
        ?>
"><i class="icon-minus"></i></button>
            </div>
            <div class="<?php 
        if ($p->capcode === 'A') {
            ?>
adminpost<?php 
        }
        ?>
 post_wrapper">
                <?php 
        if ($p_media !== null) {
            ?>
                <div class="post_file" style="overflow:visible;">
                    <span class="post_file_controls">
                    <?php 
            if ($p_media->getMediaStatus($this->getRequest()) !== 'banned' || $this->getAuth()->hasAccess('media.see_hidden')) {
                ?>
                        <?php 
                if (!$p->radix->hide_thumbnails || $this->getAuth()->hasAccess('media.see_hidden')) {
                    ?>
                            <?php 
                    $dropdowntest = 0;
                    if ($dropdowntest === 1) {
                        ?>
                            <a href="<?php 
                        echo $this->getUri()->create((isset($modifiers['post_show_board_name']) && $modifiers['post_show_board_name'] ? '_' : $p->radix->shortname) . '/search/image/' . $p_media->getSafeMediaHash());
                        ?>
" class="btnr parent"><?php 
                        echo _i('View Same');
                        ?>
</a>
                            <a href="http://google.com/searchbyimage?image_url=<?php 
                        echo $p_media->getThumbLink($this->getRequest());
                        ?>
" target="_blank" class="btnr parent">Google</a>
                            <a href="http://iqdb.org/?url=<?php 
                        echo $p_media->getThumbLink($this->getRequest());
                        ?>
" target="_blank" class="btnr parent">iqdb</a>
                            <a href="http://saucenao.com/search.php?url=<?php 
                        echo $p_media->getThumbLink($this->getRequest());
                        ?>
" target="_blank" class="btnr parent">SauceNAO</a>
                            <?php 
                    } else {
                        ?>
                            <div class="saucenav">
                                <ul>
                                    <li class="btnr parent"><a href="#" onclick="return false;">Image Search</a>
                                        <ul class="saucenav-reply">
                                            <li><a href="<?php 
                        echo $this->getUri()->create((isset($modifiers['post_show_board_name']) && $modifiers['post_show_board_name'] ? '_' : $p->radix->shortname) . '/search/image/' . $p_media->getSafeMediaHash());
                        ?>
"><?php 
                        echo _i('View Same');
                        ?>
</a></li>
                                            <li><a href="http://google.com/searchbyimage?image_url=<?php 
                        echo $p_media->getThumbLink($this->getRequest());
                        ?>
" target="_blank">Google</a></li>
                                            <li><a href="http://iqdb.org/?url=<?php 
                        echo $p_media->getThumbLink($this->getRequest());
                        ?>
" target="_blank">Iqdb</a></li>
                                            <li><a href="http://saucenao.com/search.php?url=<?php 
                        echo $p_media->getThumbLink($this->getRequest());
                        ?>
" target="_blank">SauceNAO</a></li>
                                        </ul>
                                    </li>
                                </ul>
                            </div>
                            <?php 
                    }
                    ?>
                            <?php 
                    if (!$p->radix->archive || $p->radix->getValue('archive_full_images')) {
                        ?>
                                <a href="<?php 
                        echo $p_media->getMediaDownloadLink($this->getRequest());
                        ?>
" download="<?php 
                        echo $p_media->getMediaFilenameProcessed();
                        ?>
" style="border-color: #9E9E9E!important;" class="btnr parent"><i class="icon-download-alt"></i></a>
                            <?php 
                    }
                    ?>
                        <?php 
                }
                ?>
                    <?php 
            }
            ?>
                    </span>
                    <?php 
            if ($p_media->getMediaStatus($this->getRequest()) !== 'banned' || $this->getAuth()->hasAccess('media.see_banned')) {
                ?>
                    <?php 
                if (mb_strlen($p_media->getMediaFilenameProcessed()) > 35) {
                    ?>
                        <a href="<?php 
                    echo $p_media->getMediaLink($this->getRequest()) ? $p_media->getMediaLink($this->getRequest()) : $p_media->getRemoteMediaLink($this->getRequest());
                    ?>
" class="post_file_filename" rel="tooltip" title="<?php 
                    echo htmlspecialchars($p_media->media_filename);
                    ?>
" target="_blank"><?php 
                    echo mb_substr($p_media->getMediaFilenameProcessed(), 0, 30, 'utf-8') . ' (...)' . mb_substr($p_media->getMediaFilenameProcessed(), mb_strrpos($p_media->getMediaFilenameProcessed(), '.', 'utf-8'), null, 'utf-8');
                    ?>
</a>,
                    <?php 
                } else {
                    ?>
                        <a href="<?php 
                    echo $p_media->getMediaLink($this->getRequest()) ? $p_media->getMediaLink($this->getRequest()) : $p_media->getRemoteMediaLink($this->getRequest());
                    ?>
" class="post_file_filename" rel="tooltip" title="<?php 
                    echo htmlspecialchars($p_media->media_filename);
                    ?>
" target="_blank"><?php 
                    echo $p_media->getMediaFilenameProcessed();
                    ?>
</a>,
                    <?php 
                }
                ?>
                    <span class="post_file_metadata">
                        <?php 
                echo \Rych\ByteSize\ByteSize::formatBinary($p_media->media_size, 0) . ', ' . $p_media->media_w . 'x' . $p_media->media_h;
                ?>
                    </span>
                    <?php 
            }
            ?>
                </div>
                <div class="thread_image_box">
                    <?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 $p_media->getMediaLink($this->getRequest()) ? $p_media->getMediaLink($this->getRequest()) : $p_media->getRemoteMediaLink($this->getRequest());
                ?>
" target="_blank" rel="noreferrer" class="thread_image_link">
                            <?php 
                if (!$this->getAuth()->hasAccess('maccess.mod') && !$p->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 
                } elseif (isset($modifiers['lazyload']) && $modifiers['lazyload'] == true) {
                    ?>
                            <img src="<?php 
                    echo $this->getUri()->base() . $this->getAssetManager()->getAssetLink('images/transparent_pixel.png');
                    ?>
" data-original="<?php 
                    echo $p_media->getThumbLink($this->getRequest());
                    ?>
" width="<?php 
                    echo $p_media->preview_w;
                    ?>
" height="<?php 
                    echo $p_media->preview_h;
                    ?>
" class="lazyload post_image<?php 
                    echo $p_media->spoiler ? ' is_spoiler_image' : '';
                    ?>
" data-md5="<?php 
                    echo $p_media->media_hash;
                    ?>
" />
                            <noscript>
                                <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 $p_media->getThumbLink($this->getRequest());
                    ?>
" style="margin-left: -<?php 
                    echo $p_media->preview_w;
                    ?>
px" width="<?php 
                    echo $p_media->preview_w;
                    ?>
" height="<?php 
                    echo $p_media->preview_h;
                    ?>
" class="lazyload post_image<?php 
                    echo $p_media->spoiler ? ' is_spoiler_image' : '';
                    ?>
" data-md5="<?php 
                    echo $p_media->media_hash;
                    ?>
" />
                                </a>
                            </noscript>
                            <?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;
                    ?>
" class="lazyload post_image<?php 
                    echo $p_media->spoiler ? ' is_spoiler_image' : '';
                    ?>
" imgstate="normal" smsize="<?php 
                    echo $p->media->preview_w . "x" . $p->media->preview_h;
                    ?>
" data-md5="<?php 
                    echo $p_media->media_hash;
                    ?>
" />
                            <?php 
                }
                ?>
                        </a>
                    <?php 
            }
            ?>
                </div>
                <?php 
        }
        ?>
                <header>
                    <div class="post_data">
                        <?php 
        if (isset($modifiers['post_show_board_name']) && $modifiers['post_show_board_name']) {
            ?>
                        <span class="post_show_board">/<?php 
            echo $p->radix->shortname;
            ?>
/</span>
                        <?php 
        }
        ?>

                        <?php 
        if ($p->getTitleProcessed() !== '') {
            ?>
<h2 class="post_title"><?php 
            echo $p->getTitleProcessed();
            ?>
</h2><?php 
        }
        ?>
                        <span class="post_poster_data">
                            <?php 
        if ($p->email && $p->email !== 'noko') {
            ?>
<a href="mailto:<?php 
            echo rawurlencode($p->email);
            ?>
"><?php 
        }
        ?>
<span class="post_author"><?php 
        echo $p->getNameProcessed();
        ?>
</span><?php 
        echo $p->getNameProcessed() && $p->getTripProcessed() ? ' ' : '';
        ?>
<span class="post_tripcode"><?php 
        echo $p->getTripProcessed();
        ?>
</span><?php 
        if ($p->email && $p->email !== 'noko') {
            ?>
</a><?php 
        }
        ?>

                            <?php 
        if ($p->getPosterHashProcessed()) {
            ?>
<span class="poster_hash">ID:<?php 
            echo $p->getPosterHashProcessed();
            ?>
</span><?php 
        }
        ?>
                            <?php 
        if ($p->capcode !== 'N') {
            ?>
                                <?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 
            }
            ?>
                            <?php 
        }
        ?>
                        </span>
                        <span class="time_wrap">
                            <time datetime="<?php 
        echo gmdate(DATE_W3C, $p->timestamp);
        ?>
" <?php 
        if ($p->radix->archive) {
            ?>
 title="<?php 
            echo _i('4chan Time') . ': ' . $p->getFourchanDate();
            ?>
"<?php 
        }
        ?>
><?php 
        echo gmdate('D d M Y H:i:s', $p->timestamp);
        ?>
</time>
                        </span>
                        <a href="<?php 
        echo $this->getUri()->create([$p->radix->shortname, $controller_method, $p->thread_num]) . '#' . $num;
        ?>
" data-post="<?php 
        echo $num;
        ?>
" data-function="highlight">No.</a><a href="<?php 
        echo $this->getUri()->create([$p->radix->shortname, $controller_method, $p->thread_num]) . '#q' . $num;
        ?>
" data-post="<?php 
        echo str_replace('_', ',', $num);
        ?>
" data-function="quote"><?php 
        if ($p->capcode === 'L') {
            echo str_replace('_', ',', 1999999999);
        } else {
            echo str_replace('_', ',', $num);
        }
        ?>
</a>

                        <span class="post_type">
                            <?php 
        if ($p->poster_country !== null) {
            ?>
<span title="<?php 
            echo e($p->poster_country_name);
            ?>
" class="flag flag-<?php 
            echo strtolower($p->poster_country);
            ?>
"></span><?php 
        }
        ?>
                            <?php 
        if ($p->subnum) {
            ?>
<i class="icon-comment-alt" title="<?php 
            echo htmlspecialchars(_i('This post was submitted as a "ghost" reply.'));
            ?>
"></i><?php 
        }
        ?>
                            <?php 
        if (isset($p_media) && $p_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 ($p->deleted && !$p->timestamp_expired) {
            ?>
<i class="icon-trash" title="<?php 
            echo htmlspecialchars(_i('This post was prematurely deleted.'));
            ?>
"></i><?php 
        }
        ?>
                            <?php 
        if ($p->deleted && $p->timestamp_expired) {
            ?>
<i class="icon-trash" title="<?php 
            echo htmlspecialchars(_i('This post was deleted on %s.', gmdate('M d, Y \\a\\t H:i:s e', $p->timestamp_expired)));
            ?>
"></i><?php 
        }
        ?>
                            <?php 
        if ($p->sticky) {
            ?>
<i class="icon-pushpin" title="<?php 
            echo _i('This thread has been stickied.');
            ?>
"></i><?php 
        }
        ?>
                            <?php 
        if ($p->locked) {
            ?>
<i class="icon-lock" title="<?php 
            echo _i('This thread has been locked.');
            ?>
"></i><?php 
        }
        ?>
                        </span>

                        <span class="post_controls">
                            <?php 
        if (isset($modifiers['post_show_view_button'])) {
            ?>
<a href="<?php 
            echo $this->getUri()->create($p->radix->shortname . '/thread/' . $p->thread_num) . '#' . $num;
            ?>
" class="btnr parent"><?php 
            echo _i('View');
            ?>
</a><?php 
        }
        ?>
<a href="#" class="btnr parent" data-post="<?php 
        echo $p->doc_id;
        ?>
" data-post-id="<?php 
        echo $num;
        ?>
" data-board="<?php 
        echo htmlspecialchars($p->radix->shortname);
        ?>
" data-controls-modal="post_tools_modal" data-backdrop="true" data-keyboard="true" data-function="report"><?php 
        echo _i('Report');
        ?>
</a><?php 
        if ($p->subnum > 0 || $this->getAuth()->hasAccess('comment.passwordless_deletion') || !$p->radix->archive) {
            ?>
<a href="#" class="btnr parent" data-post="<?php 
            echo $p->doc_id;
            ?>
" data-post-id="<?php 
            echo $num;
            ?>
" data-board="<?php 
            echo htmlspecialchars($p->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>
                </header>
                <div class="backlink_list"<?php 
        echo $p->getBacklinks() ? ' style="display:block"' : '';
        ?>
>
                    <?php 
        echo _i('Quoted By:');
        ?>
 <span class="post_backlink" data-post="<?php 
        echo $p->num;
        ?>
"><?php 
        echo $p->getBacklinks() ? implode(' ', $p->getBacklinks()) : '';
        ?>
</span>
                </div>
                <div class="text<?php 
        if (preg_match('/[\\x{4E00}-\\x{9FBF}\\x{3040}-\\x{309F}\\x{30A0}-\\x{30FF}]/u', $p->getCommentProcessed())) {
            echo ' shift-jis';
        }
        ?>
">
                    <?php 
        echo $p->getCommentProcessed();
        ?>
                </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 ($p->poster_ip) {
                echo ' ' . Inet::dtop($p->poster_ip);
            }
            ?>
</button>
                </div>
                <div class="btn-group post_mod_controls" style="clear:both; padding:5px 0 0 5px;">
                    <?php 
            if ($p->op) {
                ?>
                    <button class="btn btn-mini" data-function="mod" data-board="<?php 
                echo $p->radix->shortname;
                ?>
" data-id="<?php 
                echo $p->doc_id;
                ?>
" data-action="toggle_sticky"><?php 
                echo _i('Toggle Sticky');
                ?>
</button>
                    <button class="btn btn-mini" data-function="mod" data-board="<?php 
                echo $p->radix->shortname;
                ?>
" data-id="<?php 
                echo $p->doc_id;
                ?>
" data-action="toggle_locked"><?php 
                echo _i('Toggle Locked');
                ?>
</button>
                    <?php 
            }
            ?>
                    <button class="btn btn-mini" data-function="mod" data-board="<?php 
            echo $p->radix->shortname;
            ?>
" data-board-url="<?php 
            echo $this->getUri()->create([$p->radix->shortname]);
            ?>
" data-id="<?php 
            echo $p->doc_id;
            ?>
" data-action="delete_post"><?php 
            echo _i('Delete Post');
            ?>
</button>
                    <?php 
            if (!is_null($p_media)) {
                ?>
                        <button class="btn btn-mini" data-function="mod" data-board="<?php 
                echo $p->radix->shortname;
                ?>
" data-id="<?php 
                echo $p_media->media_id;
                ?>
" data-doc-id="<?php 
                echo $p->doc_id;
                ?>
" data-action="delete_image"><?php 
                echo _i('Delete Image');
                ?>
</button>
                        <button class="btn btn-mini" data-function="mod" data-board="<?php 
                echo $p->radix->shortname;
                ?>
" data-id="<?php 
                echo $p_media->media_id;
                ?>
" data-doc-id="<?php 
                echo $p->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 $p->radix->shortname;
                ?>
" data-id="<?php 
                echo $p_media->media_id;
                ?>
" data-doc-id="<?php 
                echo $p->doc_id;
                ?>
" data-action="ban_image_global"><?php 
                echo _i('Ban Image Globally');
                ?>
</button>
                    <?php 
            }
            ?>
                    <?php 
            if ($p->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 $p->radix->shortname;
                ?>
" data-ip="<?php 
                echo Inet::dtop($p->poster_ip);
                ?>
" data-action="ban_user"><?php 
                echo _i('Ban IP:') . ' ' . Inet::dtop($p->poster_ip);
                ?>
</button>
                        <button class="btn btn-mini" data-function="searchUser" data-board="<?php 
                echo $p->radix->shortname;
                ?>
" data-id="<?php 
                echo $p->doc_id;
                ?>
" data-poster-ip="<?php 
                echo Inet::dtop($p->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 $p->radix->shortname;
                    ?>
" data-id="<?php 
                    echo $p->doc_id;
                    ?>
" data-poster-ip="<?php 
                    echo Inet::dtop($p->poster_ip);
                    ?>
"><?php 
                    echo _i('Search IP Globally');
                    ?>
</button>
                        <?php 
                }
                ?>
                    <?php 
            }
            ?>
                </div>
                <?php 
            if ($p->getReports()) {
                ?>
                    <?php 
                foreach ($p->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($p->radix->shortname);
                    ?>
" data-action="delete_report"><?php 
                    echo _i('Delete Report');
                    ?>
</button>
                            </div>
                        </div>
                    <?php 
                }
                ?>
                <?php 
            }
            ?>
                <?php 
        }
        ?>
            </div>
        </article>
        <?php 
    }
예제 #3
0
 /**
  * Send the comment and attached media to database
  *
  * @param Media $media
  * @param array $data extra data
  * @throws CommentSendingDatabaseException
  * @throws CommentSendingBannedException
  * @throws CommentSendingThreadWithoutMediaException
  * @throws CommentSendingSpamException
  * @throws CommentSendingImageInGhostException
  * @throws CommentSendingNoDelPassException
  * @throws CommentSendingThreadClosedException
  * @throws CommentSendingRequestCaptchaException
  * @throws CommentSendingTimeLimitException
  * @throws CommentSendingException
  * @throws CommentSendingTooManyCharactersException
  * @throws \RuntimeException
  * @throws CommentSendingDisplaysEmptyException
  * @throws CommentSendingTooManyLinesException
  * @throws CommentSendingSameCommentException
  * @throws CommentSendingWrongCaptchaException
  * @throws CommentSendingUnallowedCapcodeException
  * @return array error key with explanation to show to user, or success and post row
  */
 public function p_insert(Media $media = null, $data = [])
 {
     if (isset($data['recaptcha_challenge'])) {
         $this->recaptcha_challenge = $data['recaptcha_challenge'];
         $this->recaptcha_response = $data['recaptcha_response'];
     }
     $this->ghost = false;
     $this->ghost_exist = false;
     $this->allow_media = true;
     // some users don't need to be limited, in here go all the ban and posting limitators
     if (!$this->getAuth()->hasAccess('comment.limitless_comment')) {
         // check if the user is banned
         if ($ban = $this->ban_factory->isBanned($this->comment->poster_ip, $this->radix)) {
             if ($ban->board_id == 0) {
                 $banned_string = _i('It looks like you were banned on all boards.');
             } else {
                 $banned_string = _i('It looks like you were banned on /' . $this->radix->shortname . '/.');
             }
             if ($ban->length) {
                 $banned_string .= ' ' . _i('This ban will last until:') . ' ' . date(DATE_COOKIE, $ban->start + $ban->length) . '.';
             } else {
                 $banned_string .= ' ' . _i('This ban will last forever.');
             }
             if ($ban->reason) {
                 $banned_string .= ' ' . _i('The reason for this ban is:') . ' «' . $ban->reason . '».';
             }
             if ($ban->appeal_status == Ban::APPEAL_NONE) {
                 $banned_string .= ' ' . _i('If you\'d like to appeal to your ban, go to the %s page.', '<a href="' . $this->uri->create($this->radix->shortname . '/appeal') . '">' . _i('Appeal') . '</a>');
             } elseif ($ban->appeal_status == Ban::APPEAL_PENDING) {
                 $banned_string .= ' ' . _i('Your appeal is pending.');
             }
             throw new CommentSendingBannedException($banned_string);
         }
     }
     // check if it's a thread and its status
     if ($this->comment->thread_num > 0) {
         try {
             $thread = Board::forge($this->getContext())->getThread($this->comment->thread_num)->setRadix($this->radix);
             $status = $thread->getThreadStatus();
         } catch (BoardException $e) {
             throw new CommentSendingException($e->getMessage());
         }
         if ($status['closed']) {
             throw new CommentSendingThreadClosedException(_i('The thread is closed.'));
         }
         $this->ghost = $status['dead'];
         $this->ghost_exist = $status['ghost_exist'];
         $this->allow_media = !$status['disable_image_upload'];
     }
     foreach (['name', 'email', 'title', 'comment', 'capcode'] as $key) {
         $this->comment->{$key} = trim((string) $this->comment->{$key});
     }
     $this->comment->setDelpass(trim((string) $this->comment->getDelPass()));
     // some users don't need to be limited, in here go all the ban and posting limitators
     if (!$this->getAuth()->hasAccess('comment.limitless_comment')) {
         if ($this->comment->thread_num < 1) {
             // one can create a new thread only once every 5 minutes
             $check_op = $this->dc->qb()->select('*')->from($this->radix->getTable(), 'r')->where('r.poster_ip = :poster_ip')->andWhere('r.timestamp > :timestamp')->andWhere('r.op = :op')->setParameters([':poster_ip' => $this->comment->poster_ip, ':timestamp' => time() - $this->radix->getValue('cooldown_new_thread'), ':op' => true])->setMaxResults(1)->execute()->fetch();
             if ($check_op) {
                 throw new CommentSendingTimeLimitException(_i('You must wait up to %d minutes to make another new thread.', ceil($this->radix->getValue('cooldown_new_thread') / 60)));
             }
         }
         // check the latest posts by the user to see if he's posting the same message or if he's posting too fast
         $check = $this->dc->qb()->select('*')->from($this->radix->getTable(), 'r')->where('poster_ip = :poster_ip')->orderBy('timestamp', 'DESC')->setMaxResults(1)->setParameter(':poster_ip', $this->comment->poster_ip)->execute()->fetch();
         if ($check) {
             if ($this->comment->comment !== null && $check['comment'] === $this->comment->comment) {
                 throw new CommentSendingSameCommentException(_i('You\'re sending the same comment as the last time'));
             }
             $check_time = $this->getRadixTime();
             if ($check_time - $check['timestamp'] < $this->radix->getValue('cooldown_new_comment') && $check_time - $check['timestamp'] > 0) {
                 throw new CommentSendingTimeLimitException(_i('You must wait up to %d seconds to post again.', $this->radix->getValue('cooldown_new_comment')));
             }
         }
         // we want to know if the comment will display empty, and in case we won't let it pass
         $comment_parsed = $this->processComment();
         if ($this->comment->comment !== '' && $comment_parsed === '') {
             throw new CommentSendingDisplaysEmptyException(_i('This comment would display empty.'));
         }
         // clean up to reset eventual auto-built entries
         $this->comment->clean();
         if ($this->recaptcha_challenge && $this->recaptcha_response && $this->preferences->get('foolframe.auth.recaptcha_public', false)) {
             $recaptcha = ReCaptcha::create($this->preferences->get('foolframe.auth.recaptcha_public'), $this->preferences->get('foolframe.auth.recaptcha_private'));
             $recaptcha_result = $recaptcha->checkAnswer(Inet::dtop($this->comment->poster_ip), $this->recaptcha_challenge, $this->recaptcha_response);
             if (!$recaptcha_result->isValid()) {
                 throw new CommentSendingWrongCaptchaException(_i('Incorrect CAPTCHA solution.'));
             }
         } elseif ($this->preferences->get('foolframe.auth.recaptcha_public')) {
             // if there wasn't a recaptcha input, let's go with heavier checks
             if (substr_count($this->comment->comment, 'http') >= $this->radix->getValue('captcha_comment_link_limit')) {
                 throw new CommentSendingRequestCaptchaException();
             }
             // bots usually fill all the fields
             if ($this->comment->comment && $this->comment->title && $this->comment->email) {
                 throw new CommentSendingRequestCaptchaException();
             }
             // bots usually try various BBC, this checks if there's unparsed BBC after parsing it
             if ($comment_parsed !== '' && substr_count($comment_parsed, '[') + substr_count($comment_parsed, ']') > 4) {
                 throw new CommentSendingRequestCaptchaException();
             }
         }
         // load the spam list and check comment, name, title and email
         $spam = array_filter(preg_split('/\\r\\n|\\r|\\n/', file_get_contents(ASSETSPATH . 'packages/anti-spam/databases/urls.dat')));
         foreach ($spam as $s) {
             if (strpos($this->comment->comment, $s) !== false || strpos($this->comment->name, $s) !== false || strpos($this->comment->title, $s) !== false || strpos($this->comment->email, $s) !== false) {
                 throw new CommentSendingSpamException(_i('Your post has undesidered content.'));
             }
         }
         // check entire length of comment
         if (mb_strlen($this->comment->comment, 'utf-8') > $this->radix->getValue('max_comment_characters_allowed')) {
             throw new CommentSendingTooManyCharactersException(_i('Your comment has too many characters'));
         }
         // check total numbers of lines in comment
         if (count(explode("\n", $this->comment->comment)) > $this->radix->getValue('max_comment_lines_allowed')) {
             throw new CommentSendingTooManyLinesException(_i('Your comment has too many lines.'));
         }
     }
     \Foolz\Plugin\Hook::forge('Foolz\\Foolslide\\Model\\CommentInsert::insert.call.after.input_checks')->setObject($this)->execute();
     // process comment name+trip
     if ($this->comment->name === '') {
         $this->comment->name = $this->radix->getValue('anonymous_default_name');
         $this->comment->trip = null;
     } else {
         $this->processName();
         if ($this->comment->trip === '') {
             $this->comment->trip = null;
         }
     }
     foreach (['email', 'title', 'comment'] as $key) {
         if ($this->comment->{$key} === '') {
             $this->comment->{$key} = null;
         }
     }
     // process comment password
     if ($this->comment->getDelpass() === '') {
         throw new CommentSendingNoDelPassException(_i('You must submit a deletion password.'));
     }
     $pass = password_hash($this->comment->getDelpass(), PASSWORD_BCRYPT, ['cost' => 10]);
     if ($this->comment->getDelpass() === false) {
         throw new \RuntimeException('Password hashing failed');
     }
     $this->comment->setDelpass($pass);
     if ($this->comment->capcode != '') {
         $allowed_capcodes = ['N'];
         if ($this->getAuth()->hasAccess('comment.mod_capcode')) {
             $allowed_capcodes[] = 'M';
         }
         if ($this->getAuth()->hasAccess('comment.admin_capcode')) {
             $allowed_capcodes[] = 'A';
         }
         if ($this->getAuth()->hasAccess('comment.dev_capcode')) {
             $allowed_capcodes[] = 'D';
         }
         if (!in_array($this->comment->capcode, $allowed_capcodes)) {
             throw new CommentSendingUnallowedCapcodeException(_i('You\'re not allowed to use this capcode.'));
         }
     } else {
         $this->comment->capcode = 'N';
     }
     $microtime = str_replace('.', '', (string) microtime(true));
     $this->comment->timestamp = substr($microtime, 0, 10);
     $this->comment->op = (bool) (!$this->comment->thread_num);
     if ($this->radix->getValue('enable_flags')) {
         $reader = new Reader($this->preferences->get('foolframe.maxmind.geoip2_db_path'));
         try {
             $record = $reader->country(Inet::dtop($this->comment->poster_ip));
             $this->comment->poster_country = strtolower($record->country->isoCode);
         } catch (AddressNotFoundException $e) {
             $this->comment->poster_country = 'xx';
         }
     }
     // process comment media
     if ($media !== null) {
         // if uploading an image with OP is prohibited
         if (!$this->comment->thread_num && $this->radix->getValue('op_image_upload_necessity') === 'never') {
             throw new CommentSendingException(_i('You can\'t start a new thread with an image.'));
         }
         if (!$this->allow_media) {
             if ($this->ghost) {
                 throw new CommentSendingImageInGhostException(_i('You can\'t post images when the thread is in ghost mode.'));
             } else {
                 throw new CommentSendingException(_i('This thread has reached its image limit.'));
             }
         }
         try {
             $media->insert($microtime, $this->comment->op);
             $this->media = $media->media;
         } catch (MediaInsertException $e) {
             throw new CommentSendingException($e->getMessage());
         }
     } else {
         // if the user is forced to upload an image when making a new thread
         if (!$this->comment->thread_num && $this->radix->getValue('op_image_upload_necessity') === 'always') {
             throw new CommentSendingThreadWithoutMediaException(_i('You can\'t start a new thread without an image.'));
         }
         // in case of no media, check comment field again for null
         if ($this->comment->comment === null) {
             throw new CommentSendingDisplaysEmptyException(_i('This comment would display empty.'));
         }
         $this->media = $this->bulk->media = new MediaData();
     }
     // 2ch-style codes, only if enabled
     if ($this->comment->thread_num && $this->radix->getValue('enable_poster_hash')) {
         $this->comment->poster_hash = substr(substr(crypt(md5($this->comment->poster_ip . 'id' . $this->comment->thread_num), 'id'), +3), 0, 8);
     }
     $this->comment->timestamp = $this->getRadixTime($this->comment->timestamp);
     \Foolz\Plugin\Hook::forge('Foolz\\Foolslide\\Model\\CommentInsert::insert.call.before.sql')->setObject($this)->execute();
     // being processing insert...
     if ($this->ghost) {
         $num = '
         (
             SELECT MAX(num) AS num
             FROM (
                 (
                     SELECT num
                     FROM ' . $this->radix->getTable() . ' xr
                     WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                 )
                 UNION
                 (
                     SELECT num
                     FROM ' . $this->radix->getTable('_deleted') . ' xrd
                     WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                 )
             ) x
         )';
         $subnum = '
         (
             SELECT MAX(subnum) + 1 AS subnum
             FROM (
                 (
                     SELECT subnum
                     FROM ' . $this->radix->getTable() . ' xxr
                     WHERE num = (
                         SELECT MAX(num)
                         FROM (
                             (
                                 SELECT num
                                 FROM ' . $this->radix->getTable() . ' xxxr
                                 WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                             )
                             UNION
                             (
                                 SELECT num
                                 FROM ' . $this->radix->getTable('_deleted') . ' xxxrd
                                 WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                             )
                         ) xxx
                     )
                 )
                 UNION
                 (
                     SELECT subnum
                     FROM ' . $this->radix->getTable('_deleted') . ' xxdr
                     WHERE num = (
                         SELECT MAX(num)
                         FROM (
                             (
                                 SELECT num
                                 FROM ' . $this->radix->getTable() . ' xxxr
                                 WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                             )
                             UNION
                             (
                                 SELECT num
                                 FROM ' . $this->radix->getTable('_deleted') . ' xxxdrd
                                 WHERE thread_num = ' . $this->dc->getConnection()->quote($this->comment->thread_num) . '
                             )
                         ) xxxd
                     )
                 )
             ) xx
         )';
         $thread_num = $this->comment->thread_num;
     } else {
         $num = '
         (
             SELECT MAX(num) + 1 AS num
             FROM (
                 (
                     SELECT COALESCE(MAX(num), 0) AS num
                     FROM ' . $this->radix->getTable() . ' xr
                 )
                 UNION
                 (
                     SELECT COALESCE(MAX(num), 0) AS num
                     FROM ' . $this->radix->getTable('_deleted') . ' xdr
                 )
             ) x
         )';
         $subnum = 0;
         if ($this->comment->thread_num > 0) {
             $thread_num = $this->dc->getConnection()->quote($this->comment->thread_num);
         } else {
             $thread_num = '
             (
                 SELECT MAX(thread_num) + 1 AS thread_num
                 FROM (
                     (
                         SELECT COALESCE(MAX(num), 0) as thread_num
                         FROM ' . $this->radix->getTable() . ' xxr
                     )
                     UNION
                     (
                         SELECT COALESCE(MAX(num), 0) as thread_num
                         FROM ' . $this->radix->getTable('_deleted') . ' xxdr
                     )
                 ) xx
             )';
         }
     }
     try {
         $query_fields = ['num' => $num, 'subnum' => $subnum, 'thread_num' => $thread_num];
         $fields = ['media_id' => $this->media->media_id ? $this->media->media_id : 0, 'op' => (int) $this->op, 'timestamp' => $this->comment->timestamp, 'capcode' => $this->comment->capcode, 'email' => $this->comment->email, 'name' => $this->comment->name, 'trip' => $this->comment->trip, 'title' => $this->comment->title, 'comment' => $this->comment->comment, 'delpass' => $this->comment->getDelpass(), 'spoiler' => (int) $this->media->spoiler, 'poster_ip' => $this->comment->poster_ip, 'poster_hash' => $this->comment->poster_hash, 'poster_country' => $this->comment->poster_country, 'preview_orig' => $this->media->preview_orig, 'preview_w' => $this->media->preview_w, 'preview_h' => $this->media->preview_h, 'media_filename' => $this->media->media_filename, 'media_w' => $this->media->media_w, 'media_h' => $this->media->media_h, 'media_size' => $this->media->media_size, 'media_hash' => $this->media->media_hash, 'media_orig' => $this->media->media_orig, 'exif' => $this->media->exif !== null ? @json_encode($this->media->exif) : null, 'timestamp_expired' => 0];
         foreach ($fields as $key => $item) {
             if ($item === null) {
                 $fields[$key] = 'null';
             } else {
                 $fields[$key] = $this->dc->getConnection()->quote($item);
             }
         }
         $fields = $query_fields + $fields;
         $this->dc->getConnection()->beginTransaction();
         $this->dc->getConnection()->executeUpdate('INSERT INTO ' . $this->radix->getTable() . ' (' . implode(', ', array_keys($fields)) . ') VALUES (' . implode(', ', array_values($fields)) . ')');
         $last_id = $this->dc->getConnection()->lastInsertId($this->radix->getTable('_doc_id_seq'));
         $comment = $this->dc->qb()->select('*')->from($this->radix->getTable(), 'r')->where('doc_id = :doc_id')->setParameter(':doc_id', $last_id)->execute()->fetchAll();
         $this->bulk->import($comment[0], $this->radix);
         if (!$this->radix->archive) {
             $this->insertTriggerThreads();
             $this->insertTriggerDaily();
             $this->insertTriggerUsers();
         }
         // update poster_hash for op posts
         if ($this->comment->op && $this->radix->getValue('enable_poster_hash')) {
             $this->comment->poster_hash = substr(substr(crypt(md5($this->comment->poster_ip . 'id' . $this->comment->thread_num), 'id'), 3), 0, 8);
             $this->dc->qb()->update($this->radix->getTable(), 'ph')->set('poster_hash', $this->dc->getConnection()->quote($this->comment->poster_hash))->where('doc_id = :doc_id')->setParameter(':doc_id', $this->comment->doc_id)->execute();
         }
         $this->dc->getConnection()->commit();
         // clean up some caches
         Cache::item('foolslide.model.board.getThreadComments.thread.' . md5(serialize([$this->radix->shortname, $this->comment->thread_num])))->delete();
         // clean up the 10 first pages of index and gallery that are cached
         for ($i = 1; $i <= 10; $i++) {
             Cache::item('foolslide.model.board.getLatestComments.query.' . $this->radix->shortname . '.by_post.' . $i)->delete();
             Cache::item('foolslide.model.board.getLatestComments.query.' . $this->radix->shortname . '.by_thread.' . $i)->delete();
             Cache::item('foolslide.model.board.getThreadsComments.query.' . $this->radix->shortname . '.' . $i)->delete();
         }
     } catch (\Doctrine\DBAL\DBALException $e) {
         $this->logger->error('\\Foolz\\Foolslide\\Model\\CommentInsert: ' . $e->getMessage());
         $this->dc->getConnection()->rollBack();
         throw new CommentSendingDatabaseException(_i('Something went wrong when inserting the post in the database. Try again.'));
     }
     return $this;
 }
예제 #4
0
파일: Bans.php 프로젝트: voh/FoolFuuka
    public function toString()
    {
        $users = $this->getContext()->getService('users');
        $radix_coll = $this->getContext()->getService('foolfuuka.radix_collection');
        $form = $this->getForm();
        ?>
<div class="admin-container">
    <div class="admin-container-header">
        <?php 
        echo _i('Bans');
        ?>
    </div>

    <div class="pull-right">
        <?php 
        echo $form->open(['action' => 'admin/moderation/find_ban']);
        ?>
        <div class="input-prepend">
            <label class="add-on" for="form_ip">Search by IP</label><?php 
        echo $form->input('ip');
        ?>
        </div>
        <?php 
        echo $form->close();
        ?>
    </div>

    <table class="table table-hover table-condensed">
        <thead>
            <tr>
                <th><?php 
        echo _i('IP');
        ?>
</th>
                <th><?php 
        echo _i('Board');
        ?>
</th>
                <th><?php 
        echo _i('Reason');
        ?>
</th>
                <th><?php 
        echo _i('Appeal');
        ?>
</th>
                <th><?php 
        echo _i('Issued - Length');
        ?>
</th>
                <th><?php 
        echo _i('Actions');
        ?>
</th>
            </tr>
        </thead>
        <tbody>
            <?php 
        foreach ($this->getParamManager()->getParam('bans') as $b) {
            ?>
            <tr>
                <td><?php 
            echo Inet::dtop($b->ip);
            echo $this->getPreferences()->get('foolfuuka.sphinx.global') ? '<br><small><a href="' . $this->getUri()->create('_/search/poster_ip/' . Inet::dtop($b->ip)) . '" target="_blank">' . _i('Search posts') . '</a></small>' : '';
            ?>
</td>
                <td><?php 
            echo $b->board_id ? '/' . $radix_coll->getById($b->board_id)->shortname . '/' : _i('Global');
            ?>
</td>
                <td><?php 
            echo htmlentities($b->reason);
            ?>
<br><small><?php 
            echo _i('By:') . ' ' . htmlentities($users->getUserBy('id', $b->creator_id)->username);
            ?>
</small></td>
                <td><?php 
            echo htmlentities($b->appeal);
            ?>
<br><small><?php 
            echo _i('Status:') . ' ' . ($b->appeal_status == Ban::APPEAL_PENDING ? _i('pending') : '') . ($b->appeal_status == Ban::APPEAL_REJECTED ? _i('rejected') : '') . ($b->appeal_status == Ban::APPEAL_NONE ? _i('none') : '');
            ?>
</small></td>
                <td><?php 
            echo date('d-M-y H:i:s T', $b->start);
            ?>
, <?php 
            echo $b->length ? $b->length / 24 / 60 / 60 . ' ' . _i('Day(s)') : _i('Forever');
            ?>
<br><small><?php 
            echo _i('Status:') . ' ' . (!$b->length || time() < $b->start + $b->length ? _i('ongoing') : _i('expired'));
            ?>
</small></td>
                <td>
                    <div class="btn-group">
                        <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
                            <?php 
            echo _i('Action');
            ?>
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="<?php 
            echo $this->getUri()->create('admin/moderation/ban_manage/unban/' . $b->id);
            ?>
"><?php 
            echo _i('Unban');
            ?>
</a></li>
                            <?php 
            if ($b->appeal_status == Ban::APPEAL_PENDING) {
                ?>
                                <li><a href="<?php 
                echo $this->getUri()->create('admin/moderation/ban_manage/reject_appeal/' . $b->id);
                ?>
"><?php 
                echo _i('Reject appeal');
                ?>
</a></li>
                            <?php 
            }
            ?>
                        </ul>
                    </div>
                </td>
            </tr>
            <?php 
        }
        ?>
        </tbody>
    </table>

    <?php 
        $page = $this->getParamManager()->getParam('page');
        ?>
    <?php 
        if ($page) {
            ?>
    <div class="pagination">
      <ul>
        <?php 
            if ($page > 1) {
                ?>
        <li class=""><a href="<?php 
                echo $this->getParamManager()->getParam('page_url') . ($page - 1);
                ?>
"><?php 
                echo _i('Prev');
                ?>
</a></li>
        <?php 
            }
            ?>
        <li class=""><a href="<?php 
            echo $this->getParamManager()->getParam('page_url') . ($page + 1);
            ?>
"><?php 
            echo _i('Next');
            ?>
</a></li>
      </ul>
    </div>
    <?php 
        }
        ?>
</div>
<?php 
    }
예제 #5
0
파일: Chan.php 프로젝트: procod3R/FoolFuuka
 public function radix_search()
 {
     if ($this->getPost('submit_search_global')) {
         $this->radix = null;
     }
     $text = $this->getPost('text');
     if ($this->radix !== null && $this->getPost('submit_post')) {
         return $this->radix_post(str_replace(',', '_', $text));
     }
     $this->response = new StreamedResponse();
     // Check all allowed search modifiers and apply only these
     $modifiers = ['boards', 'subject', 'text', 'username', 'tripcode', 'email', 'filename', 'capcode', 'uid', 'image', 'deleted', 'ghost', 'type', 'filter', 'start', 'end', 'order', 'page'];
     if ($this->getAuth()->hasAccess('comment.see_ip')) {
         $modifiers[] = 'poster_ip';
         $modifiers[] = 'deletion_mode';
     }
     // GET -> URL Redirection to provide URL presentable for sharing links.
     if ($this->getPost()) {
         if ($this->radix !== null) {
             $redirect_url = [$this->radix->shortname, 'search'];
         } else {
             $redirect_url = ['_', 'search'];
         }
         foreach ($modifiers as $modifier) {
             if ($this->getPost($modifier)) {
                 if ($modifier === 'image') {
                     array_push($redirect_url, $modifier);
                     array_push($redirect_url, rawurlencode(Media::urlsafe_b64encode(Media::urlsafe_b64decode($this->getPost($modifier)))));
                 } elseif ($modifier === 'boards') {
                     if ($this->getPost('submit_search_global')) {
                     } elseif (count($this->getPost($modifier)) == 1) {
                         $boards = $this->getPost($modifier);
                         $redirect_url[0] = $boards[0];
                     } elseif (count($this->getPost($modifier)) > 1) {
                         $redirect_url[0] = '_';
                         // avoid setting this if we're just searching on all the boards
                         $sphinx_boards = [];
                         foreach ($this->radix_coll->getAll() as $k => $b) {
                             if ($b->sphinx) {
                                 $sphinx_boards[] = $b;
                             }
                         }
                         if (count($sphinx_boards) !== count($this->getPost($modifier))) {
                             array_push($redirect_url, $modifier);
                             array_push($redirect_url, rawurlencode(implode('.', $this->getPost($modifier))));
                         }
                     }
                 } else {
                     array_push($redirect_url, $modifier);
                     array_push($redirect_url, rawurlencode($this->getPost($modifier)));
                 }
             }
         }
         return new RedirectResponse($this->uri->create($redirect_url), 303);
     }
     $search = $this->uri->uri_to_assoc($this->request->getPathInfo(), 1, $modifiers);
     $this->param_manager->setParam('search', $search);
     // latest searches system
     if (!is_array($cookie_array = @json_decode($this->getCookie('search_latest_5'), true))) {
         $cookie_array = [];
     }
     // sanitize
     foreach ($cookie_array as $item) {
         // all subitems must be array, all must have 'board'
         if (!is_array($item) || !isset($item['board'])) {
             $cookie_array = [];
             break;
         }
     }
     $search_opts = array_filter($search);
     $search_opts['board'] = $this->radix !== null ? $this->radix->shortname : false;
     unset($search_opts['page']);
     // if it's already in the latest searches, remove the previous entry
     foreach ($cookie_array as $key => $item) {
         if ($item === $search_opts) {
             unset($cookie_array[$key]);
             break;
         }
     }
     // we don't want more than 5 entries for latest searches
     if (count($cookie_array) > 4) {
         array_pop($cookie_array);
     }
     array_unshift($cookie_array, $search_opts);
     $this->builder->getPartial('tools_search')->getParamManager()->setParam('latest_searches', $cookie_array);
     $this->response->headers->setCookie(new Cookie($this->getContext(), 'search_latest_5', json_encode($cookie_array), 60 * 60 * 24 * 30));
     foreach ($search as $key => $value) {
         if ($value !== null) {
             $search[$key] = trim(rawurldecode($value));
         }
     }
     if ($search['boards'] !== null) {
         $search['boards'] = explode('.', $search['boards']);
     }
     if ($search['image'] !== null) {
         $search['image'] = base64_encode(Media::urlsafe_b64decode($search['image']));
     }
     if ($this->getAuth()->hasAccess('comment.see_ip') && $search['poster_ip'] !== null) {
         if (!filter_var($search['poster_ip'], FILTER_VALIDATE_IP)) {
             return $this->error(_i('The poster IP you inserted is not a valid IP address.'));
         }
         $search['poster_ip'] = Inet::ptod($search['poster_ip']);
     }
     try {
         $board = Search::forge($this->getContext())->getSearch($search)->setRadix($this->radix)->setPage($search['page'] ? $search['page'] : 1);
         $board->getComments();
     } catch (\Foolz\Foolfuuka\Model\SearchException $e) {
         return $this->error($e->getMessage());
     } catch (\Foolz\Foolfuuka\Model\BoardException $e) {
         return $this->error($e->getMessage());
     } catch (\Foolz\SphinxQL\ConnectionException $e) {
         return $this->error($this->preferences->get('foolfuuka.sphinx.custom_message', 'It appears that the search engine is offline at the moment. Please try again later.'));
     }
     // Generate the $title with all search modifiers enabled.
     $title = [];
     if ($search['text']) {
         array_push($title, sprintf(_i('that contain &lsquo;%s&rsquo;'), e($search['text'])));
     }
     if ($search['subject']) {
         array_push($title, sprintf(_i('with the subject &lsquo;%s&rsquo;'), e($search['subject'])));
     }
     if ($search['username']) {
         array_push($title, sprintf(_i('with the username &lsquo;%s&rsquo;'), e($search['username'])));
     }
     if ($search['tripcode']) {
         array_push($title, sprintf(_i('with the tripcode &lsquo;%s&rsquo;'), e($search['tripcode'])));
     }
     if ($search['filename']) {
         array_push($title, sprintf(_i('with the filename &lsquo;%s&rsquo;'), e($search['filename'])));
     }
     if ($search['image']) {
         array_push($title, sprintf(_i('with the image hash &lsquo;%s&rsquo;'), e($search['image'])));
     }
     if ($search['deleted'] == 'deleted') {
         array_push($title, _i('that have been deleted'));
     }
     if ($search['deleted'] == 'not-deleted') {
         array_push($title, _i('that has not been deleted'));
     }
     if ($search['ghost'] == 'only') {
         array_push($title, _i('that are by ghosts'));
     }
     if ($search['ghost'] == 'none') {
         array_push($title, _i('that are not by ghosts'));
     }
     if ($search['type'] == 'sticky') {
         array_push($title, _i('that were stickied'));
     }
     if ($search['type'] == 'op') {
         array_push($title, _i('that are only OP posts'));
     }
     if ($search['type'] == 'posts') {
         array_push($title, _i('that are only non-OP posts'));
     }
     if ($search['filter'] == 'image') {
         array_push($title, _i('that do not contain images'));
     }
     if ($search['filter'] == 'text') {
         array_push($title, _i('that only contain images'));
     }
     if ($search['capcode'] == 'user') {
         array_push($title, _i('that were made by users'));
     }
     if ($search['capcode'] == 'mod') {
         array_push($title, _i('that were made by mods'));
     }
     if ($search['capcode'] == 'admin') {
         array_push($title, _i('that were made by admins'));
     }
     if ($search['start']) {
         array_push($title, sprintf(_i('posts after %s'), e($search['start'])));
     }
     if ($search['end']) {
         array_push($title, sprintf(_i('posts before %s'), e($search['end'])));
     }
     if ($search['order'] == 'asc') {
         array_push($title, _i('in ascending order'));
     }
     if (!empty($title)) {
         $title = sprintf(_i('Searching for posts %s.'), implode(' ' . _i('and') . ' ', $title));
     } else {
         $title = _i('Displaying all posts with no filters applied.');
     }
     if ($this->radix) {
         $this->builder->getProps()->addTitle($title);
     } else {
         $this->builder->getProps()->addTitle('Global Search &raquo; ' . $title);
     }
     if ($board->getSearchCount() > 5000) {
         $search_title = sprintf(_i('%s <small>Returning only first %d of %d results found.</small>', $title, $this->preferences->get('foolfuuka.sphinx.max_matches', 5000), $board->getSearchCount()));
     } else {
         $search_title = sprintf(_i('%s <small>%d results found.</small>', $title, $board->getSearchCount()));
     }
     $this->param_manager->setParam('section_title', $search_title);
     $main_partial = $this->builder->createPartial('body', 'board');
     $main_partial->getParamManager()->setParam('board', $board->getComments());
     $pagination = $search;
     unset($pagination['page']);
     $pagination_arr = [];
     $pagination_arr[] = $this->radix !== null ? $this->radix->shortname : '_';
     $pagination_arr[] = 'search';
     foreach ($pagination as $key => $item) {
         if ($item || $item === 0) {
             $pagination_arr[] = rawurlencode($key);
             if (is_array($item)) {
                 $item = implode('.', $item);
             }
             if ($key == 'poster_ip') {
                 $item = Inet::dtop($item);
             }
             $pagination_arr[] = rawurlencode($item);
         }
     }
     $pagination_arr[] = 'page';
     $this->param_manager->setParam('pagination', ['base_url' => $this->uri->create($pagination_arr), 'current_page' => $search['page'] ?: 1, 'total' => ceil($board->getCount() / 25)]);
     $this->param_manager->setParam('modifiers', ['post_show_board_name' => $this->radix === null, 'post_show_view_button' => true]);
     $this->profiler->logMem('Controller Chan $this', $this);
     $this->profiler->log('Controller Chan::search End');
     $this->response->setCallback(function () {
         $this->builder->stream();
     });
     return $this->response;
 }
예제 #6
0
 public function action_ban_manage($action, $id)
 {
     try {
         $ban = $this->ban_factory->getById($id);
     } catch (\Foolz\Foolfuuka\Model\BanException $e) {
         throw new NotFoundHttpException();
     }
     if ($this->getPost() && !$this->checkCsrfToken()) {
         $this->notices->set('warning', _i('The security token wasn\'t found. Try resubmitting.'));
     } elseif ($this->getPost()) {
         switch ($action) {
             case 'unban':
                 $ban->delete();
                 $this->notices->setFlash('success', _i('The poster with IP %s has been unbanned.', Inet::dtop($ban->ip)));
                 return $this->redirect('admin/moderation/bans');
                 break;
             case 'reject_appeal':
                 $ban->appealReject();
                 $this->notices->setFlash('success', _i('The appeal of the poster with IP %s has been rejected.', Inet::dtop($ban->ip)));
                 return $this->redirect('admin/moderation/bans');
                 break;
             default:
                 throw new NotFoundHttpException();
         }
     }
     switch ($action) {
         case 'unban':
             $this->_views['method_title'] = _i('Unbanning') . ' ' . Inet::dtop($ban->ip);
             $data['alert_level'] = 'warning';
             $data['message'] = _i('Do you want to unban this user?');
             break;
         case 'reject_appeal':
             $this->_views['method_title'] = _i('Rejecting appeal for') . ' ' . Inet::dtop($ban->ip);
             $data['alert_level'] = 'warning';
             $data['message'] = _i('Do you want to reject the appeal of this user? He won\'t be able to appeal again.');
             break;
         default:
             throw new NotFoundHttpException();
     }
     $this->builder->createPartial('body', 'confirm')->getParamManager()->setParams($data);
     return new Response($this->builder->build());
 }
예제 #7
0
    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 
    }