June 30, 2007
7:16 pm | Last updated: June 30, 2007 at: 7:25 pm

After successful installation of WP-Cache, I’ve encountered another problem, that’s the compatiblity issues between Spam Karma 2 (SK2) and WP-Cache. This issues led me to Priv’s SK2-WP-Cache-Compatibility plugin which sucessfully fixed the case of the missing comments.

When you use Spam Karma 2 with WP-Cache, cached files are not flushed after a successfully comment approval. That’s basically because SK2 intercepts some actions, WP-Cache will not get notified. Priv had created a small plugin for SK2, that will directly call wp-cache to flush cache, after a comment is approved.

Download this zip, extract and drop the php into sk2_plugins directory, it should just work.

So far so good, this problem is solved, but here comes another one, if you want SK2 and WP-Cache work together, even after installing the plugin above. You’ll have to turn off  ‘encrypted payloadcheck in sk2, see the reason below.

Reason: There’s a problem discovered by Reiner, SK2 generates some dynamic hidden field to check if the page is really loaded by a browser before the comment is posted.

The ‘encrypted payload’ plugin will cause the biggest problem, since it contains an ‘IP’ field that generated base upon client’s IP.

With wp-cache, encrypted payload will be fixed, so the ip will not match the real commenter’s ip. IP mismatch will cause a minus 2.5 karma, which will prevent many normal comments comes in.

Solution: While reading the comments on Priv’s blog, I found the fix for the payload SK2 plugin to still work with WP-Cache. This fix also solves problems that may have occurred with the stopwatch plugin which uses the time embedded in the payload plugin (which as a side note, breaks the plugins independance, but well). This also gives a good example of how to use the mfunc thingy:

Fix: Go to your SK2 folder and open SK2_payload_plugin.php, replace the form_insert function with:

[code]
function form_insert($post_ID)
{
$seed = $this->get_option_value(’secret_seed’);
if (empty ($seed))
{
$seed = sk2_rand_str(10);
$this->set_option_value(’secret_seed’, $seed);
$this->log_msg(__(”Resetting secret seed to: $seed.”), 5);
}
$time = time();
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
//echo (”“); // debug
$payload = md5($time . $seed . $ip . $post_ID);
echo ““;
echo “
“;
echo “
“;
echo “
“;
echo ““;
}
[/code]

Note the added mfunc tags. The seed and postids are passed as parameters so that the replacement function doesn’t have to fetch them. WP-Cache is smart enough not to output those parameters in the HTML file received by the client, which makes you safe from seeing the seed hijacked.

Now, add this function to wp-cache-phase1.php:

[code]
function cached_sk2_javascript_payload($seed,$postid) {
$time = time();
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$payload = md5($time . $seed . $ip . $postid);
echo “
“;
echo “
“;
echo “
“;
}
[/code]

This way, time and IP won’t be cached and the stopwatch+payload plugins will still work. The javascript_plugin only computes some math stuff so it’s not broken by WP-cache.

Plugins Page

Spam Karma 2, SK2, WP-Cache, Plugins, WordPress Plugins, Encypted Payload, Payload SK2 plugin, Stopwatch plugin, SK2 WP-Cache Compatibility, WordPress Tips, WordPress Tweaks

Related Posts:

No comment yet

Leave a comment »

1  Trackbacks & Pingbacks: | TrackBack URI

  1. Pingback from
    1
    Usare Spam Karma 2 e WP-Cache assieme e senza problemi | Davide Salerno says:August 9th, 2007 at 3:56 am

    [...] Ecco quello che ho fatto per far funzionare Spam Karma 2 e WP-Cache assieme e senza problemi, il tutto grazie alle indicazioni trovate sul blog di Priv e su D’ Technology Weblog. [...]

Leave a Response

Comment Preview
« Spam Karma 2 PluginWordPress Theme Generator »
Feed Icon

Subscribe via RSS or email: