-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-invisible.php
47 lines (38 loc) · 1.48 KB
/
index-invisible.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require './ArCaptcha.php';
$ArCaptcha = new ArCaptcha('SITE_KEY', 'SECRET_KEY', ['size' => 'invisible', 'callback' => 'callback']); // dont forget to replace your site_key and secret_key
?>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') { // check form submission
if ($ArCaptcha->verify($_POST["arcaptcha-token"])) { // verify that captcha is solved
echo "OK!";
} else {
echo "FAILED!";
}
} else { // show form
?>
<!DOCTYPE html>
<head></head>
<body>
<?php echo $ArCaptcha->getScript() // try to inject script into body ?>
<form method="POST" id="form" action="" name="form">
<?php echo $ArCaptcha->getWidget() // try to inject div with arcaptcha class ?>
<input id="submit_value" type="button" name="submit_value" value="Submit"/>
</form>
<script>
document.getElementById("submit_value").addEventListener('click',onClick);
function onClick(e){
e.preventDefault();
arcaptcha.execute();
}
function callback(token){
console.log(token);
// submit the form
document.getElementById("form").submit();
}
</script>
</body>
</html>
<?php
}
?>