本文整理汇总了PHP中Vote::karma方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::karma方法的具体用法?PHP Vote::karma怎么用?PHP Vote::karma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vote
的用法示例。
在下文中一共展示了Vote::karma方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: killspam
function killspam($id)
{
global $db;
require_once mnminclude . 'link.php';
require_once mnminclude . 'votes.php';
require_once mnminclude . 'tags.php';
$user = $db->get_row('SELECT * FROM ' . table_users . " where user_id={$id}");
if (!$user->user_id) {
return;
}
canIChangeUser($user->user_level);
$db->query('UPDATE `' . table_users . "` SET user_enabled=0, `user_pass` = '63205e60098a9758101eeff9df0912ccaaca6fca3e50cdce3', user_level = 'Spammer' WHERE `user_id` = {$id}");
$results = $db->get_results($sql = "SELECT comment_id, comment_link_id FROM `" . table_comments . "` WHERE `comment_user_id` = {$id}");
if ($results) {
foreach ($results as $result) {
$db->query($sql = 'UPDATE `' . table_comments . '` SET `comment_status` = "spam" WHERE `comment_id` = "' . $result->comment_id . '"');
$vars = array('comment_id' => $result->comment_id);
check_actions('comment_spam', $vars);
$link = new Link();
$link->id = $result->comment_link_id;
$link->read();
$link->recalc_comments();
$link->store();
}
}
ban_ip($user->user_ip, $user->user_lastip);
$results = $db->get_results("SELECT * FROM `" . table_groups . "` WHERE group_creator = '{$id}'");
if ($results) {
foreach ($results as $result) {
$db->query('DELETE FROM `' . table_group_member . '` WHERE member_group_id = ' . $result->group_id);
$db->query('DELETE FROM `' . table_group_shared . '` WHERE share_group_id = ' . $result->group_id);
}
}
$db->query("DELETE FROM `" . table_groups . "` WHERE group_creator = '{$id}'");
$results = $db->get_results("SELECT vote_id,vote_link_id FROM `" . table_votes . "` WHERE `vote_user_id` = {$id}");
if ($results) {
foreach ($results as $result) {
$db->query('DELETE FROM `' . table_votes . '` WHERE `vote_id` = "' . $result->vote_id . '"');
$link = new Link();
$link->id = $result->vote_link_id;
$link->read();
$vote = new Vote();
$vote->type = 'links';
$vote->link = $result->vote_link_id;
if (Voting_Method == 1) {
$link->votes = $vote->count();
$link->reports = $link->count_all_votes("<0");
} elseif (Voting_Method == 2) {
$link->votes = $vote->rating();
$link->votecount = $vote->count();
$link->reports = $link->count_all_votes("<0");
} elseif (Voting_Method == 3) {
$link->votes = $vote->count();
$link->karma = $vote->karma();
$link->reports = $link->count_all_votes("<0");
}
$link->store_basic();
$link->check_should_publish();
}
}
$results = $db->get_results($sql = "SELECT link_id, link_url FROM `" . table_links . "` WHERE `link_author` = {$id}");
global $USER_SPAM_RULESET, $FRIENDLY_DOMAINS;
$filename = mnmpath . $USER_SPAM_RULESET;
$lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$approved = file(mnmpath . $FRIENDLY_DOMAINS, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($results) {
foreach ($results as $result) {
if (preg_match('/:\\/\\/(www\\.)?([^\\/]+)(\\/|$)/', $result->link_url, $m)) {
$domain = strtoupper($m[2]) . "\n";
if (!in_array($domain, $lines) && !in_array($domain, $approved)) {
$lines[] = $domain;
$changed = 1;
}
}
$vars = array('link_id' => $result->link_id);
check_actions('story_spam', $vars);
}
}
if ($changed) {
if (is_writable($filename)) {
if ($handle = fopen($filename, 'w')) {
fwrite($handle, join("\n", $lines));
fclose($handle);
}
}
}
$db->query($sql = 'UPDATE `' . table_links . '` SET `link_status` = "spam" WHERE `link_author` = "' . $id . '"');
$db->query('DELETE FROM `' . table_saved_links . '` WHERE `saved_user_id` = "' . $id . '"');
$db->query('DELETE FROM `' . table_trackbacks . '` WHERE `trackback_user_id` = "' . $id . '"');
$db->query('DELETE FROM `' . table_friends . '` WHERE `friend_id` = "' . $id . '"');
$db->query('DELETE FROM `' . table_messages . "` WHERE `sender`={$id} OR `receiver`={$id}");
}
示例2: Vote
function insert_vote($user = 0, $value = 10)
{
global $anon_karma;
require_once mnminclude . 'votes.php';
if ($value > 10) {
$value = 10;
}
$vote = new Vote();
$vote->type = 'links';
$vote->user = $user;
$vote->link = $this->id;
$vote->value = $value;
// if($value<10) {$vote->value=($anon_karma/10)*$value;}
if ($user > 0) {
require_once mnminclude . 'user.php';
$dbuser = new User($user);
if ($dbuser->id > 0) {
$vote->karma = $dbuser->karma;
}
} elseif (!anonymous_vote) {
return;
} else {
$vote->karma = $anon_karma;
}
if ($vote->insert()) {
$vote = new Vote();
$vote->type = 'links';
$vote->link = $this->id;
if (Voting_Method == 1) {
$this->votes = $vote->count();
$this->reports = $this->count_all_votes("<0");
} elseif (Voting_Method == 2) {
$this->votes = $vote->rating();
$this->votecount = $vote->count();
$this->reports = $this->count_all_votes("<0");
} elseif (Voting_Method == 3) {
$this->votes = $vote->count();
$this->votecount = $vote->count();
$this->karma = $vote->karma();
$this->reports = $this->count_all_votes("<0");
}
$this->store_basic();
$this->check_should_publish();
$vars = array('vote' => $this);
check_actions('link_insert_vote_post', $vars);
return true;
}
return false;
}
示例3: Vote
function insert_vote($user = 0, $value = 10)
{
global $anon_karma;
require_once mnminclude . 'votes.php';
if ($value > 10) {
$value = 10;
}
$vote = new Vote();
$vote->type = 'links';
$vote->user = $user;
$vote->link = $this->id;
$vote->value = $value;
// if($value<10) {$vote->value=($anon_karma/10)*$value;}
if ($user > 0) {
require_once mnminclude . 'user.php';
$dbuser = new User($user);
if ($dbuser->id > 0) {
$vote->karma = $dbuser->karma;
}
} elseif (!anonymous_vote) {
return;
} else {
$vote->karma = $anon_karma;
}
if ($vote->insert()) {
$vote = new Vote();
$vote->type = 'links';
$vote->link = $this->id;
if (Voting_Method == 1) {
$this->votes = $vote->count();
$this->reports = $this->count_all_votes("<0");
} elseif (Voting_Method == 2) {
$this->votes = $vote->rating();
$this->votecount = $vote->count();
$this->reports = $this->count_all_votes("<0");
} elseif (Voting_Method == 3) {
$this->votes = $vote->count();
$this->votecount = $vote->count();
$this->karma = $vote->karma();
$this->reports = $this->count_all_votes("<0");
}
$this->store_basic();
$this->check_should_publish();
/***** This code was to update the user_karma with the value of "Voted on an article" when the auto vote is set to true upon story submission. It was causing double update of the user_karma upon voting. We provisioned a new code in /module/karma_main.php in the karma_do_submit3 function *****/
//$vars = array('vote' => $this);
//check_actions('link_insert_vote_post', $vars);
return true;
}
return false;
}