{ $idval = $GLOBALS['Reque']->reqval["thrid"]; $thr_titleval = $GLOBALS['Reque']->reqval["thr_title"]; $thr_descval = $GLOBALS['Reque']->delContent($_REQUEST["thr_desc"]); $GLOBALS['WebSe']->isLoginUser($getUrl = BASE_WEBURL . '/?thread-' . $idval . '.html'); $updatethread = "UPDATE `" . SQL_PREFIX . "thread` SET thr_title = '" . $thr_titleval . "' ,thr_desc = '" . $thr_descval . "' WHERE `thr_id` = " . $idval . " and use_id = " . $_SESSION["webUser"]["use_id"] . " "; $GLOBALS['MySql']->querySql($updatethread); $GLOBALS['Templ']->assign('infomessage', $GLOBALS['_LANG']['bd_editsusse']); $GLOBALS['Templ']->assign('URL_TIME', URL_TIME); $GLOBALS['Templ']->assign('geturl', BASE_WEBURL . '/?thread-' . $idval . '.html'); $GLOBALS['Templ']->display('suggestion_tpl.html'); } } $Thread = new Thread(); if ($GLOBALS['Webur']->getval["type"] == 'add') { $Thread->add(); } else { if ($GLOBALS['Webur']->getval["type"] == 'addinfo') { $Thread->addinfo(); } else { if ($GLOBALS['Webur']->getval["type"] == 'edit') { $Thread->edit(); } else { if ($GLOBALS['Webur']->getval["type"] == 'editinfo') { $Thread->editinfo(); } else { if ($GLOBALS['Webur']->getval["type"] == 'del') { $Thread->del(); } else { if (intval($GLOBALS['Webur']->getval["idval"]) != '') { $Thread->infolist();
function buildThread50($id, $return = false, $mod = false, $thread = null, $antibot = false) { global $board, $config, $build_pages; $id = round($id); if ($antibot) { $antibot->reset(); } if (!$thread) { $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id` DESC LIMIT :limit", $board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->bindValue(':limit', $config['noko50_count'] + 1, PDO::PARAM_INT); $query->execute() or error(db_error($query)); $num_images = 0; while ($post = $query->fetch(PDO::FETCH_ASSOC)) { if (!isset($thread)) { $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); } else { if ($post['files']) { $num_images += $post['num_files']; } $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); } } // Check if any posts were found if (!isset($thread)) { error($config['error']['nonexistant']); } if ($query->rowCount() == $config['noko50_count'] + 1) { $count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM ``posts_%s`` WHERE `thread` = :thread UNION ALL\n\t\t\t\t\t\t SELECT SUM(`num_files`) FROM ``posts_%s`` WHERE `files` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri'])); $count->bindValue(':thread', $id, PDO::PARAM_INT); $count->execute() or error(db_error($count)); $c = $count->fetch(); $thread->omitted = $c['num'] - $config['noko50_count']; $c = $count->fetch(); $thread->omitted_images = $c['num'] - $num_images; } $thread->posts = array_reverse($thread->posts); } else { $allPosts = $thread->posts; $thread->posts = array_slice($allPosts, -$config['noko50_count']); $thread->omitted += count($allPosts) - count($thread->posts); foreach ($allPosts as $index => $post) { if ($index == count($allPosts) - count($thread->posts)) { break; } if ($post->files) { $thread->omitted_images += $post->num_files; } } } $hasnoko50 = $thread->postCount() >= $config['noko50_min']; $body = Element('thread.html', array('board' => $board, 'thread' => $thread, 'body' => $thread->build(false, true), 'config' => $config, 'id' => $id, 'mod' => $mod, 'hasnoko50' => $hasnoko50, 'isnoko50' => true, 'antibot' => $mod ? false : ($antibot ? $antibot : create_antibot($board['uri'], $id)), 'boardlist' => createBoardlist($mod), 'return' => $mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])); if ($return) { return $body; } else { file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page50'], $id), $body); } }
function buildThread($id, $return = false, $mod = false) { global $board, $config, $build_pages; $id = round($id); if (event('build-thread', $id)) { return; } if ($config['cache']['enabled'] && !$mod) { // Clear cache cache::delete("thread_index_{$board['uri']}_{$id}"); cache::delete("thread_{$board['uri']}_{$id}"); } $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { if (!isset($thread)) { $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); } else { $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); } } // Check if any posts were found if (!isset($thread)) { error($config['error']['nonexistant']); } $body = Element('thread.html', array('board' => $board, 'thread' => $thread, 'body' => $thread->build(), 'config' => $config, 'id' => $id, 'mod' => $mod, 'antibot' => $mod || $return ? false : create_antibot($board['uri'], $id), 'boardlist' => createBoardlist($mod), 'return' => $mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])); if ($config['try_smarter'] && !$mod) { $build_pages[] = thread_find_page($id); } if ($return) { return $body; } file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id), $body); // json api if ($config['api']['enabled']) { $api = new Api(); $json = json_encode($api->translateThread($thread)); $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; file_write($jsonFilename, $json); } }
public function build($mod = false) { global $config, $board; $boards = listBoards(); $body = ''; $overflow = array(); $board = array('url' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])); $query = ''; foreach ($boards as &$_board) { if (in_array($_board['uri'], explode(' ', $this->settings['exclude']))) { continue; } $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']); } $query = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC', $query); $query = query($query) or error(db_error()); $count = 0; $threads = array(); while ($post = $query->fetch()) { if (!isset($threads[$post['board']])) { $threads[$post['board']] = 1; } else { $threads[$post['board']] += 1; } if ($count < $this->settings['thread_limit']) { $config['uri_thumb'] = '/' . $post['board'] . '/thumb/'; $config['uri_img'] = '/' . $post['board'] . '/src/'; $board['dir'] = $post['board'] . '/'; $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); $posts = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $post['board'])); $posts->bindValue(':id', $post['id']); $posts->bindValue(':limit', $post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'], PDO::PARAM_INT); $posts->execute() or error(db_error($posts)); $num_images = 0; while ($po = $posts->fetch()) { $config['uri_thumb'] = '/' . $post['board'] . '/thumb/'; $config['uri_img'] = '/' . $post['board'] . '/src/'; if ($po['files']) { $num_images++; } $thread->add(new Post($po, $mod ? '?/' : $config['root'], $mod)); } if ($posts->rowCount() == ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) { $ct = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM ``posts_%s`` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `files` IS NOT NULL AND `thread` = :thread", $post['board'], $post['board'])); $ct->bindValue(':thread', $post['id'], PDO::PARAM_INT); $ct->execute() or error(db_error($count)); $c = $ct->fetch(); $thread->omitted = $c['num'] - ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']); $c = $ct->fetch(); $thread->omitted_images = $c['num'] - $num_images; } $thread->posts = array_reverse($thread->posts); $body .= '<h2><a href="' . $config['root'] . $post['board'] . '">/' . $post['board'] . '/</a></h2>'; $body .= $thread->build(true); } else { $page = 'index'; if (floor($threads[$post['board']] / $config['threads_per_page']) > 0) { $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1; } $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html'); } $count += 1; } $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; $body .= '<script type="text/javascript" src="/' . $this->settings['uri'] . '/ukko.js"></script>'; $config['default_stylesheet'] = array('Yotsuba B', $config['stylesheets']['Yotsuba B']); return Element('index.html', array('config' => $config, 'board' => $board, 'no_post_form' => true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod))); }
/** * Build the HTML of a single thread in the catalog */ private function buildOne($post, $mod = false) { global $config; openBoard($post['board']); $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); $replies = $this->fetchReplies($post['board'], $post['id']); // Number of replies to a thread that are displayed beneath it $preview_count = $post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']; // Chomp the last few replies $disp_replies = array_splice($replies, 0, $preview_count); $disp_img_count = 0; foreach ($disp_replies as $reply) { if ($reply['files'] !== '') { ++$disp_img_count; } // Append the reply to the thread as it's being built $thread->add(new Post($reply, $mod ? '?/' : $config['root'], $mod)); } // Count the number of omitted image replies $omitted_img_count = count(array_filter($replies, function ($p) { return $p['files'] !== ''; })); // Set the corresponding omitted numbers on the thread if (!empty($replies)) { $thread->omitted = count($replies); $thread->omitted_images = $omitted_img_count; } // Board name and link $html = '<h2><a href="' . $config['root'] . $post['board'] . '/">/' . $post['board'] . '/</a></h2>'; // The thread itself $html .= $thread->build(true); return $html; }
$action = filter_input(INPUT_POST, "action"); } switch ($action) { case 'POST': $title = filter_input(INPUT_POST, "title"); $text = filter_input(INPUT_POST, "text"); $thread = new Thread(); if ($get_id) { //既存をupdate $params = array('thread_id' => $get_id, 'title' => $title, 'text' => $text); $thread->update($params); } else { //新規をPOST $user_id = $_SESSION["user_id"]; $params = array('user_id' => $user_id, 'title' => $title, 'text' => $text); $get_id = $thread->add($params); } break; case 'delete': print $action; if ($get_id) { //DELETE $thread = new Thread(); $thread->deleteRow($get_id); header('Location: /bbs/'); exit; } else { print "delete miss"; } break; }
function buildThread($id, $return = false, $mod = false) { global $board, $config; $id = round($id); if (event('build-thread', $id)) { return; } if ($config['cache']['enabled'] && !$mod) { // Clear cache cache::delete("thread_index_{$board['uri']}_{$id}"); cache::delete("thread_{$board['uri']}_{$id}"); } $query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); while ($post = $query->fetch()) { if (!isset($thread)) { $thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['sage'], $post['embed'], $mod ? '?/' : $config['root'], $mod); } else { $thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], $mod ? '?/' : $config['root'], $mod)); } } // Check if any posts were found if (!isset($thread)) { error($config['error']['nonexistant']); } $body = Element('thread.html', array('board' => $board, 'body' => $thread->build(), 'config' => $config, 'id' => $id, 'mod' => $mod, 'antibot' => $mod ? false : create_antibot($board['uri'], $id), 'boardlist' => createBoardlist($mod), 'return' => $mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['uri'] . '/' . $config['file_index'])); if ($return) { return $body; } file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id), $body); }