當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。