Fixed captcha and various improvements

This commit is contained in:
genuineparts 2025-06-04 10:21:08 +02:00
parent 26732d5cd8
commit d032d1e427
4 changed files with 56 additions and 54 deletions

View file

@ -27,8 +27,7 @@ class captcha{
function getCaptcha(){
global $config;
if($config['captcha']==1) {
//return '<div id="mcaptcha__widget-container"><label mcaptcha_url="https://'.$config['mcaptcha_url'].'/widget/?sitekey='.$config['mcaptcha_sitekey'].'" for="mcaptcha__token" id="mcaptcha__token-label"><input type="text" name="mcaptcha__token" id="mcaptcha__token" /></label></div><script src="https://unpkg.com/@mcaptcha/vanilla-glue@0.1.0-rc2/dist/index.js"></script>';
return '<input type="text" name="shift" id="mcaptcha__token"><label data-mcaptcha_url="https://'.$config['mcaptcha_url'].'/widget/?sitekey='.$config['mcaptcha_sitekey'].'" for="mcaptcha__token" id="mcaptcha__token-label">mCaptcha authorization token.<a href="https://mcaptcha.org/docs/user-manual/how-to-mcaptcha-without-js/">Instructions</a>.</label><input type="text" name="mcaptcha__token"><div id="mcaptcha__widget-container"></div><script src="https://unpkg.com/@mcaptcha/vanilla-glue@0.1.0-rc2/dist/index.js"></script>';
return '<label data-mcaptcha_url="https://'.$config['mcaptcha_url'].'/widget/?sitekey='.$config['mcaptcha_sitekey'].'" for="mcaptcha__token" id="mcaptcha__token-label">mCaptcha authorization token.<a href="https://mcaptcha.org/docs/user-manual/how-to-mcaptcha-without-js/">Instructions</a>.<input type="text" name="mcaptcha__token" id="mcaptcha__token" /></label><div id="mcaptcha__widget-container"></div> <script src="https://unpkg.com/@mcaptcha/vanilla-glue@0.1.0-rc2/dist/index.js"></script>';
} else if ($config['captcha']==2) {
return '<script src="https://www.google.com/recaptcha/api.js"></script><div class="g-recaptcha" data-sitekey="'.$config['recaptcha_sitekey'].'"></div>';
} else {
@ -37,9 +36,8 @@ class captcha{
}
function validate($response){
global $config;
global $config,$functions;
if($config['captcha']==1) {
var_dump($response);
if(isset($response['mcaptcha__token']) && $response['mcaptcha__token']!=''){
$token = $response['mcaptcha__token'];
} else {
@ -65,19 +63,17 @@ class captcha{
// schließe den cURL-Handle und gebe die Systemresourcen frei
curl_close($ch);
var_dump($fh);
if(!$fh){
return false;
}else{
$response = json_decode($fh, true);
if($response["valid"] !== true){
$cresp = json_decode($fh, true);
if($cresp["valid"] === true){
return true;
}else{
return false;
}
}
}else if($config['captcha']==2) {
var_dump($response);
if(isset($response['g-recaptcha-response']) && $response['g-recaptcha-response']!=''){
$data = $response['g-recaptcha-response'];
} else {
@ -95,12 +91,11 @@ class captcha{
// schließe den cURL-Handle und gebe die Systemresourcen frei
curl_close($ch);
if(!$fh){
return false;
}else{
$response = json_decode($fh, true);
if($response["success"] !== true){
$cresp = json_decode($fh, true);
if($cresp["success"] === true){
return true;
}else{
return false;

View file

@ -1,9 +1,9 @@
<?php
$module["session"]["name"]="Sessionmanagement Module";
$module["session"]["ver"]="0.9.0";
$module["session"]["ver"]="0.9.1";
/**
* Project: astat - simple site engine
* File: /inc/sessions.class.php
* File: /inc/sessions.class.php
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -187,8 +187,15 @@ class session {
if((isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS'])) || $https){
$https = true;
}
setcookie($name, $data, $validto, $path, $domain,$httponly,$https);
$arr_cookie_options = array (
'expires' => $validto,
'path' => $path,
'domain' => $domain, // leading dot for compatibility or use subdomain
'secure' => $https, // or false
'httponly' => $httponly, // or false
'samesite' => 'Strict' // None || Lax || Strict
);
setcookie($name, $data, $arr_cookie_options);
}
function update_session($sid, $uid=''){