$debugtmp .= ", PROFIL: " . $profil . ", SIGNATURE: " . $signature; $connector = new BitcoinTalkConnector(); $user = $connector->getUserDetails($profil); // User exists? if ($user) { $identifier = $user["uid"]; $username = $user["username"]; $posts = $user["posts"]; $activity = $user["activity"]; $registration = date("F j, Y", $user["registration"]); $address = $user["address"]; $message = "Mastercoin faucet"; // Debug info $debugtmp .= ", ID: " . $identifier . ", USERNAME: "******", ADDRESS: " . $address . ", POSTS: " . $posts . ", ACTIVITY: " . $activity . ", REGISTRATION: " . $registration; try { $validsignature = isMessageSignatureValid($address, $signature, $message); } catch (Exception $e) { $validsignature = false; } // Signature valid? if ($validsignature) { // Is user qualified for a reward? if ($checkQualification == false || isQualifiedBitcointalk($user)) { // Check, if Cookie check is enabled if ($checkCookie == false || cookieExists() == false) { $rewardmanager = new RewardManager(); // Check IP if ($checkHost == false || ($reward = $rewardmanager->getRewardByIp()) == null) { // Check user id and authentication method if ($checkAuthMethod == false || ($reward = $rewardmanager->lookupRewardByUser($identifier, $referrer)) == null) { $formid = generateUid();
die("-1\tinvalid arguments"); } // // you can do something to check the message if you put data in it. // // $message_arr = explode(':', $message); // if (empty($message_arr[0]) || time() - $message_arr[0] > 30*60) { // // expire time is 30 minutes // die("-1\tmessage expired"); // } // find the item by source_message $sql = "SELECT * FROM `bitpass_messages` \nWHERE source_message = :source_message AND (btc_address = '' OR btc_address = NULL) "; $item = DB::pfetch($sql, array(':source_message' => $message)); if (empty($item)) { die("-1\tcan't find bitpass_messages item OR already used"); } try { if (!isMessageSignatureValid($address, $signature, $message)) { die("-1\tsignature invalid"); } } catch (Exception $e) { die("-1\t" . $e->getMessage()); } // update the item $sql = " UPDATE `bitpass_messages` \nSET btc_address = :btc_address,\n\tsignature_base64 = :signature_base64,\n\tverify_time = :verify_time,\n\tlatitude = :latitude,\n\tlongitude = :longitude\nWHERE bitpass_message_id = :bitpass_message_id "; $arr = array(':btc_address' => $address, ':signature_base64' => $signature, ':bitpass_message_id' => $item['bitpass_message_id'], ':verify_time' => date('Y-m-d H:i:s'), ':latitude' => $latitude > 0 ? $latitude : 0, ':longitude' => $longitude > 0 ? $longitude : 0); if (DB::pexec($sql, $arr, DB::RETURN_AFFECTED_ROWS) == 0) { die("-1\tupdate bitpass_messages failure"); } // success echo "1\tOK";