Exemplo n.º 1
0
 function execute()
 {
     global $wgUser, $wgOut, $wgVoteDirectory, $wgCommentsDirectory, $IP;
     require_once "{$wgVoteDirectory}/VoteClass.php";
     require_once "{$wgVoteDirectory}/Publish.php";
     require_once "{$wgVoteDirectory}/RSS.php";
     require_once "{$wgCommentsDirectory}/CommentClass.php";
     if ($_POST["mk"] == md5($_POST["pid"] . 'pants' . $wgUser->mName)) {
         require_once "{$IP}/extensions/UserStats/UserStatsClass.php";
         $stats = new UserStatsTrack(1, $wgUser->mId, $wgUser->mName);
         if (($_GET["Action"] == 1 || $_GET["Action"] == 2) && is_numeric($_POST["pid"]) && (is_numeric($_POST["TheVote"]) || $_GET["Action"] == 2)) {
             //echo 'test2';
             $Vote = new Vote($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             if ($_GET["Action"] == 1) {
                 $Vote->insert($_POST["TheVote"]);
                 $stats->incVoteCount();
             } else {
                 $Vote->delete();
             }
             $CommentList = new Comment($_POST["pid"]);
             $publish = new Publish();
             $publish->PageID = $_POST["pid"];
             $publish->VoteCount = $Vote->count(1);
             $publish->CommentCount = $CommentList->count();
             $publish->check_score();
             echo $Vote->count(1);
         }
         if ($_GET["Action"] == 3) {
             $Vote = new VoteStars($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             $Vote->insert($_POST["TheVote"]);
             $stats->incVoteCount();
             echo $Vote->display();
         }
         if ($_GET["Action"] == 4) {
             $Vote = new VoteStars($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             $Vote->delete();
             echo $Vote->display();
         }
     }
     // This line removes the navigation and everything else from the
     // page, if you don't set it, you get what looks like a regular wiki
     // page, with the body you defined above.
     $wgOut->setArticleBodyOnly(true);
 }
Exemplo n.º 2
0
 function insert_vote($user = 0, $value = 10)
 {
     if (parent::insert_vote($user, $value)) {
         $vote = new Vote();
         $vote->type = 'links';
         $vote->link = $this->id;
         if (Voting_Method == 2) {
             $this->votes = $vote->rating("!=0");
             $this->votecount = $vote->count("!=0");
             $this->reports = $this->count_all_votes("<0");
         } else {
             $this->reports = $this->count_all_votes("<0");
             $this->votes = $vote->count() - $this->reports;
         }
         $this->store_basic();
         $this->check_should_publish();
         $vars = array('vote' => $this);
         check_actions('link_insert_vote_post', $vars);
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
function wfVoteDelete($pageId)
{
    global $wgUser;
    if (!$wgUser->isAllowed('voteny')) {
        return '';
    }
    if (is_numeric($pageId)) {
        $vote = new Vote($pageId);
        $vote->delete();
        return $vote->count(1);
    } else {
        return 'error';
    }
}
Exemplo n.º 4
0
 function insert_vote($user = 0, $value = 10)
 {
     global $anon_karma;
     require_once mnminclude . 'votes.php';
     if (!is_numeric($this->id)) {
         return false;
     }
     $vote = new Vote();
     $vote->type = 'comments';
     $vote->user = $user;
     $vote->link = $this->id;
     $vote->value = $value;
     if ($vote->insert()) {
         $vote = new Vote();
         $vote->type = 'comments';
         $vote->link = $this->id;
         $this->votes = $vote->count() - $vote->count('<0');
         if (comment_buries_spam > 0 && $vote->count_all("<0") >= comment_buries_spam) {
             $this->status = 'discard';
             $this->store();
             $vars = array('comment_id' => $this->id);
             check_actions('comment_spam', $vars);
             require_once mnminclude . 'link.php';
             $link = new Link();
             $link->id = $this->link;
             $link->read();
             $link->recalc_comments();
             $link->store();
         }
         $vars = array('vote' => $this);
         check_actions('comment_insert_vote_post', $vars);
         return $vote->sum();
     }
     return false;
 }
Exemplo n.º 5
0
function spam_trigger_killspam($id)
{
    global $db, $current_user;
    #	include_once(mnminclude.'link.php');
    #	include_once(mnminclude.'votes.php');
    $oldlevel = $current_user->user_level;
    $current_user->user_level = 'admin';
    killspam($id);
    $current_user->user_level = $oldlevel;
    return;
    $db->query('UPDATE `' . table_users . "` SET user_enabled=0, `user_pass` = '63205e60098a9758101eeff9df0912ccaaca6fca3e50cdce3', user_level='Spammer' WHERE `user_id` = {$id}");
    $db->query('UPDATE `' . table_links . '` SET `link_status` = "discard" WHERE `link_author` = "' . $id . '"');
    $results = $db->get_results("SELECT comment_id, comment_link_id FROM `" . table_comments . "` WHERE `comment_user_id` = {$id}");
    if ($results) {
        foreach ($results as $result) {
            $comment_id = $result->comment_id;
            $db->query('DELETE FROM `' . table_comments . '` WHERE `comment_id` = "' . $comment_id . '"');
            $db->query('DELETE FROM `' . table_comments . '` WHERE `comment_parent` = "' . $comment_id . '"');
            $link = new Link();
            $link->id = $result->comment_link_id;
            $link->read();
            $link->recalc_comments();
            $link->store();
        }
    }
    $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");
            }
            $link->store_basic();
            $link->check_should_publish();
        }
    }
    $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}");
}
Exemplo n.º 6
0
	function votes($user) {
		$vote = new Vote('links', $this->id, $user);
		return $vote->count();
	}
Exemplo n.º 7
0
	function insert_vote($user=0) {
		global $anon_karma;
		require_once(mnminclude.'votes.php');

		$vote = new Vote;
		$vote->user=$user;
		$vote->link=$this->id;
		if ($vote->exists()) return false;
		$vote->value=$anon_karma;
		if($user>0) {
			require_once(mnminclude.'user.php');
			$dbuser = new User($user);
			if($dbuser->id>0) {
				$vote->value = round($dbuser->karma);
			}
		}
		if($vote->insert()) {
			$vote->user=-1;
			$this->votes=$vote->count();
			$this->store_basic();
			return true;
		}
		return false;
	}
Exemplo n.º 8
0
 function votes($user)
 {
     require_once mnminclude . 'votes.php';
     $vote = new Vote();
     $vote->user = $user;
     $vote->link = $this->id;
     return $vote->count();
 }
Exemplo n.º 9
0
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}");
}
Exemplo n.º 10
0
$value = intval($_REQUEST['value']);
if ($value < -10 || $value > -1) {
    error(_(PLIGG_Visual_Problem_BadVote) . " {$value}");
}
$link->id = $id;
$link->read_basic();
if ($current_user->user_id != $_REQUEST['user']) {
    error(_(PLIGG_Visual_Problem_BadUser) . $current_user->user_id . '-' . $_REQUEST['user']);
}
$md5 = md5($_REQUEST['user'] . $link->randkey);
if ($md5 !== $_REQUEST['md5']) {
    error(_(PLIGG_Visual_Problem_BadKey));
}
$vote = new Vote();
$vote->link = $link->id;
$vote->type = 'links';
$vote->user = $user_id;
$count = $vote->count('< 0');
if ($count > 0) {
    error(_(PLIGG_Visual_Problem_AlreadyVoted));
}
$vote->value = $value;
if (!$vote->insert()) {
    error(_(PLIGG_Visual_Problem_ErrorInserting));
}
echo _(PLIGG_Visual_Problem_OkThanks);
function error($mess)
{
    echo "{$mess}";
    die;
}
Exemplo n.º 11
0
 function insert_vote($user = 0, $value = 10)
 {
     global $anon_karma;
     require_once mnminclude . 'votes.php';
     if (!is_numeric($this->id)) {
         return false;
     }
     $vote = new Vote();
     $vote->type = 'comments';
     $vote->user = $user;
     $vote->link = $this->id;
     $vote->value = $value;
     if ($vote->insert()) {
         $vote = new Vote();
         $vote->type = 'comments';
         $vote->link = $this->id;
         $this->votes = $vote->count();
         $vars = array('vote' => $this);
         check_actions('comment_insert_vote_post', $vars);
         return $vote->sum();
     }
     return false;
 }
Exemplo n.º 12
0
                 tags_insert_string($linkres->id, $dblang, $linkres->tags);
                 require_once mnminclude . 'votes.php';
                 for ($i = 1; $i <= $feed->feed_votes; $i++) {
                     $value = 10;
                     $vote = new Vote();
                     $vote->type = 'links';
                     $vote->user = 0;
                     $vote->link = $linkres->id;
                     $vote->ip = '0.0.0.' . $i;
                     $vote->value = $value;
                     $vote->insert();
                     $vote = "";
                     $vote = new Vote();
                     $vote->type = 'links';
                     $vote->link = $linkres->id;
                     $linkres->votes = $vote->count();
                     $linkres->store_basic();
                     $linkres->check_should_publish();
                 }
                 $thecount = $thecount + 1;
             }
         }
         $sql = "Update `" . table_prefix . "feeds` set `feed_last_check` = FROM_UNIXTIME(" . (time() - 300) . ") where `feed_id` = {$feed->feed_id};";
         //echo $sql;
         $db->query($sql);
     } else {
         echo "Feed not fully setup, skipping <hr>";
     }
 } else {
     echo "Feed Frequency is " . $feed->feed_freq_hours . ".<br>";
     $x = strtotime($feed->feed_last_check);
Exemplo n.º 13
0
 function execute()
 {
     global $wgUser, $wgOut, $wgVoteDirectory, $IP;
     require_once 'CommentClass.php';
     require_once "{$wgVoteDirectory}/VoteClass.php";
     require_once "{$wgVoteDirectory}/Publish.php";
     require_once "{$IP}/extensions/UserStats/UserStatsClass.php";
     $stats = new UserStatsTrack(1, $wgUser->mId, $wgUser->mName);
     // Vote for a Comment
     if ($_POST["mk"] == md5($_POST["cid"] . 'pants' . $wgUser->mName)) {
         if (is_numeric($_GET["Action"]) && $_GET["Action"] == 1 && is_numeric($_POST["cid"])) {
             if (is_numeric($_POST["cid"]) && is_numeric($_POST["vt"])) {
                 $dbr =& wfGetDB(DB_MASTER);
                 $sql = "SELECT comment_page_id,comment_user_id, comment_username FROM Comments WHERE CommentID = " . $_POST["cid"];
                 $res = $dbr->query($sql);
                 $row = $dbr->fetchObject($res);
                 if ($row) {
                     $PageID = $row->comment_page_id;
                     $Comment = new Comment($PageID);
                     $Comment->setUser($wgUser->mName, $wgUser->mId);
                     $Comment->CommentID = $_POST["cid"];
                     $Comment->setCommentVote($_POST["vt"]);
                     $Comment->setVoting($_POST["vg"]);
                     $Comment->addVote();
                     $out = $Comment->getCommentScore();
                     //must update stats for user doing the voting
                     $stats->incCommentScoreGiven($_POST["vt"]);
                     //also must update the stats for user receiving the vote
                     $stats_comment_owner = new UserStatsTrack(1, $row->comment_user_id, $row->comment_username);
                     $stats_comment_owner->updateCommentScoreRec($_POST["vt"]);
                     echo $out;
                 }
             }
         }
     }
     // get new Comment list
     if (is_numeric($_GET["Action"]) && $_GET["Action"] == 2 && is_numeric($_POST["pid"])) {
         $Comment = new Comment($_POST["pid"]);
         $Comment->setUser($wgUser->mName, $wgUser->mId);
         $Comment->setOrderBy($_POST["ord"]);
         if ($_POST["shwform"] == 1) {
             $output .= $Comment->displayOrderForm();
         }
         $output .= $Comment->display();
         if ($_POST["shwform"] == 1) {
             $output .= $Comment->diplayForm();
         }
         echo $output;
     }
     if ($_POST['ct'] != "" && is_numeric($_GET["Action"]) && $_GET["Action"] == 3) {
         $input = $_POST['ct'];
         $host = $_SERVER['SERVER_NAME'];
         $input = str_replace($host, "", $input);
         $AddComment = true;
         if ($AddComment == true) {
             $Comment = new Comment($_POST["pid"]);
             $Comment->setUser($wgUser->mName, $wgUser->mId);
             $Comment->setCommentText($_POST['ct']);
             $Comment->setCommentParentID($_POST['par']);
             $Comment->add();
             //$stats->incCommentCount();
             //score check after comment add
             $Vote = new Vote($_POST["pid"]);
             $publish = new Publish();
             $publish->PageID = $_POST["pid"];
             $publish->VoteCount = $Vote->count(1);
             $publish->CommentCount = $Comment->count();
             $publish->check_score();
         }
     }
     if (is_numeric($_GET["Action"]) && $_GET["Action"] == 4 && is_numeric($_GET["pid"])) {
         $Comment = new Comment($_GET["pid"]);
         $Comment->setUser($wgUser->mName, $wgUser->mId);
         echo $Comment->getLatestCommentID();
     }
     // This line removes the navigation and everything else from the
     // page, if you don't set it, you get what looks like a regular wiki
     // page, with the body you defined above.
     $wgOut->setArticleBodyOnly(true);
 }
Exemplo n.º 14
0
 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;
 }
Exemplo n.º 15
0
 /**
  * 好友的投票
  */
 public function actionFriends()
 {
     $uid = Yii::app()->request->getQuery('uid');
     $mid = Yii::app()->user->id;
     if ($uid == $mid) {
         $this->redirect(array('my'));
     }
     $model = new Vote();
     //初始化
     $criteria = new CDbCriteria();
     $criteria->order = 'ctime DESC';
     $criteria->condition = "uid=:uid";
     $criteria->params = array(':uid' => $uid);
     $date = Yii::app()->request->getQuery('date');
     if (!empty($date)) {
         $year = $date[0] . $date[1] . $date[2] . $date[3];
         $month = $date[4] . $date[5];
         $start = mktime(0, 0, 0, $month, 1, $year);
         $end = mktime(0, 0, 0, $month + 1, 1, $year);
         $condition = "{$start} < ctime AND ctime < {$end}";
         $criteria->addCondition($condition);
     }
     //取得数据总数,分页显示
     $total = $model->count($criteria);
     $pages = new CPagination($total);
     $pages->pageSize = self::PAGE_SIZE;
     $pages->applyLimit($criteria);
     //获取数据集
     $mini_list = $model->findAll($criteria);
     $data = array('mini_list' => $mini_list, 'pages' => $pages);
     $this->render('my', $data);
 }
Exemplo n.º 16
0
 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;
 }
Exemplo n.º 17
0
 function insert_vote($user = 0, $value = 10)
 {
     global $anon_karma;
     require_once mnminclude . 'votes.php';
     $vote = new Vote();
     $vote->type = 'comments';
     $vote->user = $user;
     $vote->link = $this->id;
     $vote->value = $value;
     if ($vote->insert()) {
         $vote = new Vote();
         $vote->type = 'comments';
         $vote->link = $this->id;
         $this->votes = $vote->count();
         return $vote->sum();
     }
     return false;
 }