Commit a2e2b7ca authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

removed noscript block as its incompatible with noscript extension

parent 140c8a24
......@@ -272,7 +272,7 @@ class HumanVerification extends Controller
return redirect('admin/bot');
}
public function browserVerification(Request $request, $javascript = false)
public function browserVerification(Request $request)
{
$key = $request->input("id", "");
......@@ -281,8 +281,8 @@ class HumanVerification extends Controller
abort(404);
}
Redis::connection("cache")->pipeline(function ($redis) use ($key, $javascript) {
$redis->rpush($key, $javascript);
Redis::connection("cache")->pipeline(function ($redis) use ($key) {
$redis->rpush($key, true);
$redis->expire($key, 30);
});
......
......@@ -47,8 +47,7 @@ class BrowserVerification
}
$result = Redis::connection("cache")->blpop($mgv, 5);
if ($result !== null) {
$result = boolval($result[1]);
$request->request->add(["javascript" => $result]);
$request->request->add(["headerPrinted" => false, "jskey" => $mgv]);
return $next($request);
} else {
return redirect("/");
......@@ -65,11 +64,9 @@ class BrowserVerification
$answer = Redis::connection("cache")->blpop($key, 2);
if ($answer !== null) {
$answer = boolval($answer[1]);
$request->request->add(["javascript" => $answer]);
echo (view('layouts.resultpage.resources')->render());
flush();
$request->request->add(["headerPrinted" => true]);
$request->request->add(["headerPrinted" => true, "jskey" => $key]);
return $next($request);
}
......
......@@ -305,6 +305,10 @@ class MetaGer
}
if (!$this->apiAuthorized && !$this->adgoalLoaded) {
if (empty($this->adgoalHash)) {
$js = Redis::connection('cache')->lpop("js" . $this->jskey);
if ($js !== null && boolval($js)) {
$this->javascript = true;
}
$this->adgoalHash = $this->startAdgoal($this->results);
}
if (!$this->javascript) {
......@@ -976,11 +980,12 @@ class MetaGer
}
$this->headerPrinted = $request->input("headerPrinted", false);
$request->request->remove("headerPrinted");
$this->javascript = $request->input("javascript", false);
if ($this->javascript !== true && $this->javascript !== false) {
$this->javascript = false;
}
$request->request->remove("javascript");
# Javascript option will be set by an asynchronious script we will check for it when we are fetching adgoal
# Until then javascript parameter will be false
$this->javascript = false;
$this->jskey = $request->input('jskey', '');
$request->request->remove("jskey");
$this->url = $request->url();
$this->fullUrl = $request->fullUrl();
......
......@@ -2,12 +2,5 @@
<html lang="{!! trans('staticPages.meta.language') !!}">
<head>
<meta charset="UTF-8">
<noscript>
<link rel="stylesheet" href="/index.css?id={{ $key }}">
</noscript>
<script>
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "/index-js.css?id={{ $key }}";
document.head.appendChild(link);
</script>
<link rel="stylesheet" href="/index.css?id={{ $key }}" beforeLoad="console.log('test');">
<script src="/index.js?id={{ $key }}"></script>
<?php
use Illuminate\Support\Facades\Redis;
use Jenssegers\Agent\Agent;
use Prometheus\RenderTextFormat;
......@@ -203,8 +204,20 @@ Route::group(
Route::get('r/metager/{mm}/{pw}/{url}', ['as' => 'humanverification', 'uses' => 'HumanVerification@removeGet']);
Route::post('img/dog.jpg', 'HumanVerification@whitelist');
Route::get('index.css', 'HumanVerification@browserVerification');
Route::get('index-js.css', function (\Illuminate\Http\Request $request) {
return App::make('\App\Http\Controllers\HumanVerification')->browserVerification($request, true);
Route::get('index.js', function () {
$key = Request::input("id", "");
// Verify that key is a md5 checksum
if (!preg_match("/^[a-f0-9]{32}$/", $key)) {
abort(404);
}
Redis::connection("cache")->pipeline(function ($redis) use ($key) {
$redis->rpush("js" . $key, true);
$redis->expire($key, 30);
});
return response(view('layouts.resultpage.verificationCss'), 200)->header("Content-Type", "text/css");
});
Route::get('meta/picture', 'Pictureproxy@get');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment