From cdeccbb9ba041b47aec0b6e6cc7acea268cf32ad Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 26 Aug 2013 12:13:40 +1000 Subject: Uploading files via URL: fix for URL parameters (eg. image.png?id=343543) --- post.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'post.php') diff --git a/post.php b/post.php index df7fe435..7ab1eb59 100644 --- a/post.php +++ b/post.php @@ -273,8 +273,12 @@ if (isset($_POST['delete'])) { if (!preg_match($config['url_regex'], $post['file_url'])) error($config['error']['invalidimg']); - - $post['extension'] = strtolower(mb_substr($post['file_url'], mb_strrpos($post['file_url'], '.') + 1)); + if (mb_strpos($post['file_url'], '?') !== false) + $url_without_params = mb_substr($post['file_url'], 0, mb_strpos($post['file_url'], '?')); + else + $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'])) error($config['error']['unknownext']); @@ -305,7 +309,7 @@ if (isset($_POST['delete'])) { fclose($fp); $_FILES['file'] = array( - 'name' => basename($post['file_url']), + 'name' => basename($url_without_params), 'tmp_name' => $post['file_tmp'], 'error' => 0, 'size' => filesize($post['file_tmp']) -- cgit v1.3 From 09388f6588843d8042fc2542d049deb47c57ce07 Mon Sep 17 00:00:00 2001 From: Dan Saunders Date: Sun, 25 Aug 2013 23:23:02 -0400 Subject: Added a post-delete action for themes This would be really useful for themes that focus on posts --- post.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'post.php') diff --git a/post.php b/post.php index 7ab1eb59..2450bf06 100644 --- a/post.php +++ b/post.php @@ -75,6 +75,9 @@ 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']; -- cgit v1.3 From 319cd2520ff18120570e56eba04ceb1206007375 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 27 Aug 2013 08:13:23 +1000 Subject: Upload by URL: still use fatal_error_handler() on shutdown --- post.php | 1 + 1 file changed, 1 insertion(+) (limited to 'post.php') diff --git a/post.php b/post.php index 2450bf06..6de3edfa 100644 --- a/post.php +++ b/post.php @@ -288,6 +288,7 @@ if (isset($_POST['delete'])) { $post['file_tmp'] = tempnam($config['tmp'], 'url'); function unlink_tmp_file($file) { @unlink($file); + fatal_error_handler(); } register_shutdown_function('unlink_tmp_file', $post['file_tmp']); -- cgit v1.3 From 5003a692b4505eccdb57447fbf77e4333c8014c0 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 27 Aug 2013 08:55:03 +1000 Subject: exiftool: Use -overwrite_original. Important bugfix; old images were never being deleted when using exiftool (instead kept as *_original in /tmp) --- post.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'post.php') diff --git a/post.php b/post.php index 6de3edfa..21d294cd 100644 --- a/post.php +++ b/post.php @@ -526,7 +526,8 @@ if (isset($_POST['delete'])) { escapeshellarg($upload)); if ($config['use_exiftool'] && !$config['strip_exif']) { if ($exiftool_error = shell_exec_error( - 'exiftool -q -orientation=1 -n ' . escapeshellarg($upload))) + 'exiftool -overwrite_original -q -q -orientation=1 -n ' . + escapeshellarg($upload))) error('exiftool failed!', null, $exiftool_error); } else { // TODO: Find another way to remove the Orientation tag from the EXIF profile @@ -589,7 +590,8 @@ if (isset($_POST['delete'])) { if ($config['redraw_image'] || (!@$post['exif_stripped'] && $config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg'))) { if (!$config['redraw_image'] && $config['use_exiftool']) { - if($error = shell_exec_error('exiftool -ignoreMinorErrors -q -q -all= ' . escapeshellarg($upload))) + if($error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= ' . + escapeshellarg($upload))) error('Could not strip EXIF metadata!', null, $error); } else { $image->to($post['file']); -- cgit v1.3