Skip to content

Commit

Permalink
Merge pull request #1 from SimpleMachines/release-2.1
Browse files Browse the repository at this point in the history
Sync with the base repository
  • Loading branch information
dragomano authored Mar 9, 2022
2 parents b9e3b27 + f3b02b8 commit ac3ac18
Show file tree
Hide file tree
Showing 39 changed files with 282 additions and 184 deletions.
4 changes: 4 additions & 0 deletions SSI.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
require_once($sourcedir . '/Class-BrowserDetect.php');
require_once($sourcedir . '/Subs-Auth.php');

// Ensure we don't trip over disabled internal functions
if (version_compare(PHP_VERSION, '8.0.0', '>='))
require_once($sourcedir . '/Subs-Compat.php');

// Create a variable to store some SMF specific functions in.
$smcFunc = array();

Expand Down
3 changes: 2 additions & 1 deletion Sources/Cache/APIs/FileBased.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ public function cacheSettings(array &$config_vars)
if (!isset($context['settings_post_javascript']))
$context['settings_post_javascript'] = '';

$context['settings_post_javascript'] .= '
if (empty($context['settings_not_writable']))
$context['settings_post_javascript'] .= '
$("#cache_accelerator").change(function (e) {
var cache_type = e.currentTarget.value;
$("#cachedir").prop("disabled", cache_type != "'. $class_name .'");
Expand Down
3 changes: 2 additions & 1 deletion Sources/Cache/APIs/MemcacheImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ public function cacheSettings(array &$config_vars)
if (!isset($context['settings_post_javascript']))
$context['settings_post_javascript'] = '';

$context['settings_post_javascript'] .= '
if (empty($context['settings_not_writable']))
$context['settings_post_javascript'] .= '
$("#cache_accelerator").change(function (e) {
var cache_type = e.currentTarget.value;
$("#'. self::CLASS_KEY .'").prop("disabled", cache_type != "MemcacheImplementation" && cache_type != "MemcachedImplementation");
Expand Down
3 changes: 2 additions & 1 deletion Sources/Cache/APIs/MemcachedImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ public function cacheSettings(array &$config_vars)
if (!isset($context['settings_post_javascript']))
$context['settings_post_javascript'] = '';

$context['settings_post_javascript'] .= '
if (empty($context['settings_not_writable']))
$context['settings_post_javascript'] .= '
$("#cache_accelerator").change(function (e) {
var cache_type = e.currentTarget.value;
$("#'. self::CLASS_KEY .'").prop("disabled", cache_type != "MemcacheImplementation" && cache_type != "MemcachedImplementation");
Expand Down
3 changes: 2 additions & 1 deletion Sources/Cache/APIs/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public function cacheSettings(array &$config_vars)
if (!isset($context['settings_post_javascript']))
$context['settings_post_javascript'] = '';

$context['settings_post_javascript'] .= '
if (empty($context['settings_not_writable']))
$context['settings_post_javascript'] .= '
$("#cache_accelerator").change(function (e) {
var cache_type = e.currentTarget.value;
$("#cachedir_'. $class_name_txt_key .'").prop("disabled", cache_type != "'. $class_name .'");
Expand Down
10 changes: 5 additions & 5 deletions Sources/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function CalendarMain()
// Need a start date for all views
if (!empty($_REQUEST['start_date']))
{
$start_parsed = date_parse(convertDateToEnglish($_REQUEST['start_date']));
$start_parsed = date_parse(str_replace(',', '', convertDateToEnglish($_REQUEST['start_date'])));
if (empty($start_parsed['error_count']) && empty($start_parsed['warning_count']))
{
$_REQUEST['year'] = $start_parsed['year'];
Expand All @@ -125,12 +125,12 @@ function CalendarMain()
$month = !empty($_REQUEST['month']) ? (int) $_REQUEST['month'] : $today['month'];
$day = !empty($_REQUEST['day']) ? (int) $_REQUEST['day'] : (!empty($_REQUEST['month']) ? 1 : $today['day']);

$start_object = checkdate($month, $day, $year) === true ? date_create(implode('-', array($year, $month, $day))) : date_create(implode('-', array($today['year'], $today['month'], $today['day'])));
$start_object = checkdate($month, $day, $year) === true ? date_create(implode('-', array($year, $month, $day)) . ' ' . getUserTimezone()) : date_create(implode('-', array($today['year'], $today['month'], $today['day'])) . ' ' . getUserTimezone());

// Need an end date for the list view
if (!empty($_REQUEST['end_date']))
{
$end_parsed = date_parse(convertDateToEnglish($_REQUEST['end_date']));
$end_parsed = date_parse(str_replace(',', '', convertDateToEnglish($_REQUEST['end_date'])));
if (empty($end_parsed['error_count']) && empty($end_parsed['warning_count']))
{
$_REQUEST['end_year'] = $end_parsed['year'];
Expand All @@ -146,14 +146,14 @@ function CalendarMain()

if (isset($end_month, $end_day, $end_year) && checkdate($end_month, $end_day, $end_year))
{
$end_object = date_create(implode('-', array($end_year, $end_month, $end_day)));
$end_object = date_create(implode('-', array($end_year, $end_month, $end_day)) . ' ' . getUserTimezone());
}

if (empty($end_object) || $start_object >= $end_object)
{
$num_days_shown = empty($modSettings['cal_days_for_index']) || $modSettings['cal_days_for_index'] < 1 ? 1 : $modSettings['cal_days_for_index'];

$end_object = date_create(date_format($start_object, 'Y-m-d'));
$end_object = date_create(date_format($start_object, 'Y-m-d') . ' ' . getUserTimezone());

date_add($end_object, date_interval_create_from_date_string($num_days_shown . ' days'));
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Load.php
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,7 @@ function loadMemberContext($user, $display_custom_fields = false)
$value = $value ? $txt['yes'] : $txt['no'];

// Enclosing the user input within some other text?
$simple_value = $value;
if (!empty($custom['enclose']))
$value = strtr($custom['enclose'], array(
'{SCRIPTURL}' => $scripturl,
Expand All @@ -1863,6 +1864,7 @@ function loadMemberContext($user, $display_custom_fields = false)
'title' => tokenTxtReplace(!empty($custom['title']) ? $custom['title'] : $custom['col_name']),
'col_name' => tokenTxtReplace($custom['col_name']),
'value' => un_htmlspecialchars(tokenTxtReplace($value)),
'simple' => tokenTxtReplace($simple_value),
'raw' => $profile['options'][$custom['col_name']],
'placement' => !empty($custom['placement']) ? $custom['placement'] : 0,
);
Expand Down
24 changes: 14 additions & 10 deletions Sources/ManageServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,7 @@ function ModifySettings()
$settings_not_writable = !is_writable($boarddir . '/Settings.php');
$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');

if ($settings_not_writable)
$context['settings_message'] = array(
'label' => $txt['settings_not_writable'],
'tag' => 'div',
'class' => 'centertext strong'
);
elseif ($settings_backup_fail)
if ($settings_backup_fail)
$context['settings_message'] = array(
'label' => $txt['admin_backup_fail'],
'tag' => 'div',
Expand Down Expand Up @@ -188,6 +182,7 @@ function ModifyGeneralSettings($return_config = false)
// Setup the template stuff.
$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
$context['settings_title'] = $txt['general_settings'];
$context['save_disabled'] = $context['settings_not_writable'];

// Saving settings?
if (isset($_REQUEST['save']))
Expand Down Expand Up @@ -226,7 +221,8 @@ function ModifyGeneralSettings($return_config = false)
prepareServerSettingsContext($config_vars);

// Some javascript for SSL
addInlineJavaScript('
if (empty($context['settings_not_writable']))
addInlineJavaScript('
$(function()
{
$("#force_ssl").change(function()
Expand Down Expand Up @@ -535,6 +531,7 @@ function hideGlobalCookies()

$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
$context['settings_title'] = $txt['cookies_sessions_settings'];
$context['save_disabled'] = $context['settings_not_writable'];

// Saving settings?
if (isset($_REQUEST['save']))
Expand Down Expand Up @@ -731,7 +728,7 @@ function ModifyGeneralSecuritySettings($return_config = false)
*/
function ModifyCacheSettings($return_config = false)
{
global $context, $scripturl, $txt, $cacheAPI, $cache_enable;
global $context, $scripturl, $txt, $cacheAPI, $cache_enable, $cache_accelerator;

// Detect all available optimizers
$detectedCacheApis = loadCacheAPIs();
Expand Down Expand Up @@ -1041,7 +1038,14 @@ function ModifyLoadBalancingSettings($return_config = false)
*/
function prepareServerSettingsContext(&$config_vars)
{
global $context, $modSettings, $smcFunc;
global $context, $modSettings, $smcFunc, $txt;

if ($context['settings_not_writable'])
$context['settings_message'] = array(
'label' => $txt['settings_not_writable'],
'tag' => 'div',
'class' => 'centertext strong'
);

if (isset($_SESSION['adm-save']))
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/ManageSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ function ModifyAntispamSettings($return_config = false)
$context['question_answers'][$row['id_question']] = array(
'lngfile' => $lang,
'question' => $row['question'],
'answers' => $smcFunc['json_decode']($row['answers'], true),
'answers' => (array) $smcFunc['json_decode']($row['answers'], true),
);
$context['qa_by_lang'][$lang][] = $row['id_question'];
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Memberlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ function MLSearch()
}

foreach ($context['custom_search_fields'] as $field)
$context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']);
$context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], tokenTxtReplace($field['name']));

$context['sub_template'] = 'search';
$context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : '');
Expand Down
2 changes: 1 addition & 1 deletion Sources/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ function getXmlProfile($xml_format)
$data[] = array(
'tag' => $custom_field['col_name'],
'attributes' => array('label' => $custom_field['title']),
'content' => $custom_field['raw'],
'content' => $custom_field['simple'],
'cdata' => true,
);
}
Expand Down
13 changes: 11 additions & 2 deletions Sources/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -1234,9 +1234,18 @@ function($m)
foreach ($attachmentRestrictionTypes as $type)
if (!empty($modSettings[$type]))
{
$context['attachment_restrictions'][$type] = sprintf($txt['attach_restrict_' . $type . ($modSettings[$type] >= 1024 ? '_MB' : '')], comma_format($modSettings[$type] >= 1024 ? $modSettings[$type] / 1024 : $modSettings[$type], 2));

// Show the max number of attachments if not 0.
if ($type == 'attachmentNumPerPostLimit')
$context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], max($modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity'], 0));
{
$context['attachment_restrictions'][$type] .= ' (' . sprintf($txt['attach_remaining'], max($modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity'], 0)) . ')';
}
elseif ($type == 'attachmentPostLimit' && $context['attachments']['total_size'] > 0)
{
$context['attachment_restrictions'][$type] .= '<span class="attach_available"> (' . sprintf($txt['attach_available'], max($modSettings['attachmentPostLimit'] - ($context['attachments']['total_size'] / 1024), 0)) . ')</span>';
}

}
}

Expand Down Expand Up @@ -2233,8 +2242,8 @@ function Post2()
unlink($attachment['tmp_name']);
}
}
unset($_SESSION['temp_attachments']);
}
unset($_SESSION['temp_attachments']);

// Make the poll...
if (isset($_REQUEST['poll']))
Expand Down
3 changes: 0 additions & 3 deletions Sources/Profile-Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,6 @@ function export_attachment($uid)
send_http_status(403);
exit;
}

// We need the topic.
list ($_REQUEST['topic']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

// This doesn't count as a normal download.
Expand Down
22 changes: 11 additions & 11 deletions Sources/Profile-Modify.php
Original file line number Diff line number Diff line change
Expand Up @@ -966,25 +966,25 @@ function saveProfileChanges(&$profile_vars, &$post_errors, $memID)
'ignore_boards',
);

if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd']))
$_POST['ignore_brd'] = array();
if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['brd']))
$_POST['brd'] = array();

unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds.
if (isset($_POST['ignore_brd']))
if (isset($_POST['brd']))
{
if (!is_array($_POST['ignore_brd']))
$_POST['ignore_brd'] = array($_POST['ignore_brd']);
if (!is_array($_POST['brd']))
$_POST['brd'] = array($_POST['brd']);

foreach ($_POST['ignore_brd'] as $k => $d)
foreach ($_POST['brd'] as $k => $d)
{
$d = (int) $d;
if ($d != 0)
$_POST['ignore_brd'][$k] = $d;
$_POST['brd'][$k] = $d;
else
unset($_POST['ignore_brd'][$k]);
unset($_POST['brd'][$k]);
}
$_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']);
unset($_POST['ignore_brd']);
$_POST['ignore_boards'] = implode(',', $_POST['brd']);
unset($_POST['brd']);
}

// Here's where we sort out all the 'other' values...
Expand Down Expand Up @@ -1278,7 +1278,7 @@ function makeCustomFieldChanges($memID, $area, $sanitize = true, $returnErrors =
if (empty($value) && !is_numeric($value))
$value = '';

if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference)))
if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_FULL_SPECIAL_CHARS) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference)))
{
if ($returnErrors)
$errors[] = 'custom_field_nohtml_fail';
Expand Down
Loading

0 comments on commit ac3ac18

Please sign in to comment.