Quellcode durchsuchen

Merge branch 'release-2.1' of https://github.com/SimpleMachines/SMF2.1 into release-2.1

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer vor 11 Jahren
Ursprung
Commit
7b1f4db314

+ 41 - 40
Sources/ManagePermissions.php

@@ -2240,59 +2240,60 @@ function loadIllegalGuestPermissions()
 	global $context;
 
 	$context['non_guest_permissions'] = array(
+		'access_mod_center',
+		'admin_forum',
+		'announce_topic',
+		'approve_posts',
+		'calendar_edit',
+		'delete',
 		'delete_replies',
+		'edit_news',
+		'issue_warning',
 		'karma_edit',
-		'poll_add_own',
+		'lock',
+		'make_sticky',
+		'manage_attachments',
+		'manage_bans',
+		'manage_boards',
+		'manage_membergroups',
+		'manage_permissions',
+		'manage_smileys',
+		'mark_any_notify',
+		'mark_notify',
+		'merge_any',
+		'moderate_board',
+		'moderate_forum',
+		'modify',
+		'modify_replies',
+		'move',
+		'pm_autosave_draft',
+		'pm_draft',
 		'pm_read',
 		'pm_send',
-		'profile_identity',
+		'poll_add',
+		'poll_edit',
+		'poll_lock',
+		'poll_remove',
+		'post_autosave_draft',
+		'post_draft',
+		'profile_blurb',
+		'profile_displayed_name',
 		'profile_extra',
-		'profile_signature',
 		'profile_forum',
+		'profile_identity',
 		'profile_other',
 		'profile_password',
-		'profile_title',
-		'profile_blurb',
-		'profile_displayed_name',
 		'profile_remove',
+		'profile_remote_avatar',
 		'profile_server_avatar',
+		'profile_signature',
+		'profile_title',
 		'profile_upload_avatar',
-		'profile_remote_avatar',
-		'mark_any_notify',
-		'mark_notify',
-		'admin_forum',
-		'manage_boards',
-		'manage_attachments',
-		'manage_smileys',
-		'edit_news',
-		'access_mod_center',
-		'moderate_forum',
-		'issue_warning',
-		'manage_membergroups',
-		'manage_permissions',
-		'manage_bans',
-		'move_own',
-		'modify_replies',
-		'send_mail',
-		'approve_posts',
-		'post_draft',
-		'post_autosave_draft',
-		'pm_draft',
-		'pm_autosave_draft',
+		'remove',
 		'report_any',
-		'make_sticky',
-		'merge_any',
+		'send_email_to_members',
+		'send_mail',
 		'split_any',
-		'lock_any',
-		'move_any',
-		'modify_any',
-		'remove_any',
-		'moderate_board',
-		'poll_add_any',
-		'poll_edit_any',
-		'poll_lock_any',
-		'poll_remove_any',
-		'announce_topic'
 	);
 
 	call_integration_hook('integrate_load_illegal_guest_permissions');

+ 41 - 13
Sources/Subs-Graphics.php

@@ -274,6 +274,16 @@ function checkImagick()
 	return class_exists('Imagick', false);
 }
 
+/**
+ * Checks whether the MagickWand extension is present.
+ *
+ * @return whether or not MagickWand is available.
+ */
+ function checkMagickWand()
+ {
+ 	return function_exists('newMagickWand');
+ }
+
 /**
  * See if we have enough memory to thumbnail an image
  *
@@ -317,8 +327,8 @@ function resizeImageFile($source, $destination, $max_width, $max_height, $prefer
 {
 	global $sourcedir;
 
-	// Nothing to do without GD or IM
-	if (!checkGD() && !checkImagick())
+	// Nothing to do without GD or IM/MW
+	if (!checkGD() && !checkImagick() && !checkMagickWand())
 		return false;
 
 	static $default_formats = array(
@@ -362,12 +372,13 @@ function resizeImageFile($source, $destination, $max_width, $max_height, $prefer
 		$sizes = array(-1, -1, -1);
 
 	// See if we have -or- can get the needed memory for this operation
-	if (checkGD() && !imageMemoryCheck($sizes))
+	// ImageMagick isn't subject to PHP's memory limits :)
+	if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes))
 		return false;
 
 	// A known and supported format?
 	// @todo test PSD and gif.
-	if (checkImagick() && isset($default_formats[$sizes[2]]))
+	if ((checkImagick() || checkMagickWand()) && isset($default_formats[$sizes[2]]))
 	{
 		return resizeImage(null, $destination, null, null, $max_width, $max_height, true, $preferred_format);
 	}
@@ -404,7 +415,7 @@ function resizeImage($src_img, $destName, $src_width, $src_height, $max_width, $
 {
 	global $gd2, $modSettings;
 
-	if (checkImagick())
+	if (checkImagick() || checkMagickWand())
 	{
 		static $default_formats = array(
 			'1' => 'gif',
@@ -415,15 +426,32 @@ function resizeImage($src_img, $destName, $src_width, $src_height, $max_width, $
 		);
 		$preferred_format = empty($preferred_format) || !isset($default_formats[$preferred_format]) ? 2 : $preferred_format;
 
-		$imagick = New Imagick($destName);
-		$src_width = empty($src_width) ? $imagick->getImageWidth() : $src_width;
-		$src_height = empty($src_height) ? $imagick->getImageHeight() : $src_height;
-		$dest_width = empty($max_width) ? $src_width : $max_width;
-		$dest_height = empty($max_height) ? $src_height : $max_height;
+		if (checkImagick())
+		{
+
+			$imagick = New Imagick($destName);
+			$src_width = empty($src_width) ? $imagick->getImageWidth() : $src_width;
+			$src_height = empty($src_height) ? $imagick->getImageHeight() : $src_height;
+			$dest_width = empty($max_width) ? $src_width : $max_width;
+			$dest_height = empty($max_height) ? $src_height : $max_height;
 
-		$imagick->setImageFormat($default_formats[$preferred_format]);
-		$imagick->resizeImage($dest_width, $dest_height, Imagick::FILTER_LANCZOS, 1, true);
-		$success = $imagick->writeImage($destName);
+			$imagick->setImageFormat($default_formats[$preferred_format]);
+			$imagick->resizeImage($dest_width, $dest_height, Imagick::FILTER_LANCZOS, 1, true);
+			$success = $imagick->writeImage($destName);
+		}
+		else
+		{
+			$magick_wand = newMagickWand();
+			MagickReadImage($magick_wand, $destName);
+			$src_width = empty($src_width) ? MagickGetImageWidth($magick_wand) : $src_width;
+			$src_height = empty($src_height) ? MagickGetImageSize($magick_wand) : $src_height;
+			$dest_width = empty($max_width) ? $src_width : $max_width;
+			$dest_height = empty($max_height) ? $src_height : $max_height;
+			
+			MagickSetImageFormat($magick_wand, $default_formats[$preferred_format]);
+			MagickResizeImage($magic_wand, $dest_width, $dest_height, MW_LanczosFilter, 1, true);
+			$success = MagickWriteImage($magick_wand, $destName);
+		}
 
 		return !empty($success);
 	}

+ 47 - 0
other/upgrade_2-1_mysql.sql

@@ -772,4 +772,51 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '1';
 ---# Adding "modified_reason" column to messages
 ALTER TABLE {$db_prefix}messages
 ADD COLUMN modified_reason varchar(255) NOT NULL;
+---#
+
+/******************************************************************************/
+--- Cleaning up guest permissions
+/******************************************************************************/
+---# Removing permissions guests can no longer have...
+---{
+	$illegal_board_permissions = array(
+		'announce_topic',
+		'delete_any',
+		'lock_any',
+		'make_sticky',
+		'merge_any',
+		'modify_any',
+		'modify_replies',
+		'move_any',
+		'poll_add_any',
+		'poll_edit_any',
+		'poll_lock_any',
+		'poll_remove_any',
+		'remove_any',
+		'report_any',
+		'split_any'
+	);
+
+	$illegal_permissions = array('calendar_edit_any', 'moderate_board', 'moderate_forum', 'send_email_to_members');
+
+	$smcFunc['db_query']('', '
+		DELETE FROM {db_prefix}board_permissions
+		WHERE id_group = {int:guests}
+		AND permission IN ({array_string:illegal_board_perms})',
+		array(
+			'guests' => -1,
+			'illegal_board_perms' => $illegal_board_permissions,
+		)
+	);
+
+	$smcFunc['db_query']('', '
+		DELETE FROM {db_prefix}permissions
+		WHERE id_group = {int:guests}
+		AND permission IN ({array_string:illegal_perms}',
+		array(
+			'guests' => -1,
+			'illegal_perms' => $illegal_permissions,
+		)
+	);
+---}
 ---#

+ 47 - 0
other/upgrade_2-1_postgresql.sql

@@ -851,4 +851,51 @@ ADD COLUMN in_inbox smallint NOT NULL default '1';
 ---# Adding "modified_reason" column to messages
 ALTER TABLE {$db_prefix}messages
 ADD COLUMN modified_reason varchar(255) NOT NULL default '';
+---#
+
+/******************************************************************************/
+--- Cleaning up guest permissions
+/******************************************************************************/
+---# Removing permissions guests can no longer have...
+---{
+	$illegal_board_permissions = array(
+		'announce_topic',
+		'delete_any',
+		'lock_any',
+		'make_sticky',
+		'merge_any',
+		'modify_any',
+		'modify_replies',
+		'move_any',
+		'poll_add_any',
+		'poll_edit_any',
+		'poll_lock_any',
+		'poll_remove_any',
+		'remove_any',
+		'report_any',
+		'split_any'
+	);
+
+	$illegal_permissions = array('calendar_edit_any', 'moderate_board', 'moderate_forum', 'send_email_to_members');
+
+	$smcFunc['db_query']('', '
+		DELETE FROM {db_prefix}board_permissions
+		WHERE id_group = {int:guests}
+		AND permission IN ({array_string:illegal_board_perms})',
+		array(
+			'guests' => -1,
+			'illegal_board_perms' => $illegal_board_permissions,
+		)
+	);
+
+	$smcFunc['db_query']('', '
+		DELETE FROM {db_prefix}permissions
+		WHERE id_group = {int:guests}
+		AND permission IN ({array_string:illegal_perms}',
+		array(
+			'guests' => -1,
+			'illegal_perms' => $illegal_permissions,
+		)
+	);
+---}
 ---#

+ 47 - 0
other/upgrade_2-1_sqlite.sql

@@ -828,4 +828,51 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '1';
 ---# Adding "modified_reason" column to messages
 ALTER TABLE {$db_prefix}messages
 ADD COLUMN modified_reason varchar(255) NOT NULL default '';
+---#
+
+/******************************************************************************/
+--- Cleaning up guest permissions
+/******************************************************************************/
+---# Removing permissions guests can no longer have...
+---{
+	$illegal_board_permissions = array(
+		'announce_topic',
+		'delete_any',
+		'lock_any',
+		'make_sticky',
+		'merge_any',
+		'modify_any',
+		'modify_replies',
+		'move_any',
+		'poll_add_any',
+		'poll_edit_any',
+		'poll_lock_any',
+		'poll_remove_any',
+		'remove_any',
+		'report_any',
+		'split_any'
+	);
+
+	$illegal_permissions = array('calendar_edit_any', 'moderate_board', 'moderate_forum', 'send_email_to_members');
+
+	$smcFunc['db_query']('', '
+		DELETE FROM {db_prefix}board_permissions
+		WHERE id_group = {int:guests}
+		AND permission IN ({array_string:illegal_board_perms})',
+		array(
+			'guests' => -1,
+			'illegal_board_perms' => $illegal_board_permissions,
+		)
+	);
+
+	$smcFunc['db_query']('', '
+		DELETE FROM {db_prefix}permissions
+		WHERE id_group = {int:guests}
+		AND permission IN ({array_string:illegal_perms}',
+		array(
+			'guests' => -1,
+			'illegal_perms' => $illegal_permissions,
+		)
+	);
+---}
 ---#