-
Notifications
You must be signed in to change notification settings - Fork 2
/
correction.php
35 lines (33 loc) · 1.21 KB
/
correction.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
<?php
if ( isset( $_POST['text'] ) and strlen( $_POST['text'] ) > 5 and strlen( $_POST['text'] ) < 5000 ) {
if ( isset( $_POST['g-recaptcha-response'] ) && !empty($_POST['g-recaptcha-response'] ) ) {
//your site secret key
$secret = '6LdothcUAAAAAA8YEJKKNov2S7EoOtcOxGu8tnuG';
//get verify response data
$verifyResponse = file_get_contents( 'https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response'] );
$responseData = json_decode( $verifyResponse );
if ( $responseData->success ) {
file_put_contents( 'corrections/corrections.txt', $_POST['text'] . PHP_EOL , FILE_APPEND | LOCK_EX );
echo '{
"response": "Text saved! Thank you very much. شكراً جزيلاً.",
"status": "success"
}';
} else {
echo '{
"response": "Incorrect captcha response. الرجاء التاكيد أنكم لستم روبوت.",
"status": "error"
}';
}
} else {
echo '{
"response": "Incorrect captcha response. الرجاء التاكيد أنكم لستم روبوت.",
"status": "error"
}';
}
} else {
echo '{
"response": "Input too long or too short. الدخل طويل جداً أو قصير جداً.",
"status": "error"
}';
}
?>