Browse Source

! $context['browser'] was not setting all vars resulting in index errors on mods

Spuds 13 years ago
parent
commit
fba49b3745
3 changed files with 28 additions and 4 deletions
  1. 2 0
      Sources/Admin.php
  2. 1 1
      Sources/Display.php
  3. 25 3
      Sources/Load.php

+ 2 - 0
Sources/Admin.php

@@ -720,6 +720,7 @@ function AdminSearchInternal()
 		'ManageSettings', 'ManageBoards', 'ManageNews', 'ManageAttachments', 'ManageCalendar', 'ManageMail', 'ManagePaid', 'ManagePermissions',
 		'ManagePosts', 'ManageRegistration', 'ManageSearch', 'ManageSearchEngines', 'ManageServer', 'ManageSmileys', 'ManageLanguages',
 	);
+	// @todo add hook to add more include_files here
 	foreach ($include_files as $file)
 		require_once($sourcedir . '/' . $file . '.php');
 
@@ -789,6 +790,7 @@ function AdminSearchInternal()
 		array('ModifyPruningSettings', 'area=logs;sa=pruning'),
 	);
 
+	// @todo add hook to add more $settings search
 	foreach ($settings_search as $setting_area)
 	{
 		// Get a list of their variables.

+ 1 - 1
Sources/Display.php

@@ -1232,7 +1232,7 @@ function Download()
 		isAllowedTo('view_attachments');
 
 		// Make sure this attachment is on this board.
-		// @todo: We must verify that $topic is the attachment's topic, or else the permission check above is broken.
+		// NOTE: We must verify that $topic is the attachment's topic, or else the permission check above is broken.
 		$request = $smcFunc['db_query']('', '
 			SELECT a.id_folder, a.filename, a.file_hash, a.fileext, a.id_attach, a.attachment_type, a.mime_type, a.approved, m.id_member
 			FROM {db_prefix}attachments AS a

+ 25 - 3
Sources/Load.php

@@ -1229,9 +1229,33 @@ function loadMemberContext($user, $display_custom_fields = false)
 function detectBrowser()
 {
 	global $context, $user_info;
+	
+	// Always have these available in $context to support mods that don't use isBrowser
+	$context['browser'] = array(
+		'is_opera6' => false,
+		'is_opera7' => false,
+		'is_opera8' => false,
+		'is_opera9' => false,
+		'is_opera10' => false,
+		'is_ie4' => false,
+		'is_mac_ie' => false,
+		'is_firefox1' => false,
+		'is_firefox2' => false,
+		'is_firefox3' => false,
+		'is_iphone' => false,
+		'is_android' => false,
+		'is_chrome' => false,
+		'is_safari' => false,
+		'is_ie8' => false,
+		'is_ie7' => false,
+		'is_ie6' => false,
+		'is_ie5.5' => false,
+		'is_ie5' => false,
+		'ie_standards_fix' => false,
+	);
 
 	// The following determines the user agent (browser) as best it can.
-	$context['browser'] = array(
+	$context['browser'] += array(
 		'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
 		'is_webkit' => strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false,
 		'is_firefox' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1,
@@ -1297,7 +1321,6 @@ function detectBrowser()
 		$context['browser']['ie_standards_fix'] = !$context['browser']['is_ie8'];
 
 		$context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_ie8'] && !$context['browser']['is_ie7'];
-
 	}
 
 	$context['browser']['needs_size_fix'] = false;
@@ -1316,7 +1339,6 @@ function detectBrowser()
 	}
 	else
 		$context['browser']['possibly_robot'] = false;
-
 }
 
 /**