|
|
|
@ -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', '<SHA1 uid from your cookies>'); // uid that is able to delete anything
|
|
|
|
|
* define('UID_SALT', '<some string to salt uids with>');
|
|
|
|
@ -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 '<a href="' . UPLOAD_PATH . $row['img'] . '" target="_blank">';
|
|
|
|
|
echo '<img src="' . UPLOAD_PATH . $row['img'] . '" alt="' . $row['img'] . '" />';
|
|
|
|
|
echo '<img src="' . THUMB_PATH . preg_replace('/\.(?:png|gif|bmp)$/', '.jpg', $row['img']) . '" alt="' . $row['img'] . '" />';
|
|
|
|
|
echo '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|