Add Netsyms Captcheck CAPTCHA alternative #4

Merged
skylarmt merged 1 commits from captcheck into master 7 years ago

@ -1439,6 +1439,7 @@ $modsForHesk_settings = mfh_getSettings();
$on = '';
$on2 = '';
$on3 = '';
$off = '';
$div = 'block';
@ -1446,6 +1447,9 @@ $modsForHesk_settings = mfh_getSettings();
$on = 'checked="checked"';
} elseif ($hesk_settings['recaptcha_use'] == 2) {
$on2 = 'checked="checked"';
} elseif ($hesk_settings['recaptcha_use'] == 3) {
$on3 = 'checked="checked"';
$div = 'none';
} else {
$off = 'checked="checked"';
$div = 'none';
@ -1471,6 +1475,12 @@ $modsForHesk_settings = mfh_getSettings();
class="fa fa-question-circle settingsquestionmark"></i></a></div>
<br/>
<div class="radio"><label><input type="radio" name="s_recaptcha_use" value="3"
onclick="javascript:hesk_toggleLayer('recaptcha','none')" <?php echo $on3; ?> /> <?php echo $hesklang['sir3']; ?>
</label>
</div>
<br/>
<div id="recaptcha" style="display: <?php echo $div; ?>;">
&nbsp;<br/>

@ -140,7 +140,7 @@ $set['secimg_sum'] = '';
for ($i = 1; $i <= 10; $i++) {
$set['secimg_sum'] .= substr('AEUYBDGHJLMNPQRSTVWXZ123456789', rand(0, 29), 1);
}
$set['recaptcha_use'] = hesk_checkMinMax(intval(hesk_POST('s_recaptcha_use')), 0, 2, 0);
$set['recaptcha_use'] = hesk_checkMinMax(intval(hesk_POST('s_recaptcha_use')), 0, 3, 0);
$set['recaptcha_public_key'] = hesk_input(hesk_POST('s_recaptcha_public_key'));
$set['recaptcha_private_key'] = hesk_input(hesk_POST('s_recaptcha_private_key'));
$set['question_use'] = empty($_POST['s_question_use']) ? 0 : 1;

@ -221,6 +221,10 @@ if (is_dir(HESK_PATH . 'install')) {
echo '<script src="https://www.google.com/recaptcha/api.js?hl=' . $hesklang['RECAPTCHA'] . '" async defer></script>';
}
if (defined('CAPTCHECK')) {
echo '<script src="https://captcheck.netsyms.com/captcheck.js" async defer></script>';
}
if (defined('VALIDATOR')) {
?>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/validation-scripts.js"></script>

@ -216,6 +216,8 @@ function print_add_ticket()
// Tell header to load reCaptcha API if needed
if ($hesk_settings['recaptcha_use'] == 2) {
define('RECAPTCHA', 1);
} else if ($hesk_settings['recaptcha_use'] == 3) {
define('CAPTCHECK', 1);
}
// Get categories
@ -1058,6 +1060,15 @@ function print_add_ticket()
</div>
<?php
}
elseif ($hesk_settings['recaptcha_use'] == 3)
{
?>
<div class="col-md-9">
<div class="captcheck_container">
</div>
</div>
<?php
}
// At least use some basic PHP generated image (better than nothing)
else {
$cls = in_array('mysecnum', $_SESSION['iserror']) ? ' class="isError" ' : '';

@ -1376,7 +1376,8 @@ $hesklang['nkba']='Knowledgebase search requires enough unique articles to work
$hesklang['saa']='Sticky articles are displayed at the top of articles list';
$hesklang['yhbr']='You have been locked out the system for %s minutes because of too many replies to a ticket.';
$hesklang['sir']='ReCaptcha V1 API (old)';
$hesklang['sir2']='ReCaptcha V2 API (recommended)';
$hesklang['sir2']='ReCaptcha V2 API';
$hesklang['sir3']='Captcheck';
$hesklang['rcpb']='Site key (Public key)';
$hesklang['rcpv']='Secret key (Private key)';

@ -114,6 +114,29 @@ if ($hesk_settings['secimg_use'] && !isset($_SESSION['img_verified'])) {
} else {
$hesk_error_buffer['mysecnum'] = $hesklang['recaptcha_error'];
}
} // Using Netsyms Captcheck
elseif ($hesk_settings['recaptcha_use'] == 3) {
$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'] === true) {
$_SESSION['img_verified'] = true;
} else {
$hesk_error_buffer['mysecnum'] = $hesklang['recaptcha_error'];
}
} // Using PHP generated image
else {
$mysecnum = intval(hesk_POST('mysecnum', 0));

Loading…
Cancel
Save