Example #1
0
         error($config['error']['tooshort_body']);
     }
 }
 if ($config['force_subject_op'] && $post['op']) {
     $stripped_whitespace = preg_replace('/^[\\pZ\\pC]+|[\\pZ\\pC]+$/u', '', $post['subject']);
     if ($stripped_whitespace == '') {
         error(_('It is required to enter a subject when starting a new thread on this board.'));
     }
 }
 if (!$post['op']) {
     // Check if thread is locked
     // but allow mods to post
     if ($thread['locked'] && !hasPermission($config['mod']['postinlocked'], $board['uri'])) {
         error($config['error']['locked']);
     }
     $numposts = numPosts($post['thread']);
     if ($config['reply_hard_limit'] != 0 && $config['reply_hard_limit'] <= $numposts['replies']) {
         error($config['error']['reply_hard_limit']);
     }
     if ($post['has_file'] && $config['image_hard_limit'] != 0 && $config['image_hard_limit'] <= $numposts['images']) {
         error($config['error']['image_hard_limit']);
     }
 }
 if ($post['has_file']) {
     // Determine size sanity
     $size = 0;
     if ($config['multiimage_method'] == 'split') {
         foreach ($_FILES as $key => $file) {
             $size += $file['size'];
         }
     } elseif ($config['multiimage_method'] == 'each') {
Example #2
0
function index($page, $mod = false)
{
    global $board, $config, $debug;
    $body = '';
    $offset = round($page * $config['threads_per_page'] - $config['threads_per_page']);
    $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `sticky` DESC, `bump` DESC LIMIT :offset,:threads_per_page", $board['uri']));
    $query->bindValue(':offset', $offset, PDO::PARAM_INT);
    $query->bindValue(':threads_per_page', $config['threads_per_page'], PDO::PARAM_INT);
    $query->execute() or error(db_error($query));
    if ($page == 1 && $query->rowCount() < $config['threads_per_page']) {
        $board['thread_count'] = $query->rowCount();
    }
    if ($query->rowCount() < 1 && $page > 1) {
        return false;
    }
    $threads = array();
    while ($th = $query->fetch(PDO::FETCH_ASSOC)) {
        $thread = new Thread($th, $mod ? '?/' : $config['root'], $mod);
        if ($config['cache']['enabled']) {
            $cached = cache::get("thread_index_{$board['uri']}_{$th['id']}");
            if (isset($cached['replies'], $cached['omitted'])) {
                $replies = $cached['replies'];
                $omitted = $cached['omitted'];
            } else {
                unset($cached);
            }
        }
        if (!isset($cached)) {
            $posts = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $board['uri']));
            $posts->bindValue(':id', $th['id']);
            $posts->bindValue(':limit', $th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'], PDO::PARAM_INT);
            $posts->execute() or error(db_error($posts));
            $replies = array_reverse($posts->fetchAll(PDO::FETCH_ASSOC));
            if (count($replies) == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) {
                $count = numPosts($th['id']);
                $omitted = array('post_count' => $count['replies'], 'image_count' => $count['images']);
            } else {
                $omitted = false;
            }
            if ($config['cache']['enabled']) {
                cache::set("thread_index_{$board['uri']}_{$th['id']}", array('replies' => $replies, 'omitted' => $omitted));
            }
        }
        $num_images = 0;
        foreach ($replies as $po) {
            if ($po['num_files']) {
                $num_images += $po['num_files'];
            }
            $thread->add(new Post($po, $mod ? '?/' : $config['root'], $mod));
        }
        $thread->images = $num_images;
        $thread->replies = isset($omitted['post_count']) ? $omitted['post_count'] : count($replies);
        if ($omitted) {
            $thread->omitted = $omitted['post_count'] - ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']);
            $thread->omitted_images = $omitted['image_count'] - $num_images;
        }
        $threads[] = $thread;
        $body .= $thread->build(true);
    }
    if ($config['file_board']) {
        $body = Element('fileboard.html', array('body' => $body, 'mod' => $mod));
    }
    return array('board' => $board, 'body' => $body, 'post_url' => $config['post_url'], 'config' => $config, 'boardlist' => createBoardlist($mod), 'threads' => $threads);
}
Example #3
0
         $post['thumb'] = substr_replace($post['thumb'], '', 0, mb_strlen($board['dir'] . $config['dir']['thumb']));
     }
 }
 $id = post($post, $OP);
 if (isset($post['tracked_cites'])) {
     foreach ($post['tracked_cites'] as $cite) {
         $query = prepare('INSERT INTO `cites` VALUES (:board, :post, :target_board, :target)');
         $query->bindValue(':board', $board['uri']);
         $query->bindValue(':post', $id, PDO::PARAM_INT);
         $query->bindValue(':target_board', $cite[0]);
         $query->bindValue(':target', $cite[1], PDO::PARAM_INT);
         $query->execute() or error(db_error($query));
     }
 }
 buildThread($OP ? $id : $post['thread']);
 if (!$OP && strtolower($post['email']) != 'sage' && !$thread['sage'] && ($config['reply_limit'] == 0 || numPosts($post['thread']) < $config['reply_limit'])) {
     bumpThread($post['thread']);
 }
 if ($OP) {
     clean();
 }
 buildIndex();
 if (isset($_SERVER['HTTP_REFERER'])) {
     // Tell Javascript that we posted successfully
     if (isset($_COOKIE[$config['cookies']['js']])) {
         $js = json_decode($_COOKIE[$config['cookies']['js']]);
     } else {
         $js = (object) array();
     }
     // Tell it to delete the cached post for referer
     $js->{$_SERVER['HTTP_REFERER']} = true;