Skip to content

Commit 25b9ea3

Browse files
authored
Merge pull request #141 from iMattPro/develop
More fixes
2 parents c71ec4f + ccab2b6 commit 25b9ea3

7 files changed

Lines changed: 41 additions & 16 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ build/*
99
*~
1010
.idea
1111
*/node_modules
12+
includes/qi_constants.php

includes/class_qi.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public static function page_header($page_title = '')
5050
'S_USER_LANG' => $user->lang['USER_LANG'],
5151

5252
'TRANSLATION_INFO' => $user->lang['TRANSLATION_INFO'],
53-
'QI_VERSION' => QI_VERSION,
53+
'QI_VERSION' => self::current_version(),
5454

55-
'VERSION_CHECK_TITLE' => !empty($update) ? sprintf($user->lang['VERSION_CHECK_TITLE'], $update['current'], QI_VERSION) : '',
55+
'VERSION_CHECK_TITLE' => !empty($update) ? sprintf($user->lang['VERSION_CHECK_TITLE'], $update['current'], self::current_version()) : '',
5656
'VERSION_CHECK_CURRENT' => !empty($update) ? $update['current'] : '',
5757
'U_VERSION_CHECK_URL' => !empty($update) ? $update['download'] : '',
5858
));
@@ -345,7 +345,7 @@ public static function msg_handler($errno, $msg_text, $errfile, $errline)
345345
'MSG_EXPLAIN' => '',
346346
'SETTINGS_FORM' => '',
347347
'RETURN_LINKS' => $l_return_index,
348-
'QI_VERSION' => QI_VERSION,
348+
'QI_VERSION' => self::current_version(),
349349
'L_QUICKINSTALL' => $user->lang['QUICKINSTALL'],
350350
'L_PHPBB_QI_TEXT' => $user->lang['PHPBB_QI_TEXT'],
351351
'L_FOR_PHPBB_VERSIONS' => $user->lang['FOR_PHPBB_VERSIONS'],
@@ -405,9 +405,28 @@ public static function get_update()
405405
$version_helper = new qi_version_helper();
406406

407407
return $version_helper
408-
->set_current_version(QI_VERSION)
408+
->set_current_version(self::current_version())
409409
->force_stability('stable')
410410
->set_file_location('www.phpbb.com', '/customise/db/official_tool/phpbb3_quickinstall', 'version_check')
411411
->get_update();
412412
}
413+
414+
/**
415+
* Get the current version of QuickInstall from composer.json
416+
*
417+
* @return string
418+
*/
419+
public static function current_version()
420+
{
421+
global $quickinstall_path;
422+
423+
static $composerJson = null;
424+
425+
if ($composerJson === null) {
426+
$composerJson = file_get_contents("{$quickinstall_path}composer.json");
427+
$composerJson = json_decode($composerJson, true);
428+
}
429+
430+
return $composerJson["version"];
431+
}
413432
}

includes/class_qi_settings.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
*/
2222
class settings
2323
{
24+
/**
25+
* Cookie with the latest used profile name as payload.
26+
*/
27+
const QI_PROFILE_COOKIE = 'qi_profile';
28+
2429
/**
2530
* Array with configuration settings.
2631
* @private
@@ -84,11 +89,11 @@ function __construct($profile = '', $mode = '')
8489
$this->profile = $profile;
8590
$this->set_profile_cookie($profile);
8691
}
87-
else if (!empty($_COOKIE[QI_PROFILE_COOKIE]) && is_readable("{$quickinstall_path}settings/{$_COOKIE[QI_PROFILE_COOKIE]}.cfg"))
92+
else if (!empty($_COOKIE[self::QI_PROFILE_COOKIE]) && is_readable("{$quickinstall_path}settings/{$_COOKIE[self::QI_PROFILE_COOKIE]}.cfg"))
8893
{
8994
// Get the previously used profile.
90-
$config = file("{$quickinstall_path}settings/{$_COOKIE[QI_PROFILE_COOKIE]}.cfg", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
91-
$this->profile = $_COOKIE[QI_PROFILE_COOKIE];
95+
$config = file("{$quickinstall_path}settings/{$_COOKIE[self::QI_PROFILE_COOKIE]}.cfg", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
96+
$this->profile = $_COOKIE[self::QI_PROFILE_COOKIE];
9297
}
9398
else
9499
{
@@ -827,7 +832,7 @@ function set_profile_cookie($profile = 'default')
827832
{
828833
// A Julian year == 365.25 days * 86,400 seconds
829834
$expire_time = time() + 31557600;
830-
setcookie(QI_PROFILE_COOKIE, $profile, $expire_time);
835+
setcookie(self::QI_PROFILE_COOKIE, $profile, $expire_time);
831836
}
832837

833838
/**

includes/qi_constants.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*
88
*/
99

10-
define('QI_VERSION', '1.4.0');
11-
//define('QI_DEBUG', true); // un-comment this disable template caching
10+
// IMPORTANT NOTE:
11+
// This file is for development and debugging purposes only. Use class constants instead of
12+
// defining global constants here. This file is ignored by git.
1213

13-
// Cookies set by QI
14-
define('QI_PROFILE_COOKIE', 'qi_profile'); // Cookie with the latest used profile name as payload.
14+
//define('QI_DEBUG', true); // un-comment this disable template caching

includes/qi_functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ function gen_error_msg($msg_text, $msg_title = 'General Error', $msg_explain = '
270270
'MSG_EXPLAIN' => $msg_explain,
271271
'SETTINGS_FORM' => $settings_form,
272272
'RETURN_LINKS' => $l_return_index,
273-
'QI_VERSION' => QI_VERSION,
273+
'QI_VERSION' => qi::current_version(),
274274
'L_QUICKINSTALL' => $l_quickinstall,
275275
'L_PHPBB_QI_TEXT' => $l_phpbb_qi_text,
276276
'L_FOR_PHPBB_VERSIONS' => $l_for_phpbb_versions,

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
else if (!empty($settings->update_text)) // PROFILE_UPDATED
250250
{
251251
$update_title = sprintf($user->lang['PROFILE_UPDATED'], $settings->profile);
252-
$update_explain = sprintf($user->lang['UPDATED_EXPLAIN'], QI_VERSION);
252+
$update_explain = sprintf($user->lang['UPDATED_EXPLAIN'], qi::current_version());
253253

254254
$update_msg = '<ul>';
255255
foreach ($settings->update_text as $update)

modules/qi_create.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,11 +831,11 @@ public function __construct()
831831
$user->ip = &$user_ip;
832832
if (defined('PHPBB_31'))
833833
{
834-
add_log('admin', sprintf($user->lang['LOG_INSTALL_INSTALLED_QI'], QI_VERSION));
834+
add_log('admin', sprintf($user->lang['LOG_INSTALL_INSTALLED_QI'], qi::current_version()));
835835
}
836836
else
837837
{
838-
add_log('admin', 'LOG_INSTALL_INSTALLED_QI', QI_VERSION);
838+
add_log('admin', 'LOG_INSTALL_INSTALLED_QI', qi::current_version());
839839
}
840840

841841
// purge cache

0 commit comments

Comments
 (0)