Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "";
- $password = "";
- $dbname = "";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $dbdata = array();
- $arr = array();
- $stmt = $conn->query($sql);
- $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- while ($row = $stmt->fetch()) {
- array_push($dbdata,$row);
- array_push($arr,$row['response']);
- }
- if(sizeof($arr)>0){
- $url = 'https://faucet.raiblockscommunity.net/elaborate.php';
- $ch = curl_init($url);
- $data = array("ask_address" => "addr", 'donate' => '1', 'captchas' => json_encode($arr), 'accepted' => '1');
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
- $result = curl_exec($ch);
- curl_close($ch);
- $accepted = json_decode($result);
- var_dump($accepted);
- $users = array();
- $reffs = array();
- $torem = array();
- if($accepted->error == "no"){
- foreach($dbdata as $dt){
- $asd = $conn->query("DELETE FROM captchas WHERE cId=".$dt['cId']."");
- $asd->execute();
- array_push($torem, $dt['cId']);
- if(!in_array($dt['userId'], $users)){
- array_push($users, $dt['userId']);
- }
- }
- $update = array();
- foreach($accepted->valid_captchas as $acc){
- $uId = $dbdata[$acc]['userId'];
- array_push($update,$uId);
- $stmt = $conn->query("SELECT reffered FROM users WHERE userId=".$uId."");
- $res = $stmt->execute();
- $stmt->setFetchMode(PDO::FETCH_ASSOC);
- while ($row = $stmt->fetch()) {
- if(intval($row['reffered']) > 0){
- array_push($reffs,$row['reffered']);
- }
- }
- }
- $newbal = implode(", ", $update);
- $stmt = $conn->query("UPDATE balances SET balance=balance+0.2 WHERE uId IN ($newbal)");
- $res = $stmt->execute();
- $stmt = $conn->query("UPDATE users SET filled=filled+1 WHERE userId IN ($newbal)");
- $res = $stmt->execute();
- $newpend = implode(", ", $users);
- $stmt = $conn->query("UPDATE users SET pendingCredit=0 WHERE userId IN ($newpend)");
- $res = $stmt->execute();
- $newarray = implode(", ", $reffs);
- $asd = $conn->query("UPDATE balances SET balance=balance+0.02 WHERE uId IN ($newarray)");
- $asd->execute();
- }
- else if($accepted->error = 'Invalid claims.'){
- $asd = $conn->prepare("DELETE FROM captchas WHERE cId!='0'");
- $asd->execute();
- echo('Captchas removed from the table.');
- }
- }
- }
- catch(PDOException $e) {
- echo "Error: " . $e->getMessage();
- }
- $conn = null;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement