-
Notifications
You must be signed in to change notification settings - Fork 10
/
coins.php
89 lines (88 loc) · 4.19 KB
/
coins.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
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* ------- U-232 Codename Trinity ----------*
* ---------------------------------------------*
* -------- @authors U-232 Team --------------*
* ---------------------------------------------*
* ----- @site https://u-232.duckdns.org/ ----*
* ---------------------------------------------*
* ----- @copyright 2020 U-232 Team ----------*
* ---------------------------------------------*
* ------------ @version V6 ------------------*
*/
require_once(__DIR__.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
dbconn();
loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('coins'));
// / Mod by dokty - tbdev.net
$id = (int)$_GET["id"];
$points = (int)$_GET["points"];
if (!is_valid_id($id) || !is_valid_id($points)) {
die();
}
$pointscangive = [
"10",
"20",
"50",
"100",
"200",
"500",
"1000",
];
if (!in_array($points, $pointscangive)) {
stderr($lang['gl_error'], $lang['coins_you_cant_give_that_amount_of_points']);
}
($sdsa = sql_query("SELECT 1 FROM coins WHERE torrentid=".sqlesc($id)." AND userid =".sqlesc($CURUSER["id"]))) || sqlerr(__FILE__, __LINE__);
$asdd = $sdsa->fetch_assoc();
if ($asdd) {
stderr($lang['gl_error'], $lang['coins_you_already_gave_points_to_this_torrent']);
}
($res = sql_query("SELECT owner,name,points FROM torrents WHERE id = ".sqlesc($id))) || sqlerr(__FILE__, __LINE__);
($row = $res->fetch_assoc()) || stderr($lang['gl_error'], $lang['coins_torrent_was_not_found']);
$userid = (int)$row["owner"];
if ($userid == $CURUSER["id"]) {
stderr($lang['gl_error'], $lang['coins_you_cant_give_your_self_points']);
}
if ($CURUSER["seedbonus"] < $points) {
stderr($lang['gl_error'], $lang['coins_you_dont_have_enough_points']);
}
($sql = sql_query('SELECT seedbonus '.'FROM users '.'WHERE id = '.sqlesc($userid))) || sqlerr(__FILE__, __LINE__);
$User = $sql->fetch_assoc();
sql_query("INSERT INTO coins (userid, torrentid, points) VALUES (".sqlesc($CURUSER["id"]).", ".sqlesc($id).", ".sqlesc($points).")") || sqlerr(__FILE__,
__LINE__);
sql_query("UPDATE users SET seedbonus=seedbonus+".sqlesc($points)." WHERE id=".sqlesc($userid)) || sqlerr(__FILE__, __LINE__);
sql_query("UPDATE users SET seedbonus=seedbonus-".sqlesc($points)." WHERE id=".sqlesc($CURUSER["id"])) || sqlerr(__FILE__, __LINE__);
sql_query("UPDATE torrents SET points=points+".sqlesc($points)." WHERE id=".sqlesc($id)) || sqlerr(__FILE__, __LINE__);
$msg = sqlesc("{$lang['coins_you_have_been_given']} ".htmlsafechars($points)." {$lang['coins_points_by']} ".$CURUSER["username"]." {$lang['coins_for_torrent']} [url=".$TRINITY20['baseurl']."/details.php?id=".$id."]".htmlsafechars($row["name"])."[/url].");
$subject = sqlesc($lang['coins_you_have_been_given_a_gift']);
sql_query("INSERT INTO messages (sender, receiver, msg, added, subject) VALUES({$TRINITY20['bot_id']}, ".sqlesc($userid).", $msg, ".TIME_NOW.", $subject)") || sqlerr(__FILE__,
__LINE__);
$update['points'] = ($row['points'] + $points);
$update['seedbonus_uploader'] = ($User['seedbonus'] + $points);
$update['seedbonus_donator'] = ($CURUSER['seedbonus'] - $points);
//==The torrent
$cache->update_row($cache_keys['torrent_details'].$id, [
'points' => $update['points'],
], $TRINITY20['expires']['torrent_details']);
//==The uploader
$cache->update_row($cache_keys['user_stats'].$userid, [
'seedbonus' => $update['seedbonus_uploader'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$userid, [
'seedbonus' => $update['seedbonus_uploader'],
], $TRINITY20['expires']['user_stats']);
//==The donator
$cache->update_row($cache_keys['user_stats'].$CURUSER["id"], [
'seedbonus' => $update['seedbonus_donator'],
], $TRINITY20['expires']['u_stats']);
$cache->update_row($cache_keys['user_statss'].$CURUSER["id"], [
'seedbonus' => $update['seedbonus_donator'],
], $TRINITY20['expires']['user_stats']);
//== delete the pm keys
$cache->delete($cache_keys['inbox_new'].$userid);
$cache->delete($cache_keys['inbox_new_sb'].$userid);
$cache->delete($cache_keys['coin_points'].$id);
header("Refresh: 3; url=details.php?id=$id");
stderr($lang['coins_done'], $lang['coins_successfully_gave_points_to_this_torrent']);
?>