]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/BlogspamNetPlugin.php
Added wait on signon failure due to update contacts failing
[quix0rs-gnu-social.git] / plugins / BlogspamNetPlugin.php
index d9372bcd56a42ad57bc5b67b3f06e54cf07b712c..d52e6006ac8dbb4bc33bd203af9d59521782826f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Plugin to check submitted notices with blogspam.net
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Plugin
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @copyright 2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Brion Vibber <brion@status.net>
+ * @copyright 2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET')) {
     exit(1);
 }
 
@@ -45,10 +46,10 @@ define('BLOGSPAMNETPLUGIN_VERSION', '0.1');
  * hits, but it's better than nothing.
  *
  * @category Plugin
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  *
  * @see      Event
  */
@@ -69,14 +70,14 @@ class BlogspamNetPlugin extends Plugin
     {
         $args = $this->testArgs($notice);
         common_debug("Blogspamnet args = " . print_r($args, TRUE));
-        $request = xmlrpc_encode_request('testComment', array($args));
-        $context = stream_context_create(array('http' => array('method' => "POST",
-                                                               'header' =>
-                                                               "Content-Type: text/xml\r\n".
-                                                               "User-Agent: " . $this->userAgent(),
-                                                               'content' => $request)));
-        $file = file_get_contents($this->baseUrl, false, $context);
-        $response = xmlrpc_decode($file);
+        $requestBody = xmlrpc_encode_request('testComment', array($args));
+
+        $request = new HTTPClient($this->baseUrl, HTTPClient::METHOD_POST);
+        $request->setHeader('Content-Type', 'text/xml');
+        $request->setBody($requestBody);
+        $httpResponse = $request->send();
+
+        $response = xmlrpc_decode($httpResponse->getBody());
         if (xmlrpc_is_fault($response)) {
             throw new ServerException("$response[faultString] ($response[faultCode])", 500);
         } else {
@@ -119,7 +120,7 @@ class BlogspamNetPlugin extends Plugin
         $args['site'] = common_root_url();
         $args['version'] = $this->userAgent();
 
-        $args['options'] = "max-size=140,min-size=0,min-words=0,exclude=bayasian";
+        $args['options'] = "max-size=" . common_config('site','textlimit') . ",min-size=0,min-words=0,exclude=bayasian";
 
         return $args;
     }
@@ -139,6 +140,6 @@ class BlogspamNetPlugin extends Plugin
 
     function userAgent()
     {
-        return 'BlogspamNetPlugin/'.BLOGSPAMNETPLUGIN_VERSION . ' Laconica/' . LACONICA_VERSION;
+        return 'BlogspamNetPlugin/'.BLOGSPAMNETPLUGIN_VERSION . ' StatusNet/' . STATUSNET_VERSION;
     }
 }