コード例 #1
0
function votesys_gen_vote()
{
    if (is_user_logged_in()) {
        $userdata = get_userdata(get_current_user_id());
        echo "<center>Sveikas " . $userdata->display_name . "<br><br>";
        $vote_user = get_user_stats(get_current_user_id());
        $settings = get_option('votesys_options');
        echo "Jūs turite: " . $vote_user->points . " balsavimo taškus.<br><br>";
        echo "Visa informacija kodėl verta balsuoti, ką gausite balsuodami ir kaip tai padaryti nurodita <a href = '" . $settings['help_href'] . "'> čia.</a> <br><br>";
        echo "<i>Pastaba: paslaugų uždėjimo sistemą kolkas yra tobulinama todėl jas kolkas galite atsiimti tik parašius administracijai skype arba pm (Ideo)</i><br><br>";
        echo "<b>Svetainės kuriose galite balsuoti</b><br><br>";
        echo "<table class ='vote-table-top' width = '100%'>";
        echo "<tr class ='vote-table-top'><th>Topo pavadinimas</th><th>Taškų kuriuos gausite skaičius</th><th>Galite balsuoti vieną karta per</th><th>Ar galite balsuoti?</th><th>Baneris</th></tr>";
        global $wpdb;
        $table_name = $wpdb->prefix . 'votesys_topsite';
        $results = $wpdb->get_results("SELECT * FROM  `" . $table_name . "`");
        foreach ($results as $site) {
            echo "<tr class = 'vote-table-middle'><th class = 'vote-table-middle1'>" . $site->site_name . "</th>";
            echo "<th class = 'vote-table-middle1'>" . $settings['add_point_sk'] . "</th>";
            echo "<th class = 'vote-table-middle1'>" . $site->vote_interval_text . "</th>";
            if (can_vote($vote_user, $site->vote_site_id)) {
                echo "<th style='color:green;'>TAIP</th>";
            } else {
                echo "<th style='color:red;'>NE</th>";
            }
            echo "<th class = 'vote-table-middle1'><a href=wp-content/plugins/Vote-system/vote.php?userid=" . $vote_user->id . "&siteid=" . $site->vote_site_id . "><img src =" . $site->site_banner_url . "></img></th></tr>";
        }
        echo "</table></center>";
    } else {
        echo "<center> Sveiki! <br><br> <div class = 'vote-warning' >Jus nesate prisijunge prie tinklapio todėl už atiduotus balsus negausite taškų !</div> <br>";
        echo "Visa informacija kodėl verta balsuoti, ką gausite balsuodami ir kaip tai padaryti nurodita <b>SICIA REIKIA HREFO PADORAUS NEZINAU KA RASYTTTTTTTTT</b><a href = ''> čia.</a> <br><br>";
        echo "<b>Svetainės kuriose galite balsuoti</b><br><br>";
        echo "<table class ='vote-table-top' width = '100%'>";
        echo "<tr class ='vote-table-top'><th>Topo pavadinimas</th><th>Taškų kuriuos gutumete balsuojant prisijungus skaičius</th><th>Baneris</th></tr>";
        global $wpdb;
        $table_name = $wpdb->prefix . 'votesys_topsite';
        $results = $wpdb->get_results("SELECT * FROM  `" . $table_name . "`");
        $settings = get_option('votesys_options');
        foreach ($results as $site) {
            echo "<tr class = 'vote-table-middle'><th class = 'vote-table-middle1'>" . $site->site_name . "</th>";
            echo "<th class = 'vote-table-middle1'>" . $settings['add_point_sk'] . "</th>";
            echo "<th class = 'vote-table-middle1'>" . $site->site_web . "</th></tr>";
        }
        echo "</table></center>";
    }
}
コード例 #2
0
function vote($voter, $site_id)
{
    $settings = get_option('votesys_options');
    if ($settings['track_by_time']) {
        if (can_vote($voter, $site_id)) {
            //dadeda tasku
            add_points($voter, $settings['add_point_sk']);
            //panaikina senaji balsa mysqle
            delete_vote($voter->id, $site_id);
            //uzregistruoja nauja balsa mysqle
            create_vote($voter->id, $site_id);
        }
    } else {
        //dadeda tasku
        add_points($voter, $settings['add_point_sk']);
        //panaikina senaji balsa mysqle
        delete_vote($voter->id, $site_id);
        //uzregistruoja nauja balsa mysqle
        create_vote($voter->id, $site_id);
    }
}
コード例 #3
0
/**
 * Show form to vote an item. (itemDetail)
 */
function voting_item_detail()
{
    if (osc_is_this_category('voting', osc_item_category_id()) && osc_get_preference('item_voting', 'voting') == '1') {
        $aux_vote = ModelVoting::newInstance()->getItemAvgRating(osc_item_id());
        $aux_count = ModelVoting::newInstance()->getItemNumberOfVotes(osc_item_id());
        $vote['vote'] = $aux_vote['vote'];
        $vote['total'] = $aux_count['total'];
        $hash = '';
        if (osc_logged_user_id() == 0) {
            $hash = $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'];
            $hash = sha1($hash);
        } else {
            $hash = null;
        }
        $vote['can_vote'] = true;
        if (osc_get_preference('user', 'voting') == 1) {
            if (!osc_is_web_user_logged_in()) {
                $vote['can_vote'] = false;
            }
        }
        if (!can_vote(osc_item_id(), osc_logged_user_id(), $hash)) {
            $vote['can_vote'] = false;
        }
        require 'item_detail.php';
    }
}
コード例 #4
0
ファイル: ajax.php プロジェクト: oanav/closetshare
            if (can_vote($itemId, $userId, $hash)) {
                ModelVoting::newInstance()->insertItemVote($itemId, $userId, $iVote, $hash);
            }
        } else {
            if ($user == 1 && is_null($hash)) {
                if (can_vote($itemId, $userId, $hash)) {
                    ModelVoting::newInstance()->insertItemVote($itemId, $userId, $iVote, $hash);
                }
            }
        }
    }
    // return updated voting
    $item = Item::newInstance()->findByPrimaryKey($itemId);
    View::newInstance()->_exportVariableToView('item', $item);
    if (osc_is_this_category('voting', osc_item_category_id())) {
        $aux_vote = ModelVoting::newInstance()->getItemAvgRating(osc_item_id());
        $aux_count = ModelVoting::newInstance()->getItemNumberOfVotes(osc_item_id());
        $vote['vote'] = $aux_vote['vote'];
        $vote['total'] = $aux_count['total'];
        $vote['can_vote'] = true;
        if (osc_get_preference('user', 'voting') == 1) {
            if (!osc_is_web_user_logged_in()) {
                $vote['can_vote'] = false;
            }
        }
        if (!can_vote(osc_item_id(), osc_logged_user_id(), $hash)) {
            $vote['can_vote'] = false;
        }
        require 'view_votes.php';
    }
}
コード例 #5
0
            //1 = true
            Nominee::un_vote($nominee_id);
            Vote::delete_vote($session->user_id, $nominee_id, $nominee_position);
        } else {
            if (can_vote($session->user_id, $nominee_position) == true) {
                // 0 = true
                Nominee::add_vote($nominee_id);
                $vote = new Vote();
                $vote->user_id = $session->user_id;
                $vote->nominee_id = $nominee_id;
                $vote->nominee_position = $nominee_position;
                $vote->create();
            }
        }
    }
    redirect_to("../public/index.php?prev=" . previously_voted($session->user_id, $nominee_id, $nominee_position) . "&can_vote=" . can_vote($session->user_id, $nominee_position));
} else {
    redirect_to("../public/index.php");
}
function previously_voted($user_id, $nominee_id, $nominee_pos)
{
    global $db;
    $sql = "SELECT COUNT(" . C_VOTE_ID . ") FROM " . T_VOTES;
    $sql .= " WHERE " . C_VOTE_USER_ID . "='" . $user_id . "'";
    $sql .= " AND " . C_VOTE_NOMINEE_ID . "=" . $nominee_id;
    $sql .= " AND " . C_VOTE_NOMINEE_POSITION . "='" . $nominee_pos . "'";
    $db->query($sql);
    return mysql_result($db->query($sql), 0) == 1 ? true : false;
}
function can_vote($user_id, $nominee_pos)
{