当前位置: 首页>>代码示例>>PHP>>正文


PHP Akismet::check方法代码示例

本文整理汇总了PHP中Akismet::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::check方法的具体用法?PHP Akismet::check怎么用?PHP Akismet::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akismet的用法示例。


在下文中一共展示了Akismet::check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: akismet_fake_draft

function akismet_fake_draft(&$post)
{
    global $mybb, $isspam, $akismet, $cache;
    $exclude_array = explode(',', $mybb->settings['akismetuserstoignore']);
    if (!$mybb->settings['akismetswitch'] || in_array($mybb->user['uid'], $exclude_array) || is_super_admin($mybb->user['uid'])) {
        return;
    }
    if ($mybb->settings['akismetfidsignore']) {
        $akismet_fids_ignore = explode(',', $mybb->settings['akismetfidsignore']);
        if (in_array($post->data['fid'], $akismet_fids_ignore)) {
            return;
        }
    }
    if ($mybb->settings['akismetuidsignore']) {
        $akismet_uids_ignore = explode(',', $mybb->settings['akismetuidsignore']);
        if (in_array($mybb->user['usergroup'], $akismet_uids_ignore)) {
            return;
        }
    }
    $akismet_array = array('type' => 'post', 'username' => $post->data['username'], 'email' => $mybb->user['email'], 'website' => $mybb->user['website'], 'message' => $post->data['message'], 'user_ip' => $mybb->user['ipaddress']);
    if (!$akismet) {
        $akismet = new Akismet($mybb->settings['bburl'], $mybb->settings['akismetapikey'], $akismet_array);
    }
    if ($akismet->check()) {
        global $db;
        $isspam = true;
        // Update our spam count attempts
        ++$mybb->user['akismetstopped'];
        $db->update_query("users", array('akismetstopped' => $mybb->user['akismetstopped']), "uid = '{$mybb->user['uid']}'");
        // Check if the person should be banned
        if ($mybb->settings['akismetnumtillban'] > 0 && $mybb->user['akismetstopped'] >= $mybb->settings['akismetnumtillban']) {
            $banned_user = array("uid" => $mybb->user['uid'], "admin" => 0, "gid" => 7, "oldgroup" => $mybb->user['usergroup'], "dateline" => TIME_NOW, "bantime" => 'perm', "lifted" => 'perm', "reason" => "Automatically banned by the Akismet system for spamming.", "oldadditionalgroups" => '');
            $db->insert_query("banned", $banned_user);
            $db->update_query("users", array('usergroup' => 7), "uid = '{$mybb->user['uid']}'");
            $cache->update_moderators();
            // We better do this..otherwise they have dodgy permissions
            $mybb->user['banoldgroup'] = $mybb->user['usergroup'];
            $mybb->user['usergroup'] = 7;
            global $mybbgroups;
            $mybbgroups = $mybb->user['usergroup'];
            if ($mybb->user['additionalgroups']) {
                $mybbgroups .= ',' . $mybb->user['additionalgroups'];
            }
        }
        // Fake visibility
        // Essentially because you can't modify the $visible variable we need to trick it
        // into thinking its saving a draft so it won't modify the users lastpost and postcount
        // In akismet_verify, its set back to -4 so we can still uniquely verify that this is a spam message
        // before it's inserted into the database.
        $post->data['savedraft'] = 1;
    }
}
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:52,代码来源:akismet.php


注:本文中的Akismet::check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。