Source code of Leftypol imageboard
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.7 KiB

14 years ago
<?php
require 'inc/functions.php';
require 'inc/display.php';
if (file_exists('inc/instance-config.php')) {
require 'inc/instance-config.php';
}
require 'inc/config.php';
require 'inc/template.php';
require 'inc/user.php';
require 'inc/mod.php';
14 years ago
// If not logged in
14 years ago
if(!$mod) {
14 years ago
if(isset($_POST['login'])) {
// Check if inputs are set and not empty
if( !isset($_POST['username']) ||
!isset($_POST['password']) ||
empty($_POST['username']) ||
empty($_POST['password'])
) loginForm(ERROR_INVALID, $_POST['username']);
// Open connection
sql_open();
if(!login($_POST['username'], $_POST['password']))
loginForm(ERROR_INVALID, $_POST['username']);
// Login successful
// Set cookies
setCookies();
14 years ago
// Redirect
header('Location: ?' . MOD_DEFAULT, true, REDIRECT_HTTP);
14 years ago
14 years ago
// Close connection
sql_close();
} else {
loginForm();
}
} else {
$query = $_SERVER['QUERY_STRING'];
$regex = Array(
14 years ago
'board' => str_replace('%s', '(\w{1,8})', preg_quote(BOARD_PATH, '/'))
);
if(preg_match('/^\/?$/', $query)) {
14 years ago
// Dashboard
// Body
$body = '';
$body .= '<fieldset><legend>Boards</legend>' .
ulBoards() .
'</fieldset>';
die(Element('page.html', Array(
'index'=>ROOT,
'title'=>'Dashboard',
'body'=>$body
)
));
14 years ago
} elseif(preg_match('/^\/' . $regex['board'] . '(' . preg_quote(FILE_INDEX, '/') . ')?$/', $query, $matches)) {
// Board index
14 years ago
$boardName = $matches[1];
// Open board
openBoard($boardName);
14 years ago
echo Element('index.html', index(1));
} else {
14 years ago
error("Page not found.");
}
14 years ago
}
// Close the connection in-case it's still open
sql_close();
14 years ago
?>