Page handling

This commit is contained in:
Savetheinternet 2010-12-02 18:02:48 +11:00
parent 20fd2fc232
commit c327056f13

21
mod.php
View File

@ -9,7 +9,7 @@
require 'inc/user.php';
// If not logged in
if(!$user) {
if(!$mod) {
if(isset($_POST['login'])) {
// Check if inputs are set and not empty
if( !isset($_POST['username']) ||
@ -28,6 +28,9 @@
// Set cookies
setCookies();
// Redirect
header('Location: ?' . MOD_DEFAULT, true, 302);
// Close connection
sql_close();
} else {
@ -36,21 +39,25 @@
} else {
$query = $_SERVER['QUERY_STRING'];
$regex = Array(
'board' => str_replace('%s', '\w{1,8}', preg_quote(BOARD_PATH, '/'))
'board' => str_replace('%s', '(\w{1,8})', preg_quote(BOARD_PATH, '/'))
);
// Dashboard
if(preg_match('/^\/?$/', $query)) {
// Dashboard
// Board index
} elseif(preg_match('/^\/' . $regex['board'] . '(' . preg_quote(FILE_INDEX, '/') . ')?$/', $query)) {
} elseif(preg_match('/^\/' . $regex['board'] . '(' . preg_quote(FILE_INDEX, '/') . ')?$/', $query, $matches)) {
// Board index
$boardName = $matches[1];
// Open board
openBoard($boardName);
echo Element('index.html', index(1));
} else {
error("Page not found.");
error("Page not found.");
}
// The rest is not done yet...
}
?>