<?php
/*
-* $Id: spam_babycart.php 7964 2011-03-05 17:05:30Z vargenau $
* Author: Bob Apthorpe <apthorpe+babycart@cynistar.net>
* Proof-of-concept PHP fragment to flag blog/wiki spam
*
* copy contrib/babycart to /usr/local/bin/
*/
-function check_babycart(&$text, $ip, $user_id='') {
+function check_babycart(&$text, $ip, $user_id = '')
+{
// $X_babycart = '/usr/bin/perl /home/apthorpe/pjx/babycart/babycart';
// cygwin:
if (!defined('BABYCART_PATH'))
$descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
$process = proc_open(BABYCART_PATH, $descriptorspec, $pipes);
if (is_resource($process)) {
- // $pipes now looks like this:
- // 0 => writeable handle connected to child stdin
- // 1 => readable handle connected to child stdout
- // Any error output will be appended to $pipes[2]
+ // $pipes now looks like this:
+ // 0 => writeable handle connected to child stdin
+ // 1 => readable handle connected to child stdout
+ // Any error output will be appended to $pipes[2]
// Send comment out for analysis
fwrite($pipes[0], $comment);
// print "Response: $response\n";
// split into status, note, score, rules...
if ($response) {
- if (substr($response,0,2) == 'OK')
+ if (substr($response, 0, 2) == 'OK')
return false;
/*
response fields are:
return explode(',', $response, 4);
}
}
- trigger_error("Couldn't process ".BABYCART_PATH.".\n".$error, E_USER_WARNING);
+ trigger_error("Couldn't process " . BABYCART_PATH . ".\n" . $error, E_USER_WARNING);
return -1; // process error
}