summaryrefslogtreecommitdiff
path: root/post.php
diff options
context:
space:
mode:
Diffstat (limited to 'post.php')
-rw-r--r--post.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/post.php b/post.php
index a8ba8dba..72b692cb 100644
--- a/post.php
+++ b/post.php
@@ -182,7 +182,7 @@ if (isset($_POST['delete'])) {
// Check the referrer
if ($config['referer_match'] !== false &&
- (!isset($_SERVER['HTTP_REFERER']) || !preg_match($config['referer_match'], urldecode($_SERVER['HTTP_REFERER']))))
+ (!isset($_SERVER['HTTP_REFERER']) || !preg_match($config['referer_match'], rawurldecode($_SERVER['HTTP_REFERER']))))
error($config['error']['referer']);
checkDNSBL();
@@ -740,6 +740,20 @@ if (isset($_POST['delete'])) {
if ($config['always_noko'] || $noko) {
$redirect = $root . $board['dir'] . $config['dir']['res'] .
sprintf($config['file_page'], $post['op'] ? $id:$post['thread']) . (!$post['op'] ? '#' . $id : '');
+
+ if (!$post['op'] && isset($_SERVER['HTTP_REFERER'])) {
+ $regex = array(
+ 'board' => str_replace('%s', '(\w{1,8})', preg_quote($config['board_path'], '/')),
+ 'page' => str_replace('%d', '(\d+)', preg_quote($config['file_page'], '/')),
+ 'page50' => str_replace('%d', '(\d+)', preg_quote($config['file_page50'], '/')),
+ 'res' => preg_quote($config['dir']['res'], '/'),
+ );
+
+ if (preg_match('/\/' . $regex['board'] . $regex['res'] . $regex['page50'] . '([?&].*)?$/', $_SERVER['HTTP_REFERER'])) {
+ $redirect = $root . $board['dir'] . $config['dir']['res'] .
+ sprintf($config['file_page50'], $post['op'] ? $id:$post['thread']) . (!$post['op'] ? '#' . $id : '');
+ }
+ }
} else {
$redirect = $root . $board['dir'] . $config['file_index'];
@@ -749,6 +763,8 @@ if (isset($_POST['delete'])) {
_syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] .
sprintf($config['file_page'], $post['op'] ? $id : $post['thread']) . (!$post['op'] ? '#' . $id : ''));
+ if (!$post['mod']) header('X-Associated-Content: "' . $redirect . '"');
+
if ($post['op'])
rebuildThemes('post-thread', $board['uri']);
else