Nooku Server is an open source project powered by Assembla

Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.

nooku-server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
 * @version        $Id$
 * @category    Nooku
 * @package        Nooku_Server
 * @subpackage    Users
 * @copyright    Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net).
 * @license        GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * Abstract spam service filter class.
 *
 * @author      Arunas Mazeika <http://nooku.assembla.com/profile/arunasmazeika>
 * @category    Nooku
 * @package        Nooku_Server
 * @subpackage    Users
 */

abstract class ComUsersFilterSpamServiceAbstract extends ComUsersFilterSpamAbstract {

    /**
     * @var string The service API key.
     */
    protected $_api_key;

    /**
     * @var bool Indicates if the service requires an API key for using it.
     */
    protected $_has_api_key;

    public function __construct(KConfig $config = null) {
        if (!$config) {
            $config = new KConfig();
        }

        parent::__construct($config);

        $this->_has_api_key = $config->has_api_key;

        if ($this->_has_api_key && !$config->api_key) {
            throw new KFilterException('The API key is missing');
        }

        $this->_api_key = $config->api_key;
    }

    protected function _initialize(KConfig $config) {
        $config->append(array('api_key' => null, 'has_api_key' => true));
        parent::_initialize($config);
    }

    /**
     * DNSBL Test.
     *
     * @param string The lookup string.
     * @return mixed False if test succeeds (no block), lookup result otherwise.
     */
    protected function _isDnsblBlocked($lookup)
    {
        if($lookup[strlen($lookup) - 1] != '.') $lookup .= '.';
        $result = gethostbyname($lookup);
        if($result == $lookup) {
            return false;
        } else {
            return $result;
        }
    }
}
Ajax-loader Loading, please wait...