Skip to content

Commit

Permalink
Merge pull request #2 from SimpleMachines/release-3.0
Browse files Browse the repository at this point in the history
Fetch latest changes
  • Loading branch information
dragomano committed Jan 18, 2024
2 parents 6509147 + b08968c commit c7e6b9b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Sources/Actions/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function execute(bool $internal = false, bool $redirect = true): void
if (!empty(Config::$modSettings['tfa_mode']) && !empty(User::$me->id) && !empty($_COOKIE[Config::$cookiename . '_tfa'])) {
list(, , $exp) = Utils::jsonDecode($_COOKIE[Config::$cookiename . '_tfa'], true);

Cookie::setTFACookie((int) $exp - time(), $salt, Cookie::encrypt(User::$me->tfa_backup, $salt));
Cookie::setTFACookie((int) $exp - time(), User::$me->id, Cookie::encrypt(User::$me->tfa_backup, $salt));
}

session_destroy();
Expand Down
10 changes: 7 additions & 3 deletions Sources/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public static function load(string $template_name, string $lang = '', bool $fata
*
* @param array|string $custom_dirs Optional custom directories to include.
*/
public static function addDirs(array $custom_dirs = []): void
public static function addDirs(array|string $custom_dirs = []): void
{
// We only accept real directories.
if (!empty($custom_dirs)) {
Expand Down Expand Up @@ -592,13 +592,17 @@ public static function sentenceList(array $list): string
* Wrapper for number_format() that uses Lang::$txt['number_format'] to
* figure out the parameters to pass to number_format().
*
* @param int|float $number A number.
* @param int|float|string $number A number.
* @param int $decimals If set, will use the specified number of decimal
* places. Otherwise it's automatically determined.
* @return string A formatted number
*/
public static function numberFormat(int|float $number, ?int $decimals = null): string
public static function numberFormat(int|float|string $number, ?int $decimals = null): string
{
if (is_string($number)) {
$number = intval($number);
}

// Cache these values...
if (!isset(self::$decimal_separator)) {
// Not set for whatever reason?
Expand Down
18 changes: 11 additions & 7 deletions Sources/ServerSideIncludes.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,12 @@ public static function queryPosts(
$posts = [];

while ($row = Db::$db->fetch_assoc($request)) {
$topic = new Topic($row['id_topic'], [
$topic = new Topic((int) $row['id_topic'], [
'id_board' => $row['id_board'],
'id_first_msg' => $row['id_msg'],
]);

$row['body'] = BBCodeParser::load()->parse($row['body'], $row['smileys_enabled'], $row['id_msg']);
$row['body'] = BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], $row['id_msg']);

// Censor it!
Lang::censorText($row['subject']);
Expand Down Expand Up @@ -680,7 +680,7 @@ public static function recentTopics(int $num_recent = 8, ?array $exclude_boards
$posts = [];

while ($row = Db::$db->fetch_assoc($request)) {
$row['body'] = strip_tags(strtr(BBCodeParser::load()->parse($row['body'], $row['smileys_enabled'], $row['id_msg']), ['<br>' => '&#10;']));
$row['body'] = strip_tags(strtr(BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], $row['id_msg']), ['<br>' => '&#10;']));

if (Utils::entityStrlen($row['body']) > 128) {
$row['body'] = Utils::entitySubstr($row['body'], 0, 128) . '...';
Expand Down Expand Up @@ -1091,7 +1091,7 @@ public static function randomMember(string $random_type = '', string $output_met
}

// Get the lowest ID we're interested in.
$member_id = mt_rand(1, Config::$modSettings['latestMember']);
$member_id = mt_rand(1, (int) Config::$modSettings['latestMember']);

$where_query = '
id_member >= {int:selected_member}
Expand Down Expand Up @@ -1339,6 +1339,8 @@ public static function boardStats(string $output_method = 'echo'): ?array
', Lang::$txt['total_topics'], ': ', Lang::numberFormat($totals['topics']), ' <br>
', Lang::$txt['total_cats'], ': ', Lang::numberFormat($totals['categories']), '<br>
', Lang::$txt['total_boards'], ': ', Lang::numberFormat($totals['boards']);

return null;
}

/**
Expand Down Expand Up @@ -1438,7 +1440,7 @@ public static function logOnline(string $output_method = 'echo'): ?array
return self::whosOnline($output_method);
}

self::whosOnline($output_method);
return self::whosOnline($output_method);
}

/**
Expand Down Expand Up @@ -1823,6 +1825,8 @@ public static function quickSearch(string $output_method = 'echo'): ?string
<form action="', Config::$scripturl, '?action=search2" method="post" accept-charset="', Utils::$context['character_set'], '">
<input type="hidden" name="advanced" value="0"><input type="text" name="search" size="30"> <input type="submit" value="', Lang::$txt['search'], '" class="button">
</form>';

return null;
}

/**
Expand Down Expand Up @@ -2168,7 +2172,7 @@ public static function boardNews(?int $board = null, ?int $limit = null, ?int $s
$recycle_board = !empty(Config::$modSettings['recycle_enable']) && !empty(Config::$modSettings['recycle_board']) ? (int) Config::$modSettings['recycle_board'] : 0;

while ($row = Db::$db->fetch_assoc($request)) {
$topic = new Topic($row['id_topic'], [
$topic = new Topic((int) $row['id_topic'], [
'id_board' => $row['id_board'],
'num_replies' => $row['num_replies'],
'locked' => $row['locked'],
Expand Down Expand Up @@ -2197,7 +2201,7 @@ public static function boardNews(?int $board = null, ?int $limit = null, ?int $s
$row['body'] .= '...';
}

$row['body'] = BBCodeParser::load()->parse($row['body'], $row['smileys_enabled'], $row['id_msg']);
$row['body'] = BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], $row['id_msg']);

if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
$row['icon'] = 'recycled';
Expand Down
2 changes: 1 addition & 1 deletion other/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ function DatabaseSettings()
// Do they meet the install requirements?
// @todo Old client, new server?
if (version_compare($databases[Config::$db_type]['version'], preg_replace('~^\D*|\-.+?$~', '', $databases[Config::$db_type]['version_check']())) > 0) {
$incontext['error'] = Lang::$txt['error_db_too_low'];
$incontext['error'] = sprintf(Lang::$txt['error_db_too_low'], $databases[Config::$db_type]['name']);

return false;
}
Expand Down

0 comments on commit c7e6b9b

Please sign in to comment.