WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Exec-PHP] Shows PHP Code on Non-Homepage Post Listings (7 posts)

  1. WebGeek
    Member
    Posted 5 years ago #

    I found a bug that I'm not sure if it's always been there or just showed up in 2.8. When you see the list of posts on your blog homepage it's fine, but when you click to page 2,3,4, etc of the listings, the PHP code is exposed and not executed. When you click through to the actual post, it's fine.

    This is also a potential security risk.

    http://wordpress.org/extend/plugins/exec-php/

  2. mmorpglife
    Member
    Posted 5 years ago #

    I had the same problem. This seems to be caused by one of WordPress' native functions force_balance_tags. This function worked before as well on the content of your blog but for some reason exec-php executed before this filter. In any case, the way I resolved it is I added these lines to exec-php file /include/runtime.php function filter_user_content($content).

    if(strpos($content,'< ?php ')!==FALSE)
    	{
    		$content=str_replace('< ?php','<?php',$content);
    	}

    Now it executes the code properly. The problem with this approach is that once you upgrade exec-PHP and they do not include this fix or provide another one for this particular problem you will again have this nasty bug. I resolved this by making a small plugin of my own called my-fixes.php. Put it in the plugins folder. and has this code in it:

    add_filter('the_content', 'my_filter_php_tag', 0); //fix for exec-php plugin and wordpress 2.8 and messed up php tag
    
    function my_filter_php_tag($content)
    {
    	if(strpos($content,'< ?php ')!==FALSE)
    	{
    		$content=str_replace('< ?php','<?php',$content);
    	}
    	return $content;
    }

    Hope this helps...

  3. serviendo
    Member
    Posted 4 years ago #

    This worked for me, many thanks mmorpglife.

    This was only happeningon one of my blogs - the other 2 were fine. Settings were the same too. Odd how these things happen!

  4. 1xxooxx
    Member
    Posted 4 years ago #

    AWESOME! The fix worked for me perfectly! I'm using you fix at http://TheN2S.com

    Here was my problem: http://wordpress.org/support/topic/333634?replies=1

  5. McShelby
    Member
    Posted 4 years ago #

    This is an issue introduced with WordPress 2.8. See http://core.trac.wordpress.org/ticket/10248

  6. McShelby
    Member
    Posted 4 years ago #


  7. ibooktravel
    Member
    Posted 4 years ago #

    On my home page this will fix a simple < ?php echo "Hello World"; ?> but it makes a complete mess with < ?php include ('http://ibooktravel.com.au/wp-content/plugins/front-slider/front-slider.php');?> filling the page with errors.... Without the code
    if(strpos($content,'< ?php ')!==FALSE) {$content=str_replace('< ?php','<?php',$content); }
    I get the php displaying as a string on both home page and posts. Can anyone help ?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags