tildechan/core/board.php

72 lines
1.6 KiB
PHP

<?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
}
?>