function votingapi_add_vote
($content_type,
$content_id,
$value,
$value_type = VOTINGAPI_VALUE_DEFAULT_TYPE,
$tag = VOTINGAPI_VALUE_DEFAULT_TAG,
$uid =
NULL) {
if ($uid ==
NULL) {
global $user;
$uid =
$user-
>uid;
}
$vobj->vote_id = db_next_id('{votingapi_vote}');
$vobj->content_type = $content_type;
$vobj->content_id = $content_id;
$vobj->value = $value;
$vobj->value_type = $value_type;
$vobj->tag = $tag;
$vobj->uid = $uid;
$vobj->timestamp = time();
$vobj->hostname = $_SERVER['REMOTE_ADDR'];
// Append internal IP if it exists.
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$vobj->hostname .= '-'. $_SERVER['HTTP_X_FORWARDED_FOR'];
}
db_query("INSERT INTO {votingapi_vote} (vote_id, content_type, content_id, value, value_type, tag, uid, timestamp, hostname) VALUES (%d, '%s', %d, %f, '%s', '%s', %d, %d, '%s')",
$vobj->vote_id, $vobj->content_type, $vobj->content_id, $vobj->value, $vobj->value_type, $vobj->tag, $vobj->uid, $vobj->timestamp, $vobj->hostname);
// Give other modules a chance to act on the insert operation.
votingapi_invoke('insert', $vobj);
return $vobj;
}