diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-04-12 23:23:47 +1000 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-04-12 23:23:47 +1000 |
| commit | 95709e7588b9fb5a2e43049e0157cedc254b2536 (patch) | |
| tree | e7732391f27c6789b00de0dad9b1b98d4d2d0b66 /inc | |
| parent | c39c54c2c2764596863e43a6d6ee4b07b52af327 (diff) | |
Removed `board`.`id`. Use the board URI/name at the key instead.
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/filters.php | 2 | ||||
| -rw-r--r-- | inc/functions.php | 25 | ||||
| -rw-r--r-- | inc/mod.php | 8 |
3 files changed, 19 insertions, 16 deletions
diff --git a/inc/filters.php b/inc/filters.php index b3a0ca43..68e948c9 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -100,7 +100,7 @@ class Filter { if($all_boards) $query->bindValue(':board', null, PDO::PARAM_NULL); else - $query->bindValue(':board', $board['id']); + $query->bindValue(':board', $board['uri']); $query->execute() or error(db_error($query)); diff --git a/inc/functions.php b/inc/functions.php index da58675c..e6f66b86 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -276,10 +276,10 @@ function setupBoard($array) { global $board, $config; $board = array( - 'id' => $array['id'], - 'uri' => $array['uri'], - 'name' => $array['title'], - 'title' => $array['subtitle']); + 'uri' => $array['uri'], + 'name' => $array['title'], + 'title' => $array['subtitle'] + ); $board['dir'] = sprintf($config['board_path'], $board['uri']); $board['url'] = sprintf($config['board_abbreviation'], $board['uri']); @@ -287,13 +287,16 @@ function setupBoard($array) { loadConfig(); if(!file_exists($board['dir'])) - mkdir($board['dir'], 0777) or error("Couldn't create " . $board['dir'] . ". Check permissions.", true); + @mkdir($board['dir'], 0777) or error("Couldn't create " . $board['dir'] . ". Check permissions.", true); if(!file_exists($board['dir'] . $config['dir']['img'])) - @mkdir($board['dir'] . $config['dir']['img'], 0777) or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true); + @mkdir($board['dir'] . $config['dir']['img'], 0777) + or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true); if(!file_exists($board['dir'] . $config['dir']['thumb'])) - @mkdir($board['dir'] . $config['dir']['thumb'], 0777) or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true); + @mkdir($board['dir'] . $config['dir']['thumb'], 0777) + or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true); if(!file_exists($board['dir'] . $config['dir']['res'])) - @mkdir($board['dir'] . $config['dir']['res'], 0777) or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true); + @mkdir($board['dir'] . $config['dir']['res'], 0777) + or error("Couldn't create " . $board['dir'] . $config['dir']['img'] . ". Check permissions.", true); } function openBoard($uri) { @@ -567,12 +570,12 @@ function checkBan($board = 0) { if(event('check-ban', $board)) return true; - $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `uri`, `bans`.`id` FROM `bans` LEFT JOIN `boards` ON `boards`.`id` = `board` WHERE (`board` IS NULL OR `uri` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1"); + $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1"); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':board', $board); $query->execute() or error(db_error($query)); if($query->rowCount() < 1 && $config['ban_range']) { - $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `uri`, `bans`.`id` FROM `bans` LEFT JOIN `boards` ON `boards`.`id` = `board` WHERE (`board` IS NULL OR `uri` = :board) AND :ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!' ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1"); + $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND :ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!' ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1"); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':board', $board); $query->execute() or error(db_error($query)); @@ -580,7 +583,7 @@ function checkBan($board = 0) { if($query->rowCount() < 1 && $config['ban_cidr'] && !isIPv6()) { // my most insane SQL query yet - $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `uri`, `bans`.`id` FROM `bans` LEFT JOIN `boards` ON `boards`.`id` = `board` WHERE (`board` IS NULL OR `uri` = :board) + $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `bans`.`id` FROM `bans` WHERE (`board` IS NULL OR `board` = :board) AND ( `ip` REGEXP '^(\[0-9]+\.\[0-9]+\.\[0-9]+\.\[0-9]+\)\/(\[0-9]+)$' AND diff --git a/inc/mod.php b/inc/mod.php index de6e2e9a..1b52840c 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -96,7 +96,7 @@ function modLog($action, $_board=null) { if(isset($_board)) $query->bindValue(':board', $_board); elseif(isset($board)) - $query->bindValue(':board', $board['id']); + $query->bindValue(':board', $board['uri']); else $query->bindValue(':board', null, PDO::PARAM_NULL); $query->execute() or error(db_error($query)); @@ -125,7 +125,7 @@ function ulBoards() { $b['title'] . (isset($b['subtitle']) ? '<span class="unimportant"> — ' . $b['subtitle'] . '</span>' : '') . ($mod['type'] >= $config['mod']['manageboards'] ? - ' <a href="?/board/' . $b['uri'] . '" class="unimportant">[manage]</a>' : '') . + ' <a href="?/' . $b['uri'] . '/edit" class="unimportant">[manage]</a>' : '') . '</li>'; } @@ -139,10 +139,10 @@ function form_newBan($ip=null, $reason='', $continue=false, $delete=false, $boar global $config, $mod; $boards = listBoards(); - $__boards = '<li><input type="radio" checked="checked" name="board_id" id="board_*" value="-1"/> <label style="display:inline" for="board_*"><em>' . _('all boards') . '</em></label></li>'; + $__boards = '<li><input type="radio" checked="checked" name="board" id="board_*" value=""/> <label style="display:inline" for="board_*"><em>' . _('all boards') . '</em></label></li>'; foreach($boards as &$_board) { $__boards .= '<li>' . - '<input type="radio" name="board_id" id="board_' . $_board['uri'] . '" value="' . $_board['id'] . '">' . + '<input type="radio" name="board" id="board_' . $_board['uri'] . '" value="' . $_board['uri'] . '">' . '<label style="display:inline" for="board_' . $_board['uri'] . '"> ' . ($_board['uri'] == '*' ? '<em>"*"</em>' |
