Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
Captcheck/readme.md

80 řádky
3.2 KiB
Markdown

před 7 roky
<img src="https://source.netsyms.com/Netsyms/Captcheck/raw/master/logo.png" alt="Captcheck" style="max-width: 50%;" />
před 7 roky
před 7 roky
před 6 roky
Easy, light, self-hostable CAPTCHA service. Works on modern browsers (and
IE9+). Uses a selection of icons from Font-Awesome. Text-only accessibility
před 7 roky
mode and support for keyboard-only operation.
před 7 roky
před 7 roky
Thanks to textcaptcha.com for supplying the data for the text CAPTCHA.
před 7 roky
How to use
----------
před 6 roky
In your form, put an empty div with the class "captcheck_container".
Add `captcheck.js` (or `captcheck.min.js`) into your page.
před 7 roky
<!DOCTYPE html>
<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="submit.php">
<input type="text" name="form_field" placeholder="Some random form field" />
<div class="captcheck_container">
před 7 roky
</div>
<button type="submit">Submit Form</button>
</form>
</body>
</html>
před 6 roky
When the form is submitted, your server will receive two extra form fields:
před 7 roky
`captcheck_session_code` and `captcheck_selected_answer`.
před 6 roky
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
před 7 roky
variable `msg` is available with an explanation.
před 6 roky
Example URL:
před 7 roky
`http(s)://captcheck-url/api.php?action=verify&session_id=<captcheck_session_code>&answer_id=<captcheck_selected_answer>`
před 6 roky
Example responses:
`{"session":"some_session_id","result":true}`
před 7 roky
`{"session":"some_session_id","result":false,"msg":"Answer incorrect."}`
před 11 měsíci
### Content-Security-Policy and Nonces
před 6 roky
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.
před 7 roky
Installation
------------
1. Run composer install.
2. Copy settings.template.php to settings.php and plug in your settings.
3. Install the database.
4. Customize captcheck.js with the correct api_url.
5. Follow the How to Use section and the example setup in test.html and test.php.
před 7 roky
Execution Flow
--------------
před 6 roky
JS = captcheck.js, API = api.php, FORM = parent form,
před 7 roky
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)
API -> JS: Sends info, saves session ID, correct answer, and scrambled answer codes in DB
JS -> API: Requests answer images by sending scrambled value and session ID
JS -> FORM: Adds hidden field with value=session ID, displays question and images (or text box)
před 7 roky
[USER SUBMITS FORM]
SITE -> API: Sends session ID and answer
před 7 roky
API -> SITE: Responds with true/false to indicate if the answer is valid, marks session as expired to prevent CAPTCHA reuse