Template: Favicon fix.

This commit is contained in:
Nate 2020-03-18 13:14:50 -06:00
parent 889e370a10
commit 1f145a08c7
1 changed files with 30 additions and 9 deletions

View File

@ -101,18 +101,39 @@
if (is_array($_SESSION['theme']) && @sizeof($_SESSION['theme']) != 0) {
//load into array
foreach ($_SESSION['theme'] as $subcategory => $setting) {
if (isset($setting['text']) && $setting['text'] != '') {
$settings['theme'][$subcategory] = escape($setting['text']);
}
else if (isset($setting['boolean'])) {
$settings['theme'][$subcategory] = $setting['boolean'] == 'true' ? true : false;
}
else {
$settings['theme'][$subcategory] = escape($setting);
switch($subcategory) {
//exceptions
case 'favicon':
if ($setting['text'] != '') {
$tmp_url = parse_url($setting['text']);
$tmp_path = pathinfo($setting['text']);
if (
is_array($tmp_url) && @sizeof($tmp_url) != 0 &&
is_array($tmp_path) && @sizeof($tmp_path) != 0 &&
(
($tmp_url['scheme'] != '' && $tmp_url['scheme'].'://'.$tmp_url['host'].$tmp_url['path'] == $tmp_path['dirname'].'/'.$tmp_path['filename'].'.'.$tmp_path['extension']) //is url
|| $tmp_url['path'] == $tmp_path['dirname'].'/'.$tmp_path['filename'].'.'.$tmp_path['extension'] //is path
)) {
$settings['theme'][$subcategory] = $setting['text'];
}
unset($tmp_url, $tmp_path);
}
break;
//otherwise
default:
if (isset($setting['text']) && $setting['text'] != '') {
$settings['theme'][$subcategory] = escape($setting['text']);
}
else if (isset($setting['boolean'])) {
$settings['theme'][$subcategory] = $setting['boolean'] == 'true' ? true : false;
}
else {
$settings['theme'][$subcategory] = escape($setting);
}
}
}
//pre-process some settings
$settings['theme']['favicon'] = $settings['theme']['favicon'] != '' ? urlencode($settings['theme']['favicon']) : PROJECT_PATH.'/themes/default/favicon.ico';
$settings['theme']['favicon'] = $settings['theme']['favicon'] != '' ? $settings['theme']['favicon'] : PROJECT_PATH.'/themes/default/favicon.ico';
$settings['theme']['font_loader_version'] = $settings['theme']['font_loader_version'] != '' ? urlencode($settings['theme']['font_loader_version']) : '1';
$settings['theme']['message_delay'] = is_numeric($settings['theme']['message_delay']) ? 1000 * (float) $settings['theme']['message_delay'] : 3000;
$settings['theme']['menu_side_width_contracted'] = is_numeric($settings['theme']['menu_side_width_contracted']) ? $settings['theme']['menu_side_width_contracted'] : '60';