Skip to content

Commit e841137

Browse files
authored
Merge pull request #175 from iMattPro/develop
Strengthen version acquisition + more fixes
2 parents 66f0e62 + a26c2ba commit e841137

File tree

3 files changed

+39
-24
lines changed

3 files changed

+39
-24
lines changed

includes/qi_functions.php

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ function get_alternative_env($selected_option = '')
469469
*/
470470
function get_installed_boards()
471471
{
472-
global $settings, $template, $phpEx;
472+
global $settings, $template;
473473

474474
// list of boards
475475
$boards_dir = $settings->get_boards_dir();
@@ -483,32 +483,45 @@ function get_installed_boards()
483483
continue;
484484
}
485485

486-
$version = '';
487-
// Try to find out phpBB version.
488-
if (file_exists("{$boards_dir}$board/includes/constants.$phpEx"))
489-
{
490-
$rows = file("{$boards_dir}$board/includes/constants.$phpEx", FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
491-
492-
foreach ($rows as $row)
493-
{
494-
if (($pos = strpos($row, "'PHPBB_VERSION', '")) !== false)
495-
{
496-
$pos += 18;
497-
$version = substr($row, $pos, -3);
498-
break;
499-
}
500-
}
501-
unset($rows);
502-
}
503-
504486
$template->assign_block_vars('board_row', array(
505487
'BOARD_NAME' => htmlspecialchars($board),
506488
'BOARD_URL' => $settings->get_boards_url() . urlencode($board),
507-
'VERSION' => $version,
489+
'VERSION' => get_phpbb_version($boards_dir . $board),
508490
));
509491
}
510492
}
511493

494+
/**
495+
* Returns the version of a phpBB board (acquired from its constant.php file)
496+
*
497+
* @param string $board_path Path to a phpbb board root directory
498+
* @return string A phpbb version, e.g.: '3.3.0'
499+
*/
500+
function get_phpbb_version($board_path)
501+
{
502+
global $phpEx;
503+
504+
$version = '';
505+
// Try to find out phpBB version.
506+
if (file_exists("$board_path/includes/constants.$phpEx"))
507+
{
508+
$rows = file("$board_path/includes/constants.$phpEx", FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
509+
510+
foreach ($rows as $row)
511+
{
512+
if (strpos($row, 'PHPBB_VERSION') !== false)
513+
{
514+
preg_match("/'PHPBB_VERSION', '(.*)'/", $row, $matches);
515+
$version = isset($matches[1]) ? $matches[1] : '';
516+
break;
517+
}
518+
}
519+
unset($rows);
520+
}
521+
522+
return $version;
523+
}
524+
512525
function db_connect($db_data = '')
513526
{
514527
global $phpbb_root_path, $phpEx, $sql_db, $db, $quickinstall_path, $settings;

index.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
}
116116
}
117117

118+
$phpbb_version = get_phpbb_version($phpbb_root_path);
119+
118120
if (file_exists($phpbb_root_path . 'phpbb/class_loader.' . $phpEx))
119121
{
120122
define('PHPBB_31', true);
@@ -126,20 +128,20 @@
126128
require($phpbb_root_path . 'vendor/autoload.' . $phpEx);
127129
}
128130

129-
if (!file_exists($phpbb_root_path . 'includes/functions_install.' . $phpEx))
131+
if (!file_exists($phpbb_root_path . 'includes/functions_install.' . $phpEx) || version_compare($phpbb_version, '3.2', '>='))
130132
{
131133
define('PHPBB_32', true);
132134
}
133135

134-
if (file_exists($phpbb_root_path . 'vendor-ext'))
136+
if (file_exists($phpbb_root_path . 'vendor-ext') || version_compare($phpbb_version, '4.0', '>='))
135137
{
136138
define('PHPBB_40', true);
137139
}
138140

139141
require($phpbb_root_path . 'includes/functions.' . $phpEx);
140142
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
141143

142-
if (!function_exists('phpbb_email_hash'))
144+
if (!function_exists('phpbb_email_hash') || version_compare($phpbb_version, '3.3', '>='))
143145
{
144146
define('PHPBB_33', true);
145147
}

style/sidebar_boards.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<form id="del_board" method="post" action="{{ U_MANAGE }}">
77
{% endif %}
88
<div class="list-group-item py-2 px-0 bg-transparent border-end-0 border-start-0">
9-
<div class="d-flex w-100 align-items-center justify-content-between">
9+
<div class="d-flex w-100 justify-content-between">
1010
<div class="form-check form-switch m-1 overflow-hidden">
1111
<input type="checkbox" class="form-check-input" data-qi-mark id="del_board_{{ loop.index }}" name="select[]" value="{{ board.BOARD_NAME }}" title="{{ lang('MARK_FOR_DELETION') }}">
1212
<label class="form-check-label fw-strong" for="del_board_{{ loop.index }}"><a href="{{ board.BOARD_URL }}" title="{{ lang('GOTO_BOARD', board.BOARD_NAME) }}">{{ board.BOARD_NAME }}</a></label>

0 commit comments

Comments
 (0)