function antispam_prepare_comment_data in AntiSpam 6
Same name and namespace in other branches
- 7 antispam.module \antispam_prepare_comment_data()
Prepare comment data for AntiSpam requests.
Parameters
$content_type: string 'node' or 'comment' or 'other':
$content: object $node or $comment or $other:
$provider: integer AKISMET_SERVIE/TYPEPAD_SERVICE/DEFENSIO_SERVICE:
Return value
array
3 calls to antispam_prepare_comment_data()
- antispam_api_cmd_comment_check in ./
antispam.module - AntiSpam API: Comment Check
- antispam_api_cmd_submit_ham in ./
antispam.module - AntiSpam API: Submit Ham
- antispam_api_cmd_submit_spam in ./
antispam.module - AntiSpam API: Submit Spam
File
- ./
antispam.module, line 1880
Code
function antispam_prepare_comment_data($content_type, $content, $provider) {
// Prepare data that is common to nodes/comments.
global $user, $base_url;
if ($provider == DEFENSIO_SERVICE) {
// DEFENSIO
if ($content->signature != '') {
// for submit spam/ham, we only needs signature
$comment_data = array(
'signature' => $content->signature,
);
}
else {
// for auditing comment, we need full detail data
$comment_data = array(
// IP address of the comment submitter.
'user-ip' => !empty($content->hostname) ? $content->hostname : ip_address(),
// User agent information of the comment submitter.
'user-agent' => $_SERVER['HTTP_USER_AGENT'],
// The content of the HTTP_REFERER header should be sent here.
'referrer' => $_SERVER['HTTP_REFERER'],
// Submitted name with the comment.
'comment-author' => $content->name,
);
if ($content_type == 'comment') {
$comment_data['permalink'] = url('node/' . $content->nid, array(
'fragment' => 'comment-' . $content->cid,
));
$comment_data['comment-author-email'] = $content->mail;
$comment_data['comment-author-url'] = $content->homepage;
$comment_data['comment-content'] = $content->comment;
// date when the original article was created
$node_created = db_result(db_query('SELECT created FROM {node} WHERE nid = %d', $content->nid));
$comment_data['article-date'] = date("Y/m/d", $node_created);
$comment_data['comment-type'] = 'comment';
}
else {
if ($content_type == 'node') {
$comment_data['permalink'] = url('node/' . $content->nid);
$comment_data['comment-author_email'] = isset($user->mail) ? $user->mail : '';
$comment_data['comment-author_url'] = '';
$comment_data['comment-content'] = $content->body;
$comment_data['article-date'] = date("Y/m/d");
// now
$comment_data['comment-type'] = 'other';
}
else {
// other
$comment_data['permalink'] = '';
$comment_data['comment-author_email'] = isset($user->mail) ? $user->mail : isset($content->mail) ? $content->mail : '';
$comment_data['comment-author_url'] = isset($content->homepage) ? $content->homepage : '';
$comment_data['comment-content'] = $content->body;
$comment_data['article-date'] = date("Y/m/d");
// now
$comment_data['comment-type'] = 'other';
}
}
if ($user->uid > 0) {
$comment_data['user-logged-in'] = TRUE;
// not anonymous
}
if ($user->uid == 1) {
$comment_data['trusted-user'] = TRUE;
}
// 'comment-author' must not be a null string
if ($user->uid == 0 || empty($comment_data['comment-author'])) {
$comment_data['comment-author'] = variable_get('anonymous', t('Anonymous'));
}
}
}
else {
// AKISMET, TYPEPAD
$comment_data = array(
// IP address of the comment submitter.
'user_ip' => !empty($content->hostname) ? $content->hostname : ip_address(),
// User agent information of the comment submitter.
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
// The content of the HTTP_REFERER header should be sent here.
'referrer' => $_SERVER['HTTP_REFERER'],
// May be blank, comment, trackback, pingback, or a made up value like "registration".
'comment_type' => '',
// Submitted name with the comment.
'comment_author' => $content->name,
);
if ($content_type == 'comment') {
$comment_data['permalink'] = url('node/' . $content->nid, array(
'fragment' => 'comment-' . $content->cid,
));
$comment_data['comment_author_email'] = $content->mail;
$comment_data['comment_author_url'] = $content->homepage;
$comment_data['comment_content'] = $content->comment;
}
else {
if ($content_type == 'node') {
$comment_data['permalink'] = url('node/' . $content->nid);
$comment_data['comment_author_email'] = isset($user->mail) ? $user->mail : '';
$comment_data['comment_author_url'] = '';
$comment_data['comment_content'] = $content->body;
}
else {
// other
$comment_data['permalink'] = '';
$comment_data['comment-author_email'] = isset($user->mail) ? $user->mail : isset($content->mail) ? $content->mail : '';
$comment_data['comment-author_url'] = isset($content->homepage) ? $content->homepage : '';
$comment_data['comment_content'] = $content->body;
}
}
}
return $comment_data;
}