From 70c45d24f7e9f653b0f83a432f70c07fcb171dde Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Fri, 9 Jun 2017 17:21:46 -0600 Subject: [PATCH] Make sure question text is black, improve test sample --- captcheck.js | 5 +++-- test.html | 6 +++--- test.php | 27 +++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/captcheck.js b/captcheck.js index 5a04c6c..451fcf6 100644 --- a/captcheck.js +++ b/captcheck.js @@ -1,5 +1,5 @@ window.onload = function () { - var api_url = "http://192.168.25.1/captcheck/api.php"; + var api_url = "https://captcheck.netsyms.com/api.php"; var getJSON = function (url, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); @@ -13,7 +13,7 @@ window.onload = function () { getJSON(api_url + "?action=new", function (status, json) { /* Add custom styles */ var styles = document.createElement('style'); - styles.innerHTML = ".captcheck_box {font-family: Ubuntu, Arial, sans-serif; border: 1px solid #e0e0e0; border-radius: 3px; display: inline-block; padding: 3px; margin: 5px 2px 5px 1px; background-color: #f5f5f5;} .captcheck_answer_label > input {visibility: hidden; position: absolute;} .captcheck_answer_label > input + img {cursor: pointer; border: 2px solid transparent; border-radius: 3px; min-width: 32px; width: 18%; max-width: 64px;} .captcheck_answer_label > input:checked + img {cursor: pointer; border: 2px solid #424242; border-radius: 3px;} .captcheck_error_message { color: red; }"; + styles.innerHTML = ".captcheck_box {font-family: Ubuntu, Arial, sans-serif; color: black; border: 1px solid #e0e0e0; border-radius: 3px; display: inline-block; padding: 3px; margin: 5px 2px 5px 1px; background-color: #f5f5f5;} .captcheck_label_message {color: black;} .captcheck_answer_label > input {visibility: hidden; position: absolute;} .captcheck_answer_label > input + img {cursor: pointer; border: 2px solid transparent; border-radius: 3px; min-width: 32px; width: 18%; max-width: 64px;} .captcheck_answer_label > input:checked + img {cursor: pointer; border: 2px solid #424242; border-radius: 3px;} .captcheck_error_message {color: red;}"; document.body.appendChild(styles); /* Get captcha container div */ @@ -35,6 +35,7 @@ window.onload = function () { answer_div.innerHTML = answers; /* Create question */ var question_div = document.createElement("div"); + question_div.setAttribute("class", "captcheck_label_message"); question_div.innerHTML = "Click on the " + data.question + ":"; /* Add question and answers */ diff --git a/test.html b/test.html index da05f99..75e6bb6 100644 --- a/test.html +++ b/test.html @@ -1,14 +1,14 @@ - Captcheck Test Page + Captcheck Sample Form -
- + +
diff --git a/test.php b/test.php index 6952c66..663015b 100644 --- a/test.php +++ b/test.php @@ -1,6 +1,29 @@ $_GET, "api" => json_decode(file_get_contents("http://localhost/captcheck/api.php?action=verify&session_id=" . $_GET["captcheck_session_code"] . "&answer_id=".$_GET["captcheck_selected_answer"]), true)]); \ No newline at end of file +var_dump($_POST); + + + +$url = 'https://captcheck.netsyms.com/api.php'; +$data = [ + 'session_id' => $_POST['captcheck_session_code'], + 'answer_id' => $_POST['captcheck_selected_answer'], + 'action' => "verify" +]; +$options = [ + 'http' => [ + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", + 'method' => 'POST', + 'content' => http_build_query($data) + ] +]; +$context = stream_context_create($options); +$result = file_get_contents($url, false, $context); +$resp = json_decode($result, TRUE); +if (!$resp['result']) { + exit("\n\nCAPTCHA did not verify:" . $resp['msg']); +} else { + exit("\n\nCAPTCHA verified!"); +}