summaryrefslogtreecommitdiff
path: root/post.php
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2016-02-09 12:37:03 +0100
committerczaks <marcin@6irc.net>2016-02-09 12:37:03 +0100
commitc53f13bf90716461780fef0a2b4b6e2b5b3cb002 (patch)
tree5cd18f303da0b0e6fdc87f175adf5f5f86d881e2 /post.php
parentfe66c51a19920378885fb790d341cc50c933b046 (diff)
parent028fd3df15b2e2edc96c5b84156b0b039ea16562 (diff)
Merge branch 'master' of https://github.com/vichan-devel/vichan
Diffstat (limited to 'post.php')
-rw-r--r--post.php81
1 files changed, 55 insertions, 26 deletions
diff --git a/post.php b/post.php
index 93592590..729170a7 100644
--- a/post.php
+++ b/post.php
@@ -3,8 +3,9 @@
* Copyright (c) 2010-2014 Tinyboard Development Group
*/
-require 'inc/functions.php';
-require 'inc/anti-bot.php';
+require_once 'inc/functions.php';
+require_once 'inc/anti-bot.php';
+require_once 'inc/bans.php';
// Fix for magic quotes
if (get_magic_quotes_gpc()) {
@@ -92,18 +93,22 @@ if (isset($_POST['delete'])) {
buildIndex();
-
- rebuildThemes('post-delete', $board['uri']);
-
$is_mod = isset($_POST['mod']) && $_POST['mod'];
$root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root'];
-
+
if (!isset($_POST['json_response'])) {
header('Location: ' . $root . $board['dir'] . $config['file_index'], true, $config['redirect_http']);
} else {
header('Content-Type: text/json');
echo json_encode(array('success' => true));
}
+
+ // We are already done, let's continue our heavy-lifting work in the background (if we run off FastCGI)
+ if (function_exists('fastcgi_finish_request'))
+ @fastcgi_finish_request();
+
+ rebuildThemes('post-delete', $board['uri']);
+
} elseif (isset($_POST['report'])) {
if (!isset($_POST['board'], $_POST['reason']))
error($config['error']['bot']);
@@ -307,7 +312,12 @@ if (isset($_POST['delete'])) {
$url_without_params = $post['file_url'];
$post['extension'] = strtolower(mb_substr($url_without_params, mb_strrpos($url_without_params, '.') + 1));
- if (!in_array($post['extension'], $config['allowed_ext']) && !in_array($post['extension'], $config['allowed_ext_files']))
+
+ if ($post['op'] && $config['allowed_ext_op']) {
+ if (!in_array($post['extension'], $config['allowed_ext_op']))
+ error($config['error']['unknownext']);
+ }
+ else if (!in_array($post['extension'], $config['allowed_ext']) && !in_array($post['extension'], $config['allowed_ext_files']))
error($config['error']['unknownext']);
$post['file_tmp'] = tempnam($config['tmp'], 'url');
@@ -516,7 +526,7 @@ if (isset($_POST['delete'])) {
"\n<tinyboard flag alt>".geoip\geoip_country_name_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR']))."</tinyboard>";
}
}
-
+
if ($config['user_flag'] && isset($_POST['user_flag']))
if (!empty($_POST['user_flag']) ){
@@ -530,6 +540,15 @@ if (isset($_POST['delete'])) {
$post['body'] .= "\n<tinyboard flag>" . strtolower($user_flag) . "</tinyboard>" .
"\n<tinyboard flag alt>" . $flag_alt . "</tinyboard>";
}
+
+ if ($config['allowed_tags'] && $post['op'] && isset($_POST['tag']) && isset($config['allowed_tags'][$_POST['tag']])) {
+ $post['body'] .= "\n<tinyboard tag>" . $_POST['tag'] . "</tinyboard>";
+ }
+
+ if ($config['proxy_save'] && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+ $proxy = preg_replace("/[^0-9a-fA-F.,: ]/", '', $_SERVER['HTTP_X_FORWARDED_FOR']);
+ $post['body'] .= "\n<tinyboard proxy>".$proxy."</tinyboard>";
+ }
if (mysql_version() >= 50503) {
$post['body_nomarkup'] = $post['body']; // Assume we're using the utf8mb4 charset
@@ -555,7 +574,11 @@ if (isset($_POST['delete'])) {
if ($post['has_file']) {
$fnarray = array();
foreach ($post['files'] as $key => &$file) {
- if (!in_array($file['extension'], $config['allowed_ext']) && !in_array($file['extension'], $config['allowed_ext_files']))
+ if ($post['op'] && $config['allowed_ext_op']) {
+ if (!in_array($file['extension'], $config['allowed_ext_op']))
+ error($config['error']['unknownext']);
+ }
+ elseif (!in_array($file['extension'], $config['allowed_ext']) && !in_array($file['extension'], $config['allowed_ext_files']))
error($config['error']['unknownext']);
$file['is_an_image'] = !in_array($file['extension'], $config['allowed_ext_files']);
@@ -800,6 +823,7 @@ if (isset($_POST['delete'])) {
$post['num_files'] = sizeof($post['files']);
$post['id'] = $id = post($post);
+ $post['slug'] = slugify($post);
insertFloodPost($post);
@@ -821,18 +845,6 @@ if (isset($_POST['delete'])) {
bumpThread($post['thread']);
}
- buildThread($post['op'] ? $id : $post['thread']);
-
- if ($config['try_smarter'] && $post['op'])
- $build_pages = range(1, $config['max_pages']);
-
- if ($post['op'])
- clean();
-
- event('post-after', $post);
-
- buildIndex();
-
if (isset($_SERVER['HTTP_REFERER'])) {
// Tell Javascript that we posted successfully
if (isset($_COOKIE[$config['cookies']['js']]))
@@ -869,6 +881,8 @@ if (isset($_POST['delete'])) {
$redirect = $root . $board['dir'] . $config['file_index'];
}
+
+ buildThread($post['op'] ? $id : $post['thread']);
if ($config['syslog'])
_syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] .
@@ -876,11 +890,6 @@ if (isset($_POST['delete'])) {
if (!$post['mod']) header('X-Associated-Content: "' . $redirect . '"');
- if ($post['op'])
- rebuildThemes('post-thread', $board['uri']);
- else
- rebuildThemes('post', $board['uri']);
-
if (!isset($_POST['json_response'])) {
header('Location: ' . $redirect, true, $config['redirect_http']);
} else {
@@ -891,6 +900,26 @@ if (isset($_POST['delete'])) {
'id' => $id
));
}
+
+ if ($config['try_smarter'] && $post['op'])
+ $build_pages = range(1, $config['max_pages']);
+
+ if ($post['op'])
+ clean();
+
+ event('post-after', $post);
+
+ buildIndex();
+
+ // We are already done, let's continue our heavy-lifting work in the background (if we run off FastCGI)
+ if (function_exists('fastcgi_finish_request'))
+ @fastcgi_finish_request();
+
+ if ($post['op'])
+ rebuildThemes('post-thread', $board['uri']);
+ else
+ rebuildThemes('post', $board['uri']);
+
} elseif (isset($_POST['appeal'])) {
if (!isset($_POST['ban_id']))
error($config['error']['bot']);