Browse Source

Merge branch 'master' of https://github.com/Spuds/playpen

emanuele 13 years ago
parent
commit
741eb9fc3b

+ 1 - 1
Sources/Admin.php

@@ -91,7 +91,7 @@ function AdminMain()
 					'label' => $txt['admin_logoff'],
 					'function' => 'AdminEndSession',
 					'enabled' => empty($modSettings['securityDisable']),
-//					'icon' => 'administration.png',
+					'icon' => 'exit.png',
 				),
 
 			),

+ 4 - 4
Sources/Class-CurlFetchWeb.php

@@ -131,11 +131,11 @@ class curl_fetch_web_data
 
 		// store this 'loops' data, someone may want all of these :O
 		$this->response[] = array(
-			'url'	 => $url,
-			'code'	=> $http_code,
-			'error'   => $error,
+			'url' => $url,
+			'code' => $http_code,
+			'error' => $error,
 			'headers' => isset($this->headers) ? $this->headers : false,
-			'body'	=> $body,
+			'body' => $body,
 		);
 
 		// If this a redirect with a location header and we have not given up, then do it again

+ 7 - 0
Sources/ManagePosts.php

@@ -196,6 +196,9 @@ function ModifyPostSettings($return_config = false)
 			array('int', 'spamWaitTime', 'postinput' => $txt['manageposts_seconds']),
 			array('int', 'edit_wait_time', 'postinput' => $txt['manageposts_seconds']),
 			array('int', 'edit_disable_time', 'subtext' => $txt['edit_disable_time_zero'], 'postinput' => $txt['manageposts_minutes']),
+		'',
+			// First & Last message preview lengths
+			array('int', 'preview_characters', 'subtext' => $txt['preview_characters_zero'], 'postinput' => $txt['preview_characters_units']),
 	);
 
 	call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
@@ -249,6 +252,10 @@ function ModifyPostSettings($return_config = false)
 				$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
 			}
 		}
+		
+		// If we're changing the post preview length let's check its valid
+		if (!empty($_POST['preview_characters']))
+			$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
 
 		call_integration_hook('integrate_save_post_settings');
 

+ 7 - 3
Sources/ManageServer.php

@@ -104,6 +104,9 @@ function ModifySettings()
 	// By default we're editing the core settings
 	$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'general';
 	$context['sub_action'] = $_REQUEST['sa'];
+	
+	// Any messages to speak of?
+	$context['settings_message'] = (isset($_REQUEST['msg']) && isset($txt[$_REQUEST['msg']])) ? $txt[$_REQUEST['msg']] : '';
 
 	// Warn the user if there's any relevant information regarding Settings.php.
 	if ($_REQUEST['sa'] != 'cache')
@@ -174,7 +177,7 @@ function ModifyGeneralSettings($return_config = false)
 		call_integration_hook('integrate_save_general_settings');
 
 		saveSettings($config_vars);
-		redirectexit('action=admin;area=serversettings;sa=general;' . $context['session_var'] . '=' . $context['session_id']);
+		redirectexit('action=admin;area=serversettings;sa=general;' . $context['session_var'] . '=' . $context['session_id']. ';msg=' . (!empty($context['settings_message']) ? $context['settings_message'] : 'core_settings_saved'));
 	}
 
 	// Fill the config array.
@@ -238,7 +241,7 @@ function ModifyDatabaseSettings($return_config = false)
 		call_integration_hook('integrate_save_database_settings');
 
 		saveSettings($config_vars);
-		redirectexit('action=admin;area=serversettings;sa=database;' . $context['session_var'] . '=' . $context['session_id']);
+		redirectexit('action=admin;area=serversettings;sa=database;' . $context['session_var'] . '=' . $context['session_id'] . ';msg=' . (!empty($context['settings_message']) ? $context['settings_message'] : 'core_settings_saved'));
 	}
 
 	// Fill the config array.
@@ -305,7 +308,7 @@ function ModifyCookieSettings($return_config = false)
 			redirectexit('action=admin;area=serversettings;sa=cookie;' . $context['session_var'] . '=' . $original_session_id, $context['server']['needs_login_fix']);
 		}
 
-		redirectexit('action=admin;area=serversettings;sa=cookie;' . $context['session_var'] . '=' . $context['session_id']);
+		redirectexit('action=admin;area=serversettings;sa=cookie;' . $context['session_var'] . '=' . $context['session_id']. ';msg=' . (!empty($context['settings_message']) ? $context['settings_message'] : 'core_settings_saved'));
 	}
 
 	// Fill the config array.
@@ -505,6 +508,7 @@ function ModifyLoadBalancingSettings($return_config = false)
 	}
 	
 	createToken('admin-ssc');
+	createToken('admin-dbsc');
 	prepareDBSettingContext($config_vars);
 }
 

+ 1 - 1
Sources/ManageSettings.php

@@ -1732,7 +1732,7 @@ function EditCustomProfiles()
 			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
 
 		// Regex you say?  Do a very basic test to see if the pattern is valid
-		if (isset($_POST['regex']) && (empty($_POST['regex']) || @preg_match($_POST['regex'], 'dummy') === false))
+		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false)
 			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
 			
 		$_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);

+ 10 - 8
Sources/MessageIndex.php

@@ -365,8 +365,8 @@ 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, 385) AS last_body,
-				SUBSTRING(mf.body, 1, 385) 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, 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)
@@ -398,15 +398,17 @@ function MessageIndex()
 			if (!$pre_query)
 				$topic_ids[] = $row['id_topic'];
 
-			if (!empty($settings['message_index_preview']))
+			// Does the theme support message previews?
+			if (!empty($settings['message_index_preview']) && !empty($modSettings['preview_characters']))
 			{
-				// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
+				// Limit them to $modSettings['preview_characters'] characters
 				$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br />' => '&#10;')));
-				if ($smcFunc['strlen']($row['first_body']) > 128)
-					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
+				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
+					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
+				
 				$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br />' => '&#10;')));
-				if ($smcFunc['strlen']($row['last_body']) > 128)
-					$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
+				if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
+					$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
 
 				// Censor the subject and message preview.
 				censorText($row['first_subject']);

+ 2 - 2
Sources/Post.php

@@ -545,13 +545,13 @@ function Post()
 
 			// Do all bulletin board code tags, with or without smileys.
 			$context['preview_message'] = parse_bbc($context['preview_message'], isset($_REQUEST['ns']) ? 0 : 1);
-
+			censorText($context['preview_message']);
+			
 			if ($form_subject != '')
 			{
 				$context['preview_subject'] = $form_subject;
 
 				censorText($context['preview_subject']);
-				censorText($context['preview_message']);
 			}
 			else
 				$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';

+ 82 - 54
Sources/Subs-Admin.php

@@ -77,13 +77,13 @@ function getServerVersions($checkFor)
 
 /**
  * Search through source, theme and language files to determine their version.
- * Get detailed version information about the physical SMF files on the
- * server.
- * the input parameter allows to set whether to include SSI.php and
- * whether the results should be sorted.
- * returns an array containing information on source files, templates
- * and language files found in the default theme directory (grouped by
- * language).
+ * Get detailed version information about the physical SMF files on the server.
+ * 
+ * - the input parameter allows to set whether to include SSI.php and whether 
+ *   the results should be sorted.
+ * - returns an array containing information on source files, templates and
+ *   language files found in the default theme directory (grouped by language).
+ *
  * @param array &$versionOptions
  */
 function getFileVersions(&$versionOptions)
@@ -223,25 +223,38 @@ function getFileVersions(&$versionOptions)
  *
  * The most important function in this file for mod makers happens to be the
  * updateSettingsFile() function, but it shouldn't be used often anyway.
- * updates the Settings.php file with the changes in config_vars.
- * expects config_vars to be an associative array, with the keys as the
- * variable names in Settings.php, and the values the varaible values.
- * does not escape or quote values.
- * preserves case, formatting, and additional options in file.
- * writes nothing if the resulting file would be less than 10 lines
- * in length (sanity check for read lock.)
+ * 
+ * - updates the Settings.php file with the changes supplied in config_vars.
+ * - expects config_vars to be an associative array, with the keys as the
+ *   variable names in Settings.php, and the values the variable values.
+ * - does not escape or quote values.
+ * - preserves case, formatting, and additional options in file.
+ * - writes nothing if the resulting file would be less than 10 lines
+ *   in length (sanity check for read lock.)
+ * - check for changes to db_last_error and passes those off to a separate handler
+ * - attempts to create a backup file and will use it should the writing of the 
+ *   new settings file fail
  *
  * @param array $config_vars
  */
 function updateSettingsFile($config_vars)
 {
-	global $boarddir, $cachedir;
+	global $boarddir, $cachedir, $context;
+	
+	// Updating the db_last_error, then don't mess around with Settings.php
+	if (count($config_vars) === 1 && isset($config_vars['db_last_error']))
+	{
+		updateDbLastError($config_vars['db_last_error']);
+		return;
+	}
 
-	// When is Settings.php last changed?
+	// When was Settings.php last changed?
 	$last_settings_change = filemtime($boarddir . '/Settings.php');
 
-	// Load the file.  Break it up based on \r or \n, and then clean out extra characters.
+	// Load the settings file.
 	$settingsArray = trim(file_get_contents($boarddir . '/Settings.php'));
+	
+	// Break it up based on \r or \n, and then clean out extra characters.
 	if (strpos($settingsArray, "\n") !== false)
 		$settingsArray = explode("\n", $settingsArray);
 	elseif (strpos($settingsArray, "\r") !== false)
@@ -249,23 +262,15 @@ function updateSettingsFile($config_vars)
 	else
 		return;
 
-	// Make sure we got a good file.
-	if (count($config_vars) == 1 && isset($config_vars['db_last_error']))
-	{
-		$temp = trim(implode("\n", $settingsArray));
-		if (substr($temp, 0, 5) != '<?php' || substr($temp, -2) != '?' . '>')
-			return;
-		if (strpos($temp, 'sourcedir') === false || strpos($temp, 'boarddir') === false)
-			return;
-	}
-
 	// Presumably, the file has to have stuff in it for this function to be called :P.
 	if (count($settingsArray) < 10)
 		return;
 
+	// remove any /r's that made there way in here
 	foreach ($settingsArray as $k => $dummy)
 		$settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n";
 
+	// go line by line and see whats changing
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
 	{
 		// Don't trim or bother with it if it's not a variable.
@@ -277,7 +282,13 @@ function updateSettingsFile($config_vars)
 		// Look through the variables to set....
 		foreach ($config_vars as $var => $val)
 		{
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
+			// be sure someone is not updating db_last_error this with a group
+			if ($var === 'db_last_error')
+			{
+				updateDbLastError($val);
+				unset($config_vars[$var]);
+			}
+			elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
 			{
 				$comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#');
 				$settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n";
@@ -287,6 +298,7 @@ function updateSettingsFile($config_vars)
 			}
 		}
 
+		// End of the file ... maybe
 		if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>')
 			$end = $i;
 	}
@@ -295,16 +307,18 @@ function updateSettingsFile($config_vars)
 	if (empty($end) || $end < 10)
 		$end = count($settingsArray) - 1;
 
-	// Still more?  Add them at the end.
+	// Still more variables to go?  Then lets add them at the end.
 	if (!empty($config_vars))
 	{
 		if (trim($settingsArray[$end]) == '?' . '>')
 			$settingsArray[$end++] = '';
 		else
 			$end++;
-
+		
+		// Add in any newly defined vars that were passed
 		foreach ($config_vars as $var => $val)
 			$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
+		
 		$settingsArray[$end] = '?' . '>';
 	}
 	else
@@ -315,24 +329,22 @@ function updateSettingsFile($config_vars)
 		return;
 
 	// Try to avoid a few pitfalls:
-	// like a possible race condition,
-	// or a failure to write at low diskspace
-
-	// Check before you act: if cache is enabled, we can do a simple test
-	// Can we even write things on this filesystem?
+	//  - like a possible race condition,
+	//  - or a failure to write at low diskspace
+	//
+	// Check before you act: if cache is enabled, we can do a simple write test
+	// to validate that we even write things on this filesystem.
 	if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
 		$cachedir = $boarddir . '/cache';
+	
 	$test_fp = @fopen($cachedir . '/settings_update.tmp', "w+");
 	if ($test_fp)
 	{
 		fclose($test_fp);
-
-		$test_fp = @fopen($cachedir . '/settings_update.tmp', 'r+');
-		$written_bytes = fwrite($test_fp, "test");
-		fclose($test_fp);
+		$written_bytes = file_put_contents($cachedir . '/settings_update.tmp', 'test', LOCK_EX);
 		@unlink($cachedir . '/settings_update.tmp');
 
-		if ($written_bytes !== strlen("test"))
+		if ($written_bytes !== 4)
 		{
 			// Oops. Low disk space, perhaps. Don't mess with Settings.php then.
 			// No means no. :P
@@ -344,23 +356,39 @@ function updateSettingsFile($config_vars)
 	clearstatcache();
 	if (filemtime($boarddir . '/Settings.php') === $last_settings_change)
 	{
-		// You asked for it...
-		// Blank out the file - done to fix a oddity with some servers.
-		$fp = @fopen($boarddir . '/Settings.php', 'w');
-
-		// Is it even writable, though?
-		if ($fp)
+		// save the old before we do anything
+		$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
+
+		// write out the new
+		$write_settings = implode('', $settingsArray);
+		$written_bytes = file_put_contents($boarddir . '/Settings.php', $write_settings, LOCK_EX);
+		
+		// survey says ...
+		if ($written_bytes !== strlen($write_settings) && !$settings_backup_fail)
 		{
-			fclose($fp);
+			// Well this is not good at all, lets see if we can save this
+			$context['settings_message'] = 'settings_error';
 
-			$fp = fopen($boarddir . '/Settings.php', 'r+');
-			foreach ($settingsArray as $line)
-				fwrite($fp, strtr($line, "\r", ''));
-			fclose($fp);
+			if (file_exists($boarddir . '/Settings_bak.php'))
+				@copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php');
 		}
 	}
 }
 
+/**
+ * Saves the time of the last db error for the error log
+ * - Done separately from updateSettingsFile to avoid race conditions 
+ *   which can occur during a db error
+ * - If it fails Settings.php will assume 0
+ */
+function updateDbLastError($time) 
+{
+	global $boarddir; 
+	
+	// Write out the db_last_error file with the error timestamp 
+	file_put_contents($boarddir . '/db_last_error.php', "<?php\n$db_last_error = " . $time . ";\n?" . ">\n", LOCK_EX);
+	@touch($boarddir . '/' . 'Settings.php');
+}
 /**
  * Saves the admins current preferences to the database.
  */
@@ -400,9 +428,9 @@ function updateAdminPreferences()
 
 /**
  * Send all the administrators a lovely email.
- * loads all users who are admins or have the admin forum permission.
- * uses the email template and replacements passed in the parameters.
- * sends them an email.
+ * - loads all users who are admins or have the admin forum permission.
+ * - uses the email template and replacements passed in the parameters.
+ * - sends them an email.
  */
 function emailAdmins($template, $replacements = array(), $additional_recipients = array())
 {

+ 10 - 3
Sources/Who.php

@@ -413,10 +413,15 @@ function determineActions($urls, $preferred_prefix = false)
 			{
 				if (allowedTo($allowedActions[$actions['action']]))
 					$data[$k] = $txt['whoallow_' . $actions['action']];
+				elseif (in_array('moderate_forum', $allowedActions[$actions['action']]))
+					$data[$k] = $txt['who_moderate'];
+				elseif (in_array('admin_forum', $allowedActions[$actions['action']]))
+					$data[$k] = $txt['who_admin'];
 				else
 					$data[$k] = $txt['who_hidden'];
 			}
-			// Unlisted or unknown action.
+			elseif (!empty($actions['action']))
+				$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
 			else
 				$data[$k] = $txt['who_unknown'];
 		}
@@ -685,7 +690,9 @@ function Credits($in_admin = false)
 
 	$context['copyrights'] = array(
 		'smf' => sprintf($forum_copyright, $forum_version),
-
+		'other' => array(
+			'<a href="http://p.yusukekamiyamane.com/">Fugue Icons</a> | &copy; 2012 Yusuke Kamiyamane | These icons are licensed under a Creative Commons Attribution 3.0 License',
+		),
 		/* Modification Authors:  You may add a copyright statement to this array for your mods.
 			Copyright statements should be in the form of a value only without a array key.  I.E.:
 				'Some Mod by Thantos &copy; 2010',
@@ -721,7 +728,7 @@ function Credits($in_admin = false)
 			$title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ' : ' . $version;
 
 			// build this one out and stash it away
-			$mod_name = empty($credit_info['url']) ? '<strong>' . $title . '</strong>' : '<a href="' . $credit_info['url'] . '">' . '<strong>' . $title . '</strong>' . '</a>';
+			$mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>';
 			$mods[] =  $mod_name . (!empty($license) ? ' | ' . $license  : '') . (!empty($copyright) ? ' | ' . $copyright  : '');
 		}
 		cache_put_data('mods_credits', $mods, 86400);

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

@@ -781,7 +781,7 @@ function template_show_settings()
 				</h3>
 			</div>';
 
-	// Have we got some custom code to insert?
+	// Have we got a message to display?
 	if (!empty($context['settings_message']))
 		echo '
 			<div class="information">', $context['settings_message'], '</div>';

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

@@ -255,7 +255,7 @@ function template_main()
 					</td>
 					<td class="subject ', $alternate_class, '">
 						<div ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\');"' : ''), '>
-							', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], ($context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '';
+							', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], ($context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '';
 
 			// Is this topic new? (assuming they are logged in!)
 			if ($topic['new'] && $context['user']['is_logged'])

+ 4 - 4
Themes/default/Recent.template.php

@@ -179,7 +179,7 @@ function template_unread()
 							</td>
 							<td class="subject ', $color_class2, ' windowbg2">
 								<div>
-									', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
+									', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
 									<a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
 									<p>
 										', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>
@@ -201,7 +201,7 @@ function template_unread()
 
 			if ($showCheckboxes)
 				echo '
-							<td class="windowbg2" valign="middle" align="center">
+							<td class="' . (!empty($color_class) ? $color_class : 'windowbg2') . '" valign="middle" align="center">
 								<input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
 							</td>';
 			echo '
@@ -363,7 +363,7 @@ function template_replies()
 							</td>
 							<td class="subject ', $color_class2, ' windowbg2">
 								<div>
-									', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
+									', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
 									<a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
 									<p>
 										', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>
@@ -385,7 +385,7 @@ function template_replies()
 
 			if ($showCheckboxes)
 				echo '
-							<td class="windowbg2" valign="middle" align="center">
+							<td class="' . (!empty($color_class) ? $color_class : 'windowbg2') . '" valign="middle" align="center">
 								<input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
 							</td>';
 			echo '

+ 10 - 0
Themes/default/Settings.template.php

@@ -263,6 +263,16 @@ function template_settings()
 			'id' => 'additional_options_collapsable',
 			'label' => $txt['additional_options_collapsable'],
 		),
+	'',
+		array(
+			'id' => 'message_index_preview',
+			'label' => $txt['message_index_preview'],
+		),
+		array(
+			'id' => 'message_index_preview_first',
+			'label' => $txt['message_index_preview_first'],
+			'description' => $txt['message_index_preview_first_desc'],
+		),
 	);
 }
 

+ 9 - 0
Themes/default/Who.template.php

@@ -208,6 +208,15 @@ function template_credits()
 	echo '
 					</dd>
 				</dl>';
+				
+	if (!empty($context['copyrights']['other']))
+	{
+		echo '
+				<dl>
+					<dt><strong>', $txt['credits_other'], '</strong></dt>
+					<dd>', implode('</dd><dd>', $context['copyrights']['other']), '</dd>
+				</dl>';
+	}
 
 	if (!empty($context['copyrights']['mods']))
 	{

BIN
Themes/default/images/admin/exit.png


+ 2 - 5
Themes/default/index.template.php

@@ -68,9 +68,6 @@ function template_init()
 	// Does this theme use the strict doctype?
 	$settings['strict_doctype'] = false;
 
-	// Does this theme use post previews on the message index?
-	$settings['message_index_preview'] = false;
-
 	// Set the following variable to true if this theme requires the optional theme strings file to be loaded.
 	$settings['require_theme_strings'] = false;
 }
@@ -331,7 +328,7 @@ function template_body_above()
 		// If we're on a certain board, limit it to this board ;).
 		elseif (!empty($context['current_board']))
 			echo '
-				<input type="hidden" name="', (!empty($modSettings['search_dropdown']) ? 'sd_brd[' : 'brd['), $context['current_board'],   ']"', 'value="', $context['current_board'], '" />';
+				<input type="hidden" name="', (!empty($modSettings['search_dropdown']) ? 'sd_brd[' : 'brd['), $context['current_board'], ']"', ' value="', $context['current_board'], '" />';
 
 		echo '
 				<input type="submit" name="search2" value="', $txt['search'], '" class="button_submit" />
@@ -635,4 +632,4 @@ function template_css()
 	<link rel="stylesheet" type="text/css" href="', $filename, '" />';
 }
 
-?>
+?>

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

@@ -507,6 +507,9 @@ $txt['spamWaitTime'] = 'Time required between posts from the same IP';
 $txt['edit_wait_time'] = 'Courtesy edit wait time';
 $txt['edit_disable_time'] = 'Maximum time after posting to allow edit';
 $txt['edit_disable_time_zero'] = '0 to disable';
+$txt['preview_characters'] = 'Maximum length of last/first post preview';
+$txt['preview_characters_units'] = 'characters';
+$txt['preview_characters_zero'] = '0 to disable';
 
 $txt['enableBBC'] = 'Enable bulletin board code (BBC)';
 $txt['enablePostHTML'] = 'Enable <em>basic</em> HTML in posts';

+ 1 - 0
Themes/default/languages/Help.english.php

@@ -391,6 +391,7 @@ $helptxt['loginHistoryDays'] = 'The number of days to keep login history under u
 $helptxt['oldTopicDays'] = 'If this option is enabled a warning will be displayed to the user when attempting to reply to a topic which has not had any new replies for the amount of time, in days, specified by this setting. Set this setting to 0 to disable the feature.';
 $helptxt['edit_wait_time'] = 'Number of seconds allowed for a post to be edited before logging the last edit date.';
 $helptxt['edit_disable_time'] = 'Number of minutes allowed to pass before a user can no longer edit a post they have made. Set to 0 disable. <br /><br /><em>Note: This will not affect any user who has permission to edit other people\'s posts.</em>';
+$helptxt['preview_characters'] = 'This option sets the number of available characters for the first and last message topic preview.  <strong>Note</strong> this only makes the information available to the theme, the theme must support the message_index_preview setting';
 $helptxt['posts_require_captcha'] = 'This setting will force users to pass anti-spam bot verification each time they make a post to a board. Only users with a post count below the number set will need to enter the code - this should help combat automated spamming scripts.';
 $helptxt['enableSpellChecking'] = 'Enable spell checking. You MUST have the pspell library installed on your server and your PHP configuration set up to use the pspell library. Your server ' . (function_exists('pspell_new') ? 'DOES' : 'DOES NOT') . ' appear to have this set up.';
 $helptxt['disable_wysiwyg'] = 'This setting disallows all users from using the WYSIWYG (&quot;What You See Is What You Get&quot;) editor on the post page.';

+ 2 - 0
Themes/default/languages/ManageSettings.english.php

@@ -98,6 +98,8 @@ $txt['who_enabled'] = 'Enable who\'s online list';
 $txt['make_email_viewable'] = 'Allow viewable email addresses';
 $txt['meta_keywords'] = 'Meta keywords associated with forum';
 $txt['meta_keywords_note'] = 'For search engines. Leave blank for default.';
+$txt['settings_error'] = 'Warning: Updating of Settings.php failed, the settings cannot be saved.';
+$txt['core_settings_saved'] = 'The settings were successfully saved';
 
 $txt['karmaMode'] = 'Karma mode';
 $txt['karma_options'] = 'Disable karma|Enable karma total|Enable karma positive/negative';

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

@@ -63,6 +63,9 @@ $txt['forum_width_desc'] = 'Set the forum width. Examples: 950px, 80%, 1240px.';
 $txt['enable_random_news'] = 'Enable random news line in the forum header';
 $txt['show_group_key'] = 'Show group key on board index';
 $txt['additional_options_collapsable'] = 'Enable collapsible additional post options';
+$txt['message_index_preview'] = 'Show post previews on the message index';
+$txt['message_index_preview_first'] = 'When show post previews, Show the text of the first post';
+$txt['message_index_preview_first_desc'] = 'Leave un-checked to show the text of the last post instead';
 $txt['allow_no_censored'] = 'Allow users to turn off word censoring';
 $txt['who_display_viewing'] = 'Show who is viewing the board index and posts';
 $txt['who_display_viewing_off'] = 'Don\'t show';

+ 4 - 0
Themes/default/languages/Who.english.php

@@ -4,6 +4,9 @@
 global $scripturl, $context;
 
 $txt['who_hidden'] = '<em>Nothing, or nothing you can see...</em>';
+$txt['who_admin'] = 'Viewing the admin portal';
+$txt['who_moderate'] = 'Viewing the moderator portal';
+$txt['who_generic'] = 'Viewing the';
 $txt['who_unknown'] = '<em>Unknown Action</em>';
 $txt['who_user'] = 'User';
 $txt['who_time'] = 'Time';
@@ -132,6 +135,7 @@ $txt['credits_anyone'] = 'And for anyone we may have missed, thank you!';
 $txt['credits_copyright'] = 'Copyrights';
 $txt['credits_forum'] = 'Forum';
 $txt['credits_modifications'] = 'Modifications';
+$txt['credits_other'] = 'Software/Graphics';
 $txt['credits_groups_ps'] = 'Project Support';
 $txt['credits_groups_dev'] = 'Developers';
 $txt['credits_groups_support'] = 'Support Specialists';

+ 9 - 1
other/Settings.php

@@ -156,7 +156,15 @@ $sourcedir = dirname(__FILE__) . '/Sources';
 
 ########## Error-Catching ##########
 # Note: You shouldn't touch these settings.
-$db_last_error = 0;
+if (file_exists(dirname(__FILE__) . '/db_last_error.php')); 
+	include(dirname(__FILE__) . '/db_last_error.php'); 
+
+if (!isset($db_last_error))
+{
+	// File does not exist so lets try to create it
+	updateDbLastError(0); 
+	$db_last_error = 0; 
+}
 
 if (file_exists(dirname(__FILE__) . '/install.php'))
 {

+ 8 - 0
other/install.php

@@ -1966,6 +1966,14 @@ function updateSettingsFile($vars)
 	return true;
 }
 
+function updateDbLastError() 
+{
+	// Write out the db_last_error file with the error timestamp 
+	file_put_contents(dirname(__FILE__) . '/db_last_error.php', "<?php\n$db_last_error = 0;\n?" . ">\n");
+	
+	return true;
+}
+
 // Create an .htaccess file to prevent mod_security. SMF has filtering built-in.
 function fixModSecurity()
 {

+ 6 - 0
other/upgrade.php

@@ -689,6 +689,7 @@ function upgradeExit($fallThrough = false)
 		$upgradeData = base64_encode(serialize($upcontext['user']));
 		copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
 		changeSettings(array('upgradeData' => '"' . $upgradeData . '"'));
+		updateLastError();
 	}
 
 	// Handle the progress of the step, if any.
@@ -2167,6 +2168,11 @@ function changeSettings($config_vars)
 	fwrite($fp, rtrim($settingsArray[$i]));
 	fclose($fp);
 }
+function updateLastError() 
+{
+	// clear out the db_last_error file
+	file_put_contents(dirname(__FILE__) . '/db_last_error.php', "<?php\n$db_last_error = 0;\n?" . ">\n");
+}
 
 function php_version_check()
 {

+ 3 - 3
other/upgrade_2-1_mysql.sql

@@ -135,13 +135,13 @@ ADD COLUMN credits varchar(255) NOT NULL DEFAULT '';
 /******************************************************************************/
 ---# Altering the session_id columns...
 ALTER TABLE {$db_prefix}log_online
-CHANGE `session` varchar(64) NOT NULL DEFAULT '';
+CHANGE `session` `session` varchar(64) NOT NULL DEFAULT '';
 
 ALTER TABLE {$db_prefix}log_errors
-CHANGE `session` char(64) NOT NULL default '                                                                ';
+CHANGE `session` `session` char(64) NOT NULL default '                                                                ';
 
 ALTER TABLE {$db_prefix}sessions
-CHANGE `session_id` char(64) NOT NULL;
+CHANGE `session_id` `session_id` char(64) NOT NULL;
 ---#
 
 /******************************************************************************/

+ 3 - 3
other/upgrade_2-1_postgresql.sql

@@ -139,13 +139,13 @@ ADD COLUMN credits varchar(255) NOT NULL DEFAULT '';
 /******************************************************************************/
 ---# Altering the session_id columns...
 ALTER TABLE {$db_prefix}log_online
-CHANGE `session` varchar(64) NOT NULL DEFAULT '';
+CHANGE `session` `session` varchar(64) NOT NULL DEFAULT '';
 
 ALTER TABLE {$db_prefix}log_errors
-CHANGE `session` char(64) NOT NULL default '                                                                ';
+CHANGE `session` `session` char(64) NOT NULL default '                                                                ';
 
 ALTER TABLE {$db_prefix}sessions
-CHANGE `session_id` char(64) NOT NULL;
+CHANGE `session_id` `session_id` char(64) NOT NULL;
 ---#
 
 /******************************************************************************/

+ 3 - 3
other/upgrade_2-1_sqlite.sql

@@ -135,13 +135,13 @@ ADD COLUMN credits varchar(255) NOT NULL DEFAULT '';
 /******************************************************************************/
 ---# Altering the session_id columns...
 ALTER TABLE {$db_prefix}log_online
-CHANGE `session` varchar(64) NOT NULL DEFAULT '';
+CHANGE `session` `session` varchar(64) NOT NULL DEFAULT '';
 
 ALTER TABLE {$db_prefix}log_errors
-CHANGE `session` char(64) NOT NULL default '                                                                ';
+CHANGE `session` `session` char(64) NOT NULL default '                                                                ';
 
 ALTER TABLE {$db_prefix}sessions
-CHANGE `session_id` char(64) NOT NULL;
+CHANGE `session_id` `session_id` char(64) NOT NULL;
 ---#
 
 /******************************************************************************/