Compare commits

..

No commits in common. 'master' and 'v0.4' have entirely different histories.
master ... v0.4

10
.env

@ -1,10 +0,0 @@
SUBNET=172.16.28
EXPOSE_APACHE_WEB_SERVER_ON_PORT=8787
EXPOSE_APACHE_WEB_SERVER_ONLY_ON_IP_ADDRESS_COLON=
EXPOSE_MARIADB_ON_PORT=3386
MARIADB_ROOT_PASSWORD=qwerty
MARIADB_USERNAME=root
MARIADB_PASSWORD=qwerty
MARIADB_HOSTNAME=mariadb
MARIADB_PORT=3306
MARIADB_DATABASE_NAME=captcheck

@ -1,2 +0,0 @@
RewriteEngine On
RewriteRule ^captcheck.dist.js captcheck.min.js [L]

@ -1,23 +1,9 @@
Copyright (C) 2017-2021 Netsyms Technologies.
Copyright (C) 2017 Netsyms Technologies.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
NETSYMS TECHNOLOGIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL NETSYMS TECHNOLOGIES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name and other identifying marks of
Netsyms Technologies shall not be used in advertising or otherwise to promote
the sale, use or other dealings in this Software without prior written
authorization from Netsyms Technologies.
Except as contained in this notice, the name and other identifying marks of Netsyms Technologies shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Netsyms Technologies.

@ -1,17 +1,14 @@
<?php
require __DIR__ . '/required.php';
use Medoo\Medoo;
header("Content-Type: application/json");
// Oldest session allowed
$session_min_date = date("Y-m-d H:i:s", strtotime("-" . SESSION_EXPIRE_MINUTES . " minutes"));
// Delete old sessions
$old_sessions = $database->select("sessions", "sid", ["timestamp[<]" => $session_min_date]);
foreach ($old_sessions as $sid) {
$database->delete("scrambled_answers", ["sid" => $sid]);
$database->delete("sessions", ["sid" => $sid]);
}
$database->delete("scrambled_answers", ["sid" => $old_sessions]);
$database->delete("sessions", ["sid" => $old_sessions]);
switch ($VARS['action']) {
case "ping":
@ -21,9 +18,9 @@ switch ($VARS['action']) {
// generate unique session ID that has an essentially zero chance of being a duplicate.
// Contains a hash of a secure random number, a hash of the user's IP, and 23 uniqid() characters.
$skey = uniqid(substr(hash("md5", mt_rand()), 3, 5) . hash("md5", getUserIP()), true);
// Image problem
//
//
// Get five random options
$answer_count = $database->count('answers');
$answers = $database->select('answers', ['aid', 'aname'], ["LIMIT" => [mt_rand(0, $answer_count - 6), 5]]);
@ -36,15 +33,15 @@ switch ($VARS['action']) {
$scrambled["real"][] = $a['aid'];
$scrambled["fake"][] = substr(hash("md5", mt_rand()), 0, 20);
}
// Text problem
//
// Get random question
$access_count = $database->count('access_questions');
$access_question = $database->select('access_questions', ['acqid', 'acqtext'], ["LIMIT" => [mt_rand(0, $access_count - 1), 1]])[0];
// Save the session data
$database->insert("sessions", ["skey" => $skey, "aid" => $correct_answer['aid'], "acqid" => $access_question['acqid'], "expired" => 0, "timestamp" => Medoo::raw("NOW()"), "ipaddr" => getUserIP()]);
$database->insert("sessions", ["skey" => $skey, "aid" => $correct_answer['aid'], "acqid" => $access_question['acqid'], "expired" => 0, "#timestamp" => "NOW()", "ipaddr" => getUserIP()]);
$sid = $database->id();
// Save the answer data
$scrambled_insert = [];
@ -52,11 +49,11 @@ switch ($VARS['action']) {
$scrambled_insert[] = ["sid" => $sid, "aid" => $scrambled['real'][$i], "acode" => $scrambled['fake'][$i]];
}
$database->insert("scrambled_answers", $scrambled_insert);
// Vary question wording a little
$questions = ["Please click on the [].", "Click the [].", "Find the []."];
shuffle($questions);
$resp = [
"session" => $skey,
"id_prefix" => substr(hash("md5", mt_rand()), 3, 5),

@ -12,17 +12,12 @@ Don't use this file in your site; captcheck.js contains it.
padding: 3px;
margin: 5px 2px 5px 1px;
background-color: #f5f5f5;
text-decoration: none;
}
.captcheck_label_message,
.captcheck_label_message b {
color: black;
font-family: Ubuntu, Roboto, Arial, sans-serif;
}
.captcheck_answer_label {
border: 0px;
font-family: Ubuntu, Arial, sans-serif;
}
.captcheck_answer_label > input {
@ -63,7 +58,6 @@ Don't use this file in your site; captcheck.js contains it.
cursor: pointer;
color: inherit;
text-decoration: inherit;
border: 0px;
}
.captcheck_answer_images {

@ -0,0 +1 @@
function chooseAnswer(e,t){var a=document.getElementById("captcheck_"+e+"_answer_"+t);return a.checked=!0,!1}function switchMode(e){var t=document.getElementById("captcheck_"+e+"_alt_question_button"),a=document.getElementById("captcheck_"+e+"_question_image"),c=document.getElementById("captcheck_"+e+"_question_access"),n=document.getElementById("captcheck_"+e+"_answer_images"),s=document.getElementById("captcheck_"+e+"_answer_access");"&gt; Text mode"==t.innerHTML?(t.innerHTML="&gt; Image mode",a.style.display="none",c.style.display="initial",n.style.display="none",s.style.display="initial",s.innerHTML="<input type='text' name='captcheck_selected_answer' aria-label='Type your answer here.' autocomplete='off' autofill='off'/>"):(t.innerHTML="&gt; Text mode",a.style.display="initial",c.style.display="none",n.style.display="initial",s.style.display="none",s.innerHTML="")}window.onload=function(){var e="https://captcheck.netsyms.com/api.php",t=document.createElement("style");t.innerHTML=".captcheck_box,.captcheck_label_message,.captcheck_label_message b{color:#000;font-family:Ubuntu,Arial,sans-serif}.captcheck_box{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}.captcheck_question_image{display:initial}.captcheck_question_access{display:none}.captcheck_alt_question_button{float:right;font-size:80%;cursor:pointer;color:inherit;text-decoration:inherit}.captcheck_answer_images{display:initial}.captcheck_answer_access{display:none}",document.body.appendChild(t),Array.prototype.forEach.call(document.getElementsByClassName("captcheck_container"),function(t){var a=new XMLHttpRequest;a.open("GET",e+"?action=new",!0),a.onreadystatechange=function(){if(4==this.readyState){var a=this.status,c=this.responseText,n=document.createElement("div");if(n.setAttribute("class","captcheck_box"),t.appendChild(n),200==a){for(var s=JSON.parse(c),i=s.id_prefix,r="<div class='captcheck_answer_images' id='captcheck_"+i+"_answer_images'>",o=0,l=s.answers.length;l>o;o++){var p=e+"?action=img&s="+s.session+"&c="+s.answers[o];r+="<a class='captcheck_answer_label' href='' tabindex='0' onClick='chooseAnswer(\""+i+'","'+s.answers[o]+"\"); return false;' onEnter='chooseAnswer(\""+i+'","'+s.answers[o]+"\"); return false;'><input id='captcheck_"+i+"_answer_"+s.answers[o]+"' type='radio' name='captcheck_selected_answer' value='"+s.answers[o]+"' /><img src='"+p+"' /></a>"}r+="</div>";var d=document.createElement("div");d.innerHTML=r+"<div class='captcheck_answer_access' id='captcheck_"+i+"_answer_access'></div>";var _=document.createElement("div");_.setAttribute("class","captcheck_label_message"),_.setAttribute("id","captcheck_"+i+"_label_message"),_.innerHTML="<span class='captcheck_question_image' id='captcheck_"+i+"_question_image'>"+s.question_i+"</span><span class='captcheck_question_access' id='captcheck_"+i+"_question_access'>"+s.question_a+"</span><a href='' class='captcheck_alt_question_button' onClick='switchMode(\""+i+"\"); return false;' onEnter='switchMode(\""+i+"\"); return false;' id='captcheck_"+i+"_alt_question_button' aria-label='Switch between image and text question' tabindex='0'>&gt; Text mode</a>",n.appendChild(_),n.appendChild(d);var h=document.createElement("span");h.innerHTML="<input type='hidden' name='captcheck_session_code' value='"+s.session+"' />",n.appendChild(h)}else n.innerHTML="<span class='captcheck_error_message'>There was a problem loading the CAPTCHA.</span>"}},a.send()})};

@ -1,52 +1,20 @@
window.onload = function () {
var api_url = "https://captcheck.netsyms.com/api.php";
function chooseAnswer(idp, ans) {
var box = document.getElementById("captcheck_" + idp + "_answer_" + ans);
box.checked = true;
return false;
}
function switchMode(idp) {
var switch_label = document.getElementById("captcheck_" + idp + "_alt_question_button");
var img_q = document.getElementById("captcheck_" + idp + "_question_image");
var acc_q = document.getElementById("captcheck_" + idp + "_question_access");
var img_a = document.getElementById("captcheck_" + idp + "_answer_images");
var acc_a = document.getElementById("captcheck_" + idp + "_answer_access");
if (switch_label.innerHTML == "&gt; Text mode") {
switch_label.innerHTML = "&gt; Image mode";
img_q.style.display = "none";
acc_q.style.display = "initial";
img_a.style.display = "none";
acc_a.style.display = "initial";
acc_a.innerHTML = "<input type='text' name='captcheck_selected_answer' aria-label='Type your answer here.' autocomplete='off' autofill='off'/>";
} else {
switch_label.innerHTML = "&gt; Text mode";
img_q.style.display = "initial";
acc_q.style.display = "none";
img_a.style.display = "initial";
acc_a.style.display = "none";
acc_a.innerHTML = "";
}
}
/* Add custom styles */
var styles = document.createElement('style');
/* Remove newlines/comments from captcheck.css and put it here */
styles.innerHTML = ".captcheck_box,.captcheck_label_message,.captcheck_label_message b{color:#000;font-family:Ubuntu,Arial,sans-serif}.captcheck_box{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}.captcheck_question_image{display:initial}.captcheck_question_access{display:none}.captcheck_alt_question_button{float:right;font-size:80%;cursor:pointer;color:inherit;text-decoration:inherit}.captcheck_answer_images{display:initial}.captcheck_answer_access{display:none}";
document.body.appendChild(styles);
var nonce = "";
/* Loop over all the CAPTCHA containers on the page, setting up a different CAPTCHA in each */
Array.prototype.forEach.call(document.getElementsByClassName("captcheck_container"), function (container) {
if (container.dataset.stylenonce) {
nonce = container.dataset.stylenonce;
}
var xhr = new XMLHttpRequest();
xhr.open('GET', api_url + "?action=new", true);
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
var status = this.status;
var json = this.responseText;
/* Prevent rare bug where two CAPTCHAs appear in one container */
if (container.innerHTML.trim() != "") {
return;
}
/* Create captcha div */
var captcha = document.createElement("div");
captcha.setAttribute("class", "captcheck_box");
@ -60,7 +28,7 @@ window.onload = function () {
var answers = "<div class='captcheck_answer_images' id='captcheck_" + idp + "_answer_images'>";
for (var i = 0, len = data.answers.length; i < len; i++) {
var src = api_url + "?action=img&s=" + data.session + "&c=" + data.answers[i];
answers += "<a class='captcheck_answer_label' href='' data-prefix='" + idp + "' data-answer='" + data.answers[i] + "' tabindex='0' aria-role='button'><input id='captcheck_" + idp + "_answer_" + data.answers[i] + "' type='radio' name='captcheck_selected_answer' value='" + data.answers[i] + "' data-prefix='" + idp + "' data-answer='" + data.answers[i] + "' /><img src='" + src + "' data-prefix='" + idp + "' data-answer='" + data.answers[i] + "'/></a>";
answers += "<a class='captcheck_answer_label' href='' tabindex='0' onClick='chooseAnswer(\"" + idp + "\",\"" + data.answers[i] + "\"); return false;' onEnter='chooseAnswer(\"" + idp + "\",\"" + data.answers[i] + "\"); return false;'><input id='captcheck_" + idp + "_answer_" + data.answers[i] + "' type='radio' name='captcheck_selected_answer' value='" + data.answers[i] + "' /><img src='" + src + "' /></a>";
}
answers += "</div>";
var answer_div = document.createElement("div");
@ -69,7 +37,7 @@ window.onload = function () {
var question_div = document.createElement("div");
question_div.setAttribute("class", "captcheck_label_message");
question_div.setAttribute("id", "captcheck_" + idp + "_label_message")
question_div.innerHTML = "<span class='captcheck_question_image' id='captcheck_" + idp + "_question_image'>" + data.question_i + "</span><span class='captcheck_question_access' id='captcheck_" + idp + "_question_access'>" + data.question_a + "</span><a href='' class='captcheck_alt_question_button' data-prefix='" + idp + "' id='captcheck_" + idp + "_alt_question_button' aria-role='button' aria-label='Switch between image and text question' tabindex='0'>&gt; Text mode</a>";
question_div.innerHTML = "<span class='captcheck_question_image' id='captcheck_" + idp + "_question_image'>" + data.question_i + "</span><span class='captcheck_question_access' id='captcheck_" + idp + "_question_access'>" + data.question_a + "</span><a href='' class='captcheck_alt_question_button' onClick='switchMode(\"" + idp + "\"); return false;' onEnter='switchMode(\"" + idp + "\"); return false;' id='captcheck_" + idp + "_alt_question_button' aria-label='Switch between image and text question' tabindex='0'>&gt; Text mode</a>";
/* Add question and answers */
captcha.appendChild(question_div);
@ -79,30 +47,6 @@ window.onload = function () {
var skey_input = document.createElement("span");
skey_input.innerHTML = "<input type='hidden' name='captcheck_session_code' value='" + data.session + "' />";
captcha.appendChild(skey_input);
var answer_buttons = document.querySelectorAll(".captcheck_answer_label[data-prefix=\"" + idp + "\"]");
for (var i = 0; i < answer_buttons.length; i++) {
answer_buttons[i].addEventListener("click", function (ev) {
chooseAnswer(ev.target.getAttribute("data-prefix"), ev.target.getAttribute("data-answer"));
ev.preventDefault();
});
answer_buttons[i].addEventListener('keydown', function (ev) {
if (ev.key === "Enter" || ev.which === 13 || ev.keyCode === 13 || ev.key === ' ' || ev.which === 32 || ev.keyCode === 32) {
chooseAnswer(ev.target.getAttribute("data-prefix"), ev.target.getAttribute("data-answer"));
ev.preventDefault();
}
});
}
document.querySelector(".captcheck_alt_question_button[data-prefix=\"" + idp + "\"]").addEventListener("click", function (ev) {
switchMode(ev.target.getAttribute("data-prefix"));
ev.preventDefault();
});
document.querySelector(".captcheck_alt_question_button[data-prefix=\"" + idp + "\"]").addEventListener('keydown', function (ev) {
if (ev.key === "Enter" || ev.which === 13 || ev.keyCode === 13 || ev.key === ' ' || ev.which === 32 || ev.keyCode === 32) {
switchMode(ev.target.getAttribute("data-prefix"));
ev.preventDefault();
}
});
} else {
/* Add error message */
captcha.innerHTML = "<span class='captcheck_error_message'>There was a problem loading the CAPTCHA.</span>";
@ -111,13 +55,33 @@ window.onload = function () {
};
xhr.send();
});
}
/* Add custom styles */
var styles = document.createElement('style');
if (nonce != "") {
styles.setAttribute("nonce", nonce);
function chooseAnswer(idp, ans) {
var box = document.getElementById("captcheck_" + idp + "_answer_" + ans);
box.checked = true;
return false;
}
function switchMode(idp) {
var switch_label = document.getElementById("captcheck_" + idp + "_alt_question_button");
var img_q = document.getElementById("captcheck_" + idp + "_question_image");
var acc_q = document.getElementById("captcheck_" + idp + "_question_access");
var img_a = document.getElementById("captcheck_" + idp + "_answer_images");
var acc_a = document.getElementById("captcheck_" + idp + "_answer_access");
if (switch_label.innerHTML == "&gt; Text mode") {
switch_label.innerHTML = "&gt; Image mode";
img_q.style.display = "none";
acc_q.style.display = "initial";
img_a.style.display = "none";
acc_a.style.display = "initial";
acc_a.innerHTML = "<input type='text' name='captcheck_selected_answer' aria-label='Type your answer here.' autocomplete='off' autofill='off'/>";
} else {
switch_label.innerHTML = "&gt; Text mode";
img_q.style.display = "initial";
acc_q.style.display = "none";
img_a.style.display = "initial";
acc_a.style.display = "none";
acc_a.innerHTML = "";
}
/* Remove newlines/comments from captcheck.css and put it here */
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;text-decoration:none}.captcheck_label_message,.captcheck_label_message b{color:black;font-family:Ubuntu,Roboto,Arial,sans-serif}.captcheck_answer_label{border:0}.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}.captcheck_question_image{display:initial}.captcheck_question_access{display:none}.captcheck_alt_question_button{float:right;font-size:80%;cursor:pointer;color:inherit;text-decoration:inherit;border:0}.captcheck_answer_images{display:initial}.captcheck_answer_access{display:none}";
document.body.appendChild(styles);
}

9
captcheck.min.js vendored

@ -1,9 +0,0 @@
window.onload=function(){function m(c,g){document.getElementById("captcheck_"+c+"_answer_"+g).checked=!0;return!1}function n(c){var g=document.getElementById("captcheck_"+c+"_alt_question_button"),b=document.getElementById("captcheck_"+c+"_question_image"),d=document.getElementById("captcheck_"+c+"_question_access"),f=document.getElementById("captcheck_"+c+"_answer_images");c=document.getElementById("captcheck_"+c+"_answer_access");"&gt; Text mode"==g.innerHTML?(g.innerHTML="&gt; Image mode",b.style.display=
"none",d.style.display="initial",f.style.display="none",c.style.display="initial",c.innerHTML="<input type='text' name='captcheck_selected_answer' aria-label='Type your answer here.' autocomplete='off' autofill='off'/>"):(g.innerHTML="&gt; Text mode",b.style.display="initial",d.style.display="none",f.style.display="initial",c.style.display="none",c.innerHTML="")}var k="";Array.prototype.forEach.call(document.getElementsByClassName("captcheck_container"),function(c){c.dataset.stylenonce&&(k=c.dataset.stylenonce);
var g=new XMLHttpRequest;g.open("GET","https://captcheck.netsyms.com/api.php?action=new",!0);g.onreadystatechange=function(){if(4==this.readyState){var b=this.status,d=this.responseText;if(""==c.innerHTML.trim()){var f=document.createElement("div");f.setAttribute("class","captcheck_box");c.appendChild(f);if(200==b){d=JSON.parse(d);b=d.id_prefix;for(var h="<div class='captcheck_answer_images' id='captcheck_"+b+"_answer_images'>",e=0,g=d.answers.length;e<g;e++)h+="<a class='captcheck_answer_label' href='' data-prefix='"+
b+"' data-answer='"+d.answers[e]+"' tabindex='0' aria-role='button'><input id='captcheck_"+b+"_answer_"+d.answers[e]+"' type='radio' name='captcheck_selected_answer' value='"+d.answers[e]+"' data-prefix='"+b+"' data-answer='"+d.answers[e]+"' /><img src='"+("https://captcheck.netsyms.com/api.php?action=img&s="+d.session+"&c="+d.answers[e])+"' data-prefix='"+b+"' data-answer='"+d.answers[e]+"'/></a>";h+="</div>";e=document.createElement("div");e.innerHTML=h+"<div class='captcheck_answer_access' id='captcheck_"+
b+"_answer_access'></div>";h=document.createElement("div");h.setAttribute("class","captcheck_label_message");h.setAttribute("id","captcheck_"+b+"_label_message");h.innerHTML="<span class='captcheck_question_image' id='captcheck_"+b+"_question_image'>"+d.question_i+"</span><span class='captcheck_question_access' id='captcheck_"+b+"_question_access'>"+d.question_a+"</span><a href='' class='captcheck_alt_question_button' data-prefix='"+b+"' id='captcheck_"+b+"_alt_question_button' aria-role='button' aria-label='Switch between image and text question' tabindex='0'>&gt; Text mode</a>";
f.appendChild(h);f.appendChild(e);h=document.createElement("span");h.innerHTML="<input type='hidden' name='captcheck_session_code' value='"+d.session+"' />";f.appendChild(h);f=document.querySelectorAll('.captcheck_answer_label[data-prefix="'+b+'"]');for(e=0;e<f.length;e++)f[e].addEventListener("click",function(a){m(a.target.getAttribute("data-prefix"),a.target.getAttribute("data-answer"));a.preventDefault()}),f[e].addEventListener("keydown",function(a){if("Enter"===a.key||13===a.which||13===a.keyCode||
" "===a.key||32===a.which||32===a.keyCode)m(a.target.getAttribute("data-prefix"),a.target.getAttribute("data-answer")),a.preventDefault()});document.querySelector('.captcheck_alt_question_button[data-prefix="'+b+'"]').addEventListener("click",function(a){n(a.target.getAttribute("data-prefix"));a.preventDefault()});document.querySelector('.captcheck_alt_question_button[data-prefix="'+b+'"]').addEventListener("keydown",function(a){if("Enter"===a.key||13===a.which||13===a.keyCode||" "===a.key||32===
a.which||32===a.keyCode)n(a.target.getAttribute("data-prefix")),a.preventDefault()})}else f.innerHTML="<span class='captcheck_error_message'>There was a problem loading the CAPTCHA.</span>"}}};g.send()});var l=document.createElement("style");""!=k&&l.setAttribute("nonce",k);l.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;text-decoration:none}.captcheck_label_message,.captcheck_label_message b{color:black;font-family:Ubuntu,Roboto,Arial,sans-serif}.captcheck_answer_label{border:0}.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}.captcheck_question_image{display:initial}.captcheck_question_access{display:none}.captcheck_alt_question_button{float:right;font-size:80%;cursor:pointer;color:inherit;text-decoration:inherit;border:0}.captcheck_answer_images{display:initial}.captcheck_answer_access{display:none}";
document.body.appendChild(l)};

24
composer.lock generated

@ -1,23 +1,23 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "3d60b6d6d1ba750afa45d307e067f006",
"packages": [
{
"name": "catfan/medoo",
"version": "v1.7.10",
"version": "v1.4.4",
"source": {
"type": "git",
"url": "https://github.com/catfan/Medoo.git",
"reference": "2d675f73e23f63bbaeb9a8aa33318659a3d3c32f"
"reference": "bcabbef4d8355d52fc4d19f17463e5e816c9ef44"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/catfan/Medoo/zipball/2d675f73e23f63bbaeb9a8aa33318659a3d3c32f",
"reference": "2d675f73e23f63bbaeb9a8aa33318659a3d3c32f",
"url": "https://api.github.com/repos/catfan/Medoo/zipball/bcabbef4d8355d52fc4d19f17463e5e816c9ef44",
"reference": "bcabbef4d8355d52fc4d19f17463e5e816c9ef44",
"shasum": ""
},
"require": {
@ -31,7 +31,7 @@
"ext-pdo_oci8": "For Oracle version 8 database",
"ext-pdo_pqsql": "For PostgreSQL database",
"ext-pdo_sqlite": "For SQLite database",
"ext-pdo_sqlsrv": "For MSSQL database on both Window/Liunx platform"
"ext-pdo_sqlsrv": "For MSSQL database on Windows platform"
},
"type": "framework",
"autoload": {
@ -49,11 +49,10 @@
"email": "angel@catfan.me"
}
],
"description": "The lightweight PHP database framework to accelerate development",
"description": "The lightest PHP database framework to accelerate development",
"homepage": "https://medoo.in",
"keywords": [
"database",
"database library",
"lightweight",
"mariadb",
"mssql",
@ -64,11 +63,7 @@
"sql",
"sqlite"
],
"support": {
"issues": "https://github.com/catfan/Medoo/issues",
"source": "https://github.com/catfan/Medoo"
},
"time": "2020-02-11T08:20:42+00:00"
"time": "2017-06-02T15:25:04+00:00"
}
],
"packages-dev": [],
@ -78,6 +73,5 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.0.0"
"platform-dev": []
}

@ -1,26 +0,0 @@
version: "3.6"
services:
web:
build: ./docker-web
restart: always
ports:
- ${EXPOSE_APACHE_WEB_SERVER_ONLY_ON_IP_ADDRESS_COLON}${EXPOSE_APACHE_WEB_SERVER_ON_PORT}:80
volumes:
- .:/var/www/html
environment:
MARIADB_USERNAME: ${MARIADB_USERNAME}
MARIADB_PASSWORD: ${MARIADB_PASSWORD}
MARIADB_HOSTNAME: ${MARIADB_HOSTNAME}
MARIADB_PORT: ${MARIADB_PORT}
MARIADB_DATABASE_NAME: ${MARIADB_DATABASE_NAME}
mariadb:
image: mariadb:10.4
restart: always
volumes:
- ./data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
ports:
- 127.0.0.1:${EXPOSE_MARIADB_ON_PORT}:${MARIADB_PORT}

@ -1,13 +0,0 @@
FROM php:7.2-apache
RUN docker-php-ext-install mysqli pdo pdo_mysql
RUN docker-php-ext-enable mysqli
RUN a2enmod rewrite
RUN apt-get update && apt-get install -y zlib1g-dev libpng-dev libfreetype6-dev
RUN docker-php-ext-configure gd --with-gd --with-zlib-dir --with-png-dir --with-freetype-dir
RUN docker-php-ext-install gd

@ -1,143 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta content="width=device-width,initial-scale=1" name=viewport>
<title>Captcheck</title>
<link rel="stylesheet" href="https://static.netsyms.net/bootstrap/4/bootstrap.materia.min.css" />
<link rel="stylesheet" href="https://static.netsyms.net/prism/prism.css" />
<script async src="https://static.netsyms.net/fontawesome/5.2/js/all.min.js"></script>
<script defer async src="https://static.netsyms.net/prism/prism.js"></script>
<style>
h2, h3, p {
text-align: center;
}
pre {
padding-left: 5px;
}
.bg-minty {
background-color: #7dffd2;
}
@media only screen and (min-width: 768px) and (max-width: 991px) {
h2, h3 {
text-align: left;
}
.site-icon {
margin-top: 18px;
}
}
@media only screen and (min-width: 992px) and (max-width: 1199px) {
h2, h3 {
text-align: left;
}
.site-icon {
margin-top: 14px;
}
}
@media only screen and (min-width: 1200px) {
h2, h3 {
text-align: left;
}
.site-icon {
margin-top: 0px;
}
}
</style>
<div class="container">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12" style="text-align: center;" >
<img src="logo.png" class="site-icon" style="width: 400px; max-width: 100%;" />
</div>
</div>
<p style="font-size: 15px; line-height: 20px;">Open source reCAPTCHA alternative</p>
<div class="d-flex">
<ul class="nav nav-pills mx-auto">
<li class="nav-item">
<span class="nav-link">
<i class="fab fa-php"></i> PHP 7
</span>
</li>
<li class="nav-item">
<span class="nav-link">
<i class="fas fa-database"></i> MySQL
</span>
</li>
<li class="nav-item">
<a class="nav-link" href="https://source.netsyms.com/Netsyms/Captcheck/src/branch/master/LICENSE" style="color: #444;">
<i class="fas fa-file-contract"></i> MIT
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://source.netsyms.com/Netsyms/Captcheck" style="color: #444;">
<i class="fas fa-code-branch"></i> Git
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="row my-4">
<div class="col-12 col-md-6">
<div class="card">
<div class="card-header bg-minty">
<h4 class="card-heading d-flex mb-0"><span class="mr-auto">Demo</span> <a onclick="document.getElementById('demoframe').src = document.getElementById('demoframe').src" title="Reset demo"><i class="fas fa-sync-alt"></i></a></h4>
</div>
<div class="card-body">
<iframe style="border: 0px solid white; width: 100%; height: 100%; height: 350px;" src="test.html" id="demoframe"></iframe>
</div>
</div>
</div>
<div class="col-12 col-md-6">
<div class="card">
<div class="card-header bg-minty">
<h4 class="card-heading mb-0">Use</h4>
</div>
<div class="card-body">
<b>Put this in your page somewhere:</b>
<pre><code class="language-html">&lt;script src="https://captcheck.netsyms.com/captcheck.min.js">&lt;/script></code></pre>
<b>Put this in your form where you want the CAPTCHA:</b>
<pre><code class="language-html">&lt;div class="captcheck_container">&lt;/div></code></pre>
<b>Put this in your server-side form validation (PHP example):</b>
<pre><code class="language-php">
$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']) {
// Replace with error-handling code
exit("CAPTCHA did not verify:" . $resp['msg']);
} else {
// The CAPTCHA is valid.
exit("CAPTCHA verified!");
}
</code></pre>
<b>If you have a strict Content Security Policy, change your div to this:</b>
<pre><code class="language-html">&lt;div class="captcheck_container" data-stylenonce="your nonce here">&lt;/div></code></pre>
Note: by using this hosted service, you agree to <a href="https://netsyms.com/legal">these terms</a>. If you don't like them, feel free to host Captcheck on your own server.
Popular sites should self-host as well just to be nice.
</div>
</div>
</div>
</div>
<div class="footer"><p>Copyright &copy; 2018 <a href="https://netsyms.com">Netsyms Technologies</a>. MIT License.<br /><a href="https://source.netsyms.com/Netsyms/Captcheck">Get the source</a> and run your own CAPTCHA service.</p></div>
</div>

@ -0,0 +1,2 @@
<?php
header("Location: test.html");

@ -1,17 +1,16 @@
<img src="https://source.netsyms.com/Netsyms/Captcheck/raw/master/logo.png" alt="Captcheck" style="max-width: 50%;" />
Easy, light, self-hostable CAPTCHA service. Works on modern browsers (and
IE9+). Uses a selection of icons from Font-Awesome. Text-only accessibility
Easy, light, self-hostable CAPTCHA service. Works on modern browsers (and
IE9+). Uses a selection of icons from Font-Awesome. Text-only accessibility
mode and support for keyboard-only operation.
Thanks to textcaptcha.com for supplying the data for the text CAPTCHA.
How to use
----------
In your form, put an empty div with the class "captcheck_container".
Add `captcheck.js` (or `captcheck.min.js`) into your page.
In your form, put an empty div with the class "captcheck_container".
Add `captcheck.js` (or `captcheck.dist.js`) into your page.
<!DOCTYPE html>
<html>
@ -31,28 +30,22 @@ Add `captcheck.js` (or `captcheck.min.js`) into your page.
</body>
</html>
When the form is submitted, your server will receive two extra form fields:
When the form is submitted, your server will receive two extra form fields:
`captcheck_session_code` and `captcheck_selected_answer`.
In your form handling code, send a request to `http(s)://captcheck-url/api.php`.
Pass the variables `session_id` and `answer_id` with the values sent with the form,
and also pass the variable `action` with the value `verify`.
You will receive a JSON response with (among other things) `"result": true` or
`"result": false`. If result is false, the user failed the test, and another
In your form handling code, send a request to `http(s)://captcheck-url/api.php`.
Pass the variables `session_id` and `answer_id` with the values sent with the form,
and also pass the variable `action` with the value `verify`.
You will receive a JSON response with (among other things) `"result": true` or
`"result": false`. If result is false, the user failed the test, and another
variable `msg` is available with an explanation.
Example URL:
Example URL:
`http(s)://captcheck-url/api.php?action=verify&session_id=<captcheck_session_code>&answer_id=<captcheck_selected_answer>`
Example responses:
`{"session":"some_session_id","result":true}`
Example responses:
`{"session":"some_session_id","result":true}`
`{"session":"some_session_id","result":false,"msg":"Answer incorrect."}`
### Content-Security-Policy and Nonces
Add `data-stylenonce="nonce_here"` to the `.captcheck_container` div.
If you have multiple CAPTCHAs on one page, only one of them needs the nonce
specified.
Installation
------------
@ -67,7 +60,7 @@ Installation
Execution Flow
--------------
JS = captcheck.js, API = api.php, FORM = parent form,
JS = captcheck.js, API = api.php, FORM = parent form,
SITE = form processing code, -> = some action taken on the right by the left
JS -> API: Request session ID, question, and answers (with scrambled random codes)

@ -1,12 +1,17 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Captcheck Sample Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="captcheck.js"></script>
<form action="test.php" method="POST">
<input type="text" name="form_field" placeholder="Some random form field" />
<div class="captcheck_container">
</div>
<button type="submit">Submit Form</button>
</form>
<html>
<head>
<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="POST">
<input type="text" name="form_field" placeholder="Some random form field" />
<div class="captcheck_container">
</div>
<button type="submit">Submit Form</button>
</form>
</body>
</html>

@ -2,6 +2,10 @@
header("Content-Type: text/plain");
var_dump($_POST);
$url = 'https://captcheck.netsyms.com/api.php';
$data = [
'session_id' => $_POST['captcheck_session_code'],
@ -18,16 +22,8 @@ $options = [
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$resp = json_decode($result, TRUE);
echo "Form fields:\n";
var_export($_POST);
echo "\n\nAPI request fields:\n";
var_export($data);
echo "\n\nAPI response (JSON):\n";
echo json_encode(json_decode($result, TRUE), JSON_PRETTY_PRINT);
if (!$resp['result']) {
exit("\n\nCAPTCHA did not verify: " . $resp['msg']);
exit("\n\nCAPTCHA did not verify:" . $resp['msg']);
} else {
exit("\n\nCAPTCHA verified!");
}

Loading…
Cancel
Save