88 * @copyright 2024 Simple Machines and individual contributors
99 * @license https://www.simplemachines.org/about/smf/license.php BSD
1010 *
11- * @version 3.0 Alpha 1
11+ * @version 3.0 Alpha 3
1212 */
1313
1414// Stuff we will ignore.
1515global $ ignoreFiles , $ currentVersion ;
16+
1617$ ignoreFiles = [
1718 'index\.php ' ,
1819 '\.(?!php)[^.]*$ ' ,
1920];
2021
2122try {
22- if (($ upgradeFile = fopen ('./other/upgrade.php ' , 'r ' )) !== false ) {
23- $ upgradeContents = fread ($ upgradeFile , 1250 );
24-
25- // In production, only check index.english.php
26- if (!preg_match ('~define\( \'SMF_VERSION \', \'([^ \']+) \'\);~i ' , $ upgradeContents , $ versionResults )) {
27- throw new Exception ('Error: Could not locate SMF_VERSION ' );
28- }
29- if (version_compare ($ versionResults [1 ], '2.1.0 ' , '> ' )) {
30- $ ignoreFiles [] = '^(?!index\.) ' ;
31- }
23+ if (($ indexFile = fopen ('./index.php ' , 'r ' )) === false ) {
24+ throw new Exception ('Unable to open file ./index.php ' );
25+ }
3226
33- // We need SMF_LANG_VERSION, obviously.
34- if (!preg_match ('~define\( \'SMF_LANG_VERSION \', \'([^ \']+) \'\);~i ' , $ upgradeContents , $ versionResults )) {
35- throw new Exception ('Error: Could not locate SMF_LANG_VERSION ' );
36- }
37- $ currentVersion = $ versionResults [1 ];
27+ $ indexContents = fread ($ indexFile , 1250 );
3828
39- if (!file_exists ('./Languages ' )) {
40- checkLanguageDirectory ('./Themes/default/languages ' , '~([A-Za-z]+)\.english\.php~i ' );
41- } else {
42- checkLanguageDirectory ('./Languages/en_US ' , '~([A-Za-z]+)\.php~i ' );
43- // foreach (new DirectoryIterator('./Languages') as $dirInfo)
44- // if(!in_array($dirInfo->getFileName(), ['.', '..']) && is_dir($dirInfo->getPathname()))
45- // checkLanguageDirectory($dirInfo->getPathname());
46- }
47- } else {
48- throw new Exception ('Unable to open file ./upgrade.php ' );
29+ if (!preg_match ('~define\( \'SMF_VERSION \', \'([^ \']+) \'\);~i ' , $ indexContents , $ versionResults )) {
30+ throw new Exception ('Error: Could not locate SMF_VERSION ' );
4931 }
50- }
51- catch (Exception $ e ) {
32+
33+ $ currentVersion = $ versionResults [1 ];
34+ $ ignoreFiles [] = '^(?!General\.) ' ;
35+
36+ checkLanguageDirectory ('./Languages/en_US ' , '~([A-Za-z]+)\.php~i ' );
37+ } catch (Exception $ e ) {
5238 fwrite (STDERR , $ e ->getMessage ());
5339 exit (1 );
5440}
@@ -95,4 +81,4 @@ function checkLanguageDirectory($language_dir, $search)
9581 }
9682 }
9783 }
98- }
84+ }
0 commit comments