Exemple #1
0
} else {
    if (isset($_POST['msg']) && validate_msg($_POST['msg'])) {
        $msg = $_POST['msg'];
    } else {
        if (($msg = messages_get_most_recent($_SESSION['UID'])) === false) {
            html_draw_error(gettext("Invalid Message ID or no Message ID specified."));
        }
    }
}
list($tid, $pid) = explode('.', $msg);
// Poll stuff
if (isset($_POST['poll_submit'])) {
    if (isset($_POST['poll_vote']) && is_array($_POST['poll_vote'])) {
        $poll_votes_array = $_POST['poll_vote'];
        if (poll_check_tabular_votes($tid, $poll_votes_array)) {
            poll_vote($tid, $poll_votes_array);
            header_redirect("messages.php?webtag={$webtag}&msg={$msg}");
        } else {
            html_draw_error(gettext("You must pick and answer for every question"));
        }
    } else {
        html_draw_error(gettext("You must select an answer to vote for"));
    }
} else {
    if (isset($_POST['poll_change_vote'])) {
        poll_delete_vote($tid);
        header_redirect("messages.php?webtag={$webtag}&msg={$msg}");
    } else {
        if (isset($_POST['post_vote_down_x']) || isset($_POST['post_vote_up_x'])) {
            $post_rating = isset($_POST['post_vote_down_x']) ? -1 : 1;
            post_set_user_rating($tid, $pid, $_SESSION['UID'], $post_rating);
        list($tid, $pid) = explode('.', $msg);
    } else {
        light_html_draw_top(sprintf("title=%s", gettext("Error")), "robots=noindex,nofollow");
        light_html_display_error_msg(gettext("No Messages"));
        light_html_draw_bottom();
        exit;
    }
}
// Poll stuff
if (isset($_POST['pollsubmit'])) {
    if (isset($_POST['tid']) && is_numeric($_POST['tid'])) {
        $tid = $_POST['tid'];
        if (isset($_POST['pollvote']) && is_array($_POST['pollvote'])) {
            $poll_votes = $_POST['pollvote'];
            if (poll_check_tabular_votes($tid, $poll_votes)) {
                poll_vote($tid, $poll_votes);
            } else {
                light_html_draw_top(sprintf("title=%s", gettext("Error")));
                light_html_display_error_msg(gettext("You must vote in every group."));
                light_html_draw_bottom();
                exit;
            }
        } else {
            light_html_draw_top(sprintf("title=%s", gettext("Error")));
            light_html_display_error_msg(gettext("You must select an option to vote for!"));
            light_html_draw_bottom();
            exit;
        }
    }
} else {
    if (isset($_POST['pollchangevote'])) {
    $old[] = $file;
    file_write_contents(DATA_PATH . 'poll.old.dat', serialize($old));
    rcms_delete_files(DATA_PATH . 'poll.dat');
    return 0;
}
function poll_get_archive()
{
    if (!is_file(DATA_PATH . 'poll.old.dat')) {
        $old = array();
    } else {
        $old = @unserialize(@file_get_contents(DATA_PATH . 'poll.old.dat'));
    }
    foreach ($old as $id => $data) {
        $old[$id]['t'] = 0;
        foreach ($old[$id]['c'] as $v_id => $v_total) {
            $old[$id]['t'] += $v_total;
        }
        foreach ($old[$id]['c'] as $v_id => $v_total) {
            if ($old[$id]['t'] != 0) {
                $old[$id]['p'][$v_id] = round($v_total / $old[$id]['t'] * 100);
            } else {
                $old[$id]['p'][$v_id] = 0;
            }
        }
    }
    return $old;
}
// Vote in poll form
if (isset($_POST['poll_vote'])) {
    $system->results['vote'] = poll_vote($_POST['poll_vote'], $_SERVER['REMOTE_ADDR']);
}