https://www.icyphoenix.com/viewtopic.php?f=35&t=540&p=4742#p4742
-----------------------------------
Mighty Gorgon
Tue 14 Nov, 2006 01:46

Re: Questions
-----------------------------------
Now I should really have solved it! :lol:

I have added a function in [b]functions.php[/b]

[codeblock]function check_style_exists($style_id)
{
	global $db, $board_config, $template, $images, $phpbb_root_path;
	global $phpEx, $themes_style;

	if ( defined('CACHE_THEMES') )
	{
		include( $phpbb_root_path . './includes/def_themes.' . $phpEx );
		if ( empty($themes_style) )
		{
			cache_themes();
			@include( $phpbb_root_path . './includes/def_themes.' . $phpEx );
		}
	}
	if ( !empty($themes_style[$style_id]) )
	{
		$stile_exists = true;
	}
	else
	{
		$sql = 'SELECT *
			FROM ' . THEMES_TABLE . '
			WHERE themes_id = ' . (int) $style;
		if ( !($result = $db->sql_query($sql, false, true)) )
		{
			message_die(CRITICAL_ERROR, 'Could not query database for theme info');
		}

		if ( !($row = $db->sql_fetchrow($result)) )
		{
			$stile_exists = false;
		}
		else
		{
			$stile_exists = true;
		}
	}

	return $stile_exists;
}[/codeblock]

And added a new check in [b]common.php[/b] if the user is trying to change its template:

FIND
[codeblock]		$board_config['default_style'] = ($board_config['default_style'] == 0) ? $old_style : $board_config['default_style'];[/codeblock]

REPLACE WITH
[codeblock]		$board_config['default_style'] = (check_style_exists($board_config['default_style']) == false) ? $old_style : $board_config['default_style'];[/codeblock]

Let me know if this time it is working as expected! :wink:


