Exemplo n.º 1
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.º 2
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.º 3
0
 public function ajax_delete()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     $this->requestLogin();
     if (!isset($this->params['vid'])) {
         $this->error("未知的投票");
     }
     $vid = intval($this->params['vid']);
     try {
         $vote = new Vote($vid);
     } catch (VoteNullException $e) {
         $this->error("未知的投票");
     }
     $u = User::getInstance();
     if (!$u->isAdmin() && $u->userid != $vote->uid) {
         $this->error("你无权删除此投票");
     }
     $vote->delete();
 }
Exemplo n.º 4
0
$votePoints = (int) $_GET['points'];
if (empty($videoID)) {
    die;
}
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}
$ip = md5($ip);
$dbh = new Database();
$sth = $dbh->prepare("SELECT * FROM " . DB_PREFIX . "votes WHERE video = ? AND ip = ?");
$sth->execute(array($videoID, $ip));
$result = $sth->fetchObject();
$vote = new Vote();
$vote->ip = $ip;
$vote->video = $videoID;
$vote->vote = $votePoints;
if (empty($result)) {
    if ($votePoints == 1 || $votePoints == -1) {
        $vote->create();
    }
} else {
    if ($votePoints == 1 || $votePoints == -1) {
        $vote->save();
    } elseif ($votePoints == 0) {
        $vote->delete();
    }
}
Exemplo n.º 5
0
 /**
  * (Web service method) Undo vote for current track (for this nick)
  * @param  mixed[] $args nick
  * @return mixed[] status; error_message; output (what to announce in IRC chat room)
  */
 private function web_undo_vote($args)
 {
     $nick = $args['nick'];
     $vote = Vote::get_undoable_vote($nick);
     $opt = Options::get_instance();
     if ($vote == NULL) {
         $this->fail($nick . ': Can\'t delete last vote if it is over 10 minutes old.');
     }
     if ($vote->deleted == 1) {
         $this->fail($nick . ': Your most recent vote has already been deleted.');
     }
     Vote::delete($vote->id);
     Track::update_vote($vote->track_id);
     $out = str_ireplace('${stream_title}', $vote->stream_title, $opt->txt_unvote_response);
     $out = str_ireplace('${nick}', $nick, $out);
     $out = str_ireplace('${value}', $num_txt, $out);
     return array('status' => 'ok', 'error_message' => '', 'output' => $out, 'private' => $opt->txt_unvote_response_switch);
 }