From a395805e580e07edef1d47eea43daf3fd92880d3 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Thu, 16 Dec 2010 17:04:52 +1100 Subject: Style for mod controls on posts --- style.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'style.css') diff --git a/style.css b/style.css index 8d8bae1c..bc6314c0 100644 --- a/style.css +++ b/style.css @@ -167,4 +167,17 @@ span.omitted { } br.clear { clear: left; +} +span.controls { + float: right; + margin: 0; + padding: 0; + font-size: 80%; +} +span.controls.op { + float: none; + margin-left: 10px; +} +span.controls a { + margin: 0; } \ No newline at end of file -- 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 'style.css') 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 9c388687dc3d1297a85de453ff90520c24270662 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sun, 2 Jan 2011 01:52:22 +1100 Subject: Ban styling --- style.css | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'style.css') diff --git a/style.css b/style.css index d7646c5d..0211e04e 100644 --- a/style.css +++ b/style.css @@ -186,4 +186,25 @@ span.controls.op { } span.controls a { margin: 0; +} +div.ban { + background: white; + border: 1px solid #98E; + max-width: 700px; + margin: 30px auto; +} +div.ban p, div.ban h2 { + padding: 3px 7px; +} +div.ban h2 { + background: #98E; + color: black; + font-size: 12pt; +} +div.ban p { + font-size: 12px; + margin-bottom: 12px; +} +div.ban p.reason { + font-weight: bold; } \ No newline at end of file -- cgit v1.3 From f4c5ee88f24476f4ea9232942fb2c22272d0da1f Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sun, 2 Jan 2011 22:32:38 +1100 Subject: Mod controls styling --- style.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'style.css') diff --git a/style.css b/style.css index 0211e04e..ca26a8da 100644 --- a/style.css +++ b/style.css @@ -80,6 +80,18 @@ form table tr th { form table tr th { background: #98E; } +form table tr td div { + text-align: cetner; + float: left; + padding-left: 3px; +} +form table tr td div input { + display: block; + margin: 2px auto 0 auto; +} +form table tr td div label { + font-size: 10px; +} .unimportant, .unimportant * { font-size: 10px; } -- cgit v1.3 From 62bd2ee348f460b3d4cbbdbd8469a783b4c64c78 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Wed, 19 Jan 2011 00:41:43 +1100 Subject: A bunch of stuff. --- inc/config.php | 9 ++++++ inc/functions.php | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- inc/mod.php | 41 ------------------------- post.php | 9 ++++-- style.css | 10 ++++++ 5 files changed, 117 insertions(+), 44 deletions(-) (limited to 'style.css') diff --git a/inc/config.php b/inc/config.php index f3906b1b..746efb63 100644 --- a/inc/config.php +++ b/inc/config.php @@ -76,6 +76,7 @@ define('ERROR_LOCKED', 'Thread locked. You may not reply at this time.', true); define('ERROR_NOPOST', 'You didn\'t make a post.', true); define('ERROR_FLOOD', 'Flood detected; Post discared.', true); + define('ERROR_UNORIGINAL', 'Unoriginal content!', true); define('ERR_INVALIDIMG','Invalid image.', true); define('ERR_FILESIZE', 'Maximum file size: %maxsz% bytes
Your file\'s size: %filesz% bytes', true); define('ERR_MAXSIZE', 'The file was too big.', true); @@ -163,6 +164,12 @@ // "302" is recommended. define('REDIRECT_HTTP', 302, true); + // Robot stuff + // Strip repeating characters when making hashes + define('ROBOT_ENABLE', true, true); + define('ROBOT_STRIP_REPEATING', true, true); + + /* Mod stuff */ @@ -206,6 +213,8 @@ define('MOD_LOCK', MOD_MOD, true); // Post in a locked thread define('MOD_POSTINLOCKED', MOD_MOD, true); + // Post bypass unoriginal content check + define('MOD_POSTUNORIGINAL', MOD_MOD, true); /* Administration */ // Display the contents of instant-config.php diff --git a/inc/functions.php b/inc/functions.php index 70a17d23..4f4a69bd 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -261,7 +261,62 @@ $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); } - + + // Delete a post (reply or thread) + function deletePost($id) { + global $board; + + // Select post and replies (if thread) in one query + $query = prepare(sprintf("SELECT `id`,`thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id OR `thread` = :id", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + if($query->rowCount() < 1) { + error(ERROR_INVALIDPOST); + } + + // Delete posts and maybe replies + while($post = $query->fetch()) { + if(!$post['thread']) { + // Delete thread HTML page + @unlink($board['dir'] . DIR_RES . sprintf(FILE_PAGE, $post['id'])); + } elseif($query->rowCount() == 1) { + // Rebuild thread + $rebuild = $post['thread']; + } + if($post['thumb']) { + // Delete thumbnail + @unlink($board['dir'] . DIR_THUMB . $post['thumb']); + } + if($post['file']) { + // Delete file + @unlink($board['dir'] . DIR_IMG . $post['file']); + } + } + + $query = prepare(sprintf("DELETE FROM `posts_%s` WHERE `id` = :id OR `thread` = :id", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + if(isset($rebuild)) { + buildThread($rebuild); + } + } + + function clean() { + global $board; + $offset = round(MAX_PAGES*THREADS_PER_PAGE); + + // I too wish there was an easier way of doing this... + $query = prepare(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL ORDER BY `sticky` DESC, `bump` DESC LIMIT :offset, 9001", $board['uri'])); + $query->bindValue(':offset', $offset, PDO::PARAM_INT); + + $query->execute() or error(db_error($query)); + while($post = $query->fetch()) { + deletePost($post['id']); + } + } + function index($page, $mod=false) { global $board; @@ -323,7 +378,41 @@ return $pages; } + + function makerobot($body) { + $body = strtolower($body); + + // Leave only letters + $body = preg_replace('/[^a-z]/i', '', $body); + // Remove repeating characters + if(ROBOT_STRIP_REPEATING) + $body = preg_replace('/(.)\\1+/', '$1', $body); + + return sha1($body); + } + + function checkRobot($body) { + /* CREATE TABLE `robot` ( +`hash` VARCHAR( 40 ) NOT NULL COMMENT 'SHA1' +) ENGINE = INNODB; */ + + $body = makerobot($body); + $query = prepare("SELECT 1 FROM `robot` WHERE `hash` = :hash LIMIT 1"); + $query->bindValue(':hash', $body); + $query->execute() or error(db_error($query)); + if($query->fetch()) { + return true; + } else { + // Insert new hash + + $query = prepare("INSERT INTO `robot` VALUES (:hash)"); + $query->bindValue(':hash', $body); + $query->execute() or error(db_error($query)); + return false; + } + } + function buildIndex() { global $board; sql_open(); @@ -417,6 +506,7 @@ $body = preg_replace("/(^|\n)==(.+?)==\n?/m", "

$2

", $body); $body = preg_replace("/'''(.+?)'''/m", "$1", $body); $body = preg_replace("/''(.+?)''/m", "$1", $body); + $body = preg_replace("/\*\*(.+?)\*\*/m", "$1", $body); } $body = preg_replace("/\n/", '
', $body); } diff --git a/inc/mod.php b/inc/mod.php index a325d589..5e3a2c87 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -209,45 +209,4 @@ buildThread($post['thread']); } - - // Delete a post (reply or thread) - function deletePost($id) { - global $board; - - // Select post and replies (if thread) in one query - $query = prepare(sprintf("SELECT `id`,`thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id OR `thread` = :id", $board['uri'])); - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - - if($query->rowCount() < 1) { - error(ERROR_INVALIDPOST); - } - - // Delete posts and maybe replies - while($post = $query->fetch()) { - if(!$post['thread']) { - // Delete thread HTML page - @unlink($board['dir'] . DIR_RES . sprintf(FILE_PAGE, $post['id'])); - } elseif($query->rowCount() == 1) { - // Rebuild thread - $rebuild = $post['thread']; - } - if($post['thumb']) { - // Delete thumbnail - @unlink($board['dir'] . DIR_THUMB . $post['thumb']); - } - if($post['file']) { - // Delete file - @unlink($board['dir'] . DIR_IMG . $post['file']); - } - } - - $query = prepare(sprintf("DELETE FROM `posts_%s` WHERE `id` = :id OR `thread` = :id", $board['uri'])); - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - - if(isset($rebuild)) { - buildThread($rebuild); - } - } ?> \ No newline at end of file diff --git a/post.php b/post.php index 66247f4f..40830f0f 100644 --- a/post.php +++ b/post.php @@ -147,6 +147,9 @@ if(checkFlood($post)) error(ERROR_FLOOD); + if(!($mod && $mod['type'] >= MOD_POSTUNORIGINAL) && ROBOT_ENABLE && checkRobot($post['body'])) + error(ERROR_UNORIGINAL); + if($post['has_file']) { // Just trim the filename if it's too long if(strlen($post['filename']) > 30) $post['filename'] = substr($post['filename'], 0, 27).'…'; @@ -221,7 +224,6 @@ } // Todo: Validate some more, remove messy code, allow more specific configuration - $id = post($post, $OP); if($post['has_file'] && $post['zip']) { @@ -322,10 +324,13 @@ buildThread(($OP?$id:$post['thread'])); - if(!$OP) { + if(!$OP && $post['email'] != 'sage') { bumpThread($post['thread']); } + if($OP) + clean(); + buildIndex(); sql_close(); diff --git a/style.css b/style.css index ca26a8da..60c36d19 100644 --- a/style.css +++ b/style.css @@ -199,6 +199,10 @@ span.controls.op { span.controls a { margin: 0; } +div#wrap { + width: 900px; + margin:0 auto; +} div.ban { background: white; border: 1px solid #98E; @@ -219,4 +223,10 @@ div.ban p { } div.ban p.reason { font-weight: bold; +} +span.spoiler { + background: black; +} +span.spoiler:hover { + color: white; } \ No newline at end of file -- cgit v1.3 From c59f36f400eb718714154fa1ab125662bc7b89ea Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Wed, 19 Jan 2011 12:37:31 +1100 Subject: a bunch of things --- inc/config.php | 21 ++++++++++++++++++--- inc/functions.php | 35 ++++++++++++++++++++++++++++++++--- mod.php | 2 +- post.php | 45 ++++++++++++++++++++++++++++++++++++++++----- style.css | 4 ++++ templates/posts.sql | 2 +- templates/thread.html | 1 + 7 files changed, 97 insertions(+), 13 deletions(-) (limited to 'style.css') diff --git a/inc/config.php b/inc/config.php index 746efb63..65346edd 100644 --- a/inc/config.php +++ b/inc/config.php @@ -41,7 +41,8 @@ define('COOKIE_EXPIRE', 15778463, true); //6 months // Make this something long and random for security define('SALT', 'wefaw98YHEWUFuo', true); - + define('SECURE_TRIP_SALT', '@#$&^@#)$(*&@!_$(&329-8347', true); + // How many seconds before you can post, after the first visit define('LURKTIME', 30, true); @@ -51,6 +52,8 @@ define('FLOOD_TIME_IP_SAME', 120, true); // Same as above but different IP address define('FLOOD_TIME_SAME', 30, true); + // Do you need a body for your non-OP posts? + define('FORCE_BODY', true, true); // Max body length define('MAX_BODY', 1800, true); @@ -77,6 +80,9 @@ define('ERROR_NOPOST', 'You didn\'t make a post.', true); define('ERROR_FLOOD', 'Flood detected; Post discared.', true); define('ERROR_UNORIGINAL', 'Unoriginal content!', true); + define('ERROR_MUTED', 'Unoriginal content! You have been muted for %d seconds.', true); + define('ERROR_TOR', 'Hmm… That looks like a Tor exit node.', true); + define('ERROR_TOOMANYLINKS', 'Too many links; flood detected.', true); define('ERR_INVALIDIMG','Invalid image.', true); define('ERR_FILESIZE', 'Maximum file size: %maxsz% bytes
Your file\'s size: %filesz% bytes', true); define('ERR_MAXSIZE', 'The file was too big.', true); @@ -103,7 +109,11 @@ // Function name for hashing // sha1_file, md5_file, etc. define('FILE_HASH', 'sha1_file', true); - + + define('BLOCK_TOR', true, true); + // Typically spambots try to post a lot of links. Refuse a post with X standalone links? + define('MAX_LINKS', 7, true); + // Maximum image upload size in bytes define('MAX_FILESIZE', 10*1024*1024, true); // 10MB // Maximum image dimensions @@ -167,8 +177,13 @@ // Robot stuff // Strip repeating characters when making hashes define('ROBOT_ENABLE', true, true); + define('ROBOT_BOARD', 'r9k', true); define('ROBOT_STRIP_REPEATING', true, true); - + // Enable mutes + define('ROBOT_MUTE', true, true); + define('ROBOT_MUTE_MIN', 60, true); + define('ROBOT_MUTE_MAX', 120, true); + define('ROBOT_MUTE_DESCRIPTION', 'You have been muted for unoriginal content.', true); /* Mod stuff diff --git a/inc/functions.php b/inc/functions.php index 4f4a69bd..6193ab38 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -439,14 +439,43 @@ } } } + + function isDNSBL() { + $dns_black_lists = file('./dnsbl.txt', FILE_IGNORE_NEW_LINES); + + // Reverse the IP + $rev_ip = implode(array_reverse(explode('.', $_SERVER['REMOTE_ADDR'])), '.'); + $response = array(); + foreach ($dns_black_lists as $dns_black_list) { + $response = (gethostbynamel($rev_ip . '.' . $dns_black_list)); + if(!empty($response)) + return true; + } + + return false; + } + + function isTor() { + return gethostbyname( + ReverseIPOctets($_SERVER['REMOTE_ADDR']) . '.' . $_SERVER['SERVER_PORT'] . '.' . ReverseIPOctets($_SERVER['SERVER_ADDR']) . '.ip-port.exitlist.torproject.org' + ) == '127.0.0.2'; + } + + function ReverseIPOctets($inputip) { + $ipoc = explode('.', $inputip); + return $ipoc[3] . '.' . $ipoc[2] . '.' . $ipoc[1] . '.' . $ipoc[0]; + } function markup(&$body) { global $board; $body = utf8tohtml($body, true); - if(MARKUP_URLS) - $body = preg_replace(URL_REGEX, "$0", $body); + if(MARKUP_URLS) { + $body = preg_replace(URL_REGEX, "$0", $body, -1, $num_links); + if($num_links > MAX_LINKS) + error(ERROR_TOOMANYLINKS); + } if(AUTO_UNICODE) { $body = str_replace('...', '…', $body); @@ -602,7 +631,7 @@ $salt = strtr ( $salt, ':;<=>?@[\]^_`', 'ABCDEFGabcdef' ); if ( isset ( $t[2] ) ) { // secure - $trip = '!!' . substr ( crypt ( $trip, '@#$%^&*()' ), ( -1 * $length ) ); + $trip = '!!' . substr ( crypt ( $trip, SECURE_TRIP_SALT ), ( -1 * $length ) ); } else { // insecure $trip = '!' . substr ( crypt ( $trip, $salt ), ( -1 * $length ) ); diff --git a/mod.php b/mod.php index b4355fe4..80647471 100644 --- a/mod.php +++ b/mod.php @@ -464,7 +464,7 @@ openBoard($_board['uri']); $temp = ''; - $query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `ip` = :ip ORDER BY `sticky` DESC, `time` LIMIT :limit", $_board['uri'])); + $query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `ip` = :ip ORDER BY `sticky` DESC, `time` DESC LIMIT :limit", $_board['uri'])); $query->bindValue(':ip', $ip); $query->bindValue(':limit', MOD_IP_RECENTPOSTS, PDO::PARAM_INT); $query->execute() or error(db_error($query)); diff --git a/post.php b/post.php index 40830f0f..b8724522 100644 --- a/post.php +++ b/post.php @@ -62,6 +62,9 @@ // Check if banned checkBan(); + if(BLOCK_TOR && isTor()) + error(ERROR_TOR); + // Check if board exists if(!openBoard($post['board'])) error(ERROR_NOBOARD); @@ -85,6 +88,9 @@ $post['has_file'] = $OP || !empty($_FILES['file']['tmp_name']); $post['mod'] = isset($_POST['mod']) && $_POST['mod']; + if(empty($post['body']) && FORCE_BODY) + error(ERROR_TOOSHORTBODY); + if($post['mod']) { require 'inc/mod.php'; if(!$mod) { @@ -115,6 +121,15 @@ 'maxsz'=>commaize(MAX_FILESIZE)))); } + if($mod && $mod['type'] >= MOD_MOD && preg_match('/^((.+) )?## (.+)$/', $post['name'], $match)) { + if(($mod['type'] == MOD_MOD && $match[3] == 'Mod') || $mod['type'] >= MOD_ADMIN) { + $post['mod_tag'] = $match[3]; + $post['name'] = !empty($match[2])?$match[2]:'Anonymous'; + } + } else { + $post['mod_tag'] = false; + } + $trip = generate_tripcode($post['name']); $post['name'] = $trip[0]; $post['trip'] = (isset($trip[1])?$trip[1]:''); @@ -134,21 +149,40 @@ } // Check string lengths - if(strlen($post['name']) > 25) error(sprintf(ERROR_TOOLONG, 'name')); + if(strlen($post['name']) > 25) error(sprintf(ERROR_TOOLONG, 'name')); if(strlen($post['email']) > 30) error(sprintf(ERROR_TOOLONG, 'email')); if(strlen($post['subject']) > 40) error(sprintf(ERROR_TOOLONG, 'subject')); if(strlen($post['body']) > MAX_BODY) error(ERROR_TOOLONGBODY); if(!(!$OP && $post['has_file']) && strlen($post['body']) < 1) error(ERROR_TOOSHORTBODY); if(strlen($post['password']) > 20) error(sprintf(ERROR_TOOLONG, 'password')); + if($post['mod_tag']) + $post['trip'] .= ' ## ' . $post['mod_tag'] . ''; + + if(!($mod && $mod['type'] >= MOD_POSTUNORIGINAL) && ROBOT_ENABLE && $board['uri'] == ROBOT_BOARD && checkRobot($post['body'])) { + if(ROBOT_MUTE) { + $mutetime = ROBOT_MUTE_MIN+rand()%(ROBOT_MUTE_MAX-ROBOT_MUTE_MIN); + + $query = prepare("INSERT INTO `bans` VALUES (:ip, :mod, :set, :expires, :reason)"); + $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); + $query->bindValue(':mod', -1, PDO::PARAM_INT); + $query->bindValue(':set', time(), PDO::PARAM_INT); + $query->bindValue(':expires', time()+$mutetime, PDO::PARAM_INT); + $query->bindValue(':reason', ROBOT_MUTE_DESCRIPTION); + $query->execute() or error(db_error($query)); + + error(sprintf(ERROR_MUTED, $mutetime)); + } else { + error(ERROR_UNORIGINAL); + } + } + markup($post['body']); // Check for a flood - if(checkFlood($post)) + if(checkFlood($post)) { error(ERROR_FLOOD); - - if(!($mod && $mod['type'] >= MOD_POSTUNORIGINAL) && ROBOT_ENABLE && checkRobot($post['body'])) - error(ERROR_UNORIGINAL); + } if($post['has_file']) { // Just trim the filename if it's too long @@ -206,6 +240,7 @@ imagebmp($image, $post['file']); break; default: + unlink($post['file']); error('Unknwon file extension.'); } } diff --git a/style.css b/style.css index 60c36d19..058de230 100644 --- a/style.css +++ b/style.css @@ -146,6 +146,10 @@ p.intro span.name { color: #117743; font-weight: bold; } +p.intro a.nametag { + color: #F00000; + margin-left: 0; +} p.intro a { margin-left: 8px; } diff --git a/templates/posts.sql b/templates/posts.sql index 4163f125..f8e1b6fb 100644 --- a/templates/posts.sql +++ b/templates/posts.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS `posts_{board}` ( `subject` varchar(40) NOT NULL, `email` varchar(30) NOT NULL, `name` varchar(25) NOT NULL, - `trip` varchar(15) DEFAULT NULL, + `trip` varchar(45) DEFAULT NULL, `body` text NOT NULL, `time` int(11) NOT NULL, `bump` int(11) DEFAULT NULL, diff --git a/templates/thread.html b/templates/thread.html index 2fd03418..e1260ff5 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -71,6 +71,7 @@
{body} + [Return.]

Copyright © 2010 OmegaSDG

\ No newline at end of file -- cgit v1.3 From 915dcc55ebfcdb441f4b0efee90b12334718b9bd Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Thu, 20 Jan 2011 19:35:41 +1100 Subject: Added styles and yotsuba.css --- main.js | 41 +++++++++++++++++++++++++++++++++++++++++ style.css | 10 ++++++++++ yotsuba.css | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 yotsuba.css (limited to 'style.css') diff --git a/main.js b/main.js index d0b0e0d6..dd46cd18 100644 --- a/main.js +++ b/main.js @@ -24,8 +24,49 @@ function citeReply(id) { document.getElementById('body').value += '>>' + id + '\n'; } +var selectedstyle = 'Yotsuba B'; +var styles = [ + ['Yotsuba B', '/default.css'], + ['Yotsuba', '/yotsuba.css'] +]; + +function changeStyle(x) { + localStorage.stylesheet = styles[x][1]; + document.getElementById('stylesheet').href = styles[x][1]; + selectedstyle = styles[x][0]; +} + +newLink = document.createElement('link'); +newLink.rel = 'stylesheet'; +newLink.type = 'text/css'; +newLink.id = 'stylesheet'; +document.getElementsByTagName('head')[0].insertBefore(newLink, document.getElementsByTagName('link')[0].lastChild) + +if(localStorage.stylesheet) { + for(x=0;x Date: Fri, 21 Jan 2011 13:14:55 +1100 Subject: ... --- default.css | 0 inc/display.php | 13 ++++++++++++- inc/functions.php | 36 ++++++++++++++++++++++++++++++++++++ inc/mod.php | 37 +------------------------------------ main.js | 23 +++++++++++++++++++++-- style.css | 13 ++++++++++++- 6 files changed, 82 insertions(+), 40 deletions(-) create mode 100644 default.css (limited to 'style.css') diff --git a/default.css b/default.css new file mode 100644 index 00000000..e69de29b diff --git a/inc/display.php b/inc/display.php index 66637d0d..0678cef7 100644 --- a/inc/display.php +++ b/inc/display.php @@ -110,7 +110,9 @@ global $board; $built = '
' . - '

'; + '

' . + // Delete + ''; + $built .= ' '; + // Delete + $built .= ''; + $built .= ' execute() or error(db_error($query)); } + // Remove file from post + function deleteFile($id, $remove_entirely_if_already=true) { + global $board; + + $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NOT NULL LIMIT 1", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + if($query->rowCount() < 1) { + error(ERROR_INVALIDPOST); + } + + $post = $query->fetch(); + + $query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = NULL, `thumbwidth` = NULL, `thumbheight` = NULL, `filewidth` = NULL, `fileheight` = NULL, `filesize` = NULL, `filename` = NULL, `filehash` = NULL, `file` = :file WHERE `id` = :id OR `thread` = :id", $board['uri'])); + if($post['file'] == 'deleted' && $remove_entirely_if_already) { + // Already deleted; remove file fully + $query->bindValue(':file', null, PDO::PARAM_NULL); + } else { + // Delete thumbnail + @unlink($board['dir'] . DIR_THUMB . $post['thumb']); + + // Delete file + @unlink($board['dir'] . DIR_IMG . $post['file']); + + // Set file to 'deleted' + $query->bindValue(':file', 'deleted', PDO::PARAM_INT); + } + // Update database + + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + buildThread($post['thread']); + } + // Delete a post (reply or thread) function deletePost($id) { global $board; diff --git a/inc/mod.php b/inc/mod.php index 5e3a2c87..5a3e6157 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -173,40 +173,5 @@ '' . ''; } - - // Remove file from post - function deleteFile($id) { - global $board; - - $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NOT NULL LIMIT 1", $board['uri'])); - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - - if($query->rowCount() < 1) { - error(ERROR_INVALIDPOST); - } - - $post = $query->fetch(); - - $query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = NULL, `thumbwidth` = NULL, `thumbheight` = NULL, `filewidth` = NULL, `fileheight` = NULL, `filesize` = NULL, `filename` = NULL, `filehash` = NULL, `file` = :file WHERE `id` = :id OR `thread` = :id", $board['uri'])); - if($post['file'] == 'deleted') { - // Already deleted; remove file fully - $query->bindValue(':file', null, PDO::PARAM_NULL); - } else { - // Delete thumbnail - @unlink($board['dir'] . DIR_THUMB . $post['thumb']); - - // Delete file - @unlink($board['dir'] . DIR_IMG . $post['file']); - - // Set file to 'deleted' - $query->bindValue(':file', 'deleted', PDO::PARAM_INT); - } - // Update database - - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - - buildThread($post['thread']); - } + ?> \ No newline at end of file diff --git a/main.js b/main.js index dd46cd18..d0a82dda 100644 --- a/main.js +++ b/main.js @@ -14,9 +14,21 @@ function focusId(id) document.getElementById(id).focus(); init(); } + +function generatePassword() { + pass = ''; + chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+'; + for(i=0;i<8;i++) { + rnd = Math.floor(Math.random() * chars.length); + pass += chars.substring(rnd,rnd + 1); + } + return pass; +} + function dopost(form) { - localStorage.name = form.name.value; - localStorage.email = form.email.value; + localStorage.name = form.name.value.replace(/ ##.+$/, ''); + if(form.email.value != 'sage') + localStorage.email = form.email.value; return form.body.value != "" || (typeof form.thread != "undefined" && form.file.value != ""); } @@ -65,6 +77,13 @@ function init() newElement.appendChild(style); } + if(!localStorage.password) + localStorage.password = generatePassword(); + elements = document.getElementsByName('password'); + for(x=0;x Date: Wed, 16 Feb 2011 14:44:34 +1100 Subject: new styles --- style.css | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'style.css') diff --git a/style.css b/style.css index 919d51dc..4aec2b96 100644 --- a/style.css +++ b/style.css @@ -255,3 +255,19 @@ div.styles a { div.styles a.selected { text-decoration: none; } +table.test { + width: 100%; +} +table.test td, table.test th { + text-align: left; + padding: 5px; +} +table.test tr.h th { + background: #98E; +} +table.test td img { + margin: 0; +} +fieldset label { + display: block; +} \ No newline at end of file -- cgit v1.3