diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2010-11-30 20:40:37 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2010-11-30 20:40:37 +1100 |
| commit | 58b25f319c7370372065fe883ed41654d31f550c (patch) | |
| tree | c0339deec5aa3ebb7018ceffdd070428334cd186 | |
| parent | d80cca13c0447b0d5dce11ad8981e705fe8d797d (diff) | |
Multi-board support.
| -rw-r--r-- | post.php | 47 |
1 files changed, 27 insertions, 20 deletions
@@ -8,20 +8,6 @@ require 'inc/template.php'; require 'inc/user.php'; - // For example, we're on /b/ - $board = Array( - 'id' => 1, - 'uri' => 'b', - 'name' => 'Beta', - 'title' => 'In development.'); - $board['dir'] = sprintf(BOARD_PATH, $board['uri']); - $board['url'] = sprintf(BOARD_ABBREVIATION, $board['uri']); - - if(!file_exists($board['dir'])) mkdir($board['dir'], 0777); - if(!file_exists($board['dir'] . DIR_IMG)) mkdir($board['dir'] . DIR_IMG, 0777); - if(!file_exists($board['dir'] . DIR_THUMB)) mkdir($board['dir'] . DIR_THUMB, 0777); - if(!file_exists($board['dir'] . DIR_RES)) mkdir($board['dir'] . DIR_RES, 0777); - $body = ''; // Fix for magic quotes @@ -40,6 +26,7 @@ !isset($_POST['email']) || !isset($_POST['subject']) || !isset($_POST['body']) || + !isset($_POST['board']) || !isset($_POST['password']) ) error(ERROR_BOT); @@ -59,8 +46,6 @@ if(!isset($_SERVER['HTTP_REFERER']) || !preg_match(URL_MATCH, $_SERVER['HTTP_REFERER'])) error(ERROR_BOT); } - - // TODO: Since we're now using static HTML files, we can't give them cookies on their first page view // Find another anti-spam method. @@ -95,6 +80,8 @@ 'maxsz'=>commaize(MAX_FILESIZE)))); } + if(!openBoard($post['board'])) error(ERROR_NOBOARD); + $trip = generate_tripcode($post['name']); $post['name'] = $trip[0]; $post['trip'] = (isset($trip[1])?$trip[1]:''); @@ -320,11 +307,31 @@ exit; } else { - if(!file_exists(FILE_INDEX)) { - buildIndex(); + if(!file_exists(HAS_INSTALLED)) { + sql_open(); + + // Build all boards + $boards_res = mysql_query('SELECT * FROM `boards`', $sql) or error(mysql_error($sql)); + while($_board = mysql_fetch_array($boards_res)) { + setupBoard($_board); + buildIndex(); + } + + sql_close(); + touch(HAS_INSTALLED, 0777); + + die(Element('page.html', Array( + 'index'=>ROOT, + 'title'=>'Success', + 'body'=>"<center>" . + "<h2>Tinyboard is now installed!</h2>" . + "</center>" + ))); + } else { + // They opened post.php in their browser manually. + // Possible TODO: Redirect back to homepage. + error(ERROR_NOPOST); } - - header('Location: ' . ROOT . FILE_INDEX, true, 302); } ?> |
