big change to the board system, instead of using folders with differnt board configs, we will be using a simple board.php file that handles all the boards.
This commit is contained in:
parent
78b82c6785
commit
b1a8d2b6ce
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
$path = $_SERVER['DOCUMENT_ROOT'];
|
||||
require_once($path . '/core/header.php');
|
||||
require_once($path . '/core/footer.php');
|
||||
require_once($path . '/core/database.php');
|
||||
|
||||
if (!isset($_GET['code'])) {
|
||||
header('location: /404.php');
|
||||
}
|
||||
|
||||
$board_code = strtolower($_GET['code']);
|
||||
$board_page = (int)$_GET['page'] ?? 1;
|
||||
if ($board_page == 0) $board_page = 1;
|
||||
|
||||
$conn = get_database_conn();
|
||||
$board_sql = "SELECT id, title FROM board WHERE code = ? LIMIT 1";
|
||||
$stmt = mysqli_prepare($conn, $board_sql);
|
||||
mysqli_stmt_bind_param($stmt, 's', $board_code);
|
||||
if (!mysqli_stmt_execute($stmt)) {
|
||||
header('location: /404.php');
|
||||
}
|
||||
mysqli_stmt_store_result($stmt);
|
||||
if (mysqli_stmt_num_rows($stmt) != 1) {
|
||||
header('location: /404.php');
|
||||
}
|
||||
mysqli_stmt_bind_result($stmt, $board_id, $board_title);
|
||||
mysqli_stmt_fetch($stmt);
|
||||
|
||||
display_header("~chan - /$board_code/");
|
||||
?>
|
||||
<div style="
|
||||
margin: auto;
|
||||
width: 40%;
|
||||
padding-top: 50px;
|
||||
">
|
||||
<h1><?php echo "/$board_code/ - $board_title"; ?></h1>
|
||||
<!-- TODO: Add spash text -->
|
||||
<?php if (isset($_SESSION['username'])): ?>
|
||||
<hr>
|
||||
<form action="/post.php" method="post" class="input-form">
|
||||
<table>
|
||||
<tr>
|
||||
<td><b>title:</b></td>
|
||||
<td>
|
||||
<input name="title" type="text" required>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>message:</b></td>
|
||||
<td>
|
||||
<textarea name="message" cols="64" rows="8" wrap="soft" tabindex="4" maxlength="1024"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>file:</b></td>
|
||||
<td>
|
||||
<input name="upload" type="file" required>
|
||||
</td>
|
||||
</tr>
|
||||
<input type="hidden" name="board_id" value="<?php echo $board_id; ?>">
|
||||
<input type="hidden" name="type" value="new_thread">
|
||||
</table>
|
||||
<br>
|
||||
<button type="submit">post</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<hr>
|
||||
<b>(<a href="#">archive</a>) (<a href="#">catalog</a>)</b>
|
||||
<hr>
|
||||
</div>
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
// this function is the main control over displaying boards.
|
||||
function display_board(array $settings) {
|
||||
|
||||
// default settings
|
||||
$defaults = array(
|
||||
'title' => 'default',
|
||||
'code' => 'd',
|
||||
'splash' => array(
|
||||
'splash 1',
|
||||
'splash 2',
|
||||
'splash 3'
|
||||
)
|
||||
);
|
||||
|
||||
$settings = array_merge($defaults, $settings);
|
||||
|
||||
// load in the required files
|
||||
$path = $_SERVER['DOCUMENT_ROOT'];
|
||||
require_once($path . '/core/header.php');
|
||||
require_once($path . '/core/footer.php');
|
||||
require_once($path . '/core/database.php');
|
||||
|
||||
display_header('~chan - /' . $settings['code'] . '/');
|
||||
session_start();
|
||||
?>
|
||||
<div style="
|
||||
margin: auto;
|
||||
width: 40%;
|
||||
padding-top: 50px;
|
||||
">
|
||||
<h1><?php echo '/' . $settings['code'] . '/ - ' . $settings['title']; ?></h1>
|
||||
<p><?php echo $settings['splash'][array_rand($settings['splash'])]; ?></p>
|
||||
<?php if (isset($_SESSION['username'])): ?>
|
||||
<hr>
|
||||
<form action="/post.php" method="post" class="input-form">
|
||||
<table>
|
||||
<tr>
|
||||
<td><b>title:</b></td>
|
||||
<td>
|
||||
<input name="title" type="text" required>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>message:</b></td>
|
||||
<td>
|
||||
<textarea name="message" cols="30" rows="6" wrap="soft" tabindex="4" maxlength="30:"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>file:</b></td>
|
||||
<td>
|
||||
<input name="upload" type="file" required>
|
||||
</td>
|
||||
</tr>
|
||||
<input type="hidden" name="board_code" value="<?php echo $settings['code']; ?>">
|
||||
<input type="hidden" name="type" value="new_thread">
|
||||
</table>
|
||||
<br>
|
||||
<button type="submit">post</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<hr>
|
||||
<b>(<a href="#">archive</a>) (<a href="#">catalog</a>)</b>
|
||||
<hr>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
|
@ -24,13 +24,13 @@ function display_header($title = "~chan") {
|
|||
<div class="box">
|
||||
<span>
|
||||
<b>boards:</b> (
|
||||
<a href="/boards/b/">b</a>
|
||||
<a href="board.php?code=b">b</a>
|
||||
/
|
||||
<a href="/boards/g/">g</a>
|
||||
<a href="board.php?code=g">g</a>
|
||||
/
|
||||
<a href="/boards/m/">m</a>
|
||||
<a href="board.php?code=mc">mc</a>
|
||||
/
|
||||
<a href="/boards/v/">v</a>
|
||||
<a href="board.php?code=v">v</a>
|
||||
)
|
||||
</span>
|
||||
<span>
|
||||
|
@ -46,7 +46,7 @@ function display_header($title = "~chan") {
|
|||
// i just decided to echo everything out here since the <?php ?\> syntax was ugly
|
||||
echo "<a href=\"/profile.php\">profile</a>";
|
||||
echo " / ";
|
||||
echo "<a href=\"logout.php\">log out</a>";
|
||||
echo "<a href=\"/logout.php\">log out</a>";
|
||||
echo " )";
|
||||
} else {
|
||||
echo "<a href=\"/register.php\">register</a>";
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
$USER_TABLE_SQL = "
|
||||
CREATE TABLE user ( id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(32) NOT NULL,
|
||||
password VARCHAR(64) NOT NULL,
|
||||
admin BOOL NOT NULL,
|
||||
registered DATE NOT NULL,
|
||||
last_login DATE,
|
||||
);";
|
||||
|
||||
$THREAD_TABLE_SQL = "
|
||||
CREATE TABLE thread ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
user_id INT NOT NULL,
|
||||
board VARCHAR(20) NOT NULL,
|
||||
posted DATETIME NOT NULL
|
||||
);";
|
||||
?>
|
10
logout.php
10
logout.php
|
@ -7,16 +7,6 @@ session_start();
|
|||
// Unset all of the session variables.
|
||||
$_SESSION = array();
|
||||
|
||||
// If it's desired to kill the session, also delete the session cookie.
|
||||
// Note: This will destroy the session, and not just the session data!
|
||||
if (ini_get("session.use_cookies")) {
|
||||
$params = session_get_cookie_params();
|
||||
setcookie(session_name(), '', time() - 42000,
|
||||
$params["path"], $params["domain"],
|
||||
$params["secure"], $params["httponly"]
|
||||
);
|
||||
}
|
||||
|
||||
// Finally, destroy the session.
|
||||
session_destroy();
|
||||
|
||||
|
|
Loading…
Reference in New Issue