Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add filter problems
#1
Hello,
I am having problems in a web with this: add_filter('content','functionmy');


In functionmy($content), $content is empty, and then does not filter neither, and always writes the content of page.


I am using GS 3.0. In localhost it works good, but in server not; can you give me some idea?.

Thanks.
Reply
#2
cumbe Wrote:Hello,
I am having problems in a web with this: add_filter('content','functionmy');


In functionmy($content), $content is empty, and then does not filter neither, and always writes the content of page.


I am using GS 3.0. In localhost it works good, but in server not; can you give me some idea?.

Thanks.

Maybe you have another filtering plugin installed that outputs the content and returns nothing instead of returning the content. Try removing the other plugins and try again.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
Thanks mvlcek;

I have checked alls plugins, and have 2 plugins that use add_filter: simple image gallery, and dominion jcart.
In both it is the same, writes the code that calls to function, but not works; by example, if in a page i write: (% dcart :toets %), in web appears (% dcart :toets %) and must appears the list of products...

Normally, it is fixed calling to function directly with <?php....., but i want to see where is the problem for that add_filter works good.

Regards.

PD: i´m sorry for my english.
Reply
#4
Which plugins are installed? Some plugins break content filters.

Here is my known good content test plugin.

Code:
<?php
/*
Content Filter Test
*/


# get correct id for plugin
$thisfile = basename(__FILE__, ".php");

# register plugin
register_plugin(
    $thisfile,        # ID of plugin, should be filename minus php
    'Content Filter', # Title of plugin
    '1.0',              # Version of plugin
    'Shawn a',        # Author of plugin
    '',                 # Author URL
    'Test content filters',     # Plugin Description
    '',                             # Page type of plugin
    ''                              # Function that displays content
);

# activate hooks
add_filter('content','debug_content');

function debug_content($content) {
    // error_reporting(E_ALL | E_STRICT);
    // ini_set('display_errors', 1);
  return "CONTENT FILTER TEST BEGIN" . $content . "CONTENT FILTER TEST END";
}

function debug_content_show() {
    echo '<p>I append a test string to content data using a content filter</p>';
}

?>
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
Thanks shawn_a;
All is the same. I have reviewed all plugins and none have anything that breaks the content.

I´m going to do a clean installation to see what happens.

Regards.
Reply
#6
Hi,

The problem is in zzz_exec-php plugin (argggg!!!).

At least I know where the problem... Smile
Reply
#7
I could have told you that, that is why I asked what you had.
Smile
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#8
I have same problem but I want to understand why zzz_exec breaks add_filter...


In my understanding multiple filtering is possible - if the filters return modified content to the next filter.


Because of zzz_exec is always the last filter which is added to the filter list all other filters first do their work and if they return modified string next filter works on this modified string until the last filter return its output to main gs script. So I don't undestand why filtering is broken. I see zzz_exec works on $c, modifies the contents of $c and returns the content of $c.


So is it not possible to do different content modifying of content before it is send back?


Best regards
Andreas
Reply
#9
Not really sure why it causes issues, but I mean look how it works, its rather crude.

I am sure it has less to do with content filtering and is mostly the eval()
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#10
I cannot reproduce, i would need an example.

I am using my content test plugin, dynpages and exec_php and it all works fine.
I imagine it is a more complex issue, maybe something to do with the

stripslashes(htmlspecialchars_decode)
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#11
Reproducing is quite easy.
Use any plugin which produces output on page initiated by a tag like (% ..... %) and do not activate zzz_exec-php. The page will show the wanted contents instead of the tag.
Then activate zzz_exec-php. From this on page only shows tag (% ... %) and no more the contents which should be produced by the plugin. I could reproduce with EVERY plugin which has a tag like above. From the moment on zzz_exec-php is activated only the tag is shown and not the contents which should be generated instead.
So my simple filter plugin does not work too.
Best regards
Andreas
Reply
#12
Works for me still, it must be something else. Like order of filters. Let me try to rearrange them

PHP Code:
<p>PHP TEST</p>

<?
php echo "test php echo"?> 
<p>(% gallery name=gallery %)</p>

<p>{% sidebar %}</p> 
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#13
oh yeah now i remember.

php_exec has to occur last because it returns null or output of your php code.
with plugins you cannot guarantee it will be last and some plugins do trickery to make themselves last which then break filters.

php_exec does not return anything for other filters , instead it outputs directly to browser since it is using eval.

after php_exec runs, content is null.


you can probably fix this using output buffering in php_exec

PHP Code:
function eval_php_in_content($c) {
    
ob_start();
    
$return = eval("?>" stripslashes(htmlspecialchars_decode($cENT_QUOTES)) . "<?php ");
    
$c ob_get_clean();
    
// debugLog($return);
    // debugLog($c);
    
return $c;


The ordering of plugin hooks is entirely random until 3.4 where you can specify a priority.


Either way it is not recommended to put code in content, use a component or a template function.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#14
That works fine.

The naming of "zzz_..." gives an idea that this plugin must be "the last in chain" of add_filter  Cool

If buffering is enabled everything works as expected. Because of I must implement some tricky php on different places in pages this was abslutely a MUST to get success in this project  Rolleyes

I think exec-php plugin should be updated to the way you wrote because of this probably solves issues that many other users have (and do not know where to look...)

Maybe this will fix many "curious incompatibilities" with this very hacky plugin. But it is very useful and many users will be gratefull !

Best regards
Andreas
Reply
#15
You could use components or my hook_components plugin and target specific pages with a simple $id check, or use different templates for those pages with php in the template.

using eval on a content field breaks in wysiwyg editors and open you up for any kind of imaginable php code injection.

This is still a terrible plugin, even if I fix it. And if i fix it, then anyone using it that uses the return might get unexpected results.

But it might be best to release a different version with safely wrapped code tags, limited php execution protection, and a way to support anyone that is using modifying content with a return closure instead of outputting.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)