diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 350014b3eb9..70f61055689 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -35,6 +35,8 @@ */ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) { + $nbrep = 0; + // Replace php code. Note $content may come from database and does not contains body tags. $replacewith='...php...'; if ($removephppart) $replacewith=''; @@ -59,7 +61,12 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) //$replacewith='...php...'; $replacewith='...php...'; if ($removephppart) $replacewith=''; - $content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); + //$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content); + /*if ($content === null) { + if (preg_last_error() == PREG_JIT_STACKLIMIT_ERROR) $content = 'preg_replace error (when removing php tags) PREG_JIT_STACKLIMIT_ERROR'; + }*/ + $content = dolStripPhpCode($content, $replacewith); + //var_dump($content); // Replace relative link / with dolibarr URL $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep); @@ -88,6 +95,45 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) } +/** + * Remove PHP code part from a string. + * + * @param string $str String to clean + * @param string $replacewith String to use as replacement + * @return string Result string without php code + */ +function dolStripPhpCode($str, $replacewith='') +{ + $newstr = ''; + + //split on each opening tag + $parts = explode('', $part); + if (!empty($partlings)) + { + //remove content before closing tag + if (count($partlings) > 1) $partlings[0] = ''; + //append to out string + $newstr .= $replacewith.implode('',$partlings); + } + } + } + return $newstr; +} + + /** * Render a string of an HTML content and output it. * Used to ouput the page when viewed from server (Dolibarr or Apache). diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 57dbe2d8984..0d3af42d0cf 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1647,7 +1647,7 @@ print '
'; if (count($object->records) > 0) // There is at least one web site { // ***** Part for web sites - + print ''; print '
'; print $langs->trans("Website").' : '; print '
'; @@ -1807,6 +1807,7 @@ if (count($object->records) > 0) // There is at least one web site { print '
'; // Close current websitebar to open a new one + print ''; print '
'; print '
'; @@ -2732,7 +2733,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $objectpage->fetch($pageid); $jscontent = @file_get_contents($filejs); - $out = ''."\n"; + $out = ''."\n"; // Include a html so we can benefit of the header of page. // Note: We can't use iframe as it can be used to include another external html file @@ -2742,7 +2743,8 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out .= "