diff --git a/bbs.php b/bbs.php index ade3903..3a6fbcb 100644 --- a/bbs.php +++ b/bbs.php @@ -35,6 +35,7 @@ * * // Application constants * define('UPLOAD_PATH', 'image/'); // Folder to save images to + * define('THUMB_PATH', 'thumb/'); // Folder to save thumbnails to * define('MAX_FILE_SIZE', 8 << 20); // Maximum image size, 8 MiB * define('ADMIN_ID', ''); // uid that is able to delete anything * define('UID_SALT', ''); @@ -79,8 +80,18 @@ && ($img['size'] > 0) && ($img['size'] <= MAX_FILE_SIZE)) { if($img['error'] == 0) { // Move the file to the target upload folder - $target = UPLOAD_PATH . time() . $extensions[$img['type']]; - if(!move_uploaded_file($img['tmp_name'], $target)) { + $name = time(); + $target = UPLOAD_PATH . $name . $extensions[$img['type']]; + if(move_uploaded_file($img['tmp_name'], $target)) { + $output = null; + $ret = null; + exec("ffmpeg -y -loglevel error -i '$target' -vf 'scale=-1:min(100\,ih)' " . THUMB_PATH . "$name.jpg", $output, $ret); + if($ret != 0) { + // The new image file move failed, so delete the temporary file and return an error + @unlink($target); + return 'Unable to create thumbnail, please contact the webmaster.'; + } + } else { // The new image file move failed, so delete the temporary file and return an error @unlink($img['tmp_name']); return 'Unable to upload image, please contact the webmaster.'; @@ -171,7 +182,7 @@ if(!empty($row['img'])){ echo ''; - echo '' . $row['img'] . ''; + echo '' . $row['img'] . ''; echo ''; } @@ -327,4 +338,4 @@

- \ No newline at end of file +