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

added donation advertisement to random position

parent b9f362f8
...@@ -66,7 +66,7 @@ class MetaGerSearch extends Controller ...@@ -66,7 +66,7 @@ class MetaGerSearch extends Controller
$metager->startSearch($timings); $metager->startSearch($timings);
# Versuchen die Ergebnisse der Quicktips zu laden # Versuchen die Ergebnisse der Quicktips zu laden
if($quicktips !== null) { if ($quicktips !== null) {
$quicktipResults = $quicktips->loadResults(); $quicktipResults = $quicktips->loadResults();
if (!empty($timings)) { if (!empty($timings)) {
$timings["Loaded Quicktip Results"] = microtime(true) - $time; $timings["Loaded Quicktip Results"] = microtime(true) - $time;
...@@ -95,13 +95,13 @@ class MetaGerSearch extends Controller ...@@ -95,13 +95,13 @@ class MetaGerSearch extends Controller
$metager->prepareResults($timings); $metager->prepareResults($timings);
$admitad = []; $admitad = [];
$adgoal = []; $adgoal = [];
if(!$metager->isApiAuthorized() && !$metager->isDummy()){ if (!$metager->isApiAuthorized() && !$metager->isDummy()) {
$newAdmitad = new \App\Models\Admitad($metager); $newAdmitad = new \App\Models\Admitad($metager);
if(!empty($newAdmitad->hash)){ if (!empty($newAdmitad->hash)) {
$admitad[] = $newAdmitad; $admitad[] = $newAdmitad;
} }
$newAdgoal = new \App\Models\Adgoal($metager); $newAdgoal = new \App\Models\Adgoal($metager);
if(!empty($newAdgoal->hash)){ if (!empty($newAdgoal->hash)) {
$adgoal[] = $newAdgoal; $adgoal[] = $newAdgoal;
} }
} }
...@@ -109,6 +109,11 @@ class MetaGerSearch extends Controller ...@@ -109,6 +109,11 @@ class MetaGerSearch extends Controller
$metager->parseAffiliates($admitad); $metager->parseAffiliates($admitad);
$metager->parseAffiliates($adgoal); $metager->parseAffiliates($adgoal);
// Add Advertisement for Donations
if (!$metager->isApiAuthorized() && !$metager->isDummy()) {
$metager->addDonationAdvertisement();
}
$finished = true; $finished = true;
foreach ($metager->getEngines() as $engine) { foreach ($metager->getEngines() as $engine) {
if ($engine->loaded) { if ($engine->loaded) {
...@@ -153,7 +158,7 @@ class MetaGerSearch extends Controller ...@@ -153,7 +158,7 @@ class MetaGerSearch extends Controller
// This might speed up page view time for users with slow network // This might speed up page view time for users with slow network
$responseArray = str_split($resultpage->render(), 1024); $responseArray = str_split($resultpage->render(), 1024);
foreach ($responseArray as $responsePart) { foreach ($responseArray as $responsePart) {
echo($responsePart); echo ($responsePart);
flush(); flush();
} }
$requestTime = microtime(true) - $time; $requestTime = microtime(true) - $time;
...@@ -223,13 +228,13 @@ class MetaGerSearch extends Controller ...@@ -223,13 +228,13 @@ class MetaGerSearch extends Controller
$metager->rankAll(); $metager->rankAll();
$metager->prepareResults(); $metager->prepareResults();
if(!$metager->isApiAuthorized() && !$metager->isDummy()){ if (!$metager->isApiAuthorized() && !$metager->isDummy()) {
$newAdmitad = new \App\Models\Admitad($metager); $newAdmitad = new \App\Models\Admitad($metager);
if(!empty($newAdmitad->hash)){ if (!empty($newAdmitad->hash)) {
$admitad[] = $newAdmitad; $admitad[] = $newAdmitad;
} }
$newAdgoal = new \App\Models\Adgoal($metager); $newAdgoal = new \App\Models\Adgoal($metager);
if(!empty($newAdgoal->hash)){ if (!empty($newAdgoal->hash)) {
$adgoal[] = $newAdgoal; $adgoal[] = $newAdgoal;
} }
} }
......
...@@ -310,6 +310,7 @@ class MetaGer ...@@ -310,6 +310,7 @@ class MetaGer
} }
$newResults[] = $ad; $newResults[] = $ad;
} }
$this->ads = $newResults; $this->ads = $newResults;
if (!empty($timings)) { if (!empty($timings)) {
$timings["prepareResults"]["validated ads"] = microtime(true) - $timings["starttime"]; $timings["prepareResults"]["validated ads"] = microtime(true) - $timings["starttime"];
...@@ -446,6 +447,29 @@ class MetaGer ...@@ -446,6 +447,29 @@ class MetaGer
return $finished; return $finished;
} }
public function addDonationAdvertisement()
{
// ToDo: Translate Strings
$donationAd = new \App\Models\Result(
"MetaGer",
__("metaGer.ads.own.title"),
LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route("spende")),
LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route("spende")),
__("metaGer.ads.own.description"),
"MetaGer",
"https://metager.de",
1
);
$adCount = sizeof($this->ads);
// Put Donation Advertisement to random position
$position = random_int(1, max($adCount, 1)) - 1;
$this->ads = array_slice($this->ads, 0, $position) +
[$donationAd] +
array_slice($this->ads, $position, $adCount - 1);
}
public function humanVerification(&$results) public function humanVerification(&$results)
{ {
# Let's check if we need to implement a redirect for human verification # Let's check if we need to implement a redirect for human verification
......
...@@ -139,4 +139,7 @@ return [ ...@@ -139,4 +139,7 @@ return [
"filter.max" => "Maximum Sleep (in s)", "filter.max" => "Maximum Sleep (in s)",
"settings" => "Einstellungen", "settings" => "Einstellungen",
"ads.own.title" => "Jetzt MetaGer unterstützen",
"ads.own.description" => "Mit Ihrer Spende unterstützen Sie den Erhalt und die Weiterentwicklung der unabhängigen Suchmaschine metager.de und die Arbeit des gemeinnützigen Trägervereins SUMA-EV.",
]; ];
...@@ -139,4 +139,7 @@ return [ ...@@ -139,4 +139,7 @@ return [
"filter.max" => "Maximum sleep (in s)", "filter.max" => "Maximum sleep (in s)",
"settings" => "Settings", "settings" => "Settings",
"ads.own.title" => "Support MetaGer",
"ads.own.description" => "With your donation you support the maintenance and further development of the independent search engine metager.de and the work of the non-profit association SUMA-EV.",
]; ];
<?php <?php
return [ return [
"results.failed" => "Lo sentimos. No encontrado resultados adecuados.", "results.failed" => "Lo sentimos. No encontrado resultados adecuados.",
"settings.noneSelected" => "¡Guarda! No habéis seleccionado un motor de busqueda.", "settings.noneSelected" => "¡Guarda! No habéis seleccionado un motor de busqueda.",
"engines.noParser" => "Falta: Preguntar :engine. Por favor notificáis MetaGer: <a href=\"/es/kontakt\">Formulario encriptado</a>", "engines.noParser" => "Falta: Preguntar :engine. Por favor notificáis MetaGer: <a href=\"/es/kontakt\">Formulario encriptado</a>",
"formdata.noSearch" => "¡Guarda! No insertado palabras para buscar.", "formdata.noSearch" => "¡Guarda! No insertado palabras para buscar.",
"formdata.hostBlacklist" => "No recibís resultados del host \":host\"", "formdata.hostBlacklist" => "No recibís resultados del host \":host\"",
"formdata.domainBlacklist" => "No recibís resultados del dominio: \":domain\"", "formdata.domainBlacklist" => "No recibís resultados del dominio: \":domain\"",
"formdata.stopwords" => "Resultados sin \":stopwords\"", "formdata.stopwords" => "Resultados sin \":stopwords\"",
"formdata.phrase" => "Resultados \":phrase\"", "formdata.phrase" => "Resultados \":phrase\"",
"sitesearch.failed" => "Habéis querido una búsqueda en \":site\". Los motores de busqueda seleccioados no tienen resultados. Podéis hacer el sitesearch en el foco \"Web\": <a href=\":searchLink\">hier</a> ", "sitesearch.failed" => "Habéis querido una búsqueda en \":site\". Los motores de busqueda seleccioados no tienen resultados. Podéis hacer el sitesearch en el foco \"Web\": <a href=\":searchLink\">hier</a> ",
"sitesearch.success" => "Habéis querido una búsqueda \"sitesearch\". Recibís resultados solo de <a href=\"http://:site\" target=\"_blank\" rel=\"noopener\">\":site\"</a> ." "sitesearch.success" => "Habéis querido una búsqueda \"sitesearch\". Recibís resultados solo de <a href=\"http://:site\" target=\"_blank\" rel=\"noopener\">\":site\"</a> .",
];
\ No newline at end of file "ads.own.title" => "Apoya a MetaGer",
"ads.own.description" => "Con su donación, apoya el mantenimiento y desarrollo del motor de búsqueda independiente metager.de y el trabajo de la asociación patrocinadora sin fines de lucro SUMA-EV.",
];
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