Exemple #1
0
function check_voted($poll_id)
{
    $poll_logging_method = intval(get_option('poll_logging_method'));
    switch ($poll_logging_method) {
        // Do Not Log
        case 0:
            return 0;
            break;
            // Logged By Cookie
        // Logged By Cookie
        case 1:
            return check_voted_cookie($poll_id);
            break;
            // Logged By IP
        // Logged By IP
        case 2:
            return check_voted_ip($poll_id);
            break;
            // Logged By Cookie And IP
        // Logged By Cookie And IP
        case 3:
            $check_voted_cookie = check_voted_cookie($poll_id);
            if (!empty($check_voted_cookie)) {
                return $check_voted_cookie;
            } else {
                return check_voted_ip($poll_id);
            }
            break;
            // Logged By Username
        // Logged By Username
        case 4:
            return check_voted_username($poll_id);
            break;
    }
}
function check_voted_username($poll_id)
{
    global $wpdb, $user_ID;
    // Check IP If User Is Guest
    if ($user_ID == 0) {
        return check_voted_ip($poll_id);
    }
    $pollsip_userid = intval($user_ID);
    $log_expiry = intval(get_option('poll_cookielog_expiry'));
    $log_expiry_sql = '';
    if ($log_expiry > 0) {
        $log_expiry_sql = 'AND (' . current_time('timestamp') . '-(pollip_timestamp+0)) < ' . $log_expiry;
    }
    // Check User ID From IP Logging Database
    $get_voted_aids = $wpdb->get_col("SELECT pollip_aid FROM {$wpdb->pollsip} WHERE pollip_qid = {$poll_id} AND pollip_userid = {$pollsip_userid} {$log_expiry_sql}");
    if ($get_voted_aids) {
        return $get_voted_aids;
    } else {
        return 0;
    }
}