-
Notifications
You must be signed in to change notification settings - Fork 6
/
cronjob2.php
executable file
·159 lines (78 loc) · 3.28 KB
/
cronjob2.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
include("models/config.php");
error_reporting(E_ALL);
function AddMoneys($amount, $user, $currency)
{
$sq = mysql_query("SELECT * FROM userCake_Users WHERE `Username_Clean`='$user'");
$user2 = mysql_result($sq, 0, "User_ID");
$sql = mysql_query("SELECT * FROM balances WHERE `User_ID`='$user2' AND `Coin`='$currency'");
$id = mysql_result($sql, 0, "id");
if ($id < 1) {
mysql_query("INSERT INTO balances (`User_ID`,`Amount`,`Coin`,`Pending`) VALUES ('$user2','$amount','$currency','0');");
} else {
$old = mysql_result($sql, 0, "Amount");
$new = $old + $amount;
mysql_query("UPDATE balances SET `Amount` = $new WHERE `User_ID` = '$user2' AND `Coin` = '$currency';");
}
}
$sql = mysql_query("SELECT * FROM currencies");
$num = mysql_num_rows($sql);
for ($i = 0; $i < $num; $i++) {
$ip = mysql_result($sql, $i, "ip");
$port = mysql_result($sql, $i, "port");
$coin = mysql_result($sql, $i, "Acronymn");
$bitcoin = @establishRPCConnection($ip, $port);
$dec = @$bitcoin->listtransactions();
echo "LOL";
if($dec != null)
{
@print_r($dec);
foreach ($dec as $row) {
$tx = $row["txid"];
$amount = $row["amount"];
if ($row["account"] != "") {
$sqls = mysql_query("SELECT * FROM deposits WHERE `Transaction_Id`='$tx' AND `Coin`='$coin'");
$id = mysql_result($sqls, 0, "id");
$account = $row["account"];
if ($id < 1) {
mysql_query("INSERT INTO deposits (`Transaction_Id`,`Amount`,`Coin`,`Paid`,`Account`) VALUES ('$tx','$amount','$coin','0','$account');");
} else {
$paid = mysql_result($sqls, 0, "Paid");
if ($row["confirmations"] >= 3 && $paid == 0) {
AddMoneys($amount, $row["account"], $coin);
mysql_query("UPDATE deposits SET `Paid`='1' WHERE `Transaction_Id`='$tx'");
}
}
}
}
}
}
/*
if ($_GET["MANUAL"] == "true") {
$sql = mysql_query("SELECT * FROM currencies");
$num = mysql_num_rows($sql);
for ($i = 0; $i < $num; $i++) {
$ip = mysql_result($sql, $i, "ip");
$port = mysql_result($sql, $i, "port");
$coin = mysql_result($sql, $i, "Acronymn");
$sqls = mysql_query("SELECT * FROM deposits WHERE `Paid`='0' AND `Coin`='$coin'");
$numz = mysql_num_rows($sqls);
for ($iz = 0; $iz < $numz; $iz++) {
$tx = mysql_result($sqls, $iz, "Transaction_Id");
$amount = mysql_result($sqls, $iz, "Amount");
$bitcoin = establishRPCConnection($ip, $port);
$dec = $bitcoin->gettransaction($tx);
foreach ($dec as $row) {
foreach ($row as $detail) {
$account = $detail["account"];
}
}
AddMoneys($amount, $account, $coin);
mysql_query("UPDATE deposits SET `Paid`='1' WHERE `Transaction_Id`='$tx'");
mysql_query("UPDATE deposits SET `Account`='$account' WHERE `Transaction_Id`='$tx'");
echo "<br/>Am: $amount AC: $account C: $coin<br/>";
}
}
*/
//}
?>