diff --git a/inc/config.php b/inc/config.php
index 8350ad63..d0b2d543 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -505,7 +505,7 @@
// Command-line options passed to ImageMagick when using `convert` for thumbnailing. Don't touch the
// placement of "%s" and "%d".
- $config['convert_args'] = '-size %dx%d %s -thumbnail %dx%d +profile "*" %s';
+ $config['convert_args'] = '-size %dx%d %s -thumbnail %dx%d -auto-orient +profile "*" %s';
// Strip EXIF metadata from JPEG files.
$config['strip_exif'] = false;
@@ -794,27 +794,27 @@
*/
// Error messages
- $config['error']['lurk'] = _('Lurk some more before posting.');
- $config['error']['bot'] = _('You look like a bot.');
- $config['error']['referer'] = _('Your browser sent an invalid or no HTTP referer.');
- $config['error']['toolong'] = _('The %s field was too long.');
+ $config['error']['lurk'] = _('Lurk some more before posting.');
+ $config['error']['bot'] = _('You look like a bot.');
+ $config['error']['referer'] = _('Your browser sent an invalid or no HTTP referer.');
+ $config['error']['toolong'] = _('The %s field was too long.');
$config['error']['toolong_body'] = _('The body was too long.');
$config['error']['tooshort_body'] = _('The body was too short or empty.');
- $config['error']['noimage'] = _('You must upload an image.');
- $config['error']['nomove'] = _('The server failed to handle your upload.');
- $config['error']['fileext'] = _('Unsupported image format.');
- $config['error']['noboard'] = _('Invalid board!');
+ $config['error']['noimage'] = _('You must upload an image.');
+ $config['error']['nomove'] = _('The server failed to handle your upload.');
+ $config['error']['fileext'] = _('Unsupported image format.');
+ $config['error']['noboard'] = _('Invalid board!');
$config['error']['nonexistant'] = _('Thread specified does not exist.');
- $config['error']['locked'] = _('Thread locked. You may not reply at this time.');
+ $config['error']['locked'] = _('Thread locked. You may not reply at this time.');
$config['error']['reply_hard_limit'] = _('Thread has reached its maximum reply limit.');
$config['error']['image_hard_limit'] = _('Thread has reached its maximum image limit.');
- $config['error']['nopost'] = _('You didn\'t make a post.');
- $config['error']['flood'] = _('Flood detected; Post discarded.');
- $config['error']['spam'] = _('Your request looks automated; Post discarded.');
+ $config['error']['nopost'] = _('You didn\'t make a post.');
+ $config['error']['flood'] = _('Flood detected; Post discarded.');
+ $config['error']['spam'] = _('Your request looks automated; Post discarded.');
$config['error']['unoriginal'] = _('Unoriginal content!');
- $config['error']['muted'] = _('Unoriginal content! You have been muted for %d seconds.');
+ $config['error']['muted'] = _('Unoriginal content! You have been muted for %d seconds.');
$config['error']['youaremuted'] = _('You are muted! Expires in %d seconds.');
- $config['error']['dnsbl'] = _('Your IP address is listed in %s.');
+ $config['error']['dnsbl'] = _('Your IP address is listed in %s.');
$config['error']['toomanylinks'] = _('Too many links; flood detected.');
$config['error']['toomanycites'] = _('Too many cites; post discarded.');
$config['error']['toomanycross'] = _('Too many cross-board links; post discarded.');
@@ -825,19 +825,19 @@
$config['error']['invalidimg'] = _('Invalid image.');
$config['error']['unknownext'] = _('Unknown file extension.');
$config['error']['filesize'] = _('Maximum file size: %maxsz% bytes
Your file\'s size: %filesz% bytes');
- $config['error']['maxsize'] = _('The file was too big.');
+ $config['error']['maxsize'] = _('The file was too big.');
$config['error']['invalidzip'] = _('Invalid archive!');
$config['error']['fileexists'] = _('That file already exists!');
$config['error']['fileexistsinthread'] = _('That file already exists in this thread!');
$config['error']['delete_too_soon'] = _('You\'ll have to wait another %s before deleting that.');
$config['error']['mime_exploit'] = _('MIME type detection XSS exploit (IE) detected; post discarded.');
$config['error']['invalid_embed'] = _('Couldn\'t make sense of the URL of the video you tried to embed.');
- $config['error']['captcha'] = _('You seem to have mistyped the verification.');
+ $config['error']['captcha'] = _('You seem to have mistyped the verification.');
// Moderator errors
$config['error']['toomanyunban'] = _('You are only allowed to unban %s users at a time. You tried to unban %u users.');
- $config['error']['invalid'] = _('Invalid username and/or password.');
- $config['error']['notamod'] = _('You are not a mod…');
+ $config['error']['invalid'] = _('Invalid username and/or password.');
+ $config['error']['notamod'] = _('You are not a mod…');
$config['error']['invalidafter'] = _('Invalid username and/or password. Your user may have been deleted or changed.');
$config['error']['malformed'] = _('Invalid/malformed cookies.');
$config['error']['missedafield'] = _('Your browser didn\'t submit an input when it should have.');
@@ -846,10 +846,10 @@
$config['error']['boardexists'] = _('There is already a %s board.');
$config['error']['noaccess'] = _('You don\'t have permission to do that.');
$config['error']['invalidpost'] = _('That post doesn\'t exist…');
- $config['error']['404'] = _('Page not found.');
+ $config['error']['404'] = _('Page not found.');
$config['error']['modexists'] = _('That mod already exists!');
$config['error']['invalidtheme'] = _('That theme doesn\'t exist!');
- $config['error']['csrf'] = _('Invalid security token! Please go back and try again.');
+ $config['error']['csrf'] = _('Invalid security token! Please go back and try again.');
/*
* =========================
diff --git a/inc/image.php b/inc/image.php
index 92e74277..97ef8454 100644
--- a/inc/image.php
+++ b/inc/image.php
@@ -87,7 +87,7 @@ class Image {
}
$thumb->_resize($this->image->image, $width, $height);
-
+
return $thumb;
}
@@ -248,15 +248,25 @@ class ImageConvert extends ImageBase {
$this->temp = false;
}
+ public function get_size($src, $try_gd_first = true) {
+ if ($try_gd_first) {
+ if ($size = @getimagesize($src))
+ return $size;
+ }
+ $size = shell_exec_error(($this->gm ? 'gm ' : '') . 'identify -format "%w %h" ' . escapeshellarg($src . '[0]'));
+ if (preg_match('/^(\d+) (\d+)$/', $size, $m))
+ return array($m[1], $m[2]);
+ return false;
+ }
public function from() {
if ($this->width > 0 && $this->height > 0) {
$this->image = true;
return;
}
- $size = shell_exec_error(($this->gm ? 'gm ' : '') . 'identify -format "%w %h" ' . escapeshellarg($this->src . '[0]'));
- if (preg_match('/^(\d+) (\d+)$/', $size, $m)) {
- $this->width = $m[1];
- $this->height = $m[2];
+ $size = $this->get_size($this->src, false);
+ if ($size) {
+ $this->width = $size[1];
+ $this->height = $size[2];
$this->image = true;
} else {
@@ -272,13 +282,13 @@ class ImageConvert extends ImageBase {
if($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
escapeshellarg($this->src) . ' -auto-orient -strip ' . escapeshellarg($src))) {
$this->destroy();
- error('Failed to resize image!', null, $error);
+ error('Failed to redraw image!', null, $error);
}
} else {
if($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
escapeshellarg($this->src) . ' -auto-orient ' . escapeshellarg($src))) {
$this->destroy();
- error('Failed to resize image!', null, $error);
+ error('Failed to redraw image!', null, $error);
}
}
} else {
@@ -324,6 +334,10 @@ class ImageConvert extends ImageBase {
$this->height,
escapeshellarg($this->temp))) || !file_exists($this->temp))
error('Failed to resize image!', null, $error);
+ if ($size = $this->get_size($this->temp)) {
+ $this->width = $size[0];
+ $this->height = $size[1];
+ }
}
} else {
if ($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
@@ -335,6 +349,10 @@ class ImageConvert extends ImageBase {
$this->height,
escapeshellarg($this->temp))) || !file_exists($this->temp))
error('Failed to resize image!', null, $error);
+ if ($size = $this->get_size($this->temp)) {
+ $this->width = $size[0];
+ $this->height = $size[1];
+ }
}
}
}
diff --git a/mod.php b/mod.php
index 742eeefb..a01a0297 100644
--- a/mod.php
+++ b/mod.php
@@ -21,64 +21,64 @@ if (get_magic_quotes_gpc()) {
$query = isset($_SERVER['QUERY_STRING']) ? urldecode($_SERVER['QUERY_STRING']) : '';
$pages = array(
- '' => ':?/', // redirect to dashboard
- '/' => 'dashboard', // dashboard
+ '' => ':?/', // redirect to dashboard
+ '/' => 'dashboard', // dashboard
'/confirm/(.+)' => 'confirm', // confirm action (if javascript didn't work)
- '/logout' => 'logout', // logout
+ '/logout' => 'logout', // logout
- '/users' => 'users', // manage users
- '/users/(\d+)' => 'user', // edit user
- '/users/(\d+)/(promote|demote)' => 'user_promote', // prmote/demote user
+ '/users' => 'users', // manage users
+ '/users/(\d+)' => 'user', // edit user
+ '/users/(\d+)/(promote|demote)' => 'user_promote', // prmote/demote user
'/users/new' => 'user_new', // create a new user
'/new_PM/([^/]+)' => 'new_pm', // create a new pm
- '/PM/(\d+)(/reply)?' => 'pm', // read a pm
- '/inbox' => 'inbox', // pm inbox
+ '/PM/(\d+)(/reply)?' => 'pm', // read a pm
+ '/inbox' => 'inbox', // pm inbox
'/noticeboard' => 'noticeboard', // view noticeboard
- '/noticeboard/(\d+)' => 'noticeboard', // view noticeboard
- '/noticeboard/delete/(\d+)' => 'noticeboard_delete', // delete from noticeboard
- '/log' => 'log', // modlog
- '/log/(\d+)' => 'log', // modlog
+ '/noticeboard/(\d+)' => 'noticeboard', // view noticeboard
+ '/noticeboard/delete/(\d+)' => 'noticeboard_delete', // delete from noticeboard
+ '/log' => 'log', // modlog
+ '/log/(\d+)' => 'log', // modlog
'/log:([^/]+)' => 'user_log', // modlog
- '/log:([^/]+)/(\d+)' => 'user_log', // modlog
- '/news' => 'news', // view news
- '/news/(\d+)' => 'news', // view news
- '/news/delete/(\d+)' => 'news_delete', // delete from news
+ '/log:([^/]+)/(\d+)' => 'user_log', // modlog
+ '/news' => 'news', // view news
+ '/news/(\d+)' => 'news', // view news
+ '/news/delete/(\d+)' => 'news_delete', // delete from news
'/edit/(\%b)' => 'edit_board', // edit board details
'/new-board' => 'new_board', // create a new board
- '/rebuild' => 'rebuild', // rebuild static files
- '/reports' => 'reports', // report queue
- '/reports/(\d+)/dismiss(all)?' => 'report_dismiss', // dismiss a report
+ '/rebuild' => 'rebuild', // rebuild static files
+ '/reports' => 'reports', // report queue
+ '/reports/(\d+)/dismiss(all)?' => 'report_dismiss', // dismiss a report
- '/IP/([\w.:]+)' => 'ip', // view ip address
+ '/IP/([\w.:]+)' => 'ip', // view ip address
'/IP/([\w.:]+)/remove_note/(\d+)' => 'ip_remove_note', // remove note from ip address
- '/bans' => 'bans', // ban list
- '/bans/(\d+)' => 'bans', // ban list
+ '/bans' => 'bans', // ban list
+ '/bans/(\d+)' => 'bans', // ban list
- '/search' => 'search_redirect', // search
+ '/search' => 'search_redirect', // search
'/search/(posts|IP_notes|bans|log)/(.+)/(\d+)' => 'search', // search
- '/search/(posts|IP_notes|bans|log)/(.+)' => 'search', // search
+ '/search/(posts|IP_notes|bans|log)/(.+)' => 'search', // search
// CSRF-protected moderator actions
- '/ban' => 'secure_POST ban', // new ban
- '/(\%b)/ban(&delete)?/(\d+)' => 'secure_POST ban_post', // ban poster
- '/(\%b)/move/(\d+)' => 'secure_POST move', // move thread
- '/(\%b)/edit(_raw)?/(\d+)' => 'secure_POST edit_post', // edit post
- '/(\%b)/delete/(\d+)' => 'secure delete', // delete post
+ '/ban' => 'secure_POST ban', // new ban
+ '/(\%b)/ban(&delete)?/(\d+)' => 'secure_POST ban_post', // ban poster
+ '/(\%b)/move/(\d+)' => 'secure_POST move', // move thread
+ '/(\%b)/edit(_raw)?/(\d+)' => 'secure_POST edit_post', // edit post
+ '/(\%b)/delete/(\d+)' => 'secure delete', // delete post
'/(\%b)/deletefile/(\d+)' => 'secure deletefile', // delete file from post
- '/(\%b)/deletebyip/(\d+)(/global)?' => 'secure deletebyip', // delete all posts by IP address
- '/(\%b)/(un)?lock/(\d+)' => 'secure lock', // lock thread
- '/(\%b)/(un)?sticky/(\d+)' => 'secure sticky', // sticky thread
- '/(\%b)/bump(un)?lock/(\d+)' => 'secure bumplock', // "bumplock" thread
+ '/(\%b)/deletebyip/(\d+)(/global)?' => 'secure deletebyip', // delete all posts by IP address
+ '/(\%b)/(un)?lock/(\d+)' => 'secure lock', // lock thread
+ '/(\%b)/(un)?sticky/(\d+)' => 'secure sticky', // sticky thread
+ '/(\%b)/bump(un)?lock/(\d+)' => 'secure bumplock', // "bumplock" thread
- '/themes' => 'themes_list', // manage themes
+ '/themes' => 'themes_list', // manage themes
'/themes/(\w+)' => 'theme_configure', // configure/reconfigure theme
- '/themes/(\w+)/rebuild' => 'theme_rebuild', // rebuild theme
- '/themes/(\w+)/uninstall' => 'theme_uninstall', // uninstall theme
+ '/themes/(\w+)/rebuild' => 'theme_rebuild', // rebuild theme
+ '/themes/(\w+)/uninstall' => 'theme_uninstall', // uninstall theme
- '/config' => 'config', // config editor
+ '/config' => 'config', // config editor
'/config/(\%b)' => 'config', // config editor
// these pages aren't listed in the dashboard without $config['debug']
diff --git a/post.php b/post.php
index ac355e58..cfae69b7 100644
--- a/post.php
+++ b/post.php
@@ -452,7 +452,7 @@ if (isset($_POST['delete'])) {
if ($config['convert_auto_orient'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')) {
// The following code corrects the image orientation.
// Currently only works with the 'convert' option selected but it could easily be expanded to work with the rest if you can be bothered.
- if (!($config['redraw_image'] || ($config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')))) {
+ if (!($config['redraw_image'] || (($config['strip_exif'] && !$config['strip_with_exiftool']) && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg')))) {
if (in_array($config['thumb_method'], array('convert', 'convert+gifsicle', 'gm', 'gm+gifsicle'))) {
$exif = exif_read_data($upload);
$gm = in_array($config['thumb_method'], array('gm', 'gm+gifsicle'));
@@ -460,6 +460,7 @@ if (isset($_POST['delete'])) {
if($error = shell_exec_error(($gm ? 'gm ' : '') . 'convert ' .
escapeshellarg($upload) . ' -auto-orient ' . escapeshellarg($upload)))
error('Could not auto-orient image!', null, $error);
+ $size = @getimagesize($upload);
}
}
}