Exemple #1
0
function FAS_Call($type, $name, $title, $url, $content)
{
    $context = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    $blogstr = $context->getProperty('uri.host') . $context->getProperty('uri.blog');
    $DDosTimeWindowSize = 300;
    $rpc = new XMLRPC();
    $rpc->url = 'http://antispam.textcube.org/RPC/';
    if ($rpc->call('checkSpam', $blogstr, $type, $name, $title, $url, $content, $_SERVER['REMOTE_ADDR']) == false) {
        // call fail
        // Do Local spam check with "Thief-cat algorithm"
        $count = 0;
        if ($type == 2) {
            $storage = "RemoteResponses";
            $pool->reset($storage);
            $pool->setQualifier("url", "eq", $url, true);
            $pool->setQualifier("isfiltered", ">", 0);
            if ($cnt = $pool->getCount("id")) {
                $count += $cnt;
            }
        } else {
            // Comment Case
            $storage = "Comments";
            $pool->reset($storage);
            $pool->setQualifier("comment", "eq", ${$content}, true);
            $pool->setQualifier("name", "eq", $name, true);
            $pool->setQualifier("homepage", "eq", $url, true);
            $pool->setQualifier("isfiltered", ">", 0);
            if ($cnt = $pool->getCount("id")) {
                $count += $cnt;
            }
        }
        // Check IP
        $pool->reset($storage);
        $pool->setQualifier("ip", "eq", $_SERVER['REMOTE_ADDR'], true);
        $pool->setQualifier("written", ">", Timestamp::getUNIXtime() - $DDosTimeWindowSize);
        if ($cnt = $pool->getCount("id")) {
            $count += $cnt;
        }
        if ($count >= 10) {
            return false;
        }
        return true;
    }
    if (!is_null($rpc->fault)) {
        // FAS has some problem
        return true;
    }
    if ($rpc->result['result'] == true) {
        return false;
        // it's spam
    }
    return true;
}
Exemple #2
0
function EAS_Call($type, $name, $title, $url, $content)
{
    global $hostURL, $blogURL, $database;
    $blogstr = $hostURL . $blogURL;
    $rpc = new XMLRPC();
    $rpc->url = 'http://antispam.eolin.com/RPC/index.php';
    if ($rpc->call('checkSpam', $blogstr, $type, $name, $title, $url, $content, $_SERVER['REMOTE_ADDR']) == false) {
        // call fail
        // Do Local spam check with "Thief-cat algorithm"
        $count = 0;
        $tableName = $database['prefix'] . 'RemoteResponses';
        if ($type == 2) {
            $sql = 'SELECT COUNT(id) as cc FROM ' . $database['prefix'] . 'RemoteResponses WHERE';
            $sql .= ' url = \'' . POD::escapeString($url) . '\'';
            $sql .= ' AND isfiltered > 0';
            if ($row = POD::queryRow($sql)) {
                $count += @$row[0];
            }
        } else {
            // Comment Case
            $tableName = $database['prefix'] . 'Comments';
            $sql = 'SELECT COUNT(id) as cc FROM ' . $database['prefix'] . 'Comments WHERE';
            $sql .= ' comment = \'' . POD::escapeString($content) . '\'';
            $sql .= ' AND homepage = \'' . POD::escapeString($url) . '\'';
            $sql .= ' AND name = \'' . POD::escapeString($name) . '\'';
            $sql .= ' AND isfiltered > 0';
            if ($row = POD::queryRow($sql)) {
                $count += @$row[0];
            }
        }
        // Check IP
        $sql = 'SELECT COUNT(id) as cc FROM ' . $tableName . ' WHERE';
        $sql .= ' ip = \'' . POD::escapeString($_SERVER['REMOTE_ADDR']) . '\'';
        $sql .= ' AND isfiltered > 0';
        if ($row = POD::queryRow($sql)) {
            $count += @$row[0];
        }
        if ($count >= 10) {
            return false;
        }
        return true;
    }
    if (!is_null($rpc->fault)) {
        // EAS has some problem
        return true;
    }
    if ($rpc->result['result'] == true) {
        return false;
        // it's spam
    }
    return true;
}
Exemple #3
0
/**
 * @brief Syndicating routine.
 * @see Tag, User, DBModel, Model_Context
 */
function SyndicateToEolin($entryId, $entry, $mode)
{
    $context = Model_Context::getInstance();
    $blogid = $context->getProperty('blog.id');
    $rpc = new XMLRPC();
    $rpc->url = 'http://ping.eolin.com/';
    $summary = array('blogURL' => $context->getProperty('uri.default'), 'syncURL' => $context->getProperty('uri.default') . "/plugin/abstractToEolin?entryId={$entryId}");
    if ($mode == 'create') {
        $summary['blogTitle'] = $context->getProperty('blog.title');
        $summary['language'] = $context->getProperty('blog.language');
        $summary['permalink'] = $context->getProperty('uri.default') . "/" . ($context->getProperty('blog.useSloganOnPost') ? "entry/{$entry['slogan']}" : $entry['id']);
        $summary['title'] = Utils_Unicode::lessenAsByte($entry['title'], 255);
        $summary['content'] = Utils_Unicode::lessenAsByte(stripHTML(getEntryContentView($blogid, $entry['id'], $entry['content'], $entry['contentformatter'])), 1023, '');
        $summary['author'] = User::authorName($entry['userid'], $entryId);
        $summary['tags'] = Tag::getTagsWithEntryId($blogid, $entry);
        $summary['location'] = $entry['location'];
        $summary['written'] = Timestamp::getRFC1123($entry['published']);
    }
    return $rpc->call("sync.{$mode}", $summary);
}
function sendTrackbackPing($entryId, $permalink, $url, $site, $title)
{
    $rpc = new XMLRPC();
    $rpc->url = TEXTCUBE_SYNC_URL;
    $summary = array('permalink' => $permalink, 'url' => $url, 'blogName' => $site, 'title' => $title);
    $rpc->async = true;
    $rpc->call('sync.trackback', $summary);
}
Exemple #5
0
function syndicateEntry($id, $mode)
{
    $context = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    $pool->reset('XMLRPCPingSettings');
    $pool->setQualifier('blogid', 'equals', $context->getProperty('blog.id'));
    $sites = $pool->getAll('url,pingtype');
    $entry = getEntry($context->getProperty('blog.id'), $id);
    if (is_null($entry)) {
        return false;
    }
    if (!empty($sites)) {
        foreach ($sites as $site) {
            $rpc = new XMLRPC();
            $rpc->url = $site['url'];
            $result[$site['url']] = $rpc->call($context->getProperty('blog.title'), $context->getProperty('uri.default'));
        }
    }
    if ($mode == 'create') {
        fireEvent('CreatePostSyndicate', $id, $entry);
    } else {
        if ($mode == 'modify') {
            fireEvent('ModifyPostSyndicate', $id, $entry);
        } else {
            if ($mode == 'delete') {
                fireEvent('DeletePostSyndicate', $id, $entry);
            }
        }
    }
    return true;
}
Exemple #6
0
function sendCommentPing($entryId, $permalink, $name, $homepage)
{
    return true;
    global $database, $blog;
    $blogid = getBlogId();
    if ($slogan = POD::queryCell("SELECT slogan\n\t\tFROM {$database['prefix']}Entries\n\t\tWHERE blogid = {$blogid}\n\t\t\tAND id = {$entryId}\n\t\t\tAND draft = 0\n\t\t\tAND visibility = 3 \n\t\t\tAND acceptcomment = 1")) {
        $rpc = new XMLRPC();
        $rpc->url = TEXTCUBE_SYNC_URL;
        $summary = array('permalink' => $permalink, 'name' => $name, 'homepage' => $homepage);
        $rpc->async = true;
        $rpc->call('sync.comment', $summary);
    }
}