Browse Source

Some checks before doing anything.

Signed-off-by: Suki <[email protected]>
Suki 11 years ago
parent
commit
81968e14ef
2 changed files with 12 additions and 0 deletions
  1. 10 0
      Sources/Themes.php
  2. 2 0
      Themes/default/languages/Themes.english.php

+ 10 - 0
Sources/Themes.php

@@ -1357,7 +1357,17 @@ function InstallFile()
 
 function InstallDir()
 {
+	global $themedir;
 
+	// Cannot use the theme dir as a theme dir.
+	elseif (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
+		fatal_lang_error('theme_install_invalid_dir', false);
+
+	// Check is there is "somthing" on the dir.
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
+		fatal_lang_error('theme_install_error', false);
+
+	// All good!
 }
 
 /**

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

@@ -33,6 +33,8 @@ $txt['theme_install_error_file_3'] = 'The uploaded file was only partially uploa
 $txt['theme_install_error_file_4'] = 'No file was uploaded.';
 $txt['theme_install_error_file_6'] = 'Missing a temporary upload folder.';
 $txt['theme_install_error_file_7'] = 'Failed to write file to disk.';
+$txt['theme_install_invalid_dir'] = 'You did not add a path for your actual theme, you cannot re-add the default theme';
+
 
 
 $txt['theme_latest'] = 'Latest and Greatest Themes';