Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update boards.php #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 66 additions & 62 deletions boards.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<?php

include "inc/functions.php";
Expand All @@ -6,7 +7,7 @@
$founding_date = "October 23, 2013";

if (php_sapi_name() == 'fpm-fcgi' && !$admin && count($_GET) == 0) {
error('Cannot be run directly.');
error('Cannot be run directly.');
}

/* Build parameters for page */
Expand All @@ -15,12 +16,12 @@
$tags = array();

if (count($searchJson)) {
if (isset($searchJson['boards'])) {
$boards = $searchJson['boards'];
}
if (isset($searchJson['tagWeight'])) {
$tags = $searchJson['tagWeight'];
}
if (isset($searchJson['boards'])) {
$boards = $searchJson['boards'];
}
if (isset($searchJson['tagWeight'])) {
$tags = $searchJson['tagWeight'];
}
}

$boardQuery = prepare("SELECT COUNT(1) AS 'boards_total', SUM(indexed) AS 'boards_public', SUM(posts_total) AS 'posts_total' FROM ``boards``");
Expand Down Expand Up @@ -49,88 +50,91 @@
// buildJavascript();

$boardsHTML = Element("8chan/boards-table.html", array(
"config" => $config,
"boards" => $boards,
"tag_query" => $tag_query,

)
"config" => $config,
"boards" => $boards,
"tag_query" => $tag_query,
)
);

$tagsHTML = Element("8chan/boards-tags.html", array(
"config" => $config,
"tags" => $tags,
"tag_query" => $tag_query,

)
"config" => $config,
"tags" => $tags,
"tag_query" => $tag_query,
)
);

$query = query('SELECT np.* FROM newsplus np INNER JOIN `posts_n` p ON np.thread=p.id WHERE np.dead IS FALSE ORDER BY p.bump DESC');
if ($query) {
$newsplus = $query->fetchAll(PDO::FETCH_ASSOC);
$newsplus = $query->fetchAll(PDO::FETCH_ASSOC);
} else {
$newsplus = false;
$newsplus = [];
}

include("recent_threads.php");

$searchArray = array(
"config" => $config,
"boards" => $boards,
"tags" => $tags,
"search" => $searchJson['search'],
"languages" => $config['languages'],

"boards_total" => $boards_total,
"boards_public" => $boards_public,
"boards_hidden" => $boards_hidden,
"boards_omitted" => $boards_omitted,

"posts_hour" => $posts_hour,
"posts_total" => $posts_total,

"founding_date" => $founding_date,
"page_updated" => date('r'),

"html_boards" => $boardsHTML,
"html_tags" => $tagsHTML,
"newsplus" => $newsplus
"config" => $config,
"boards" => $boards,
"tags" => $tags,
"search" => $searchJson['search'],
"languages" => $config['languages'],

"boards_total" => $boards_total,
"boards_public" => $boards_public,
"boards_hidden" => $boards_hidden,
"boards_omitted" => $boards_omitted,

"posts_hour" => $posts_hour,
"posts_total" => $posts_total,

"founding_date" => $founding_date,
"page_updated" => date('r'),
"recent_threads" => $RT_HTML,

"html_boards" => $boardsHTML,
"html_tags" => $tagsHTML,
"newsplus" => $newsplus
);

$searchHTML = Element("8chan/boards-index.html", $searchArray);

$pageHTML = Element("page.html", array(
"title" => "8chan, the infinitely expanding imageboard",
"config" => $config,
"body" => $searchHTML,
)
"title" => $config['site_slogan'],
"config" => $config,
"body" => $searchHTML,
)
);

$searchHTML2 = Element("8chan/boards-search.html", $searchArray);

$pageHTML2 = Element("page.html", array(
"title" => "Boards on 8chan",
"config" => $config,
"body" => $searchHTML2,
)
"title" => "Boards on ".$config['site_name'],
"config" => $config,
"body" => $searchHTML2,
)
);


// We only want to cache if this is not a dynamic form request.
// Otherwise, our information will be skewed by the search criteria.
if (php_sapi_name() == 'cli') {
// Preserves the JSON output format of [{board},{board}].
$nonAssociativeBoardList = array_values($response['boardsFull']);

file_write("index.html", $pageHTML);
file_write("boards.html", $pageHTML2);
file_write("boards.json", json_encode($nonAssociativeBoardList));

$topbar = array();
foreach ($boards as $i => $b) {
if (is_array($config['no_top_bar_boards']) && !in_array($b['uri'], $config['no_top_bar_boards'])) {
$topbar[] = $b;
}
}

file_write("boards-top20.json", json_encode(array_splice($topbar, 0, 48)));
// Preserves the JSON output format of [{board},{board}].
$nonAssociativeBoardList = array_values($response['boardsFull']);
file_write("index.html", $pageHTML);
file_write("boards.html", $pageHTML2);
file_write("boards.json", json_encode($nonAssociativeBoardList));
$topbar = array();
foreach ($boards as $i => $b) {
if (is_array($config['no_top_bar_boards']) && !in_array($b['uri'], $config['no_top_bar_boards'])) {
$topbar[] = $b;
}
}
file_write("boards-top20.json", json_encode(array_splice($topbar, 0, 48)));
}

echo $pageHTML;