1

I was looking at the code of a Plugin for Joomla! CMS for a functionality I need: the possibility to run custom PHP scripts when a Joomla! Plugin/Events is fired.

I wanted to learn the mechanism used by this plugin and the code looked to me a bit odd (I'm quite a novice in PHP, so I guess I'm missing something).

Here is a snippet of the code for one of the above mentioned Events, the full plugin can be downloaded here.

function onBeforeCompileHead()
{
    if (strcmp($this->params->get('onBeforeCompileHead_custom_php_file_path'),'')!=0)
    {
        $custom_php_file_path = JPATH_SITE.DS.$this->params->get('onBeforeCompileHead_custom_php_file_path');
        ob_start();
        include($custom_php_file_path);
        $php = ob_get_contents();
        eval($php);
        ob_end_clean();
    }
}

I don't get why it has been used ob_start to capture the include content to then eval it (btw isn't eval evil? or because there is no user input to eval it's ok to use?).

I tried removing all that part, using isntead a simply include statement and it worked.

What am I missing?

1
  • i cant see anything you're missing either. Contact the author to get their thoughts?
    – jdog
    Jul 17, 2016 at 21:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.