From 78c42b233726342ef900cd110d9e4e656b0f0c65 Mon Sep 17 00:00:00 2001 From: eSilverStrike Date: Sun, 15 Mar 2020 12:15:08 -0400 Subject: [PATCH] Updated Staticpages plugin to v1.7.2 Updated use of COM_handleEval. Also PHP Parsing now checked on save as well. --- plugins/staticpages/autoinstall.php | 4 ++-- plugins/staticpages/functions.inc | 7 ++++++- plugins/staticpages/services.inc.php | 23 ++++++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/plugins/staticpages/autoinstall.php b/plugins/staticpages/autoinstall.php index 5fe3e660b..d39acd2ca 100644 --- a/plugins/staticpages/autoinstall.php +++ b/plugins/staticpages/autoinstall.php @@ -51,8 +51,8 @@ function plugin_autoinstall_staticpages($pi_name) $info = array( 'pi_name' => $pi_name, 'pi_display_name' => $pi_display_name, - 'pi_version' => '1.7.1', - 'pi_gl_version' => '2.2.1', + 'pi_version' => '1.7.2', + 'pi_gl_version' => '2.2.1sr1', 'pi_homepage' => 'https://www.geeklog.net/' ); diff --git a/plugins/staticpages/functions.inc b/plugins/staticpages/functions.inc index 8cda5a537..59c5e2a19 100755 --- a/plugins/staticpages/functions.inc +++ b/plugins/staticpages/functions.inc @@ -1743,6 +1743,10 @@ function plugin_upgrade_staticpages() $current_version = '1.7.1'; break; + case '1.7.1': + $current_version = '1.7.2'; + break; + default: $done = true; } @@ -2101,7 +2105,8 @@ function SP_render_content($A) if ($_SP_CONF['allow_php'] == 1) { // Check for type (ie html or php) if ($sp_php != 0) { - $sp_content = COM_handleEval($page_data, $sp_php); + $retarray = COM_handleEval($page_data, $sp_php); + $sp_content = $retarray['output']; } $sp_content = PLG_replaceTags($sp_content, '', false, 'staticpages', $sp_id); } else { diff --git a/plugins/staticpages/services.inc.php b/plugins/staticpages/services.inc.php index afcccc197..54b75013b 100644 --- a/plugins/staticpages/services.inc.php +++ b/plugins/staticpages/services.inc.php @@ -59,7 +59,7 @@ */ function service_submit_staticpages($args, &$output, &$svc_msg) { - global $_CONF, $_TABLES, $_USER, $LANG_ACCESS, $LANG12, $LANG_STATIC, + global $_CONF, $_TABLES, $_USER, $LANG_ACCESS, $LANG01, $LANG12, $LANG_STATIC, $_GROUPS, $_SP_CONF, $_STRUCT_DATA, $LANG_structureddatatypes; if (!$_CONF['disable_webservices']) { @@ -375,6 +375,27 @@ function service_submit_staticpages($args, &$output, &$svc_msg) } } + // Check PHP Parsing + if ($_SP_CONF['allow_php'] == 1 && SEC_hasRights('staticpages.PHP') && $sp_php != 0) { + if (version_compare(PHP_VERSION, '7.0.0', '>=')) { + // Use $sp_content instead of $page_data since the switch has not been made yet. + $retarray = COM_handleEval($sp_content, $sp_php); + + if (!$retarray['success']) { + // Error happened when try to load data so xml not setup correctly + $output .= COM_showMessageText(sprintf($LANG01['parse_php_error'], $retarray['error']), $LANG_STATIC['title_error_saving']); + if (!$args['gl_svc']) { + $output .= staticpageeditor($sp_id); + } + $output = COM_createHTMLDocument($output, array('pagetitle' => $LANG_STATIC['staticpageeditor'])); + + $svc_msg['error_desc'] = 'The PHP in the staticpage has parsing errors'; + + return PLG_RET_ERROR; + } + } + } + // Check for unique page ID $duplicate_id = false; $delete_old_page = false;