forked from Kliqqi-CMS/Kliqqi-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vote.php
77 lines (57 loc) · 1.86 KB
/
vote.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
include_once('internal/Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'link.php');
include(mnminclude.'html1.php');
include(mnminclude.'smartyvariables.php');
check_referrer();
$post_id = sanitize($_POST['id'], 3);
if(is_numeric($post_id) && $post_id > 0){
$link = new Link;
$link->id=$post_id;
$link->read_basic();
if ($current_user->user_id == 0 && !anonymous_vote) {
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_NoAnon'));
}
$post_user = sanitize($_POST['user'], 3);
if($current_user->user_id != $post_user) {
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_BadUser'));
}
$md5=md5($post_user.$link->randkey);
if($md5 !== sanitize($_POST['md5'], 3)){
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_BadKey'));
}
if($link->votes($current_user->user_id) > 0 || $link->reports($current_user->user_id) > 0) {
}
$value = sanitize($_POST['value'], 3);
if(sanitize($_POST['unvote'], 3) == 'true'){
$link->remove_vote($current_user->user_id, $value);
} else {
if($link->votes($current_user->user_id) > 0 || $link->reports($current_user->user_id) > 0 ||
// DB 11/10/08
(votes_per_ip > 0 && $link->votes_from_ip() + $link->reports_from_ip() >= votes_per_ip)) {
/////
error($main_smarty->get_config_vars('PLIGG_Visual_Vote_AlreadyVoted'));
}
$link->insert_vote($current_user->user_id, $value);
}
if ($link->status == 'discard') {
$link->read();
$link->status = 'new';
$link->store();
}
if(Voting_Method == 2){
$link_rating = $link->rating($link->id)/2;
$rating_width = $link_rating * 25;
$vote_count = $link->countvotes();
echo $rating_width . "~" . $link_rating . "~" . $vote_count;
}
else
{
$count=$link->votes;
echo "$count ~--~".$post_id;
}
$link->evaluate_formulas();
}
?>