MyBB Community Forums

Full Version: Print why theme can't be imported
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As the title says. I've seen recently many topics like "Can't upload theme" and the provided warning doesn't give any info. I think it should print the required changes in that error message.
below code segment is from admin/inc/functions.php in MyBB 1.6.10 (lines 654 - 659)
// Any other malicious acts?
	// Courtesy of ZiNgA BuRgA
	if(preg_match("~\\{\\$.+?\\}~s", preg_replace('~\\{\\$+[a-zA-Z_][a-zA-Z_0-9]*((?:-\\>|\\:\\:)\\$*[a-zA-Z_][a-zA-Z_0-9]*|\\[\s*\\$*([\'"]?)[a-zA-Z_ 0-9 ]+\\2\\]\s*)*\\}~', '', $template)))
	{
		return true;
	}

it is rejecting importing of some of the earlier coded themes
Yes, I know about it, but as stated in my 1st post that's absolutely not an efficient solution. I've seen for example a thread where to solve it, it was necessary to remove something with $ in a comment left by author. Not easy to find between thousands of theme file lines, that's why many of the theme security topics stay unsolved (probably most of all problems).

It could collect all the matched results with a preg_match_all or whatever and instead of just returning true it could return all the disallowed instances and then print them inside the current unhelpful warning. Also for the database pass and backtick checking.