Skip to content

Commit

Permalink
Updated Staticpages plugin to v1.7.2
Browse files Browse the repository at this point in the history
Updated use of COM_handleEval. Also PHP Parsing now checked on save as well.
  • Loading branch information
eSilverStrike committed Mar 15, 2020
1 parent 6071adf commit 78c42b2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions plugins/staticpages/autoinstall.php
Expand Up @@ -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/'
);

Expand Down
7 changes: 6 additions & 1 deletion plugins/staticpages/functions.inc
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down
23 changes: 22 additions & 1 deletion plugins/staticpages/services.inc.php
Expand Up @@ -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']) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 78c42b2

Please sign in to comment.