Skip to content

Commit 4ecd9b0

Browse files
Merge pull request #37 from Sesquipedalian/release-3.0
Updates check-smf-languages.php in light of SMF 3.0 upgrader changes
2 parents 1a9a337 + e854260 commit 4ecd9b0

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

check-smf-languages.php

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,33 @@
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.
1515
global $ignoreFiles, $currentVersion;
16+
1617
$ignoreFiles = [
1718
'index\.php',
1819
'\.(?!php)[^.]*$',
1920
];
2021

2122
try {
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

Comments
 (0)