SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | $servername = "localhost"; | |
3 | $username = ""; | |
4 | $password = ""; | |
5 | $dbname = ""; | |
6 | ||
7 | try { | |
8 | $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); | |
9 | $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
10 | ||
11 | $dbdata = array(); | |
12 | $arr = array(); | |
13 | ||
14 | ||
15 | $stmt = $conn->query($sql); | |
16 | $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); | |
17 | while ($row = $stmt->fetch()) { | |
18 | array_push($dbdata,$row); | |
19 | array_push($arr,$row['response']); | |
20 | } | |
21 | ||
22 | if(sizeof($arr)>0){ | |
23 | $url = 'https://faucet.raiblockscommunity.net/elaborate.php'; | |
24 | $ch = curl_init($url); | |
25 | $data = array("ask_address" => "addr", 'donate' => '1', 'captchas' => json_encode($arr), 'accepted' => '1'); | |
26 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
27 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
28 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
29 | curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); | |
30 | $result = curl_exec($ch); | |
31 | curl_close($ch); | |
32 | $accepted = json_decode($result); | |
33 | var_dump($accepted); | |
34 | ||
35 | $users = array(); | |
36 | $reffs = array(); | |
37 | $torem = array(); | |
38 | ||
39 | if($accepted->error == "no"){ | |
40 | foreach($dbdata as $dt){ | |
41 | ||
42 | $asd = $conn->query("DELETE FROM captchas WHERE cId=".$dt['cId'].""); | |
43 | $asd->execute(); | |
44 | array_push($torem, $dt['cId']); | |
45 | ||
46 | if(!in_array($dt['userId'], $users)){ | |
47 | array_push($users, $dt['userId']); | |
48 | } | |
49 | } | |
50 | ||
51 | $update = array(); | |
52 | ||
53 | foreach($accepted->valid_captchas as $acc){ | |
54 | $uId = $dbdata[$acc]['userId']; | |
55 | array_push($update,$uId); | |
56 | ||
57 | $stmt = $conn->query("SELECT reffered FROM users WHERE userId=".$uId.""); | |
58 | $res = $stmt->execute(); | |
59 | ||
60 | $stmt->setFetchMode(PDO::FETCH_ASSOC); | |
61 | while ($row = $stmt->fetch()) { | |
62 | if(intval($row['reffered']) > 0){ | |
63 | array_push($reffs,$row['reffered']); | |
64 | } | |
65 | } | |
66 | ||
67 | ||
68 | } | |
69 | ||
70 | $newbal = implode(", ", $update); | |
71 | $stmt = $conn->query("UPDATE balances SET balance=balance+0.2 WHERE uId IN ($newbal)"); | |
72 | $res = $stmt->execute(); | |
73 | ||
74 | $stmt = $conn->query("UPDATE users SET filled=filled+1 WHERE userId IN ($newbal)"); | |
75 | $res = $stmt->execute(); | |
76 | ||
77 | ||
78 | $newpend = implode(", ", $users); | |
79 | $stmt = $conn->query("UPDATE users SET pendingCredit=0 WHERE userId IN ($newpend)"); | |
80 | $res = $stmt->execute(); | |
81 | ||
82 | ||
83 | $newarray = implode(", ", $reffs); | |
84 | $asd = $conn->query("UPDATE balances SET balance=balance+0.02 WHERE uId IN ($newarray)"); | |
85 | $asd->execute(); | |
86 | ||
87 | ||
88 | } | |
89 | else if($accepted->error = 'Invalid claims.'){ | |
90 | $asd = $conn->prepare("DELETE FROM captchas WHERE cId!='0'"); | |
91 | $asd->execute(); | |
92 | echo('Captchas removed from the table.'); | |
93 | } | |
94 | } | |
95 | ||
96 | } | |
97 | catch(PDOException $e) { | |
98 | echo "Error: " . $e->getMessage(); | |
99 | } | |
100 | $conn = null; | |
101 | ?> |