function GetValidationResult() { // saved data for the specified Captcha object in the application $captcha = GetCaptchaObject(); if (is_null($captcha)) { LBD_HttpHelper::BadRequest('captcha'); } // identifier of the particular Captcha object instance $instanceId = GetInstanceId(); if (is_null($instanceId)) { LBD_HttpHelper::BadRequest('instance'); } // code to validate $userInput = GetUserInput(); // response MIME type & headers header('Content-Type: text/javascript'); // JSON-encoded validation result $result = false; if (isset($userInput) && isset($instanceId)) { $result = $captcha->Validate($userInput, $instanceId, LBD_ValidationAttemptOrigin::Client); $captcha->Save(); } session_write_close(); $resultJson = GetJsonValidationResult($result); echo $resultJson; }
function GetValidationResult() { // saved data for the specified Captcha object in the application $captcha = GetCaptchaObject(); if (is_null($captcha)) { LBD_HttpHelper::BadRequest('captcha'); } // identifier of the particular Captcha object instance $instanceId = GetInstanceId(); if (is_null($instanceId)) { LBD_HttpHelper::BadRequest('instance'); } // code to validate $userInput = GetUserInput(); while (ob_get_length()) { ob_end_clean(); } ob_start(); try { // response MIME type & headers header('Content-Type: text/javascript'); header('X-Robots-Tag: noindex, nofollow, noarchive, nosnippet'); // JSON-encoded validation result $result = false; if (isset($userInput) && isset($instanceId)) { $result = $captcha->Validate($userInput, $instanceId, LBD_ValidationAttemptOrigin::Client); $captcha->Save(); } $resultJson = GetJsonValidationResult($result); echo $resultJson; } catch (Exception $e) { header('Content-Type: text/plain'); echo $e->getMessage(); } ob_end_flush(); exit; }
<input type="button" name="reset" value="Clear" onclick="clear_input()"><br><br></td> </tr> <tr> <td> * - <i>Mandatory fields.</i> </td></tr> <tr></tr> <tr> <td> </td> <td> <a href="http://forecast.io"> Powered by Forecast.io </a> </td> </tr> </form> </body> </html> <?php GetUserInput(); function GetUserInput() { if (!empty($_POST["submit"])) { $street = $_POST["street"]; $city = $_POST["city"]; $state = $_POST["state"]; $degree = $_POST["degree"]; echo "<script type='text/javascript'>\n SaveUserInput('" . $street . "','" . $city . "','" . $state . "','" . $degree . "');\n </script>"; if (!empty($street) && !empty($city) && !empty($state) && !empty($degree)) { $GeoCodeFile = simplexml_load_file("http://maps.google.com/maps/api/geocode/xml?address=" . $street . "," . $city . "," . $state); $Location = GetLocation($GeoCodeFile); $CallAPI = "https://api.forecast.io/forecast/7d75118b73458c705f9b911f7d637507/" . $Location[0] . "," . $Location[1] . "?units=" . $degree . "&exclude=flags"; echo $CallAPI; GetJSON($CallAPI, $degree); }