1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-14 10:57:38 +01:00
This commit is contained in:
Savetheinternet 2011-02-16 14:44:42 +11:00
parent 532cebddfa
commit 44d280e120

View File

@ -34,23 +34,23 @@
} }
function setCookies() { function setCookies() {
global $mod; global $mod, $config;
if(!$mod) error('setCookies() was called for a non-moderator!'); if(!$mod) error('setCookies() was called for a non-moderator!');
// MOD_COOKIE contains username:hash // $config['cookies']['mod'] contains username:hash
setcookie(MOD_COOKIE, $mod['username'] . ':' . $mod['hash'], time()+COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true); setcookie($config['cookies']['mod'], $mod['username'] . ':' . $mod['hash'], time()+$config['cookies']['expire'], $config['cookies']['jail']?$config['root']:'/', null, false, true);
// Put $mod in the session // Put $mod in the session
$_SESSION['mod'] = $mod; $_SESSION['mod'] = $mod;
// Lock sessions to IP addresses // Lock sessions to IP addresses
if(MOD_LOCK_IP) if($mod['lock_ip'])
$_SESSION['mod']['ip'] = $_SERVER['REMOTE_ADDR']; $_SESSION['mod']['ip'] = $_SERVER['REMOTE_ADDR'];
} }
function destroyCookies() { function destroyCookies() {
// Delete the cookies // Delete the cookies
setcookie(MOD_COOKIE, 'deleted', time()-COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true); setcookie($config['cookies']['mod'], 'deleted', time()-$config['cookies']['expire'], $config['cookies']['jail']?$config['root']:'/', null, false, true);
// Unset the session // Unset the session
unset($_SESSION['mod']); unset($_SESSION['mod']);
@ -71,7 +71,7 @@
$cookie = explode(':', $_COOKIE['mod']); $cookie = explode(':', $_COOKIE['mod']);
if(count($cookie) != 2) { if(count($cookie) != 2) {
destroyCookies(); destroyCookies();
error(ERROR_MALFORMED); error($config['error']['malformed']);
} }
// Validate session // Validate session
@ -79,7 +79,7 @@
$cookie[1] != $_SESSION['mod']['hash']) { $cookie[1] != $_SESSION['mod']['hash']) {
// Malformed cookies // Malformed cookies
destroyCookies(); destroyCookies();
error(ERROR_MALFORMED); error($config['error']['malformed']);
} }
// Open connection // Open connection
@ -88,7 +88,7 @@
// Check username/password // Check username/password
if(!login($_SESSION['mod']['username'], $_SESSION['mod']['password'], false)) { if(!login($_SESSION['mod']['username'], $_SESSION['mod']['password'], false)) {
destroyCookies(); destroyCookies();
error(ERROR_INVALIDAFTER); error($config['error']['invalidafter']);
} }
} }
@ -96,7 +96,7 @@
// Generates a <ul> element with a list of linked // Generates a <ul> element with a list of linked
// boards and their subtitles. (without the <ul> opening and ending tags) // boards and their subtitles. (without the <ul> opening and ending tags)
function ulBoards() { function ulBoards() {
global $mod; global $mod, $config;
$body = ''; $body = '';
@ -106,16 +106,16 @@
foreach($boards as &$b) { foreach($boards as &$b) {
$body .= '<li>' . $body .= '<li>' .
'<a href="?/' . '<a href="?/' .
sprintf(BOARD_PATH, $b['uri']) . FILE_INDEX . sprintf($config['board_path'], $b['uri']) . $config['file_index'] .
'">' . '">' .
sprintf(BOARD_ABBREVIATION, $b['uri']) . sprintf($config['board_abbreviation'], $b['uri']) .
'</a> - ' . '</a> - ' .
$b['title'] . $b['title'] .
(isset($b['subtitle']) ? '<span class="unimportant"> — ' . $b['subtitle'] . '</span>' : '') . (isset($b['subtitle']) ? '<span class="unimportant"> — ' . $b['subtitle'] . '</span>' : '') .
'</li>'; '</li>';
} }
if($mod['type'] >= MOD_NEWBOARD) { if($mod['type'] >= $config['mod']['newboard']) {
$body .= '<li style="margin-top:15px;"><a href="?/new"><strong>Create new board</strong></a></li>'; $body .= '<li style="margin-top:15px;"><a href="?/new"><strong>Create new board</strong></a></li>';
} }
return $body; return $body;