From aab95da24def6a3d4579b1551c74d817f79ec10c Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Tue, 30 Nov 2010 19:59:35 +1100 Subject: Multi-board support. --- inc/display.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 6156e6cf..35110cd6 100644 --- a/inc/display.php +++ b/inc/display.php @@ -20,13 +20,14 @@ } function error($message) { + global $board; die(Element('page.html', Array( 'index'=>ROOT, 'title'=>'Error', 'subtitle'=>'An error has occured.', 'body'=>"
" . "

$message

" . - "

Go back.

" . + "

Go back.

" . "
" ))); } @@ -51,6 +52,8 @@ $this->filename = $filename; } public function build($index=false) { + global $board; + $built = '
' . '

'; @@ -75,14 +78,14 @@ $built .= ' No.' . + ' href="' . ROOT . $board['dir'] . DIR_RES . $this->thread . '.html' . '#' . $this->id . '">No.' . // JavaScript cite ''.$this->id.'' . '

'; // File info if(!empty($this->file)) { - $built .= '

File: ' . $this->file . ' (' . + $built .= '

File: ' . $this->file . ' (' . // Filesize format_bytes($this->filesize) . ', ' . // File dimensions @@ -95,7 +98,7 @@ // Filename $built .= ', ' . $this->filename . ')

' . // Thumbnail - ''; + ''; } // Body @@ -132,7 +135,9 @@ public function build($index=false) { - $built = '

File: ' . $this->file . ' (' . + global $board; + + $built = '

File: ' . $this->file . ' (' . // Filesize format_bytes($this->filesize) . ', ' . // File dimensions @@ -145,7 +150,7 @@ // Filename $built .= ', ' . $this->filename . ')

' . // Thumbnail - ''; + ''; $built .= '

'; @@ -170,11 +175,11 @@ $built .= ' No.' . + ' href="' . ROOT . $board['dir'] . DIR_RES . $this->id . '.html' . '#' . $this->id . '">No.' . // JavaScript cite - ''.$this->id.'' . + ''.$this->id.'' . // [Reply] - ($index ? '[Reply]' : '') . + ($index ? '[Reply]' : '') . '

'; // Body -- cgit v1.3 From d3526e020ad977c04387f4df964ec707307557f2 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Tue, 30 Nov 2010 20:41:57 +1100 Subject: Bug fix. --- inc/display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 35110cd6..1ce1e609 100644 --- a/inc/display.php +++ b/inc/display.php @@ -27,7 +27,7 @@ 'subtitle'=>'An error has occured.', 'body'=>"
" . "

$message

" . - "

Go back.

" . + (isset($board) ? "

Go back.

" : ''). "
" ))); } -- cgit v1.3 From 210563045dabebec3ef8a4f1c3823293659fdc8d Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Tue, 30 Nov 2010 23:15:05 +1100 Subject: Close SQL connection on error. --- inc/display.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 1ce1e609..c910e26c 100644 --- a/inc/display.php +++ b/inc/display.php @@ -21,6 +21,8 @@ function error($message) { global $board; + + if(function_exists('sql_close')) sql_close(); die(Element('page.html', Array( 'index'=>ROOT, 'title'=>'Error', -- cgit v1.3 From 84027c6d83d4a836ea362026df778b7507a9429e Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Wed, 1 Dec 2010 21:24:14 +1100 Subject: mod panel --- inc/config.php | 12 ++++++- inc/display.php | 14 ++++++++ inc/functions.php | 16 +++++++-- inc/instance-config.php | 14 ++++---- inc/user.php | 90 ++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 135 insertions(+), 11 deletions(-) (limited to 'inc/display.php') diff --git a/inc/config.php b/inc/config.php index 9dea8ad7..2c1e9dc8 100644 --- a/inc/config.php +++ b/inc/config.php @@ -23,8 +23,13 @@ define('TIME_COOKIE', 'arrived', true); // HASH_COOKIE contains an MD5 hash of TIME_COOKIE+SALT for verification. define('HASH_COOKIE', 'hash', true); + // Used for moderation login + define('MOD_COOKIE', 'mod', true); // Where to set the 'path' parameter to ROOT when creating cookies. Recommended. define('JAIL_COOKIES', true, true); + + // Whether or not to lock moderator sessions to the IP address that was logged in with. + define('MOD_LOCK_IP', true, true); // How long should the cookies last (in seconds) define('COOKIE_EXPIRE', 15778463, true); //6 months @@ -60,7 +65,12 @@ define('ERR_FILESIZE', 'Maximum file size: %maxsz% bytes
Your file\'s size: %filesz% bytes', true); define('ERR_MAXSIZE', 'The file was too big.', true); define('ERR_INVALIDZIP','Invalid archive!', true); - + + // Moderator errors + define('ERROR_INVALID', 'Invalid username and/or password.', true); + define('ERROR_INVALIDAFTER', 'Invalid username and/or password. Your user may have been deleted or changed.'); + define('ERROR_MALFORMED','Invalid/malformed cookies.', true); + // For resizing, max values define('THUMB_WIDTH', 200, true); define('THUMB_HEIGHT', 200, true); diff --git a/inc/display.php b/inc/display.php index c910e26c..29012046 100644 --- a/inc/display.php +++ b/inc/display.php @@ -34,6 +34,20 @@ ))); } + function loginForm($error=false, $username=false) { + if(function_exists('sql_close')) sql_close(); + die(Element('page.html', Array( + 'index'=>ROOT, + 'title'=>'Login', + 'body'=>Element('login.html', Array( + 'index'=>ROOT, + 'error'=>$error, + 'username'=>$username + ) + ) + ))); + } + class Post { public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename) { $this->id = $id; diff --git a/inc/functions.php b/inc/functions.php index 4a70da32..b20ed091 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -318,7 +318,7 @@ return $result; } - function buildThread($id) { + function buildThread($id, $return=false) { global $sql, $board; $id = round($id); @@ -335,7 +335,19 @@ } else { $thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'])); } - @file_put_contents($board['dir'] . DIR_RES . $id . '.html', Element('thread.html', Array('button'=>BUTTON_REPLY, 'board'=>$board, 'body'=>$thread->build(), 'post_url' => POST_URL, 'index' => ROOT, 'id' => $id))) or error("Couldn't write to file."); + $body = Element('thread.html', Array( + 'button'=>BUTTON_REPLY, + 'board'=>$board, + 'body'=>$thread->build(), + 'post_url' => POST_URL, + 'index' => ROOT, + 'id' => $id + )); + + if($return) + return $body; + else + @file_put_contents($board['dir'] . DIR_RES . $id . '.html', $body) or error("Couldn't write to file."); } mysql_free_result($query); } diff --git a/inc/instance-config.php b/inc/instance-config.php index 1ae82a3f..1c433a9c 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -8,16 +8,16 @@ * You can copy values from config.php (defaults) and paste them here. */ - /* + // Database stuff - define('MY_SERVER', 'localhost'); - define('MY_USER', ''); - define('MY_PASSWORD', ''); - define('MY_DATABASE', ''); + define('MY_SERVER', '127.0.0.1'); + define('MY_USER', 'imgboard'); + define('MY_PASSWORD', 'DF3uHz4vvhUM6rCq'); + define('MY_DATABASE', 'imgboard'); - define('ROOT', '/'); + define('ROOT', '/board/'); // define('FOO', 'bar'); - */ + ?> \ No newline at end of file diff --git a/inc/user.php b/inc/user.php index 2bdf5c05..05deb0e3 100644 --- a/inc/user.php +++ b/inc/user.php @@ -15,9 +15,97 @@ if(!isset($_COOKIE[HASH_COOKIE]) || !isset($_COOKIE[TIME_COOKIE]) || $_COOKIE[HASH_COOKIE] != md5($_COOKIE[TIME_COOKIE].SALT)) { $time = time(); setcookie(TIME_COOKIE, $time, time()+COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true); - setcookie(HASH_COOKIE, md5(time().SALT), time()+COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true); + setcookie(HASH_COOKIE, md5($time.SALT), $time+COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true); $user = Array('valid' => false, 'appeared' => $time); } else { $user = Array('valid' => true, 'appeared' => $_COOKIE[TIME_COOKIE]); } + + // 'false' means that the user is not logged in as a moderator + $mod = false; + + // Creates a small random string for validating moderators' cookies + function mkhash($length=12) { + // The method here isn't really important, + // but I think this generates a relatively + // unique string that looks cool. + // If you choose to change this, make sure it cannot include a ':' character. + return substr(base64_encode(sha1(rand() . time(), true)), 0, $length); + } + + function login($username, $password, $makehash=true) { + global $sql, $mod; + + // SHA1 password + if($makehash) { + $password = sha1($password); + } + + $res = mysql_query(sprintf( + "SELECT `id`,`type` FROM `mods` WHERE `username` = '%s' AND `password` = '%s' LIMIT 1", + mysql_real_escape_string($username), + $password + ), $sql) or error(mysql_error($sql)); + + if($user = mysql_fetch_array($res)) { + return $mod = Array( + 'id' => $user['id'], + 'type' => $user['type'], + 'username' => $username, + 'password' => $password, + 'hash' => mkhash() + ); + } else return false; + } + + function setCookies() { + global $mod; + if(!$mod) error('setCookies() was called for a non-moderator!'); + + // MOD_COOKIE contains username:hash + setcookie(MOD_COOKIE, $mod['username'] . ':' . $mod['hash'], time()+COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true); + + // Put $mod in the session + $_SESSION['mod'] = $mod; + + // Lock sessions to IP addresses + if(MOD_LOCK_IP) + $_SESSION['mod']['ip'] = $_SERVER['REMOTE_ADDR']; + } + + function destroyCookies() { + // Delete the cookies + setcookie(MOD_COOKIE, 'deleted', time()-COOKIE_EXPIRE, JAIL_COOKIES?ROOT:'/', null, false, true); + + // Unset the session + unset($_SESSION['mod']); + } + + if(isset($_COOKIE['mod']) && isset($_SESSION['mod']) && is_array($_SESSION['mod'])) { + // Should be username:session hash + $cookie = explode(':', $_COOKIE['mod']); + if(count($cookie) != 2) { + destroyCookies(); + error(ERROR_MALFORMED); + } + + // Validate session + if( $cookie[0] != $_SESSION['mod']['username'] || + $cookie[1] != $_SESSION['mod']['hash']) { + // Malformed cookies + destroyCookies(); + error(ERROR_MALFORMED); + } + + // Open connection + sql_open(); + + // Check username/password + if(!login($_SESSION['mod']['username'], $_SESSION['mod']['password'], false)) { + destroyCookies(); + error(ERROR_INVALIDAFTER); + } + + $mod = $_SESSION['mod']; + } ?> \ No newline at end of file -- cgit v1.3 From 3153ae01d424dcc157539ad41da2db510fbc9945 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 10 Dec 2010 21:14:45 +1100 Subject: Ability to show poster IP addresses to moderators --- inc/display.php | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 29012046..25fbc6ba 100644 --- a/inc/display.php +++ b/inc/display.php @@ -49,7 +49,7 @@ } class Post { - public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename) { + public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $root=ROOT) { $this->id = $id; $this->thread = $thread; $this->subject = utf8tohtml($subject); @@ -66,9 +66,11 @@ $this->filey = $filey; $this->filesize = $filesize; $this->filename = $filename; + $this->ip = $ip; + $this->root = $root; } public function build($index=false) { - global $board; + global $board, $mod; $built = '
' . '

'; @@ -84,6 +86,11 @@ // Trip . (!empty($this->trip) ? ' '.$this->trip.'':''); + // IP Address + if($mod && $mod['type'] >= MOD_SHOW_IP) { + $built .= ' [' . $this->ip . ']'; + } + // End email if(!empty($this->email)) $built .= ''; @@ -94,14 +101,14 @@ $built .= ' No.' . + ' href="' . $this->root . $board['dir'] . DIR_RES . $this->thread . '.html' . '#' . $this->id . '">No.' . // JavaScript cite - ''.$this->id.'' . + ''.$this->id.'' . '

'; // File info if(!empty($this->file)) { - $built .= '

File: ' . $this->file . ' (' . + $built .= '

File: ' . $this->file . ' (' . // Filesize format_bytes($this->filesize) . ', ' . // File dimensions @@ -114,7 +121,7 @@ // Filename $built .= ', ' . $this->filename . ')

' . // Thumbnail - ''; + ''; } // Body @@ -126,7 +133,7 @@ class Thread { public $omitted = 0; - public function __construct($id, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename) { + public function __construct($id, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $root=ROOT) { $this->id = $id; $this->subject = utf8tohtml($subject); $this->email = $email; @@ -144,6 +151,8 @@ $this->filename = $filename; $this->omitted = 0; $this->posts = Array(); + $this->ip = $ip; + $this->root = $root; } public function add(Post $post) { $this->posts[] = $post; @@ -151,9 +160,9 @@ public function build($index=false) { - global $board; + global $board, $mod; - $built = '

File: ' . $this->file . ' (' . + $built = '

File: ' . $this->file . ' (' . // Filesize format_bytes($this->filesize) . ', ' . // File dimensions @@ -166,7 +175,7 @@ // Filename $built .= ', ' . $this->filename . ')

' . // Thumbnail - ''; + ''; $built .= '

'; @@ -181,6 +190,11 @@ // Trip . (!empty($this->trip) ? ' '.$this->trip.'':''); + // IP Address + if($mod && $mod['type'] >= MOD_SHOW_IP) { + $built .= ' [' . $this->ip . ']'; + } + // End email if(!empty($this->email)) $built .= ''; @@ -191,11 +205,11 @@ $built .= ' No.' . + ' href="' . $this->root . $board['dir'] . DIR_RES . $this->id . '.html' . '#' . $this->id . '">No.' . // JavaScript cite - ''.$this->id.'' . + ''.$this->id.'' . // [Reply] - ($index ? '[Reply]' : '') . + ($index ? '[Reply]' : '') . '

'; // Body -- cgit v1.3 From dcaeb7a81a39d9d0274dac0d3a389cb1e0b6954a Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 10 Dec 2010 21:22:46 +1100 Subject: Fixed links for mod pages --- inc/display.php | 8 ++++---- inc/functions.php | 6 +++--- mod.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 25fbc6ba..83b1d3bf 100644 --- a/inc/display.php +++ b/inc/display.php @@ -108,7 +108,7 @@ // File info if(!empty($this->file)) { - $built .= '

File: ' . $this->file . ' (' . + $built .= '

File: ' . $this->file . ' (' . // Filesize format_bytes($this->filesize) . ', ' . // File dimensions @@ -121,7 +121,7 @@ // Filename $built .= ', ' . $this->filename . ')

' . // Thumbnail - ''; + ''; } // Body @@ -162,7 +162,7 @@ public function build($index=false) { global $board, $mod; - $built = '

File: ' . $this->file . ' (' . + $built = '

File: ' . $this->file . ' (' . // Filesize format_bytes($this->filesize) . ', ' . // File dimensions @@ -175,7 +175,7 @@ // Filename $built .= ', ' . $this->filename . ')

' . // Thumbnail - ''; + ''; $built .= '

'; diff --git a/inc/functions.php b/inc/functions.php index c6ef451e..4c3f281a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -135,7 +135,7 @@ } } - function index($page) { + function index($page, $mod) { global $sql, $board; $body = ''; @@ -151,7 +151,7 @@ if(mysql_num_rows($query) < 1 && $page > 1) return false; while($th = mysql_fetch_array($query)) { - $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip']); + $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $mod ? '?/' : null); $newposts = mysql_query(sprintf( "SELECT `id`, `subject`, `email`, `name`, `trip`, `body`, `time`, `thumb`, `thumbwidth`, `thumbheight`, `file`, `filewidth`, `fileheight`, `filesize`, `filename`,`ip` FROM `posts_%s` WHERE `thread` = '%s' ORDER BY `time` DESC LIMIT %d", @@ -173,7 +173,7 @@ unset($omitted); } while($po = mysql_fetch_array($newposts)) { - $thread->add(new Post($po['id'], $th['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['body'], $po['time'], $po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'], $po['filename'], $po['ip'])); + $thread->add(new Post($po['id'], $th['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['body'], $po['time'], $po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'], $po['filename'], $po['ip'], $mod ? '?/' : null)); } mysql_free_result($newposts); diff --git a/mod.php b/mod.php index ab59d43e..6fe71720 100644 --- a/mod.php +++ b/mod.php @@ -157,7 +157,7 @@ if(!openBoard($boardName)) error(ERROR_NOBOARD); - $page = index(1); + $page = index(1, true); $page['mod'] = true; echo Element('index.html', $page); -- cgit v1.3 From 409ee49ed35728b68279e290a3661a2b35b24c5f Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 10 Dec 2010 21:24:54 +1100 Subject: Fixed a small bug with the quote links on index pages --- inc/display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 83b1d3bf..a5bb1c70 100644 --- a/inc/display.php +++ b/inc/display.php @@ -103,7 +103,7 @@ ($index?'':' onclick="highlightReply(' . $this->id . ');"') . ' href="' . $this->root . $board['dir'] . DIR_RES . $this->thread . '.html' . '#' . $this->id . '">No.' . // JavaScript cite - ''.$this->id.'' . + ''.$this->id.'' . '

'; // File info -- cgit v1.3 From 5adfff925b144161c840f63ebb271c11c3c0c883 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Mon, 13 Dec 2010 02:44:43 +1100 Subject: Post moderation controls --- inc/config.php | 23 ++++++++++++++++++++++- inc/display.php | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) (limited to 'inc/display.php') diff --git a/inc/config.php b/inc/config.php index 2d2dddf6..e3080316 100644 --- a/inc/config.php +++ b/inc/config.php @@ -143,8 +143,29 @@ define('MOD_MOD', 1, true); define('MOD_ADMIN', 2, true); - // What level of administration you need to view IP addresses + // Permissions + // What level of administration you need to: + + // View IP addresses define('MOD_SHOW_IP', MOD_MOD, true); + // Delete a post + define('MOD_DELETE', MOD_JANITOR, true); + // Ban a user for a post + define('MOD_BAN', MOD_MOD, true); + // Ban and delete (one click; instant) + define('MOD_BANDELETE', MOD_BAN, true); + // Delete file (and keep post) + define('MOD_DELETEFILE', MOD_JANITOR, true); + // Delete all posts by IP + define('MOD_DELETEBYIP', MOD_BAN, true); + + // Mod links (full HTML) + // Correspond to above permission directives + define('MOD_LINK_DELETE', '[D]', true); + define('MOD_LINK_BAN', '[B]', true); + define('MOD_LINK_BANDELETE', '[B&D]', true); + define('MOD_LINK_DELETEFILE', '[F]', true); + define('MOD_LINK_DELETEBYIP', '[D+]', true); // A small file in the main directory indicating that the script has been ran and the board(s) have been generated. // This keeps the script from querying the database and causing strain when not needed. diff --git a/inc/display.php b/inc/display.php index a5bb1c70..b8a58e2b 100644 --- a/inc/display.php +++ b/inc/display.php @@ -119,9 +119,38 @@ $built .= ', ' . $fraction; } // Filename - $built .= ', ' . $this->filename . ')

' . + $built .= ', ' . $this->filename . ')

' . + // Thumbnail - ''; + ''; + } + + if($mod) { + // Mod controls (on posts) + $built .= '

'; + + // Delete + if($mod['type'] >= MOD_DELETE) + $built .= ' ' . MOD_LINK_DELETE . ''; + + // Delete all posts by IP + if($mod['type'] >= MOD_DELETEBYIP) + $built .= ' ' . MOD_LINK_DELETEBYIP . ''; + + // Ban + if($mod['type'] >= MOD_BAN) + $built .= ' ' . MOD_LINK_BAN . ''; + + // Ban & Delete + if($mod['type'] >= MOD_BANDELETE) + $built .= ' ' . MOD_LINK_BANDELETE . ''; + + // Delete file (keep post) + if($mod['type'] >= MOD_DELETEFILE) + $built .= ' ' . MOD_LINK_DELETEFILE . ''; + + + $built .= '

'; } // Body -- cgit v1.3 From be1f1192279772f83454d5c543ecc51b242dd08d Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Thu, 16 Dec 2010 17:04:10 +1100 Subject: Mod controls for OP --- inc/display.php | 76 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 28 deletions(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index b8a58e2b..b0980fa3 100644 --- a/inc/display.php +++ b/inc/display.php @@ -48,6 +48,50 @@ ))); } + function postControls($id, $thread=false) { + global $mod; + + $built = ''; + if($mod) { + // Mod controls (on posts) + if($thread) { + $built .= ''; + } else { + $built .= ''; + } + + // Delete + if($mod['type'] >= MOD_DELETE) + $built .= ' ' . MOD_LINK_DELETE . ''; + + // Delete all posts by IP + if($mod['type'] >= MOD_DELETEBYIP) + $built .= ' ' . MOD_LINK_DELETEBYIP . ''; + + // Ban + if($mod['type'] >= MOD_BAN) + $built .= ' ' . MOD_LINK_BAN . ''; + + // Ban & Delete + if($mod['type'] >= MOD_BANDELETE) + $built .= ' ' . MOD_LINK_BANDELETE . ''; + + // Delete file (keep post) + if(!$thread && $mod['type'] >= MOD_DELETEFILE) + $built .= ' ' . MOD_LINK_DELETEFILE . ''; + + if($thread) { + // Delete file (keep post) + if($mod['type'] >= MOD_STICKY) + $built .= ' ' . MOD_LINK_STICKY . ''; + + } + + $built .= ''; + } + return $built; + } + class Post { public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $root=ROOT) { $this->id = $id; @@ -125,33 +169,7 @@ ''; } - if($mod) { - // Mod controls (on posts) - $built .= '

'; - - // Delete - if($mod['type'] >= MOD_DELETE) - $built .= ' ' . MOD_LINK_DELETE . ''; - - // Delete all posts by IP - if($mod['type'] >= MOD_DELETEBYIP) - $built .= ' ' . MOD_LINK_DELETEBYIP . ''; - - // Ban - if($mod['type'] >= MOD_BAN) - $built .= ' ' . MOD_LINK_BAN . ''; - - // Ban & Delete - if($mod['type'] >= MOD_BANDELETE) - $built .= ' ' . MOD_LINK_BANDELETE . ''; - - // Delete file (keep post) - if($mod['type'] >= MOD_DELETEFILE) - $built .= ' ' . MOD_LINK_DELETEFILE . ''; - - - $built .= '

'; - } + $built .= postControls($this->id); // Body $built .= '

' . $this->body . '


'; @@ -239,8 +257,10 @@ ''.$this->id.'' . // [Reply] ($index ? '[Reply]' : '') . + // Mod controls + postControls($this->id, true) . '

'; - + // Body $built .= $this->body . -- cgit v1.3 From b0bee3556f7932949a929c0077c454314d5dbb42 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Thu, 16 Dec 2010 22:48:54 +1100 Subject: Made HTML valid in mod controls --- inc/display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index b0980fa3..a485f906 100644 --- a/inc/display.php +++ b/inc/display.php @@ -74,7 +74,7 @@ // Ban & Delete if($mod['type'] >= MOD_BANDELETE) - $built .= ' ' . MOD_LINK_BANDELETE . ''; + $built .= ' ' . MOD_LINK_BANDELETE . ''; // Delete file (keep post) if(!$thread && $mod['type'] >= MOD_DELETEFILE) -- cgit v1.3 From 627c6ac91a338cfbd9fcc618b28dd678902da8f7 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Thu, 16 Dec 2010 23:08:52 +1100 Subject: Stickies --- inc/config.php | 5 +++++ inc/display.php | 7 +++++-- inc/functions.php | 6 +++--- style.css | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) (limited to 'inc/display.php') diff --git a/inc/config.php b/inc/config.php index 78b78403..4e48b6d5 100644 --- a/inc/config.php +++ b/inc/config.php @@ -72,6 +72,7 @@ define('ERROR_INVALIDFIELD', 'The %s field was invalid.', true); define('ERROR_NOACCESS', 'You don\'t have permission to do that.', true); define('ERROR_INVALIDPOST', 'That post doesn\'t exist…', true); + define('ERROR_404', 'Page not found.', true); // For resizing, max values define('THUMB_WIDTH', 200, true); @@ -129,6 +130,10 @@ // "302" is recommended. define('REDIRECT_HTTP', 302, true); + // Static images + // These can be URLs OR base64 (data URI scheme) + define('IMAGE_STICKY', 'data:image/gif;base64,R0lGODlhEgASAIcAACM8mR5BnAFPowNVpwBZqQBerhNPpRpLoxhSqABgrwBksgFvughltA5ttwBwuwR0vyN2vDdosDJ9tQB6wkJqtGN2tgODyweR1QCZ3gGc3wiR1ROr6SGGyCqJyDqEwjaX0Das4j256GaFu22Fs0qFwkyNx1mLxEun2k264lO76V+45WSezW2Vx2+fzGCrxWW30X6/5oaIvo+rvqidtr29vo+RwIWj0ISp1KSn0aG337euxbGwxry71KW84LbMvJLLzZDK1ZDI2Y3S76fJ5qbK6KrP6K3U7aDd8bzI6Mu6vMC/z83NwtDO39PW2drd0cPO7tXW5tje7MXk9t7u4+LJw+bX1ezhz+Hg8uDr9Obw+PHo6v//7gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAMAAFsALAAAAAASABIAAAieALcIHEiwoMGDRT6ckHLQYJYhRixcENKQIBYiUmBowHCkYRQWLVZ0AJFCBYYNB6FUiGCixAILFjRkCHEwxhUbAxI4mHCAA4opB2vk6EGigIMHB4JUVEIBwg0PCxYYAFJxywgBBBo4YBDgRVUtIgYoWAAAwY+qSHDIkHAAgIuqT3ZYEejDR1UmM5xUJZhEx5K9A6nwoAF4YJUmhRMXDAgAOw==', true); + /* Mod stuff */ diff --git a/inc/display.php b/inc/display.php index a485f906..8cf4a18e 100644 --- a/inc/display.php +++ b/inc/display.php @@ -180,7 +180,7 @@ class Thread { public $omitted = 0; - public function __construct($id, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $root=ROOT) { + public function __construct($id, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $root=ROOT) { $this->id = $id; $this->subject = utf8tohtml($subject); $this->email = $email; @@ -199,13 +199,13 @@ $this->omitted = 0; $this->posts = Array(); $this->ip = $ip; + $this->sticky = $sticky; $this->root = $root; } public function add(Post $post) { $this->posts[] = $post; } - public function build($index=false) { global $board, $mod; @@ -255,8 +255,11 @@ ' href="' . $this->root . $board['dir'] . DIR_RES . $this->id . '.html' . '#' . $this->id . '">No.' . // JavaScript cite ''.$this->id.'' . + // Sticky + ($this->sticky ? '' : '') . // [Reply] ($index ? '[Reply]' : '') . + // Mod controls postControls($this->id, true) . '

'; diff --git a/inc/functions.php b/inc/functions.php index 04340be1..fd87de43 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -151,7 +151,7 @@ if(mysql_num_rows($query) < 1 && $page > 1) return false; while($th = mysql_fetch_array($query)) { - $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $mod ? '?/' : ROOT); + $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $th['sticky'], $mod ? '?/' : ROOT); $newposts = mysql_query(sprintf( "SELECT `id`, `subject`, `email`, `name`, `trip`, `body`, `time`, `thumb`, `thumbwidth`, `thumbheight`, `file`, `filewidth`, `fileheight`, `filesize`, `filename`,`ip` FROM `posts_%s` WHERE `thread` = '%s' ORDER BY `time` DESC LIMIT %d", @@ -341,7 +341,7 @@ $id = round($id); $query = mysql_query(sprintf( - "SELECT `id`,`thread`,`subject`,`name`,`email`,`trip`,`body`,`time`,`thumb`,`thumbwidth`,`thumbheight`,`file`,`filewidth`,`fileheight`,`filesize`,`filename`,`ip` FROM `posts_%s` WHERE (`thread` IS NULL AND `id` = '%d') OR `thread` = '%d' ORDER BY `thread`,`time`", + "SELECT `id`,`thread`,`subject`,`name`,`email`,`trip`,`body`,`time`,`thumb`,`thumbwidth`,`thumbheight`,`file`,`filewidth`,`fileheight`,`filesize`,`filename`,`ip`,`sticky` FROM `posts_%s` WHERE (`thread` IS NULL AND `id` = '%d') OR `thread` = '%d' ORDER BY `thread`,`time`", mysql_real_escape_string($board['uri']), $id, $id @@ -349,7 +349,7 @@ while($post = mysql_fetch_array($query)) { if(!isset($thread)) { - $thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $mod ? '?/' : ROOT); + $thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $mod ? '?/' : ROOT); } else { $thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $mod ? '?/' : ROOT)); } diff --git a/style.css b/style.css index bc6314c0..d7646c5d 100644 --- a/style.css +++ b/style.css @@ -111,6 +111,12 @@ div.post img { padding: 5px; margin: 5px 20px 0 0; } +div.post img.icon { + display: inline; + float: none; + margin: 0 5px; + padding: 0; +} div.post.op { margin-right: 20px; margin-bottom: 5px; -- cgit v1.3 From 9554291802cb8ac712ba25d1a59ced31d20b07f0 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 17 Dec 2010 02:20:16 +1100 Subject: Mod controls and permissions --- inc/config.php | 8 ++++ inc/display.php | 116 ++++++++++++++++++++++++++++++++++---------------------- inc/mod.php | 8 ++-- mod.php | 25 +++++++++--- 4 files changed, 101 insertions(+), 56 deletions(-) (limited to 'inc/display.php') diff --git a/inc/config.php b/inc/config.php index 4e48b6d5..8f265a78 100644 --- a/inc/config.php +++ b/inc/config.php @@ -152,6 +152,7 @@ // Permissions // What level of administration you need to: + /* Post Controls */ // View IP addresses define('MOD_SHOW_IP', MOD_MOD, true); // Delete a post @@ -167,6 +168,12 @@ // Sticky a thread define('MOD_STICKY', MOD_MOD, true); + /* Administration */ + // Display the contents of instant-config.php + define('MOD_SHOW_CONFIG', MOD_ADMIN, true); + // Create a new board + define('MOD_NEWBOARD', MOD_ADMIN, true); + // Mod links (full HTML) // Correspond to above permission directives define('MOD_LINK_DELETE', '[D]', true); @@ -175,6 +182,7 @@ define('MOD_LINK_DELETEFILE', '[F]', true); define('MOD_LINK_DELETEBYIP', '[D+]', true); define('MOD_LINK_STICKY', '[Sticky]', true); + define('MOD_LINK_DESTICKY', '[-Sticky]', true); // A small file in the main directory indicating that the script has been ran and the board(s) have been generated. // This keeps the script from querying the database and causing strain when not needed. diff --git a/inc/display.php b/inc/display.php index 8cf4a18e..5dbccc8f 100644 --- a/inc/display.php +++ b/inc/display.php @@ -48,50 +48,6 @@ ))); } - function postControls($id, $thread=false) { - global $mod; - - $built = ''; - if($mod) { - // Mod controls (on posts) - if($thread) { - $built .= ''; - } else { - $built .= ''; - } - - // Delete - if($mod['type'] >= MOD_DELETE) - $built .= ' ' . MOD_LINK_DELETE . ''; - - // Delete all posts by IP - if($mod['type'] >= MOD_DELETEBYIP) - $built .= ' ' . MOD_LINK_DELETEBYIP . ''; - - // Ban - if($mod['type'] >= MOD_BAN) - $built .= ' ' . MOD_LINK_BAN . ''; - - // Ban & Delete - if($mod['type'] >= MOD_BANDELETE) - $built .= ' ' . MOD_LINK_BANDELETE . ''; - - // Delete file (keep post) - if(!$thread && $mod['type'] >= MOD_DELETEFILE) - $built .= ' ' . MOD_LINK_DELETEFILE . ''; - - if($thread) { - // Delete file (keep post) - if($mod['type'] >= MOD_STICKY) - $built .= ' ' . MOD_LINK_STICKY . ''; - - } - - $built .= ''; - } - return $built; - } - class Post { public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $root=ROOT) { $this->id = $id; @@ -113,6 +69,39 @@ $this->ip = $ip; $this->root = $root; } + public function postControls() { + global $mod; + + $built = ''; + if($mod) { + // Mod controls (on posts) + $built .= ''; + + // Delete + if($mod['type'] >= MOD_DELETE) + $built .= ' ' . MOD_LINK_DELETE . ''; + + // Delete all posts by IP + if($mod['type'] >= MOD_DELETEBYIP) + $built .= ' ' . MOD_LINK_DELETEBYIP . ''; + + // Ban + if($mod['type'] >= MOD_BAN) + $built .= ' ' . MOD_LINK_BAN . ''; + + // Ban & Delete + if($mod['type'] >= MOD_BANDELETE) + $built .= ' ' . MOD_LINK_BANDELETE . ''; + + // Delete file (keep post) + if($mod['type'] >= MOD_DELETEFILE) + $built .= ' ' . MOD_LINK_DELETEFILE . ''; + + $built .= ''; + } + return $built; + } + public function build($index=false) { global $board, $mod; @@ -169,7 +158,7 @@ ''; } - $built .= postControls($this->id); + $built .= $this->postControls(); // Body $built .= '

' . $this->body . '


'; @@ -205,6 +194,41 @@ public function add(Post $post) { $this->posts[] = $post; } + public function postControls() { + global $mod; + + $built = ''; + if($mod) { + // Mod controls (on posts) + $built .= ''; + + // Delete + if($mod['type'] >= MOD_DELETE) + $built .= ' ' . MOD_LINK_DELETE . ''; + + // Delete all posts by IP + if($mod['type'] >= MOD_DELETEBYIP) + $built .= ' ' . MOD_LINK_DELETEBYIP . ''; + + // Ban + if($mod['type'] >= MOD_BAN) + $built .= ' ' . MOD_LINK_BAN . ''; + + // Ban & Delete + if($mod['type'] >= MOD_BANDELETE) + $built .= ' ' . MOD_LINK_BANDELETE . ''; + + // Delete file (keep post) + if($mod['type'] >= MOD_STICKY) + if($this->sticky) + $built .= ' ' . MOD_LINK_DESTICKY . ''; + else + $built .= ' ' . MOD_LINK_STICKY . ''; + + $built .= ''; + } + return $built; + } public function build($index=false) { global $board, $mod; @@ -261,7 +285,7 @@ ($index ? '[Reply]' : '') . // Mod controls - postControls($this->id, true) . + $this->postControls() . '

'; // Body diff --git a/inc/mod.php b/inc/mod.php index 200ffa20..b5e773f5 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -85,11 +85,11 @@ } // Generates a