Explorar el Código

Please don't try to install mods from here

Signed-off-by: Suki <[email protected]>
Suki hace 11 años
padre
commit
810d65fa2f
Se han modificado 2 ficheros con 14 adiciones y 3 borrados
  1. 12 3
      Sources/Themes.php
  2. 2 0
      Themes/default/languages/Errors.english.php

+ 12 - 3
Sources/Themes.php

@@ -1288,7 +1288,8 @@ function PickTheme()
  */
 function ThemeInstall()
 {
-	global $sourcedir, $boarddir, $boardurl, $txt, $context, $settings, $modSettings, $smcFunc;
+	global $sourcedir, $boarddir, $boardurl, $txt, $context;
+	global $settings, $modSettings, $scripturl, $smcFunc;
 
 	checkSession('request');
 
@@ -1298,6 +1299,7 @@ function ThemeInstall()
 	require_once($sourcedir . '/Subs-Package.php');
 
 	loadTemplate('Themes');
+	loadLanguage('Errors');
 
 	// Make it easier to change the path.
 	$themedir = $boarddir . '/Themes';
@@ -1465,7 +1467,7 @@ function ThemeInstall()
 			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
 	}
 
-	// Something went wrong?
+	// Let us proceed with the install.
 	if ($theme_dir != '' && basename($theme_dir) != 'Themes')
 	{
 		// Defaults.
@@ -1476,7 +1478,14 @@ function ThemeInstall()
 			'name' => $theme_name
 		);
 
-		if (file_exists($theme_dir . '/theme_info.xml'))
+		// Perhaps they are trying to install a mod, lets tell them nicely this is the wrong function.
+		if (file_exists($theme_dir . '/package-info.xml'))
+		{
+			$txt['package_get_error_is_mod'] = str_replace('{MANAGEMODURL}', $scripturl . '?action=admin;area=packages;' . $context['session_var'] . '=' . $context['session_id'], $txt['package_get_error_is_mod']);
+			fatal_lang_error('package_theme_upload_error_broken', false, $txt['package_get_error_is_mod']);
+		}
+
+		elseif (file_exists($theme_dir . '/theme_info.xml'))
 		{
 			$theme_info = file_get_contents($theme_dir . '/theme_info.xml');
 

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

@@ -292,12 +292,14 @@ $txt['package_upload_error_failed'] = 'Could not upload package, please check di
 $txt['package_upload_error_exists'] = 'The file you are uploading already exists on the server. Please delete it first then try again.';
 $txt['package_upload_error_supports'] = 'The package manager currently allows only these file types: %1$s.';
 $txt['package_upload_error_broken'] = 'Package upload failed due to the following error:<br />&quot;%1$s&quot;';
+$txt['package_theme_upload_error_broken'] = 'Theme upload failed due to the following error:<br />&quot;%1$s&quot;';
 
 $txt['package_get_error_not_found'] = 'The package you are trying to install cannot be located. You may want to manually upload the package to your Packages directory.';
 $txt['package_get_error_missing_xml'] = 'The package you are attempting to install is missing the package-info.xml that must be in the root package directory.';
 $txt['package_get_error_is_zero'] = 'Although the package was downloaded to the server it appears to be empty. Please check the Packages directory, and the &quot;temp&quot; sub-directory are both writable. If you continue to experience this problem you should try extracting the package on your PC and uploading the extracted files into a subdirectory in your Packages directory and try again. For example, if the package was called shout.tar.gz you should:<br />1) Download the package to your local PC and extract it into files.<br />2) Using an FTP client create a new directory in your &quot;Packages&quot; folder, in this example you may call it "shout".<br />3) Upload all the files from the extracted package to this directory.<br />4) Go back to the package manager browse page and the package will be automatically found by SMF.';
 $txt['package_get_error_packageinfo_corrupt'] = 'SMF was unable to find any valid information within the package-info.xml file included within the Package. There may be an error with the modification, or the package may be corrupt.';
 $txt['package_get_error_is_theme'] = 'You can\'t install a Theme from this section, please use the <a href="{MANAGETHEMEURL}">Themes and Layout</a> management page to upload it';
+$txt['package_get_error_is_mod'] = 'You can\'t install a mod from this section, please use the <a href="{MANAGEMODURL}">Package manager</a> page to upload it';
 
 $txt['no_membergroup_selected'] = 'No membergroup selected';
 $txt['membergroup_does_not_exist'] = 'The membergroup doesn\'t exist or is invalid.';