Browse Source

Delete images properly on error

pull/40/head
Savetheinternet 13 years ago
parent
commit
13ef38d7b7
  1. 7
      inc/functions.php
  2. 5
      post.php

7
inc/functions.php

@ -1122,7 +1122,14 @@
return $res; return $res;
} }
function undoImage($post) {
unlink($post['file']);
unlink($post['thumb']);
}
function createimage($type, $source_pic) { function createimage($type, $source_pic) {
global $config;
$image = false; $image = false;
switch($type) { switch($type) {
case 'jpg': case 'jpg':

5
post.php

@ -247,12 +247,12 @@
// Check if the image is valid // Check if the image is valid
if($post['width'] < 1 || $post['height'] < 1) { if($post['width'] < 1 || $post['height'] < 1) {
unlink($post['file']); undoImage($post);
error($config['error']['invalidimg']); error($config['error']['invalidimg']);
} }
if($post['width'] > $config['max_width'] || $post['height'] > $config['max_height']) { if($post['width'] > $config['max_width'] || $post['height'] > $config['max_height']) {
unlink($post['file']); undoImage($post);
error($config['error']['maxsize']); error($config['error']['maxsize']);
} }
@ -269,6 +269,7 @@
} }
if(!($mod && $mod['type'] >= $config['mod']['postunoriginal']) && $config['robot_enable'] && checkRobot($post['body_nomarkup'])) { if(!($mod && $mod['type'] >= $config['mod']['postunoriginal']) && $config['robot_enable'] && checkRobot($post['body_nomarkup'])) {
undoImage($post);
if($config['robot_mute']) { if($config['robot_mute']) {
error(sprintf($config['error']['muted'], mute())); error(sprintf($config['error']['muted'], mute()));
} else { } else {

Loading…
Cancel
Save