function antispam_api_cmd_comment_check in AntiSpam 6
Same name and namespace in other branches
- 7 antispam.module \antispam_api_cmd_comment_check()
AntiSpam API: Comment Check
Parameters
$content_type: string 'node' or 'comment' or 'other':
$content: object $node or $comment:
Return value
array result[0] - return status (int) See constants ANTISPAM_API_RESULT_xxx. result[1] - signature (string) - DEFENSIO only result[2] - spaminess (float) value between 0 to 1 - DEFENSIO only
4 calls to antispam_api_cmd_comment_check()
- antispam_api_cmd_spam_check in ./
antispam.module - AntiSpam API: Generic Data Check
- antispam_content_spam_operation in ./
antispam.module - Mark content as spam or remove the mark.
- antispam_nodeapi in ./
antispam.module - Implementation of hook_nodeapi().
- _antispam_comment_form_submit in ./
antispam.module - Comment form submit callback; check for spam.
File
- ./
antispam.module, line 2081
Code
function antispam_api_cmd_comment_check($content_type, $content) {
if (!variable_get('antispam_connection_enabled', 1)) {
return array(
ANTISPAM_API_RESULT_ERROR,
);
}
$provider = antispam_get_service_provider();
$comment_data = antispam_prepare_comment_data($content_type, $content, $provider);
$api_host = antispam_get_api_host($provider);
$api_key = antispam_get_api_key($provider);
if (empty($api_key)) {
return array(
ANTISPAM_API_RESULT_ERROR,
);
}
if ($provider == DEFENSIO_SERVICE) {
// DEFENSIO
$comment_data = array_merge(_antispam_api_prepare_request_data(), $comment_data);
$query_string = _antispam_api_build_query_string($comment_data);
$response = _antispam_api_http_post($query_string, $api_host, '/app/' . DEFENSIO_API_VERSION . '/audit-comment/' . $api_key . '.yaml');
if (!isset($response[1])) {
return ANTISPAM_API_RESULT_ERROR;
}
$res_array = _antispam_parse_yaml_response($response[1]);
$result = array();
if (isset($res_array['spam'])) {
$result[0] = $res_array['spam'] == 'true' ? ANTISPAM_API_RESULT_IS_SPAM : ANTISPAM_API_RESULT_IS_HAM;
if (isset($res_array['signature'])) {
$result[1] = $res_array['signature'];
}
if (isset($res_array['spaminess'])) {
$result[2] = $res_array['spaminess'];
}
return $result;
}
else {
return array(
ANTISPAM_API_RESULT_ERROR,
);
}
}
else {
// AKISMET, TYPEPAD
$comment_data = array_merge(_antispam_api_prepare_request_data(), $comment_data);
$query_string = _antispam_api_build_query_string($comment_data);
$host = $api_key . '.' . $api_host;
$response = _antispam_api_http_post($query_string, $host, '/' . AKISMET_API_VERSION . '/comment-check');
if (!isset($response[1])) {
return ANTISPAM_API_RESULT_ERROR;
}
return 'true' == $response[1] ? array(
ANTISPAM_API_RESULT_IS_SPAM,
) : array(
ANTISPAM_API_RESULT_IS_HAM,
);
}
}