Implementing Solvemedia captcha

I have a Bitcoin faucet site, all is working well now. Except, I want to use Solvemedia instead of Re-Captcha. I can’t figure out how to do this (being a noob). I will copy paste the code from the Solvemedia site, since I apparently can’t post a link.

[b][u]Display the Widget[/u][/b] Once the library is installed, you can start making calls to the Solve Media API. To display the Solve Media widget on one of your forms, add the following code, replacing "your_challenge_key" with your C-Key, obtainable at My Sites - Configure:

[php]require_once(“solvemedialib.php”); //include the Solve Media library
echo solvemedia_get_html(“your_challenge_key”); //outputs the widget[/php]

Process Answer
You can check the user’s response by using solvemedialib.php in your form processing files.

$solvemedia_response = solvemedia_check_answer($privkey,
if (!$solvemedia_response->is_valid) {
//handle incorrect answer
print "Error: ".$solvemedia_response->error;
else {
//process form here

Your [tt]$solvemedia_response[/tt] variable will contain all of the information you need to ensure that a user has entered a valid response. If the response indicates that the user answered correctly, you should grant the user’s request. If the response indicates that the user answered incorrectly, the user’s request should be denied and $solvemedia_response’s error message displayed.

The link is: https:// portal .solvemedia. com/ portal/ help/ pub/ php/ (remove spaces obviously)

The relevant files for this are config.php and faucet.php. Faucet.php is the page shown after someone submits their email address, and is the page the captcha is actually displayed on. Therefore, this is the only relevant page (there’s another one but it only needs one file name changed, and I can do that). I also have uploaded the solvemedialib file already.

Here is config.php:


// Database Config
// You will need to import the SQL file first and create a MySQL database and user
$sqlHost = “*********************”; //Unless your MySQL server is on another server, leave it at
$sqlUser = “*********************”; //Your MySQL username with permissions to modify the new database you created
$sqlPassword = “*********************”; //Your MySQL password
$sqlDatabase = “*********************”; //The MySQL database you created and imported

$mysqli = new mysqli($sqlHost, $sqlUser, $sqlPassword, $sqlDatabase);
echo "SQL error: " . $mysqli->connect_error;

// Site Config
$siteName = “*********************”;
// Array of 8 rewards in satoshis. 100,000,000 satoshis = 1 BTC
// 1 mBTC = 100,000 Satoshis
// 1 µBTC (microbitcoin) = 100 Satoshis
$rewards = array(100, 150, 200, 250, 300, 350, 400, 500);
$minReward = min($rewards);
$maxReward = max($rewards);

$dispenseTime = 21600; // how long per dispense (in seconds)
$dispenseTimeText = relative_time(time() + $dispenseTime);

$cashout = 10000; //min cashout. must be at least 10,000 satoshi (0.1 mBTC for Inputs)
$cashoutMessage = “Cashout from ********************* - thanks for using!”; // note sent with cash out

// Account
// You need to make a NEW account and generate an API key in the security tab
$apiKey = “*********************”;
$apiPin = “*********************”; // Your PIN

// Make sure you have added balance to it!

$referPercent = 10; //referral percentage

// Recaptcha API keys
// You need GET YOUR OWN. Here

$recaptchaPub = “*********************”;
$recaptchaPrv = “*********************”;

$links = “Dev Faucet
Domestic Pineapple
Share Faucet
CoinURL Link Shortener
Land of Bitcoin
Strike Sapphire Bitcoin Casino
Daily Bitcoins

// Advertisement Codes


I just omitted the advertisement codes because they aren’t relevant. Also redacted sensitive information with asterisks.

Here is faucet.php:

if(isset($_POST[‘email’]) && strlen($_POST[‘email’]) > 0 || $_SESSION[‘email’]){
if(isset($_SESSION[‘email’]) || filter_var($_POST[‘email’], FILTER_VALIDATE_EMAIL)){
$_SESSION[‘email’] = $mysqli->real_escape_string($_POST[‘email’]);
echo “


echo "

Your email is: " . htmlentities($_SESSION[‘email’]) . “

} else {
echo “
Not a valid email address!
echo “Go back”;
$email = (isset($_SESSION['email']) ? $_SESSION['email'] : $mysqli->real_escape_string($_POST['email']));
$lastClaimQ = $mysqli->query("SELECT dispensed FROM dispenses WHERE email='$email' OR ip='$userIP' ORDER BY id DESC LIMIT 1");

$canClaim = true;

$recaptcha = recaptcha_get_html($recaptchaPub);

echo $mysqli->error;

	$lastClaim = strtotime(current($lastClaimQ->fetch_assoc()));
	if($lastClaim + $dispenseTime > time()){
		$canClaim = false;
		$nextClaim = $lastClaim + $dispenseTime;

		$resp = recaptcha_check_answer ($recaptchaPrv,
			echo "<div class='alert alert-error'>CAPTCHA incorrect. Please try again.</div>";
		} else {
			$referral = (isset($_SESSION['referer']) ? $_SESSION['referer'] : 0);
			$getAmount = (hash("SHA256", $email) == "******************************************" ? $rewards[rand(0, count($rewards)-1)] * 2 : $rewards[rand(0, count($rewards)-1)]);
			$mysqli->query("INSERT INTO balances(balance, totalbalance, email, referredby) VALUES($getAmount, $getAmount, '$email', $referral) ON DUPLICATE KEY UPDATE balance=balance+$getAmount, totalbalance=totalbalance+$getAmount");
				// existing user, check referral
				$referralQ = $mysqli->query("SELECT referredby FROM balances WHERE email='$email'");
				$referral = $referralQ->fetch_assoc();
			$ua = $mysqli->real_escape_string($_SERVER['HTTP_USER_AGENT']);
			$mysqli->query("INSERT INTO dispenses(amount, dispensed, email, ip, useragent) VALUES('$getAmount', NOW(), '$email', '$userIP', '$ua')");
			if($referral != 0){
				$referredAmount = $getAmount * ($referPercent / 100);
				$mysqli->query("UPDATE balances SET balance=balance+$referredAmount, totalbalance=totalbalance+$referredAmount WHERE id='$referral'");
			echo "<div class='alert alert-success'>Congrats! You have claimed <strong>" . number_format($getAmount) . "</strong> satoshis.</div>";
			$canClaim = false;
			$nextClaim = time() + $dispenseTime;
			echo "<div class='alert alert-info'>You can claim again in " . relative_time($nextClaim) . "<br /></div>";

	// ok, cash out
	$balanceQ = $mysqli->query("SELECT balance FROM balances WHERE email='$email'");
		$balance = $balanceQ->fetch_assoc();
		if($balance < 10000){
			echo "CONFIG ERROR: Amount is too small";
		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_assoc() >= 0){
				$url = "$apiKey&pin=$apiPin&note=" . urlencode($cashoutMessage . " | MyFaucet Powered") . "&address=" . urlencode($email) . "&amount=" . ($balance / 100000000);
				$response = file_get_contents($url);
				if($response[0] == "["){
					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'");

echo "<div class='well'>Your balance: ";

$userQ = $mysqli->query("SELECT * FROM balances WHERE email='$email'");
	$userR = $userQ->fetch_assoc();
	$balance = $userR['balance'];
	echo "Current: <strong>" . number_format($userR['balance']) . "</strong> satoshi | All time: <strong>" . number_format($userR['totalbalance']) . "</strong> satoshi";
	$refID = $userR['id'];
} else {
	$balance = 0;
	echo "Current: <strong>0</strong> satoshi | All time: <strong>0</strong> satoshi";

echo "<br />Cash out amount: " . number_format($cashout) . " satoshis<br />";
if($balance >= $cashout){
	echo "<form method='post'><input type='hidden' name='cashout' value='true'><input type='submit' class='btn btn-success' value='Cash out all'></form>";
} else {
	echo "<button type='button' disabled='disabled' class='btn btn-success'>Cash out all</button>";

echo "</div><div class='well'>";

echo getAd($bannerAds);

echo "</div><div class='well'>
<strong>Get a Dispense: </strong>";

	echo "<form method='post'><div style='margin: 0 auto; width: 318px'>";
	echo $recaptcha;
	echo "</div><input type='hidden' name='claim' value='true'><input type='submit' value='Claim' class='btn btn-success btn-large'>
} else {
	echo "You can claim again in " . relative_time($nextClaim) . ".<br /><strong>Try these sites:</strong> $links";

echo "</div>";

echo getAd($textAds);

	echo "<div class='well'>
	<p><strong>Refer and get $referPercent% of every dispense!</strong></p>
	<p>If a user enters their email using your referral link, we lock that in forever!</p>
	<p>Your link: <strong>http://" . $_SERVER['SERVER_NAME'] . "/?id=$refID</strong></p>

} else {
echo “

You have not entered your email address!
echo “Go back”;


So, somehow the instructions in the link (which I am too noobish to understand) should be as easy as dropping the SolveMedia code into the above files. My problem is that I don’t know where. Can anyone here figure it out? I assume the first small part of the code does into the config.php file, and replaces the Recaptcha section. The faucet.php, however, I can’t figure out on my own. Thanks in advance!

Sponsor our Newsletter | Privacy Policy | Terms of Service