mysql不会为我系统中的某些人更新

时间:2015-09-09 09:06:15

标签: php mysql

        $redirect_link = false;
        $model = new Page();
        $user_ip = $model->get_client_ip_server();
        $geoData = $model->geoCheckIP($user_ip);

        $user_id = CAuth::getLoggedId();
        $user_name = CAuth::getLoggedName();
        $user_email = CAuth::getLoggedEmail();
        $user_country = $geoData['country'];

        //=====================Settings===========================//
        $vote_type = 'xTreamtop';
        $amount = 3;
        $Link = 'http://www.xtremetop100.com/in.php?site=1132356694';
        //========================================================//

        $current_time = time();
        $addTodb = false;
        $sendCubi = false;
        $getRank = $model->getVUID($user_name, $vote_type);
        $getUNMCount = $model->getCount('mw_vote', 'user="'.$user_name.'" AND type="'.$vote_type.'"');
        $getCIPCount = $model->getCount('mw_vote', 'ip="'.$user_ip.'" AND type="'.$vote_type.'"');

        if ($getUNMCount > 1) {
            if ($getCIPCount > 1) 
            {
                $unData = $model->getMID($user_name, $vote_type);
                $ipData = $model->getMIP($user_ip, $vote_type);
                $iDate = $ipData['date'];
                $uDate = $unData['date'];
                if ($iDate > $uDate){
                    $latestVote = $ipData;
                }else {
                    $latestVote = $unData;
            }
            }else 
            {
                $latestVote = $model->getMID($user_name, $vote_type);
            }
        }else {
            if ($getCIPCount > 1) 
            {
                $latestVote = $model->getMIP($user_ip, $vote_type);
            }else 
            {
                $getVUID = $model->getVUID($user_name, $vote_type);
                $getVCIP = $model->getVCIP($user_ip, $vote_type);
                $vuidDate = $getVUID['date'];
                $vcipDate = $getVCIP['date'];
                if ($vuidDate > $vcipDate){
                    $latestVote = $getVUID;
                }else {
                    $latestVote = $getVCIP;
                }
            }
        }

        if ($latestVote['rank'] == 0 or empty($latestVote['rank']))
        {
            $addTodb = true;
        }

        if ($addTodb == false) {
            $timeCalc = $current_time - $latestVote['date'];
            if ($timeCalc < 21600) {
                $msg = 'Hello '.$user_name.' you have already voted with this account ('.$user_name.') or IP ('.$user_ip.')  in the last 6hrs, Please wait '.date('h', $timeCalc).' hours and '.date('i', $timeCalc).'minutes! <br />Last voted on: '.date('M d\, h:i:s A', $latestVote['date']).'';
                header('refresh: 5; url=vote');
            }else{
                $update = $model->updateVote(array(
                        'uid' => $user_id,
                        'user' => $user_name,
                        'email' => $user_email,
                        'country' => $user_country,
                        'ip' => $user_ip,
                        'date' => $current_time,
                        'rank' => $getRank['rank']+1,
                        'cubi' => $getRank['cubi']+$amount,
                ), 'uid="'.$user_id.'" AND type="'.$vote_type.'"');

                if (!$update){
                    $msg = 'Fail to Update voting database.';
                    header('refresh: 5; url=vote');
                }else{
                    $sendCubi = true;
                }
            }
        }else {
            $insert = $model->addVote(array(
                        'uid' => $user_id,
                        'user' => $user_name,
                        'email' => $user_email,
                        'country' => $user_country,
                        'ip' => $user_ip,
                        'date' => $current_time,
                        'type' => $vote_type,
                        'rank' => '1',
                        'cubi' => $amount,
                    ));
            if ($insert){
                $sendCubi = true;
            }else{
                $msg = 'Fail to insert voting database.';
                header('refresh: 5; url=vote');
            }

        }

        if ($sendCubi) {
            $addCash = $model->addCubi($user_id, $amount);
            if ($addCash){
                $model->addLog(array(
                    'user' => $user_id,
                    'product' => base64_encode('Voted for XtremeTop100.com'),
                    'event' => 'vote',
                    'wallet' => $amount,
                    'type' => 'ingame',
                ));

                $getPoints = $model->getPoints($user_name);
                if (empty($getPoints)){
                    $addPoints = true;
                }else{
                    $addPoints = false;
                }

                if ($addPoints){
                    $model->addPoints(array(
                        'username' => $user_name,
                        'cubi' => $amount,
                        'points' => '1',
                    ));
                }else{
                    $model->updatePoints(array(
                        'username' => $user_name,
                        'cubi' => $getPoints['cubi']+$amount,
                        'points' => $getPoints['points']+1,
                    ), 'username="'.$user_name.'"');
                }

                $msg = 'Added cubi to the account';
                header('Location: '.$Link.'');
            }else{
                $msg = 'Please make post on forum saying that you could receive gold after vote';
            }

        }
        $this->view->render('page/xtreamtop');

这是我的投票系统,出于某种原因,有些人会继续投票。它不会更新数据库或只是一些人这样做的新数据库。我没有看到任何错误。如果你能查看这个剧本,请告诉我如何阻止人们在我的系统上作弊。

0 个答案:

没有答案