Browse Source

Merge pull request #29 from emanuele45/master

Okay, it's time for a pull...
Spuds 13 years ago
parent
commit
0e47361191

+ 1 - 0
Sources/Admin.php

@@ -181,6 +181,7 @@ function AdminMain()
 					'function' => 'ModifyModSettings',
 					'icon' => 'modifications.png',
 					'subsections' => array(
+						'hooks' => array($txt['hooks_title_list']),
 						'general' => array($txt['mods_cat_modifications_misc']),
 						// Mod Authors for a "ADD AFTER" on this line. Ensure you end your change with a comma. For example:
 						// 'shout' => array($txt['shout']),

+ 9 - 0
Sources/Groups.php

@@ -869,6 +869,15 @@ function GroupRequests()
 					'db' => 'reason',
 				),
 			),
+			'date' => array(
+				'header' => array(
+					'value' => $txt['date'],
+					'style' => 'width: 18%;white-space:nowrap;',
+				),
+				'data' => array(
+					'db' => 'time_submitted',
+				),
+			),
 			'action' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />',

+ 3 - 0
Sources/ManageBoards.php

@@ -626,6 +626,9 @@ function EditBoard2()
 			foreach ($_POST['groups'] as $group)
 				$boardOptions['access_groups'][] = (int) $group;
 
+		if (strlen(implode(',', $boardOptions['access_groups'])) > 255)
+			fatal_lang_error('too_many_groups', false);
+
 		// Change '1 & 2' to '1 &amp; 2', but not '&amp;' to '&amp;amp;'...
 		$boardOptions['board_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&amp;$1', $_POST['board_name']);
 		$boardOptions['board_description'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&amp;$1', $_POST['desc']);

+ 2 - 0
Sources/ManagePermissions.php

@@ -1546,6 +1546,8 @@ function loadAllPermissions($loadType = 'classic')
 	}
 	if (!in_array('w', $context['admin_features']))
 		$hiddenPermissions[] = 'issue_warning';
+	if (!in_array('k', $context['admin_features']))
+		$hiddenPermissions[] = 'karma_edit';
 
 	// Post moderation?
 	if (!$modSettings['postmod_active'])

+ 366 - 0
Sources/ManageSettings.php

@@ -151,6 +151,7 @@ function ModifyModSettings()
 	$context['page_title'] = $txt['admin_modifications'];
 
 	$subActions = array(
+		'hooks' => 'list_integration_hooks',
 		'general' => 'ModifyGeneralModSettings',
 		// Mod authors, once again, if you have a whole section to add do it AFTER this line, and keep a comma at the end.
 	);
@@ -2160,4 +2161,369 @@ function ModifyGeneralModSettings($return_config = false)
 	prepareDBSettingContext($config_vars);
 }
 
+function list_integration_hooks()
+{
+	global $sourcedir, $scripturl, $context, $txt, $modSettings, $settings;
+
+	if (!empty($_POST['remove_hooks']) && !empty($_POST['remove']) && is_array($_POST['remove']))
+	{
+		checkSession();
+
+		foreach ($_POST['remove'] as $hook => $functions)
+		{
+			if (!is_array($functions))
+				continue;
+
+			foreach ($functions as $function)
+				remove_integration_function($hook, $function);
+		}
+	}
+
+	if (!empty($_POST['disable']))
+	{
+		checkSession();
+
+		foreach ($_POST['disable'] as $hook => $functions)
+		{
+			if (!is_array($functions))
+				continue;
+
+			$active_hooks = explode(',', $modSettings[$hook]);
+			foreach ($active_hooks as &$active_hook)
+				$active_hook = trim($active_hook);
+
+			foreach ($functions as $function => $state)
+			{
+				$function = trim($function);
+				if ($state == 'disable' && in_array($function, $active_hooks))
+				{
+					remove_integration_function($hook, $function);
+					// It's a hack I know...but I'm way too lazy!!!
+					add_integration_function($hook, ']' . $function);
+				}
+				elseif ($state == 'enable' && in_array(']' . $function, $active_hooks))
+				{
+					remove_integration_function($hook, ']' . $function);
+					// It's a hack I know...but I'm way too lazy!!!
+					add_integration_function($hook, $function);
+				}
+			}
+		}
+	}
+
+	$context['filter'] = false;
+	$presentHooks = get_integration_hooks();
+	if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($presentHooks)))
+		$context['filter'] = $_GET['filter'];
+
+	$list_options = array(
+		'id' => 'list_integration_hooks',
+		'title' => $txt['hooks_title_list'],
+		'items_per_page' => 20,
+		'base_href' => $scripturl . '?action=admin;area=modsettings;sa=hooks;' . (!empty($context['filter']) ? ('filter=' . $context['filter'] . ';') : '') . $context['session_var'] . '=' . $context['session_id'],
+		'default_sort_col' => 'hook_name',
+		'get_items' => array(
+			'function' => 'get_integration_hooks_data',
+		),
+		'get_count' => array(
+			'function' => 'get_integration_hooks_count',
+		),
+		'no_items_label' => $txt['hooks_no_hooks'],
+		'columns' => array(
+			'hook_name' => array(
+				'header' => array(
+					'value' => $txt['hooks_field_hook_name'],
+				),
+				'data' => array(
+					'db' => 'hook_name',
+				),
+				'sort' =>  array(
+					'default' => 'hook_name',
+					'reverse' => 'hook_name DESC',
+				),
+			),
+			'function_name' => array(
+				'header' => array(
+					'value' => $txt['hooks_field_function_name'],
+				),
+				'data' => array(
+					'db' => 'function_name',
+				),
+				'sort' =>  array(
+					'default' => 'function_name',
+					'reverse' => 'function_name DESC',
+				),
+			),
+			'file_name' => array(
+				'header' => array(
+					'value' => $txt['hooks_field_file_name'],
+				),
+				'data' => array(
+					'db' => 'file_name',
+				),
+				'sort' =>  array(
+					'default' => 'file_name',
+					'reverse' => 'file_name DESC',
+				),
+			),
+			'status' => array(
+				'header' => array(
+					'value' => $txt['hooks_field_hook_exists'],
+					'style' => 'width:3%',
+				),
+				'data' => array(
+					'function' => create_function('$data', '
+						global $settings;
+
+						$change_status = array(\'before\' => \'\', \'after\' => \'\');
+						if ($data[\'can_be_disabled\'] && $data[\'status\'] != \'deny\')
+						{
+							$change_status[\'before\'] = \'<a href="" onclick="integrationHooks_switchstatus(this.id); return false;" id="\' . $data[\'id\'] . \'">\';
+							$change_status[\'after\'] = \'</a><input id="input_\' . $data[\'id\'] . \'" type="hidden" name="disable[\' . $data[\'hook_name\'] . \'][\' . $data[\'function_name\'] . \']" value="\' . ($data[\'enabled\'] ? \'enable\' : \'disable\') . \'" />\';
+						}
+						return $change_status[\'before\'] . \'<img src="\' . $settings[\'images_url\'] . \'/admin/post_moderation_\' . $data[\'status\'] . \'.png" alt="\' . $data[\'img_text\'] . \'" title="\' . $data[\'img_text\'] . \'" />\' . $change_status[\'after\'];
+					'),
+					'class' => 'centertext',
+				),
+				'sort' =>  array(
+					'default' => 'status',
+					'reverse' => 'status DESC',
+				),
+			),
+			'check' => array(
+				'header' => array(
+					'value' => $txt['hooks_button_remove'],
+					'style' => 'width:3%',
+				),
+				'data' => array(
+					'function' => create_function('$data', '
+						global $settings;
+
+						if (!$data[\'hook_exists\'])
+							return \'
+							<a href="" onclick="integrationHooks_remove(this.id); return false;" id="remove_\' . $data[\'id\'] . \'">
+								<img src="\' . $settings[\'images_url\'] . \'/icons/quick_remove.png" alt="*" title="*" />
+							</a>
+							<input id="input_remove_\' . $data[\'id\'] . \'" type="hidden" name="remove[\' . $data[\'hook_name\'] . \'][\' . $data[\'function_name\'] . \']" value="\' . ($data[\'enabled\'] ? \'enable\' : \'disable\') . \'" />\';
+					'),
+					'class' => 'centertext',
+				),
+			),
+		),
+		'form' => array(
+			'href' => $scripturl . '?action=admin;area=modsettings;sa=hooks;' . (!empty($context['filter']) ? ('filter=' . $context['filter'] . ';') : '') . $context['session_var'] . '=' . $context['session_id'],
+			'name' => 'list_integration_hooks',
+		),
+		'additional_rows' => array(
+			array(
+				'position' => 'after_title',
+				'value' => $txt['hooks_disable_instructions'] . '<br />
+					' . $txt['hooks_disable_legend'] . ':
+									<ul>
+					<li><img src="' . $settings['images_url'] . '/admin/post_moderation_allow.png" alt="' . $txt['hooks_active'] . '" title="' . $txt['hooks_active'] . '" /> ' . $txt['hooks_disable_legend_exists'] . '</li>
+					<li><img src="' . $settings['images_url'] . '/admin/post_moderation_moderate.png" alt="' . $txt['hooks_disabled'] . '" title="' . $txt['hooks_disabled'] . '" /> ' . $txt['hooks_disable_legend_disabled'] . '</li>
+					<li><img src="' . $settings['images_url'] . '/admin/post_moderation_deny.png" alt="' . $txt['hooks_missing'] . '" title="' . $txt['hooks_missing'] . '" /> ' . $txt['hooks_disable_legend_missing'] . '</li>
+				</ul>'
+			),
+		),
+	);
+
+	require_once($sourcedir . '/Subs-List.php');
+
+	createList($list_options);
+
+	$context['page_title'] = $txt['hooks_title_list'];
+	$context['sub_template'] = 'show_list';
+	$context['template_layers'][] = 'integrationHooks';
+	$context['default_list'] = 'list_integration_hooks';
+}
+
+function get_files_recursive($dir_path)
+{
+	$files = array();
+
+	if ($dh = opendir($dir_path))
+	{
+		while (($file = readdir($dh)) !== false)
+			if ($file != '.' && $file != '..')
+			{
+				if (is_dir($dir_path . '/' . $file))
+					$files = array_merge($files, get_files_recursive($dir_path . '/' . $file));
+				else
+					$files[] = array('dir' => $dir_path, 'name' => $file);
+			}
+	}
+	closedir($dh);
+
+	return $files;
+}
+
+function get_integration_hooks_data($start, $per_page, $sort)
+{
+	global $boarddir, $sourcedir, $settings, $txt, $context, $scripturl;
+
+	$hooks = $temp_hooks = get_integration_hooks();
+	$hooks_data = $temp_data = $hook_status = array();
+
+	$files = get_files_recursive($sourcedir);
+	if (!empty($files))
+		foreach ($files as $file)
+		{
+			if (is_file($file['dir'] . '/' . $file['name']) && substr($file['name'], -4) === '.php')
+			{
+				$fp = fopen($file['dir'] . '/' . $file['name'], 'rb');
+				$fc = fread($fp, filesize($file['dir'] . '/' . $file['name']));
+				fclose($fp);
+
+				foreach ($temp_hooks as $hook => $functions)
+				{
+					foreach ($functions as $function_o)
+					{
+						$function = str_replace(']', '', $function_o);
+						if (substr($hook, -8) === '_include')
+						{
+							$hook_status[$hook][$function]['exists'] = file_exists(strtr(trim($function), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])));
+							// I need to know if there is at least one function called in this file.
+							$temp_data['include'][basename($function)] = array('hook' => $hook, 'function' => $function);
+							unset($temp_hooks[$hook][$function_o]);
+						}
+						// @TODO replace with a preg_match? (the difference is the space before the open parentheses
+						elseif (strpos($fc, 'function ' . trim($function) . '(') !== false || strpos($fc, 'function ' . trim($function) . ' (') !== false)
+						{
+							$hook_status[$hook][$function]['exists'] = true;
+							$hook_status[$hook][$function]['in_file'] = $file['name'];
+							// I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too)
+							$temp_data['function'][$file['name']][] = $function_o;
+							unset($temp_hooks[$hook][$function_o]);
+						}
+					}
+				}
+			}
+		}
+
+	$sort_types = array(
+		'hook_name' => array('hook', SORT_ASC),
+		'hook_name DESC' => array('hook', SORT_DESC),
+		'function_name' => array('function', SORT_ASC),
+		'function_name DESC' => array('function', SORT_DESC),
+		'file_name' => array('file_name', SORT_ASC),
+		'file_name DESC' => array('file_name', SORT_DESC),
+		'status' => array('status', SORT_ASC),
+		'status DESC' => array('status', SORT_DESC),
+	);
+
+	$sort_options = $sort_types[$sort];
+	$sort = array();
+	$context['hooks_filters'] = '';
+	$hooks_filters = array();
+
+	foreach ($hooks as $hook => $functions)
+	{
+		$hooks_filters[] = '<option onclick="window.location = \'' . $scripturl . '?action=admin;area=modsettings;sa=hooks;filter=' . $hook . '\';">' . $hook . '</option>';
+		foreach ($functions as $function)
+		{
+			$enabled = strstr($function, ']') === false;
+			$function = str_replace(']', '', $function);
+			// This is a not an include and the function is included in a certain file (if not it doesn't exists so don't care)
+			if (substr($hook, -8) !== '_include' && isset($hook_status[$hook][$function]['in_file']))
+			{
+				$current_hook = isset($temp_data['include'][$hook_status[$hook][$function]['in_file']]) ? $temp_data['include'][$hook_status[$hook][$function]['in_file']] : '';
+				$enabled = false;
+
+				// Checking all the functions within this particular file
+				// if any of them is enable then the file *must* be included and the integrate_*_include hook cannot be disabled
+				foreach ($temp_data['function'][$hook_status[$hook][$function]['in_file']] as $func)
+					$enabled = $enabled || strstr($func, ']') !== false;
+
+				if (!$enabled &&  !empty($current_hook))
+					$hook_status[$current_hook['hook']][$current_hook['function']]['enabled'] = true;
+			}
+		}
+	}
+
+	if (!empty($hooks_filters))
+		$context['hooks_filters'] = '<select style="margin-left:15px;">' . '<option>---</option><option onclick="window.location = \'' . $scripturl . '?action=admin;area=modsettings;sa=hooks\';">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>';
+
+	$temp_data = array();
+	$id = 0;
+
+	foreach ($hooks as $hook => $functions)
+	{
+		if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook))
+			foreach ($functions as $function)
+			{
+				$enabled = strstr($function, ']') === false;
+				$function = str_replace(']', '', $function);
+				$hook_exists = !empty($hook_status[$hook][$function]['exists']);
+				$file_name = isset($hook_status[$hook][$function]['in_file']) ? $hook_status[$hook][$function]['in_file'] : ((substr($hook, -8) === '_include') ? 'zzzzzzzzz' : 'zzzzzzzza');
+				$status = $hook_exists ? ($enabled ? 'a' : 'b') : 'c';
+				$sort[] = $$sort_options[0];
+				$temp_data[] = array(
+					'id' => 'hookid_' . $id++,
+					'hook_name' => $hook,
+					'function_name' => $function,
+					'file_name' => (isset($hook_status[$hook][$function]['in_file']) ? $hook_status[$hook][$function]['in_file'] : ''),
+					'hook_exists' => $hook_exists,
+					'status' => $hook_exists ? ($enabled ? 'allow' : 'moderate') : 'deny',
+					'img_text' => $txt['hooks_' . ($hook_exists ? ($enabled ? 'active' : 'disabled') : 'missing')],
+					'enabled' => $enabled,
+					'can_be_disabled' => (isset($hook_status[$hook][$function]['enabled']) || $thisMod ? false : true),
+				);
+			}
+	}
+
+	array_multisort($sort, $sort_options[1], $temp_data);
+
+	$counter = 0;
+	$start++;
+
+	foreach ($temp_data as $data)
+	{
+		if (++$counter < $start)
+			continue;
+		elseif ($counter == $start + $per_page)
+			break;
+
+		$hooks_data[] = $data;
+	}
+
+	return $hooks_data;
+}
+
+function get_integration_hooks_count()
+{
+	global $context;
+
+	$hooks = get_integration_hooks();
+	$hooks_count = 0;
+
+	$context['filter'] = false;
+	if (isset($_GET['filter']))
+		$context['filter'] = $_GET['filter'];
+
+	foreach ($hooks as $hook => $functions)
+		if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook))
+			$hooks_count += count($functions);
+
+	return $hooks_count;
+}
+
+function get_integration_hooks()
+{
+	global $modSettings;
+	static $integration_hooks;
+
+	if (!isset($integration_hooks))
+	{
+		$integration_hooks = array();
+		foreach ($modSettings as $key => $value)
+		{
+			if (!empty($value) && substr($key, 0, 10) === 'integrate_')
+				$integration_hooks[$key] = explode(',', $value);
+		}
+	}
+
+	return $integration_hooks;
+}
+
 ?>

+ 2 - 2
Sources/ManageSmileys.php

@@ -1565,9 +1565,9 @@ function EditMessageIcons()
 			$_GET['icon'] = (int) $_GET['icon'];
 
 			// Do some preperation with the data... like check the icon exists *somewhere*
-			if (strpos($_POST['icon_filename'], '.gif') !== false)
+			if (strpos($_POST['icon_filename'], '.png') !== false)
 				$_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4);
-			if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.gif'))
+			if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png'))
 				fatal_lang_error('icon_not_found');
 			// There is a 16 character limit on message icons...
 			elseif (strlen($_POST['icon_filename']) > 16)

+ 6 - 2
Sources/MessageIndex.php

@@ -365,8 +365,9 @@ function MessageIndex()
 				IFNULL(meml.real_name, ml.poster_name) AS last_display_name, t.id_first_msg,
 				mf.poster_time AS first_poster_time, mf.subject AS first_subject, mf.icon AS first_icon,
 				mf.poster_name AS first_member_name, mf.id_member AS first_id_member,
-				IFNULL(memf.real_name, mf.poster_name) AS first_display_name, SUBSTRING(ml.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS last_body,
-				SUBSTRING(mf.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS first_body, ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys
+				IFNULL(memf.real_name, mf.poster_name) AS first_display_name, ' . (!empty($modSettings['preview_characters']) ? '
+				SUBSTRING(ml.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS last_body,
+				SUBSTRING(mf.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS first_body' : '') . 'ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys
 			FROM {db_prefix}topics AS t
 				INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
 				INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
@@ -810,6 +811,9 @@ function QuickModeration()
 			$stickyCache[] = $topic;
 		elseif ($action == 'move')
 		{
+			require_once($sourcedir . '/MoveTopic.php');
+			moveTopicConcurrence();
+
 			// $moveCache[0] is the topic, $moveCache[1] is the board to move to.
 			$moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']);
 

+ 37 - 0
Sources/MoveTopic.php

@@ -125,6 +125,8 @@ function MoveTopic()
 		$txt['movetopic_default'] = $temp;
 	}
 
+	moveTopicConcurrence();
+
 	// Register this form and get a sequence number in $context.
 	checkSubmitOnce('register');
 }
@@ -152,6 +154,8 @@ function MoveTopic2()
 	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == ''))
 		fatal_lang_error('movetopic_no_reason', false);
 
+	moveTopicConcurrence();
+
 	// Make sure this form hasn't been submitted before.
 	checkSubmitOnce('check');
 
@@ -689,4 +693,37 @@ function moveTopics($topics, $toBoard)
 	));
 }
 
+function moveTopicConcurrence()
+{
+	global $board, $topic, $smcFunc, $scripturl;
+
+	if (isset($_GET['current_board']))
+		$move_from = (int) $_GET['current_board'];
+
+	if (empty($move_from) || empty($board) || empty($topic))
+		return true;
+
+	if ($move_from == $board)
+		return true;
+	else
+	{
+		$request = $smcFunc['db_query']('', '
+			SELECT m.subject, b.name
+			FROM {db_prefix}topics as t
+			LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
+			LEFT JOIN {db_prefix}messages AS m ON (t.id_first_msg = m.id_msg)
+			WHERE t.id_topic = {int:topic_id}
+			LIMIT 1',
+			array(
+				'topic_id' => $topic,
+			)
+		);
+		list($topic_subject, $board_name) = $smcFunc['db_fetch_row']($request);
+		$smcFunc['db_free_result']($request);
+		$board_link = '<a href="' . $scripturl . '?board=' . $board . '.0">' . $board_name . '</a>';
+		$topic_link = '<a href="' . $scripturl . '?topic=' . $topic . '.0">' . $topic_subject . '</a>';
+		fatal_lang_error('topic_already_moved', false, array($topic_link, $board_link));
+	}
+}
+
 ?>

+ 1 - 1
Sources/Profile-Modify.php

@@ -799,7 +799,7 @@ function saveProfileFields()
 	// Cycle through the profile fields working out what to do!
 	foreach ($profile_fields as $key => $field)
 	{
-		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview']) && $key == 'signature'))
+		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature'))
 			continue;
 
 		// What gets updated?

+ 2 - 2
Sources/Profile.php

@@ -394,7 +394,7 @@ function ModifyProfile($post_errors = array())
 
 	// Before we go any further, let's work on the area we've said is valid. Note this is done here just in case we ever compromise the menu function in error!
 	$context['completed_save'] = false;
-	$context['do_preview'] = isset($_REQUEST['preview']);
+	$context['do_preview'] = isset($_REQUEST['preview_signature']);
 
 	$security_checks = array();
 	$found_area = false;
@@ -411,7 +411,7 @@ function ModifyProfile($post_errors = array())
 					fatal_lang_error('no_access', false);
 
 				// Are we saving data in a valid area?
-				if (isset($area['sc']) && isset($_REQUEST['save']))
+				if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview']))
 				{
 					$security_checks['session'] = $area['sc'];
 					$context['completed_save'] = true;

+ 29 - 0
Sources/RemoveTopic.php

@@ -48,6 +48,8 @@ function RemoveTopic2()
 	if (empty($topic))
 		redirectexit();
 
+	removeDeleteConcurrence();
+
 	$request = $smcFunc['db_query']('', '
 		SELECT t.id_member_started, ms.subject, t.approved
 		FROM {db_prefix}topics AS t
@@ -95,6 +97,8 @@ function DeleteMessage()
 	if (empty($topic) && isset($_REQUEST['topic']))
 		$topic = (int) $_REQUEST['topic'];
 
+	removeDeleteConcurrence();
+
 	$request = $smcFunc['db_query']('', '
 		SELECT t.id_member_started, m.id_member, m.subject, m.poster_time, m.approved
 		FROM {db_prefix}topics AS t
@@ -1458,4 +1462,29 @@ function mergePosts($msgs = array(), $from_topic, $target_topic)
 	updateLastMessages(array($from_board, $target_board));
 }
 
+function removeDeleteConcurrence()
+{
+	global $modSettings, $board, $topic, $smcFunc, $scripturl, $context;
+
+	// No recycle no need to go further
+	if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board']))
+		return false;
+
+	// If it's confirmed go on and delete (from recycle)
+	if (isset($_GET['confirm_delete']))
+		return true;
+
+	if (empty($board))
+		return false;
+
+	if ($modSettings['recycle_board'] != $board)
+		return true;
+	elseif (isset($_REQUEST['msg']))
+		$confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id'];
+	else
+		$confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id'];
+
+	fatal_lang_error('post_already_deleted', false, array($confirm_url));
+}
+
 ?>

+ 13 - 13
Sources/Subs-Editor.php

@@ -986,21 +986,21 @@ function getMessageIcons($board_id)
 				$icon_data[] = $row;
 			$smcFunc['db_free_result']($request);
 
-			cache_put_data('posting_icons-' . $board_id, $icon_data, 480);
-		}
-		else
-			$icon_data = $temp;
+			$icons = array();
+			foreach ($icon_data as $icon)
+			{
+				$icons[$icon['filename']] = array(
+					'value' => $icon['filename'],
+					'name' => $icon['title'],
+					'url' => $settings[file_exists($settings['theme_dir'] . '/images/post/' . $icon['filename'] . '.png') ? 'images_url' : 'default_images_url'] . '/post/' . $icon['filename'] . '.png',
+					'is_last' => false,
+				);
+			}
 
-		$icons = array();
-		foreach ($icon_data as $icon)
-		{
-			$icons[$icon['filename']] = array(
-				'value' => $icon['filename'],
-				'name' => $icon['title'],
-				'url' => $settings[file_exists($settings['theme_dir'] . '/images/post/' . $icon['filename'] . '.png') ? 'images_url' : 'default_images_url'] . '/post/' . $icon['filename'] . '.png',
-				'is_last' => false,
-			);
+			cache_put_data('posting_icons-' . $board_id, $icons, 480);
 		}
+		else
+			$icons = $temp;
 	}
 
 	return array_values($icons);

+ 40 - 0
Themes/default/Admin.template.php

@@ -1713,4 +1713,44 @@ function template_clean_cache_button_below()
 	</div>';
 }
 
+
+function template_integrationHooks_above()
+{
+}
+function template_integrationHooks_below()
+{
+	global $context;
+
+	if (empty($context['hooks_filters']))
+		return;
+
+	echo '
+	<script type="text/javascript"><!-- // --><![CDATA[
+		var tblHeader = document.getElementById(\'' . $context['default_list'] . '\').getElementsByTagName(\'th\')[0];
+		tblHeader.innerHTML += ' . JavaScriptEscape($context['hooks_filters']) . ';
+
+		function integrationHooks_switchstatus(id)
+		{
+			var elem = document.getElementById(\'input_\'+id);
+			if (elem.value == \'enable\')
+				elem.value = \'disable\';
+			else if (elem.value == \'disable\')
+				elem.value = \'enable\';
+
+			document.forms["' . $context['default_list'] . '"].submit();
+		}
+
+		function integrationHooks_remove(id)
+		{
+			var elem = document.getElementById(\'input_remove_\'+id);
+			if (elem.value == \'enable\')
+				elem.value = \'disable\';
+			else if (elem.value == \'disable\')
+				elem.value = \'enable\';
+
+			document.forms["' . $context['default_list'] . '"].submit();
+		}
+	// ]]></script>';
+}
+
 ?>

+ 1 - 1
Themes/default/BoardIndex.template.php

@@ -204,7 +204,7 @@ function template_main()
 					foreach ($board['children'] as $child)
 					{
 						if (!$child['is_redirect'])
-							$child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a  ' . ($child['new'] ? 'class="new_posts" ' : '') . 'href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>';
+							$child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a  ' . ($child['new'] ? 'class="new_posts" ' : '') . 'href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>';
 						else
 							$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
 

+ 1 - 1
Themes/default/Display.template.php

@@ -647,7 +647,7 @@ function template_main()
 	theme_linktree();
 
 	$mod_buttons = array(
-		'move' => array('test' => 'can_move', 'text' => 'move_topic', 'image' => 'admin_move.png', 'lang' => true, 'url' => $scripturl . '?action=movetopic;topic=' . $context['current_topic'] . '.0'),
+		'move' => array('test' => 'can_move', 'text' => 'move_topic', 'image' => 'admin_move.png', 'lang' => true, 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'),
 		'delete' => array('test' => 'can_delete', 'text' => 'remove_topic', 'image' => 'admin_rem.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['are_sure_remove_topic'] . '\');"', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
 		'lock' => array('test' => 'can_lock', 'text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'lang' => true, 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
 		'sticky' => array('test' => 'can_sticky', 'text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'lang' => true, 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),

+ 8 - 4
Themes/default/Errors.template.php

@@ -55,8 +55,10 @@ function template_error_log()
 					</span>
 				</h3>
 			</div>
-			<div class="pagesection floatleft">
-				&nbsp;&nbsp;', $txt['pages'], ': ', $context['page_index'], '
+			<div class="pagesection">
+				<div class="floatleft">
+					', $txt['pages'], ': ', $context['page_index'], '
+				</div>
 			</div>
 			<table border="0" cellspacing="1" class="table_grid" id="error_log">
 				<tr>
@@ -156,8 +158,10 @@ function template_error_log()
 					</td>
 				</tr>
 			</table>
-			<div class="pagesection floatleft">
-				&nbsp;&nbsp;', $txt['pages'], ': ', $context['page_index'], '
+			<div class="pagesection">
+				<div class="floatleft">
+					', $txt['pages'], ': ', $context['page_index'], '
+				</div>
 			</div>';  
 
 	echo '

+ 2 - 2
Themes/default/MessageIndex.template.php

@@ -103,7 +103,7 @@ function template_main()
 				foreach ($board['children'] as $child)
 				{
 					if (!$child['is_redirect'])
-						$child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a  ' . ($child['new'] ? 'class="new_posts" ' : '') . 'href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>';
+						$child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a  ' . ($child['new'] ? 'class="new_posts" ' : '') . 'href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>';
 					else
 						$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
 
@@ -303,7 +303,7 @@ function template_main()
 						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions[', $topic['id'], ']=sticky;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_sticky.png" width="16" alt="', $txt['set_sticky'], '" title="', $txt['set_sticky'], '" /></a>';
 
 					if ($topic['quick_mod']['move'])
-						echo '<a href="', $scripturl, '?action=movetopic;board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><img src="', $settings['images_url'], '/icons/quick_move.png" width="16" alt="', $txt['move_topic'], '" title="', $txt['move_topic'], '" /></a>';
+						echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><img src="', $settings['images_url'], '/icons/quick_move.png" width="16" alt="', $txt['move_topic'], '" title="', $txt['move_topic'], '" /></a>';
 				}
 				echo '
 					</td>';

+ 38 - 26
Themes/default/ModerationCenter.template.php

@@ -258,8 +258,10 @@ function template_reported_posts()
 				', $context['view_closed'] ? $txt['mc_reportedp_closed'] : $txt['mc_reportedp_active'], '
 			</h3>
 		</div>
-		<div class="pagesection floatleft">
-			', $txt['pages'], ': ', $context['page_index'], '
+		<div class="pagesection">
+			<div class="floatleft">
+				', $txt['pages'], ': ', $context['page_index'], '
+			</div>
 		</div>';
 
 	// Make the buttons.
@@ -357,45 +359,53 @@ function template_unapproved_posts()
 		</div>';
 	else
 		echo '
-			<div class="pagesection floatleft">
-				', $txt['pages'], ': ', $context['page_index'], '
+			<div class="pagesection">
+				<div class="floatleft">
+					', $txt['pages'], ': ', $context['page_index'], '
+				</div>
 			</div>';
 
 	foreach ($context['unapproved_items'] as $item)
 	{
 		echo '
-		<div class="cat_bar">
-			<h3 class="catbg">
-				<span class="smalltext floatleft">', $item['counter'], '&nbsp;</span>
-				<span class="smalltext floatleft"><a href="', $scripturl, '#c', $item['category']['id'], '">', $item['category']['name'], '</a> / <a href="', $scripturl, '?board=', $item['board']['id'], '.0">', $item['board']['name'], '</a> / <a href="', $scripturl, '?topic=', $item['topic']['id'], '.msg', $item['id'], '#msg', $item['id'], '">', $item['subject'], '</a></span>
-				<span class="smalltext floatright">', $txt['mc_unapproved_by'], ' ', $item['poster']['link'], ' ', $txt['on'], ': ', $item['time'], '</span>
-			</h3>
-		</div>
-		<div class="', $item['alternate'] ? 'windowbg' : 'windowbg2', '">
-			<span class="topslice"><span></span></span>
-			<div class="content">
-				<div class="post">', $item['body'], '</div>
-				<span class="floatright">
-					<a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>';
+		<div class="topic">
+			<div class="', $item['alternate'] == 0 ? 'windowbg2' : 'windowbg', ' core_posts">
+				<span class="topslice"><span></span></span>
+				<div class="content">
+					<div class="counter">', $item['counter'], '</div>
+					<div class="topic_details">
+						<h5><strong><a href="', $scripturl, '#c', $item['category']['id'], '">', $item['category']['name'], '</a> / <a href="', $scripturl, '?board=', $item['board']['id'], '.0">', $item['board']['name'], '</a> / <a href="', $scripturl, '?topic=', $item['topic'], '.', $item['start'], '#msg', $item['id'], '">', $item['subject'], '</a></strong></h5>
+						<span class="smalltext"><strong>', $txt['mc_unapproved_by'], ' ', $item['poster']['link'], ' ', $txt['on'], ':</strong> ', $item['time'], '</span>
+					</div>
+					<div class="list_posts">
+						<div class="post">', $item['body'], '</div>
+					</div>
+					<span class="floatright">
+						<a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>';
 
 			if ($item['can_delete'])
 				echo '
 					', $context['menu_separator'], '
-					<a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>';
+						<a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>';
 
-			echo '
-					<input type="checkbox" name="item[]" value="', $item['id'], '" checked="checked" class="input_check" /> ';
+			if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
+				echo '
+						<input type="checkbox" name="item[]" value="', $item['id'], '" checked="checked" class="input_check" /> ';
 
 			echo '
-				</span>
-				<br class="clear" />
+					</span>
+					<br class="clear" />
+				</div>
+				<span class="botslice"><span></span></span>
 			</div>
-			<span class="botslice"><span></span></span>
 		</div>';
 	}
 
 	echo '
-		<div class="pagesection">
+		<div class="pagesection">';
+
+	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
+		echo '
 			<div class="floatright">
 				<select name="do" onchange="if (this.value != 0 &amp;&amp; confirm(\'', $txt['mc_unapproved_sure'], '\')) submit();">
 					<option value="0">', $txt['with_selected'], ':</option>
@@ -452,8 +462,10 @@ function template_unapproved_attachments()
 			</div>';
 	else
 		echo '
-			<div class="pagesection floatleft">
-				', $txt['pages'], ': ', $context['page_index'], '
+			<div class="pagesection">
+				<div class="floatleft">
+					', $txt['pages'], ': ', $context['page_index'], '
+				</div>
 			</div>
 			<table class="table_grid" width="100%">
 			<thead>

+ 1 - 1
Themes/default/MoveTopic.template.php

@@ -19,7 +19,7 @@ function template_main()
 
 	echo '
 	<div id="move_topic" class="lower_padding">
-		<form action="', $scripturl, '?action=movetopic2;topic=', $context['current_topic'], '.0" method="post" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">
+		<form action="', $scripturl, '?action=movetopic2;current_board=' . $context['current_board'] . ';topic=', $context['current_topic'], '.0" method="post" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">
 			<div class="cat_bar">
 				<h3 class="catbg">', $txt['move_topic'], '</h3>
 			</div>

+ 1 - 1
Themes/default/Profile.template.php

@@ -2689,7 +2689,7 @@ function template_profile_signature_modify()
 
 	if (!empty($context['show_preview_button']))
 		echo '
-						<input type="submit" name="preview" id="preview_button" value="', $txt['preview_signature'], '" class="button_submit" />';
+						<input type="submit" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button_submit" />';
 
 	if ($context['signature_warning'])
 		echo '

+ 1 - 1
Themes/default/index.template.php

@@ -498,7 +498,7 @@ function template_menu()
 	{
 		echo '
 				<li id="button_', $act, '">
-					<a class="', $button['active_button'] ? 'active' : '', isset($button['is_last']) ? ' last' : '', '" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
+					<a class="', $button['active_button'] ? 'active' : '', !empty($button['is_last']) ? ' last' : '', '" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
 						', $button['title'], '
 					</a>';
 		if (!empty($button['sub_buttons']))

+ 17 - 0
Themes/default/languages/Admin.english.php

@@ -641,4 +641,21 @@ $txt['spider_stats'] = 'Stats';
 $txt['paid_subscriptions'] = 'Paid Subscriptions';
 $txt['paid_subs_view'] = 'View Subscriptions';
 
+$txt['hooks_title_list'] = 'Integration Hooks';
+$txt['hooks_field_hook_name'] = 'Hook Name';
+$txt['hooks_field_function_name'] = 'Function Name';
+$txt['hooks_field_file_name'] = 'File Name';
+$txt['hooks_field_hook_exists'] = 'Status';
+$txt['hooks_active'] = 'Exists';
+$txt['hooks_disabled'] = 'Disabled';
+$txt['hooks_missing'] = 'Not found';
+$txt['hooks_no_hooks'] = 'There are not any hooks setup.';
+$txt['hooks_button_remove'] = 'Remove';
+$txt['hooks_disable_instructions'] = 'Click on the status icon to enable or disable the hook';
+$txt['hooks_disable_legend'] = 'Legend';
+$txt['hooks_disable_legend_exists'] = 'the hook exists and is active';
+$txt['hooks_disable_legend_disabled'] = 'the hook exists but has been disabled';
+$txt['hooks_disable_legend_missing'] = 'the hook has not been found';
+$txt['hooks_reset_filter'] = 'Reset filter';
+
 ?>

+ 3 - 0
Themes/default/languages/Errors.english.php

@@ -168,6 +168,7 @@ $txt['no_span'] = 'The span feature is currently disabled.';
 $txt['invalid_days_numb'] = 'Invalid number of days to span.';
 
 $txt['moveto_noboards'] = 'There are no boards to move this topic to!';
+$txt['topic_already_moved'] = 'This topic %1$s has been moved to the board %2$s, please check its new location before moving it again.';
 
 $txt['already_activated'] = 'Your account has already been activated.';
 $txt['still_awaiting_approval'] = 'Your account is still awaiting admin approval.';
@@ -188,6 +189,7 @@ $txt['ban_name_exists'] = 'The name of this ban (%1$s) already exists. Please ch
 $txt['ban_trigger_already_exists'] = 'This ban trigger (%1$s) already exists in %2$s.';
 
 $txt['recycle_no_valid_board'] = 'No valid board selected for recycled topics';
+$txt['post_already_deleted'] = 'The topic or message has already been moved to the recycle board. Are you sure you want to delete it completely?<br />If so follow <a href="%1$s">this link</a>';
 
 $txt['login_threshold_fail'] = 'Sorry, you are out of login chances.  Please come back and try again later.';
 $txt['login_threshold_brute_fail'] = 'Sorry, but you\'ve reached your login attempts threshold.  Please wait 30 seconds and try again later.';
@@ -214,6 +216,7 @@ $txt['theme_edit_missing'] = 'The file you are trying to edit... can\'t even be
 $txt['no_dump_database'] = 'Only administrators can make database backups!';
 $txt['pm_not_yours'] = 'The personal message you\'re trying to quote is not your own or does not exist, please go back and try again.';
 $txt['mangled_post'] = 'Mangled form data - please go back and try again.';
+$txt['too_many_groups'] = 'Sorry, you selected too many groups, please remove some.';
 $txt['post_upload_error'] = 'The post data is missing. This error is can be caused by trying to submit a file larger than allowed by the server.  Please contact your administrator if this problem continues.';
 $txt['quoted_post_deleted'] = 'The post you are trying to quote either does not exist, was deleted, or is no longer viewable by you.';
 $txt['pm_too_many_per_hour'] = 'You have exceeded the limit of %1$d personal messages per hour.';

+ 2 - 0
other/upgrade.php

@@ -2170,6 +2170,8 @@ function changeSettings($config_vars)
 }
 function updateLastError() 
 {
+	global $db_last_error;
+
 	// clear out the db_last_error file
 	file_put_contents(dirname(__FILE__) . '/db_last_error.php', "<?php\n$db_last_error = 0;\n?" . ">\n");
 }

+ 64 - 25
other/upgrade_2-1_postgresql.sql

@@ -10,14 +10,12 @@ CREATE SEQUENCE {$db_prefix}member_logins_seq;
 
 ---# Creating login history table.
 CREATE TABLE {$db_prefix}member_logins (
-	id_login int(10) NOT NULL default nextval('{$db_prefix}member_logins_seq'),
-	id_member mediumint(8) NOT NULL,
-	time int(10) NOT NULL,
+	id_login int NOT NULL default nextval('{$db_prefix}member_logins_seq'),
+	id_member mediumint NOT NULL,
+	time int NOT NULL,
 	ip varchar(255) NOT NULL default '',
 	ip2 varchar(255) NOT NULL default '',
-	PRIMARY KEY id_login(id_login)
-	KEY id_member (id_member)
-	KEY time (time)
+	PRIMARY KEY (id_login)
 );
 ---#
 
@@ -104,26 +102,49 @@ unset($_GET['a']);
 
 ---# Adding new columns to ban items...
 ALTER TABLE {$db_prefix}ban_items
-ADD COLUMN ip_low5 smallint(255) unsigned NOT NULL DEFAULT '0',
-ADD COLUMN ip_high5 smallint(255) unsigned NOT NULL DEFAULT '0',
-ADD COLUMN ip_low6 smallint(255) unsigned NOT NULL DEFAULT '0',
-ADD COLUMN ip_high6 smallint(255) unsigned NOT NULL DEFAULT '0',
-ADD COLUMN ip_low7 smallint(255) unsigned NOT NULL DEFAULT '0',
-ADD COLUMN ip_high7 smallint(255) unsigned NOT NULL DEFAULT '0',
-ADD COLUMN ip_low8 smallint(255) unsigned NOT NULL DEFAULT '0',
-ADD COLUMN ip_high8 smallint(255) unsigned NOT NULL DEFAULT '0';
+ADD COLUMN ip_low5 smallint NOT NULL DEFAULT '0',
+ADD COLUMN ip_high5 smallint NOT NULL DEFAULT '0',
+ADD COLUMN ip_low6 smallint NOT NULL DEFAULT '0',
+ADD COLUMN ip_high6 smallint NOT NULL DEFAULT '0',
+ADD COLUMN ip_low7 smallint NOT NULL DEFAULT '0',
+ADD COLUMN ip_high7 smallint NOT NULL DEFAULT '0',
+ADD COLUMN ip_low8 smallint NOT NULL DEFAULT '0',
+ADD COLUMN ip_high8 smallint NOT NULL DEFAULT '0';
 ---#
 
 ---# Changing existing columns to ban items...
+---{
+upgrade_query("
+ALTER TABLE {$db_prefix}ban_items
+ALTER COLUMN ip_low1 type smallint,
+ALTER COLUMN ip_high1 type smallint,
+ALTER COLUMN ip_low2 type smallint,
+ALTER COLUMN ip_high2 type smallint,
+ALTER COLUMN ip_low3 type smallint,
+ALTER COLUMN ip_high3 type smallint,
+ALTER COLUMN ip_low4 type smallint,
+ALTER COLUMN ip_high4 type smallint;");
+upgrade_query("
 ALTER TABLE {$db_prefix}ban_items
-CHANGE ip_low1 ip_low1 smallint(255) unsigned NOT NULL DEFAULT '0',
-CHANGE ip_high1 ip_high1 smallint(255) unsigned NOT NULL DEFAULT '0',
-CHANGE ip_low2 ip_low2 smallint(255) unsigned NOT NULL DEFAULT '0',
-CHANGE ip_high2 ip_high2 smallint(255) unsigned NOT NULL DEFAULT '0',
-CHANGE ip_low3 ip_low3 smallint(255) unsigned NOT NULL DEFAULT '0',
-CHANGE ip_high3 ip_high3 smallint(255) unsigned NOT NULL DEFAULT '0',
-CHANGE ip_low4 ip_low4 smallint(255) unsigned NOT NULL DEFAULT '0',
-CHANGE ip_high4 ip_high4 smallint(255) unsigned NOT NULL DEFAULT '0';
+ALTER COLUMN ip_low1 SET DEFAULT '0',
+ALTER COLUMN ip_high1 SET DEFAULT '0',
+ALTER COLUMN ip_low2 SET DEFAULT '0',
+ALTER COLUMN ip_high2 SET DEFAULT '0',
+ALTER COLUMN ip_low3 SET DEFAULT '0',
+ALTER COLUMN ip_high3 SET DEFAULT '0',
+ALTER COLUMN ip_low4 SET DEFAULT '0',
+ALTER COLUMN ip_high4 SET DEFAULT '0';");
+upgrade_query("
+ALTER TABLE {$db_prefix}ban_items
+ALTER COLUMN ip_low1 SET NOT NULL,
+ALTER COLUMN ip_high1 SET NOT NULL,
+ALTER COLUMN ip_low2 SET NOT NULL,
+ALTER COLUMN ip_high2 SET NOT NULL,
+ALTER COLUMN ip_low3 SET NOT NULL,
+ALTER COLUMN ip_high3 SET NOT NULL,
+ALTER COLUMN ip_low4 SET NOT NULL,
+ALTER COLUMN ip_high4 SET NOT NULL;");
+---}
 ---#
 
 /******************************************************************************/
@@ -138,14 +159,32 @@ ADD COLUMN credits varchar(255) NOT NULL DEFAULT '';
 --- Adding more space for session ids
 /******************************************************************************/
 ---# Altering the session_id columns...
+---{
+upgrade_query("
+ALTER TABLE {$db_prefix}log_online
+ALTER COLUMN session type varchar(64);
+
+ALTER TABLE {$db_prefix}log_errors
+ALTER COLUMN session type char(64);
+
+ALTER TABLE {$db_prefix}sessions
+ALTER COLUMN session_id type char(64);");
+upgrade_query("
 ALTER TABLE {$db_prefix}log_online
-CHANGE `session` `session` varchar(64) NOT NULL DEFAULT '';
+ALTER COLUMN session SET DEFAULT '';
 
 ALTER TABLE {$db_prefix}log_errors
-CHANGE `session` `session` char(64) NOT NULL default '                                                                ';
+ALTER COLUMN session SET default '                                                                ';");
+upgrade_query("
+ALTER TABLE {$db_prefix}log_online
+ALTER COLUMN session SET NOT NULL;
+
+ALTER TABLE {$db_prefix}log_errors
+ALTER COLUMN session SET NOT NULL;
 
 ALTER TABLE {$db_prefix}sessions
-CHANGE `session_id` `session_id` char(64) NOT NULL;
+ALTER COLUMN session_id SET NOT NULL;");
+---}
 ---#
 
 /******************************************************************************/