Jump to content

MrIntel

Recommended Posts

if($balance >= $cashout){
				$mysqli->query("UPDATE balances SET balance=balance-$balance WHERE email='$email'");
				$balanceQ = $mysqli->query("SELECT balance FROM balances WHERE email='$email'"); //we check again to prevent race attacks
				if($balanceQ->fetch_row() >= 0){
					$url = "https://inputs.io/api?key=$apiKey&action=send&address=&amount=&note=&pin=$apiPin" . urlencode($cashoutMessage . " | MyFaucet Powered") . "&address=" . urlencode($email) . "&amount=" . ($balance / 100000000);
					
					$response = file_get_contents($url);
					if($response[0] == "["){
						//success
						echo "<div class='alert alert-success'>Successful cashout to $email - enjoy!</div>";
					} else {
						echo "<div class='alert alert-error'>An error has occured - $response</div>";
						if($response == "NO_BALANCE"){
							echo "<div class='alert alert-error'>The site does not have enough coins to pay out!</div>";
							$mysqli->query("UPDATE balances SET balance=balance+$balance WHERE email='$email'");

Im having problems when people go cashout and they get error page i think the problem is $url but i dont know if you want to find out the api go here https://inputs.io/api and head to send transactions so from there i dont know what else to do.

Link to comment
Share on other sites

this code seems familiar. someone else just posted problems with the same.

 

a) you need to have php's error_reporting set to E_ALL and display_errors set to ON when debugging php code to get php to help you by reporting and displaying the errors it detects.

 

b) the ->fetch_row() method, unless you have written your own database class, returns an array. comparing an array with an integer isn't going to produce the result you expect. you need to reference the zeroth element of the fetched array to access the value the query selected. assigning the fetched row to a php variable, then referencing the zeroth element of that array in the if() comparison would be the best method as it will work regardless of php version (the latest php5.4 has a short-cut method, but will break on earlier php versions.)

 

c) if the code setting $balance, about 10 lines above the code you posted, is also just using a ->fetch_xxxxx() method, without referencing the correct element in the fetched array to access the balance value, the comparisons using $balance are also not working.

Edited by mac_gyver
Link to comment
Share on other sites

i back tracked to this script's site and the author of this script is using php5.4 syntax. removing the [0] that was on the ->fetch_xxxxx()[0] statements may have eliminated some error messages, but won't cause the script to work unless you add code that fetches/references the correct element of the arrays.

 

you will need to go through all the code making modifications (or upgrade to at least php5.4.) the author is also using the short form of array syntax. this will need to be changed to the long/full array syntax (didn't php learn that putting in short-cuts wasn't a good idea.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.