diff options
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/config.php | 11 | ||||
| -rw-r--r-- | inc/display.php | 22 | ||||
| -rw-r--r-- | inc/functions.php | 9 |
3 files changed, 27 insertions, 15 deletions
diff --git a/inc/config.php b/inc/config.php index ef9adb80..3aa0b34f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -116,6 +116,7 @@ $config['error']['toomanyreports'] = 'You can\'t report that many posts at once.'; $config['error']['invalidpassword'] = 'Wrong password…'; $config['error']['invalidimg'] = 'Invalid image.'; + $config['error']['unknownext'] = 'Unknown file extension.'; $config['error']['filesize'] = 'Maximum file size: %maxsz% bytes<br>Your file\'s size: %filesz% bytes'; $config['error']['maxsize'] = 'The file was too big.'; $config['error']['invalidzip'] = 'Invalid archive!'; @@ -516,8 +517,14 @@ // https://github.com/savetheinternet/Tinyboard/issues/20 $config['ie_mime_type_detection'] = '/<(?:body|head|html|img|plaintext|pre|script|table|title|a href|channel|scriptlet)/'; - // Allowed file extensions - $config['allowed_ext'] = Array('jpg', 'jpeg', 'bmp', 'gif', ''); + // Allowed image file extensions + $config['allowed_ext'] = Array('jpg', 'jpeg', 'bmp', 'gif', 'png'); + + // Allowed additional file extensions (not images; downloadable files) + $config['allowed_ext_files'] = Array('mp3'); + + // Thumbnail to use for the downloadable files (not images) + $config['file_thumb'] = 'static/file.png'; // The names on the post buttons. (On most imageboards, these are both "Post".) $config['button_newtopic'] = 'New Topic'; diff --git a/inc/display.php b/inc/display.php index b6722348..9ba5cac6 100644 --- a/inc/display.php +++ b/inc/display.php @@ -259,14 +259,16 @@ if(!empty($this->file) && $this->file != 'deleted') { $built .= '<p class="fileinfo">File: <a href="' . $config['uri_img'] . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' . // Filesize - format_bytes($this->filesize) . ', ' . + format_bytes($this->filesize) . // File dimensions - $this->filex . 'x' . $this->filey; + ($this->filex && $this->filey ? + ', ' . $this->filex . 'x' . $this->filey + : '' ); // Aspect Ratio - if($config['show_ratio']) { - $fraction = fraction($this->filex, $this->filey, ':'); - $built .= ', ' . $fraction; - } + if($config['show_ratio'] && $this->filex && $this->filey) { + $fraction = fraction($this->filex, $this->filey, ':'); + $built .= ', ' . $fraction; + } // Filename $built .= ', ' . $this->filename . ')</span></p>' . @@ -377,11 +379,13 @@ $built = '<p class="fileinfo">File: <a href="' . $config['uri_img'] . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' . // Filesize - format_bytes($this->filesize) . ', ' . + format_bytes($this->filesize) . // File dimensions - $this->filex . 'x' . $this->filey; + ($this->filex && $this->filey ? + ', ' . $this->filex . 'x' . $this->filey + : '' ); // Aspect Ratio - if($config['show_ratio']) { + if($config['show_ratio'] && $this->filex && $this->filey) { $fraction = fraction($this->filex, $this->filey, ':'); $built .= ', ' . $fraction; } diff --git a/inc/functions.php b/inc/functions.php index e37a367d..2a45c606 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -363,7 +363,7 @@ $query->bindValue(':height', $post['height'], PDO::PARAM_INT); $query->bindValue(':filesize', $post['filesize'], PDO::PARAM_INT); $query->bindValue(':filename', $post['filename']); - $query->bindValue(':filehash', $post['filehash']); + $query->bindValue(':filehash', $post['file']); } else { $query->bindValue(':thumb', null, PDO::PARAM_NULL); $query->bindValue(':thumbwidth', null, PDO::PARAM_NULL); @@ -1363,12 +1363,13 @@ } break; default: - error('Unknwon file extension.'); + error($config['error']['unknownext']); } return $image; } - function resize($src, $width, $height, $destination_pic, $max_width, $max_height, $ext) { + function resize($src, $width, $height, $destination_pic, $max_width, $max_height, $ext) { + global $config; $return = Array(); $x_ratio = $max_width / $width; @@ -1414,7 +1415,7 @@ imagebmp($tmp, $destination_pic); break; default: - error('Unknwon file extension.'); + error($config['error']['unknownext']); } imagedestroy($src); |
