summaryrefslogtreecommitdiff
path: root/post.php
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2011-01-19 12:37:31 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2011-01-19 12:37:31 +1100
commitc59f36f400eb718714154fa1ab125662bc7b89ea (patch)
treebb4f8544cb351d897359fdc6ad79d48f8c9ee22b /post.php
parent62bd2ee348f460b3d4cbbdbd8469a783b4c64c78 (diff)
a bunch of things
Diffstat (limited to 'post.php')
-rw-r--r--post.php45
1 files changed, 40 insertions, 5 deletions
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'] .= ' <a class="nametag">## ' . $post['mod_tag'] . '</a>';
+
+ 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.');
}
}