Skip to content
Snippets Groups Projects
Commit a6deb4b3 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

logging solves

parent b570e7f1
No related branches found
No related tags found
1 merge request!1992Resolve "Include Audiocaptcha"
......@@ -56,10 +56,6 @@ class HumanVerification extends Controller
$tts_url = TTSController::CreateTTSUrl($text, LaravelLocalization::getCurrentLocale());
# $captcha = Captcha::create("default", true);
# $key = Crypt::decrypt($captcha["key"]);
\App\PrometheusExporter::CaptchaShown();
return view('humanverification.captcha')->with('title', 'Bestätigung notwendig')
->with('url', $redirect_url)
......@@ -117,6 +113,20 @@ class HumanVerification extends Controller
$params = array();
}
$query = isset($params["eingabe"]) ? $params["eingabe"] : "";
$time = 0;
if ($request->filled("begin")) {
$time = $request->input("begin");
$time = \filter_var($time, \FILTER_VALIDATE_FLOAT);
if ($time === false) {
$time = 0;
} else {
$time = microtime(true) - $time;
}
}
self::logCaptchaSolve($query, $time);
$params['token'] = $token; // Overwrite if exists
// Note that this will url_encode all values
......@@ -135,6 +145,22 @@ class HumanVerification extends Controller
}
}
private static function logCaptchaSolve(string $query, float $time)
{
$log = [
now()->format("Y-m-d H:i:s"),
$query,
"time=" . $time,
];
$file_path = \storage_path("logs/metager/captcha_solve.csv");
$fh = fopen($file_path, "a");
try {
\fputcsv($fh, $log);
} finally {
fclose($fh);
}
}
public static function logCaptcha(Request $request)
{
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
......
......@@ -94,7 +94,6 @@ class HumanVerification
return $next($request);
}
// TODO remove function
private function logCaptcha(\Illuminate\Http\Request $request)
{
$log = [
......@@ -102,13 +101,12 @@ class HumanVerification
$request->input("eingabe"),
"js=" . \app()->make(SearchSettings::class)->javascript_enabled,
];
$file_path = \storage_path("logs/metager/captcha.csv");
$file_path = \storage_path("logs/metager/captcha_show.csv");
$fh = fopen($file_path, "a");
try {
\fputcsv($fh, $log);
} finally {
fclose($fh);
}
// Temporary Log to test new functionality. Will be removed again soon
}
}
......@@ -7,6 +7,7 @@
<p>@lang('captcha.2')</p>
<form method="post" action="{{ route('captcha_solve') }}">
<input type="hidden" name="url" value="{!! $url !!}">
<input type="hidden" name="begin" value="{{ \microtime(true) }}">
<input type="hidden" name="c" value="{{ $correct }}">
<div id="captcha-container">
<img src="{{ $image }}" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment