-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkarma.php
More file actions
executable file
·57 lines (48 loc) · 2.36 KB
/
karma.php
File metadata and controls
executable file
·57 lines (48 loc) · 2.36 KB
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
<?php
/**************************************************************************
* 0xBB ~ Bullettin Board *
**************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* =========================================================================*
* Software: 0xBB
* Software version: 2.0
* Author: KinG-InFeT
* Copyleft: GNU General Public License
* =========================================================================*
* karma.php
***************************************************************************/
include "kernel.php";
list ($username, $password) = get_data ();
if (!login ($username, $password))
die ('<script>window.location="login.php";</script>');
$referer = "viewtopic.php?id=".$_POST['topic_id'];
$user_id = (int) $_POST['user_id'];
$vote = ($_POST['vote'] > 0) ? "+1" : "-1";
if(user_id($user_id) == $username) {
print "<script>window.location=\"". $referer ."\";</script>";
}else{
if(isset($user_id) && isset($vote)) {
$row = mysql_fetch_row (mysql_query ("SELECT vote FROM ". __PREFIX__ ."karma WHERE vote_user_id = '". $user_id ."'"));
if($vote > 0)
$vote_final = $row[0] + 1;
else
$vote_final = $row[0] - 1;
$sql = "UPDATE `". __PREFIX__ ."karma` SET vote = '". $vote_final ."' WHERE vote_user_id = '". $user_id ."'";
mysql_query($sql) or _err(mysql_error());
print "<script>window.location=\"". $referer ."\";</script>";
}else{
print "<script>window.location=\"index.php\";</script>";
}
}
?>