Exemplo n.º 1
0
$match = new Match($id);
if (!$match->read_basic()) {
    error(_('partido inexistente'));
}
if (!$match->is_votable()) {
    error(_('votos cerrados'));
}
if ($current_user->user_id == 0) {
    error(_('Los votos anónimos están deshabilitados'));
}
if ($current_user->user_id != $_REQUEST['user']) {
    error(_('usuario incorrecto'));
}
// Check the user is not a clon by cookie of others that voted the same link
if ($current_user->user_id > 0 && $match->status != 'published') {
    if (UserAuth::check_clon_votes($current_user->user_id, $match->id, 5, 'links') > 0) {
        error(_('no se puede votar con clones'));
    }
}
try {
    $match->insert_vote($vote);
} catch (Exception $e) {
    error($e->getMessage());
}
echo $match->json_votes_info(intval($vote));
function error($mess)
{
    $dict['error'] = $mess;
    echo json_encode($dict);
    die;
}
Exemplo n.º 2
0
$comment = new Comment();
$comment->id = $id;
if (!$comment->read_basic()) {
	error(_('comentario inexistente'));
}

if ($comment->author == $current_user->user_id) {
	error(_('no puedes votar a tus comentarios'));
}

if ($comment->date < time() - $globals['time_enabled_comments']) {
	error(_('votos cerrados'));
}

// Check the user is not a clon by cookie of others that voted the same cooemnt
if (UserAuth::check_clon_votes($current_user->user_id, $id, 5, 'comments') > 0) {
	error(_('no se puede votar con clones'));
}


if ($value > 0) {
	$votes_freq = intval($db->get_var("select count(*) from votes where vote_type='comments' and vote_user_id=$current_user->user_id and vote_date > subtime(now(), '0:0:30') and vote_value > 0 and vote_ip_int = ".$globals['user_ip_int']));
	$freq = 10;
} else {
	$votes_freq = intval($db->get_var("select count(*) from votes where vote_type='comments' and vote_user_id=$current_user->user_id and vote_date > subtime(now(), '0:0:30') and vote_value <= 0 and vote_ip_int = ".$globals['user_ip_int']));
	$freq = 5;
}

if ($votes_freq > $freq) {
	if ($current_user->user_id > 0 && $current_user->user_karma > 4) {
    	// Crazy votes attack, decrease karma