1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 05:02:02 +02:00

Added alert to Theme manager when incompatible code found in theme.php

This commit is contained in:
Cameron 2019-04-06 13:38:18 -07:00
parent fcced14087
commit ab0152215f

View File

@ -587,11 +587,52 @@ class theme_admin_ui extends e_admin_ui
}
/**
* Check theme.php code for methods incompatible with PHP7.
* @param $code
* @return bool
*/
private function containsErrors($code)
{
if(PHP_MAJOR_VERSION < 6)
{
return false;
}
$dep = array('call_user_method(', 'call_user_method_array(', 'define_syslog_variables', 'ereg(','ereg_replace(',
'eregi(', 'eregi_replace(', 'set_magic_quotes_runtime(', 'magic_quotes_runtime(', 'session_register(', 'session_unregister(', 'session_is_registered(',
'set_socket_blocking(', 'split(', 'spliti(', 'sql_regcase(', 'mysql_db_query(', 'mysql_escape_string(');
foreach($dep as $test)
{
if(strpos($code, $test) !== false)
{
e107::getMessage()->addDebug("Incompatible function <b>".rtrim($test,"(")."</b> found in theme.php");
return true;
}
}
return false;
}
private function renderThemeConfig($type = 'front')
{
$frm = e107::getForm();
$themeMeta = e107::getTheme($type)->get();
$themeFileContent = file_get_contents(e_THEME.$themeMeta['path']."/theme.php");
if($this->containsErrors($themeFileContent))
{
e107::getMessage()->setTitle("Incompatibility Detected", E_MESSAGE_ERROR)->addError("This theme is not compatible with your version of PHP.");
}
$this->addTitle("<span class='text-warning'>".$themeMeta['name']."</span>");
$mode = ($type == 'front') ? 1 : 2;