Esempio n. 1
0
 /**
  * Check for spam links
  *
  * @param    string $post post to check for spam
  * @return   boolean         true = spam found, false = no spam
  *                        Note: Also returns 'false' in case of problems communicating with SLV.
  *                        Error messages are logged in Geeklog's error.log
  */
 public function CheckForSpam($post)
 {
     global $_SPX_CONF;
     $retval = false;
     if (empty($post)) {
         return $retval;
     }
     $links = $this->prepareLinks($post);
     if (empty($links)) {
         return $retval;
     }
     if (!isset($_SPX_CONF['timeout'])) {
         $_SPX_CONF['timeout'] = 5;
         // seconds
     }
     if ($this->_verbose) {
         SPAMX_log("Sending to SLV: {$links}");
     }
     $params = array(new XML_RPC_Value($links, 'string'));
     $msg = new XML_RPC_Message('slv', $params);
     $cli = new XML_RPC_Client('/slv.php', 'http://www.linksleeve.org');
     if ($this->_debug) {
         $cli->setDebug(1);
     }
     $resp = $cli->send($msg, $_SPX_CONF['timeout']);
     if (!$resp) {
         COM_errorLog('Error communicating with SLV: ' . $cli->getErrorString() . '; Message was ' . $msg->serialize());
     } else {
         if ($resp->faultCode()) {
             COM_errorLog('Error communicating with SLV. Fault code: ' . $resp->faultCode() . ', Fault reason: ' . $resp->faultString() . '; Message was ' . $msg->serialize());
         } else {
             $val = $resp->value();
             // note that SLV returns '1' for acceptable posts and '0' for spam
             if ($val->scalarval() != '1') {
                 $retval = true;
                 SPAMX_log("SLV: spam detected");
             } else {
                 if ($this->_verbose) {
                     SPAMX_log("SLV: no spam detected");
                 }
             }
         }
     }
     return $retval;
 }
Esempio n. 2
0
/**
 * Send a Pingback
 *
 * @param    string $sourceURI URL of an entry on our site
 * @param    string $targetURI an entry on someone else's site
 * @return   string              empty string on success or error message
 */
function PNB_sendPingback($sourceURI, $targetURI)
{
    global $LANG_TRB;
    $retval = '';
    $pingback = PNB_getPingbackUrl($targetURI);
    if (empty($pingback)) {
        return $LANG_TRB['no_pingback_url'];
    }
    $parts = parse_url($pingback);
    if (empty($parts['port'])) {
        if (strcasecmp($parts['scheme'], 'https') == 0) {
            $parts['port'] = 443;
        } else {
            $parts['port'] = 80;
        }
    }
    if (!empty($parts['query'])) {
        $parts['path'] .= '?' . $parts['query'];
    }
    $client = new XML_RPC_Client($parts['path'], $parts['host'], $parts['port']);
    //$client->setDebug (1);
    $msg = new XML_RPC_Message('pingback.ping', array(new XML_RPC_Value($sourceURI, 'string'), new XML_RPC_Value($targetURI, 'string')));
    $response = $client->send($msg, 0, $parts['scheme']);
    if (!is_object($response) && $response == 0) {
        $retval = $client->getErrorString();
    } elseif ($response->faultCode() != 0) {
        $retval = $response->faultString();
    }
    return $retval;
}