diff --git a/inc/config.php b/inc/config.php index e167da15..4c2d5812 100644 --- a/inc/config.php +++ b/inc/config.php @@ -120,6 +120,10 @@ $config['body_truncate'] = 15; // Amount of characters to show on the index page $config['body_truncate_char'] = 2500; + // Maximum filename length (will be truncated) + $config['max_filename_len'] = 255; + // Maximum filename length to display (the rest can be viewed upon mouseover) + $config['max_filename_display'] = 30; $config['threads_per_page'] = 10; $config['max_pages'] = 10; diff --git a/inc/display.php b/inc/display.php index 620e0b56..88c52a38 100644 --- a/inc/display.php +++ b/inc/display.php @@ -352,7 +352,14 @@ } if($config['show_filename']) { // Filename - $built .= ', ' . $this->filename; + $built .= ', ' . + (strlen($this->filename) > $config['max_filename_display'] ? + '' . + substr($this->filename, 0, $config['max_filename_display']) . '…' . + '' + : + $this->filename + ); } $built .= ')
' . @@ -511,7 +518,14 @@ } if($config['show_filename']) { // Filename - $built .= ', ' . $this->filename; + $built .= ', ' . + (strlen($this->filename) > $config['max_filename_display'] ? + '' . + substr($this->filename, 0, $config['max_filename_display']) . '…' . + '' + : + $this->filename + ); } $built .= ')' . diff --git a/install.php b/install.php index 160492cd..b701c6d3 100644 --- a/install.php +++ b/install.php @@ -1,6 +1,6 @@ 30) $post['filename'] = substr($post['filename'], 0, 27).'…'; + // Truncate filename if it is too long + $post['filename'] = substr($post['filename'], 0, $config['max_filename_len']); // Move the uploaded file if(!@move_uploaded_file($_FILES['file']['tmp_name'], $post['file'])) error($config['error']['nomove']); diff --git a/templates/posts.sql b/templates/posts.sql index 5c507799..917398bd 100644 --- a/templates/posts.sql +++ b/templates/posts.sql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS `posts_{board}` ( `filewidth` int(11) DEFAULT NULL, `fileheight` int(11) DEFAULT NULL, `filesize` int(11) DEFAULT NULL, - `filename` varchar(30) DEFAULT NULL, + `filename` text DEFAULT NULL, `filehash` text DEFAULT NULL, `password` varchar(20) DEFAULT NULL, `ip` varchar(45) NOT NULL,