From 7b482a796605f9395e9c90ba63af9c9d435dff51 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Fri, 16 Oct 2020 12:04:32 +0200 Subject: [PATCH] changed counter to count all entries --- app/MetaGer.php | 65 ++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/app/MetaGer.php b/app/MetaGer.php index 4a943ceae..4ea6d383a 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -73,7 +73,10 @@ class MetaGer protected $verificationId; protected $verificationCount; protected $searchUid; - protected $redisResultWaitingKey, $redisResultEngineList, $redisEngineResult, $redisCurrentResultList; + protected $redisResultWaitingKey; + protected $redisResultEngineList; + protected $redisEngineResult; + protected $redisCurrentResultList; public $starttime; public function __construct($hash = "") @@ -258,7 +261,7 @@ class MetaGer $engines = $this->engines; // combine $this->combineResults($engines); - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["combined results"] = microtime(true) - $timings["starttime"]; } // misc (WiP) @@ -280,7 +283,7 @@ class MetaGer return ($a->getRank() < $b->getRank()) ? 1 : -1; }); } - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["sorted results"] = microtime(true) - $timings["starttime"]; } # Validate Results @@ -291,7 +294,7 @@ class MetaGer } } $this->results = $newResults; - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["validated results"] = microtime(true) - $timings["starttime"]; } # Validate Advertisements @@ -306,7 +309,7 @@ class MetaGer $newResults[] = $ad; } $this->ads = $newResults; - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["validated ads"] = microtime(true) - $timings["starttime"]; } #Adgoal Implementation @@ -322,19 +325,19 @@ class MetaGer } } $this->adgoalHash = $this->startAdgoal($this->results); - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["started adgoal"] = microtime(true) - $timings["starttime"]; } } if (!$this->javascript) { $this->adgoalLoaded = $this->parseAdgoal($this->results, $this->adgoalHash, true); - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["parsed adgoal"] = microtime(true) - $timings["starttime"]; } } else { $this->adgoalLoaded = $this->parseAdgoal($this->results, $this->adgoalHash, false); - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["parsed adgoal"] = microtime(true) - $timings["starttime"]; } } @@ -345,7 +348,7 @@ class MetaGer # Human Verification $this->humanVerification($this->results); $this->humanVerification($this->ads); - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["human verification"] = microtime(true) - $timings["starttime"]; } @@ -368,7 +371,7 @@ class MetaGer 'engines' => $this->next, ]; Cache::put($this->getSearchUid(), serialize($this->next), 60 * 60); - if(!empty($timings)){ + if (!empty($timings)) { $timings["prepareResults"]["filled cache"] = microtime(true) - $timings["starttime"]; } } else { @@ -449,7 +452,7 @@ class MetaGer $answer = null; # Hash is true if Adgoal request wasn't started in the first place - if($hash === true){ + if ($hash === true) { return true; } @@ -513,7 +516,6 @@ class MetaGer \App\PrometheusExporter::Duration($requestTime, "adgoal"); } return true; - } public function humanVerification(&$results) @@ -685,7 +687,6 @@ class MetaGer if (!empty($timings)) { $timings["createSearchEngines"]["saved engines"] = microtime(true) - $timings["starttime"]; } - } private function removeAdsFromListIfAdfree(&$sumas) @@ -744,7 +745,6 @@ class MetaGer if (!empty($timings)) { $timings["startSearch"]["searches started"] = microtime(true) - $timings["starttime"]; } - } public function checkCache() @@ -762,7 +762,6 @@ class MetaGer } } } - } # Spezielle Suchen und Sumas @@ -786,7 +785,6 @@ class MetaGer { $engines = []; foreach ($enabledSearchengines as $engineName => $engine) { - if (!isset($engine->{"parser-class"})) { die(var_dump($engine)); } @@ -874,7 +872,7 @@ class MetaGer foreach ($availableFilter as $filterName => $filter) { if (\Request::filled($filter->{"get-parameter"})) { $filter->value = \Request::input($filter->{"get-parameter"}); - } else if (\Cookie::get($this->getFokus() . "_setting_" . $filter->{"get-parameter"}) !== null) { + } elseif (\Cookie::get($this->getFokus() . "_setting_" . $filter->{"get-parameter"}) !== null) { $filter->value = \Cookie::get($this->getFokus() . "_setting_" . $filter->{"get-parameter"}); } } @@ -1018,7 +1016,7 @@ class MetaGer # 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; - if($request->filled("javascript") && is_bool($request->input("javascript"))){ + if ($request->filled("javascript") && is_bool($request->input("javascript"))) { $this->javascript = boolval($request->input("javascript")); $request->request->remove("javascript"); } @@ -1086,7 +1084,7 @@ class MetaGer $this->newtab = $request->input('newtab', 'on'); if ($this->newtab === "on") { $this->newtab = "_blank"; - } else if ($this->framed) { + } elseif ($this->framed) { $this->newtab = "_top"; } else { $this->newtab = "_self"; @@ -1187,7 +1185,7 @@ class MetaGer } } } - } else if ($this->request->filled("ff") || $this->request->filled("ft")) { + } elseif ($this->request->filled("ff") || $this->request->filled("ft")) { $this->request = $this->request->replace($this->request->except(["fc", "ff", "ft"])); } @@ -1268,7 +1266,7 @@ class MetaGer foreach ($this->sumaFile->filter->{"query-filter"} as $filterName => $filter) { if (!empty($filter->{"optional-parameter"}) && $request->filled($filter->{"optional-parameter"})) { $this->queryFilter[$filterName] = $request->input($filter->{"optional-parameter"}); - } else if (preg_match_all("/" . $filter->regex . "/si", $this->q, $matches) > 0) { + } elseif (preg_match_all("/" . $filter->regex . "/si", $this->q, $matches) > 0) { switch ($filter->match) { case "last": $this->queryFilter[$filterName] = $matches[$filter->save][sizeof($matches[$filter->save]) - 1]; @@ -1295,7 +1293,7 @@ class MetaGer if (($request->filled($filter->{"get-parameter"}) && $request->input($filter->{"get-parameter"}) !== "off") || \Cookie::get($this->getFokus() . "_setting_" . $filter->{"get-parameter"}) !== null ) { # If the filter is set via Cookie - $this->parameterFilter[$filterName] = $filter; + $this->parameterFilter[$filterName] = $filter; $this->parameterFilter[$filterName]->value = $request->input($filter->{"get-parameter"}, ''); if (empty($this->parameterFilter[$filterName]->value)) { $this->parameterFilter[$filterName]->value = \Cookie::get($this->getFokus() . "_setting_" . $filter->{"get-parameter"}); @@ -1348,12 +1346,12 @@ class MetaGer $this->hostBlacklist[] = $blacklistElement; } } - } else if (strpos($blacklistString, "*") !== 0) { + } elseif (strpos($blacklistString, "*") !== 0) { $this->hostBlacklist[] = $blacklistString; } } - foreach(Cookie::get() as $key => $value){ - if((stripos($key, $this->fokus.'_blpage') === 0) && (stripos($value, '*.') === false)){ + foreach (Cookie::get() as $key => $value) { + if ((stripos($key, $this->fokus.'_blpage') === 0) && (stripos($value, '*.') === false)) { $this->hostBlacklist[] = $value; } } @@ -1390,12 +1388,12 @@ class MetaGer $this->domainBlacklist[] = substr($blacklistElement, strpos($blacklistElement, "*.") + 2); } } - } else if (strpos($blacklistString, "*.") === 0) { + } elseif (strpos($blacklistString, "*.") === 0) { $this->domainBlacklist[] = substr($blacklistString, strpos($blacklistString, "*.") + 2); } } - foreach(Cookie::get() as $key => $value){ - if(stripos($key, $this->fokus.'_blpage') === 0 && stripos($value, '*.') === 0){ + foreach (Cookie::get() as $key => $value) { + if (stripos($key, $this->fokus.'_blpage') === 0 && stripos($value, '*.') === 0) { $this->domainBlacklist[] = str_replace("*.", "", $value); } } @@ -1744,25 +1742,16 @@ class MetaGer { $cookies = \Cookie::get(); $count = 0; - $checkBlacklist = true; $sumaFile = MetaGer::getLanguageFile(); $sumaFile = json_decode(file_get_contents($sumaFile), true); $foki = array_keys($sumaFile['foki']); foreach ($cookies as $key => $value) { - if (starts_with($key, [$this->getFokus() . "_setting_", $this->getFokus() . "_engine_"])) { + if (starts_with($key, [$this->getFokus() . "_setting_", $this->getFokus() . "_engine_", $this->getFokus() . "_blpage_"])) { $count++; continue; } - if($checkBlacklist){ - foreach($foki as $fokus){ - if(strpos($key, $fokus . '_blpage') === 0){ - $count++; - $checkBlacklist = false; - } - } - } } return $count; } -- GitLab