Make sure question text is black, improve test sample
This commit is contained in:
parent
f0101aaea2
commit
70c45d24f7
|
@ -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 <b>" + data.question + "</b>:";
|
||||
|
||||
/* Add question and answers */
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Captcheck Test Page</title>
|
||||
<title>Captcheck Sample Form</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="captcheck.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<form action="test.php" method="GET">
|
||||
<input type="text" name="junk" placeholder="Junk" />
|
||||
<form action="submit.php" method="POST">
|
||||
<input type="text" name="form_field" placeholder="Some random form field" />
|
||||
<div id="captcheck_container">
|
||||
</div>
|
||||
<button type="submit">Submit Form</button>
|
||||
|
|
27
test.php
27
test.php
|
@ -1,6 +1,29 @@
|
|||
<?php
|
||||
|
||||
//header("Content-Type: application/json");
|
||||
header("Content-Type: text/plain");
|
||||
|
||||
echo json_encode(["get" => $_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)]);
|
||||
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!");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue