From 893b774e4ab0cb49c60206edeb200ace3a1efd3d Mon Sep 17 00:00:00 2001 From: Dominik Pfennig <dominik@suma-ev.de> Date: Wed, 17 Aug 2016 09:32:47 +0200 Subject: [PATCH] =?UTF-8?q?Datenschutzerkl=C3=A4rung=20erweitert=20und=20e?= =?UTF-8?q?inige=20Formatierungen=20durchgef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetaGer.php | 941 +++++++++--------- app/Models/Result.php | 488 +++++---- app/Models/Searchengine.php | 525 +++++----- app/Models/parserSkripte/Allesklar.php | 99 +- app/Models/parserSkripte/BASE.php | 49 +- app/Models/parserSkripte/Beammachine.php | 74 +- app/Models/parserSkripte/Bing.php | 79 +- app/Models/parserSkripte/Bing_bilder.php | 64 +- app/Models/parserSkripte/Dart.php | 114 ++- app/Models/parserSkripte/Dmoznebel.php | 79 +- app/Models/parserSkripte/Dmoznebel_int.php | 51 +- app/Models/parserSkripte/Ebay.php | 117 +-- app/Models/parserSkripte/Ecoshopper.php | 105 +- app/Models/parserSkripte/Europeana.php | 110 +- app/Models/parserSkripte/Exalead.php | 137 ++- app/Models/parserSkripte/Fairmondo.php | 88 +- app/Models/parserSkripte/Fastbot.php | 79 +- app/Models/parserSkripte/Fernsehsuche.php | 81 +- app/Models/parserSkripte/Flickr.php | 84 +- app/Models/parserSkripte/Goyax.php | 66 +- app/Models/parserSkripte/Loklak.php | 68 +- app/Models/parserSkripte/Mg_hochsch_de.php | 76 +- app/Models/parserSkripte/Mg_produkt2.php | 90 +- app/Models/parserSkripte/Minisucher.php | 132 ++- app/Models/parserSkripte/Mnogosearch.php | 85 +- app/Models/parserSkripte/Nebel.php | 73 +- app/Models/parserSkripte/Onenewspage.php | 76 +- .../parserSkripte/Onenewspagegermany.php | 69 +- app/Models/parserSkripte/Onenewspagevideo.php | 66 +- app/Models/parserSkripte/Openclipart.php | 84 +- .../parserSkripte/Opencrawlastronomie.php | 93 +- .../parserSkripte/Opencrawlregengergie.php | 93 +- app/Models/parserSkripte/Opencrawltauchen.php | 91 +- app/Models/parserSkripte/Overture.php | 115 ++- app/Models/parserSkripte/OvertureAds.php | 78 +- app/Models/parserSkripte/Pixabay.php | 82 +- app/Models/parserSkripte/Qip.php | 76 +- app/Models/parserSkripte/Qualigo.php | 70 +- app/Models/parserSkripte/Similar_product.php | 56 +- .../parserSkripte/Similar_product_ads.php | 70 +- app/Models/parserSkripte/Suchticker.php | 76 +- app/Models/parserSkripte/Tuhh.php | 89 +- app/Models/parserSkripte/Wikipedia.php | 45 +- app/Models/parserSkripte/Witch.php | 26 +- app/Models/parserSkripte/Yacy.php | 30 +- app/Models/parserSkripte/Yacyunih.php | 99 +- app/Models/parserSkripte/Yandex.php | 94 +- app/Models/parserSkripte/Zeitde.php | 80 +- resources/lang/de/datenschutz.php | 64 +- resources/views/datenschutz.blade.php | 5 +- 50 files changed, 2788 insertions(+), 2893 deletions(-) diff --git a/app/MetaGer.php b/app/MetaGer.php index 405ea65a7..a10e35576 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -1,105 +1,96 @@ <?php namespace App; -use Illuminate\Http\Request; -use Jenssegers\Agent\Agent; use App; -use Storage; -use Log; -use Config; -use Redis; use App\lib\TextLanguageDetect\TextLanguageDetect; -use App\lib\TextLanguageDetect\LanguageDetect\TextLanguageDetectException; +use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Collection; +use Jenssegers\Agent\Agent; use LaravelLocalization; +use Log; +use Redis; class MetaGer { - # Einstellungen für die Suche - protected $fokus; - protected $eingabe; - protected $q; - protected $category; - protected $time; - protected $page; - protected $lang; - protected $cache = ""; - protected $site; - protected $hostBlacklist = []; - protected $domainBlacklist = []; - protected $stopWords = []; - protected $phrases = []; - protected $engines = []; - protected $results = []; - protected $ads = []; - protected $warnings = []; - protected $errors = []; - protected $addedHosts = []; - # Daten über die Abfrage - protected $ip; - protected $language; - protected $agent; - # Konfigurationseinstellungen: - protected $sumaFile; - protected $mobile; - protected $resultCount; - protected $sprueche; + # Einstellungen für die Suche + protected $fokus; + protected $eingabe; + protected $q; + protected $category; + protected $time; + protected $page; + protected $lang; + protected $cache = ""; + protected $site; + protected $hostBlacklist = []; + protected $domainBlacklist = []; + protected $stopWords = []; + protected $phrases = []; + protected $engines = []; + protected $results = []; + protected $ads = []; + protected $warnings = []; + protected $errors = []; + protected $addedHosts = []; + # Daten über die Abfrage + protected $ip; + protected $language; + protected $agent; + # Konfigurationseinstellungen: + protected $sumaFile; + protected $mobile; + protected $resultCount; + protected $sprueche; protected $domainsBlacklisted = []; - protected $urlsBlacklisted = []; + protected $urlsBlacklisted = []; protected $url; protected $languageDetect; - function __construct() - { - $this->starttime = microtime(true); - if( file_exists(config_path() . "/blacklistDomains.txt") && file_exists(config_path() . "/blacklistUrl.txt") ) - { + public function __construct() + { + $this->starttime = microtime(true); + if (file_exists(config_path() . "/blacklistDomains.txt") && file_exists(config_path() . "/blacklistUrl.txt")) { # Blacklists einlesen: - $tmp = file_get_contents(config_path() . "/blacklistDomains.txt"); + $tmp = file_get_contents(config_path() . "/blacklistDomains.txt"); $this->domainsBlacklisted = explode("\n", $tmp); - $tmp = file_get_contents(config_path() . "/blacklistUrl.txt"); - $this->urlsBlacklisted = explode("\n", $tmp); - }else - { + $tmp = file_get_contents(config_path() . "/blacklistUrl.txt"); + $this->urlsBlacklisted = explode("\n", $tmp); + } else { Log::warning("Achtung: Eine, oder mehrere Blacklist Dateien, konnten nicht geöffnet werden"); } $this->languageDetect = new TextLanguageDetect(); $this->languageDetect->setNameMode("2"); - } + } - public function getHashCode () + public function getHashCode() { $string = url()->full(); return md5($string); } - public function rankAll () + public function rankAll() { - foreach( $this->engines as $engine ) - { + foreach ($this->engines as $engine) { $engine->rank($this); } } - public function createView() - { - $viewResults = []; + public function createView() + { + $viewResults = []; # Wir extrahieren alle notwendigen Variablen und geben Sie an unseren View: - foreach($this->results as $result) - { + foreach ($this->results as $result) { $viewResults[] = get_object_vars($result); } # Wir müssen natürlich noch den Log für die durchgeführte Suche schreiben: $this->createLogs(); - if( $this->fokus === "bilder" ) - { - switch ($this->out) - { + if ($this->fokus === "bilder") { + switch ($this->out) { case 'results': return view('metager3bilderresults') ->with('results', $viewResults) @@ -153,7 +144,7 @@ class MetaGer ->with('browser', (new Agent())->browser()); break; } - } + } private function createLogs() { @@ -161,87 +152,94 @@ class MetaGer try { $logEntry = ""; - $logEntry .= "[" . date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))) . "]"; + $logEntry .= "[" . date(DATE_RFC822, mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"))) . "]"; $logEntry .= " pid=" . getmypid(); $logEntry .= " ref=" . $this->request->header('Referer'); $useragent = $this->request->header('User-Agent'); $useragent = str_replace("(", " ", $useragent); $useragent = str_replace(")", " ", $useragent); $useragent = str_replace(" ", "", $useragent); - $logEntry .= " time=" . round((microtime(true)-$this->starttime), 2) . " serv=" . $this->fokus; + $logEntry .= " time=" . round((microtime(true) - $this->starttime), 2) . " serv=" . $this->fokus; $logEntry .= " search=" . $this->eingabe; $redis->rpush('logs.search', $logEntry); - }catch( \Exception $e) - { + } catch (\Exception $e) { return; } } - public function removeInvalids () + public function removeInvalids() { $results = []; - foreach($this->results as $result) - { - if($result->isValid($this)) + foreach ($this->results as $result) { + if ($result->isValid($this)) { $results[] = $result; + } + } #$this->results = $results; } - public function combineResults () - { - foreach($this->engines as $engine) - { - foreach($engine->results as $result) - { - if($result->valid) + public function combineResults() + { + foreach ($this->engines as $engine) { + foreach ($engine->results as $result) { + if ($result->valid) { $this->results[] = $result; + } + } - foreach($engine->ads as $ad) - { + foreach ($engine->ads as $ad) { $this->ads[] = $ad; } - } - uasort($this->results, function($a, $b){ - if($a->getRank() == $b->getRank()) + } + uasort($this->results, function ($a, $b) { + if ($a->getRank() == $b->getRank()) { return 0; + } + return ($a->getRank() < $b->getRank()) ? 1 : -1; }); # Validate Results $newResults = []; - foreach($this->results as $result) - { - if($result->isValid($this)) + foreach ($this->results as $result) { + if ($result->isValid($this)) { $newResults[] = $result; + } + } $this->results = $newResults; - $counter = 0; + $counter = 0; $firstRank = 0; - foreach($this->results as $result) - { - if($counter === 0) + foreach ($this->results as $result) { + if ($counter === 0) { $firstRank = $result->rank; + } + $counter++; $result->number = $counter; - $confidence = 0; - if($firstRank > 0) - $confidence = $result->rank/$firstRank; - else + $confidence = 0; + if ($firstRank > 0) { + $confidence = $result->rank / $firstRank; + } else { $confidence = 0; - if($confidence > 0.65) + } + + if ($confidence > 0.65) { $result->color = "#FF4000"; - elseif($confidence > 0.4) + } elseif ($confidence > 0.4) { $result->color = "#FF0080"; - elseif($confidence > 0.2) + } elseif ($confidence > 0.2) { $result->color = "#C000C0"; - else + } else { $result->color = "#000000"; + } + } //Get current page form url e.g. &page=6 $currentPage = LengthAwarePaginator::resolveCurrentPage(); - $offset= $currentPage-1; + $offset = $currentPage - 1; //Create a new Laravel collection from the array data $collection = new Collection($this->results); @@ -259,72 +257,63 @@ class MetaGer $currentPageSearchResults = $this->parseAdgoal($currentPageSearchResults); //Create our paginator and pass it to the view - $paginatedSearchResults= new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage); + $paginatedSearchResults = new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage); $paginatedSearchResults->setPath('/meta/meta.ger3'); - foreach($this->request->all() as $key => $value) - { - if( $key === "out" ) + foreach ($this->request->all() as $key => $value) { + if ($key === "out") { continue; + } + $paginatedSearchResults->addQuery($key, $value); } $this->results = $paginatedSearchResults; - if( LaravelLocalization::getCurrentLocale() === "en" ) - { + if (LaravelLocalization::getCurrentLocale() === "en") { $this->ads = []; } $this->validated = false; - if( isset($this->password) ) - { + if (isset($this->password)) { # Wir bieten einen bezahlten API-Zugriff an, bei dem dementsprechend die Werbung ausgeblendet wurde: # Aktuell ist es nur die Uni-Mainz. Deshalb überprüfen wir auch nur diese. $password = getenv('mainz'); - $eingabe = $this->eingabe; + $eingabe = $this->eingabe; $password = md5($eingabe . $password); - if( $this->password === $password ) - { - $this->ads = []; + if ($this->password === $password) { + $this->ads = []; $this->validated = true; } } - } + } public function parseBoost($results) { - foreach($results as $result) - { - if(preg_match('/^(http[s]?\:\/\/)?(www.)?amazon\.de/',$result->anzeigeLink)) - { - if(preg_match('/\?/',$result->anzeigeLink)) - { - $result->link .= '&tag=boostmg01-21'; - } else - { - $result->link .= '?tag=boostmg01-21'; - } - $result->partnershop = true; - - } - } - return $results; + foreach ($results as $result) { + if (preg_match('/^(http[s]?\:\/\/)?(www.)?amazon\.de/', $result->anzeigeLink)) { + if (preg_match('/\?/', $result->anzeigeLink)) { + $result->link .= '&tag=boostmg01-21'; + } else { + $result->link .= '?tag=boostmg01-21'; + } + $result->partnershop = true; + + } + } + return $results; } public function parseAdgoal($results) { - $publicKey = getenv('adgoal_public'); + $publicKey = getenv('adgoal_public'); $privateKey = getenv('adgoal_private'); - if( $publicKey === FALSE ) - { + if ($publicKey === false) { return $results; } $tldList = ""; - try{ - foreach($results as $result) - { + try { + foreach ($results as $result) { $link = $result->anzeigeLink; - if(strpos($link, "http") !== 0) - { + if (strpos($link, "http") !== 0) { $link = "http://" . $link; } $tldList .= parse_url($link, PHP_URL_HOST) . ","; @@ -335,105 +324,103 @@ class MetaGer # Hashwert $hash = md5("meta" . $publicKey . $tldList . "GER"); - # Query + # Query $query = urlencode($this->q); - $link = "https://api.smartredirect.de/api_v2/CheckForAffiliateUniversalsearchMetager.php?p=" . $publicKey . "&k=" . $hash . "&tld=" . $tldList . "&q=" . $query; + $link = "https://api.smartredirect.de/api_v2/CheckForAffiliateUniversalsearchMetager.php?p=" . $publicKey . "&k=" . $hash . "&tld=" . $tldList . "&q=" . $query; $answer = json_decode(file_get_contents($link)); - # Nun müssen wir nur noch die Links für die Advertiser ändern: - foreach($answer as $el) - { + foreach ($answer as $el) { $hoster = $el[0]; - $hash = $el[1]; + $hash = $el[1]; - foreach($results as $result) - { - if( $hoster === $result->tld ) - { + foreach ($results as $result) { + if ($hoster === $result->tld) { # Hier ist ein Advertiser: # Das Logo hinzufügen: - if( $result->image !== "" ) + if ($result->image !== "") { $result->logo = "https://img.smartredirect.de/logos_v2/60x30/" . $hash . ".gif"; - else + } else { $result->image = "https://img.smartredirect.de/logos_v2/120x60/" . $hash . ".gif"; + } + # Den Link hinzufügen: $publicKey = $publicKey; $targetUrl = $result->anzeigeLink; - if(strpos($targetUrl, "http") !== 0) + if (strpos($targetUrl, "http") !== 0) { $targetUrl = "http://" . $targetUrl; - $gateHash = md5($targetUrl . $privateKey); - $newLink = "https://api.smartredirect.de/api_v2/ClickGate.php?p=" . $publicKey . "&k=" . $gateHash . "&url=" . urlencode($targetUrl) . "&q=" . $query; - $result->link = $newLink; + } + + $gateHash = md5($targetUrl . $privateKey); + $newLink = "https://api.smartredirect.de/api_v2/ClickGate.php?p=" . $publicKey . "&k=" . $gateHash . "&url=" . urlencode($targetUrl) . "&q=" . $query; + $result->link = $newLink; $result->partnershop = true; } } } - }catch(\ErrorException $e) - { + } catch (\ErrorException $e) { return $results; } return $results; } - public function createSearchEngines (Request $request) - { + public function createSearchEngines(Request $request) + { - if( !$request->has("eingabe") ) + if (!$request->has("eingabe")) { return; + } - # Ãœberprüfe, welche Sumas eingeschaltet sind - $xml = simplexml_load_file($this->sumaFile); + # Ãœberprüfe, welche Sumas eingeschaltet sind + $xml = simplexml_load_file($this->sumaFile); $enabledSearchengines = []; - $overtureEnabled = FALSE; - $countSumas = 0; - $sumas = $xml->xpath("suma"); - if($this->fokus === "angepasst") - { - foreach($sumas as $suma) - { - if($request->has($suma["name"]) - || ( $this->fokus !== "bilder" - && ($suma["name"]->__toString() === "qualigo" - || $suma["name"]->__toString() === "similar_product_ads" - || ( !$overtureEnabled && $suma["name"]->__toString() === "overtureAds" ) - ) - ) - ){ - - if(!(isset($suma['disabled']) && $suma['disabled']->__toString() === "1")) - { - if($suma["name"]->__toString() === "overture" || $suma["name"]->__toString() === "overtureAds") - { - $overtureEnabled = TRUE; + $overtureEnabled = false; + $countSumas = 0; + $sumas = $xml->xpath("suma"); + if ($this->fokus === "angepasst") { + foreach ($sumas as $suma) { + if ($request->has($suma["name"]) + || ($this->fokus !== "bilder" + && ($suma["name"]->__toString() === "qualigo" + || $suma["name"]->__toString() === "similar_product_ads" + || (!$overtureEnabled && $suma["name"]->__toString() === "overtureAds") + ) + ) + ) { + + if (!(isset($suma['disabled']) && $suma['disabled']->__toString() === "1")) { + if ($suma["name"]->__toString() === "overture" || $suma["name"]->__toString() === "overtureAds") { + $overtureEnabled = true; } - if( $suma["name"]->__toString() !== "qualigo" && $suma["name"]->__toString() !== "similar_product_ads" && $suma["name"]->__toString() !== "overtureAds" ) + if ($suma["name"]->__toString() !== "qualigo" && $suma["name"]->__toString() !== "similar_product_ads" && $suma["name"]->__toString() !== "overtureAds") { $countSumas += 1; + } + $enabledSearchengines[] = $suma; } } } - }else{ - foreach($sumas as $suma){ - $types = explode(",",$suma["type"]); - if(in_array($this->fokus, $types) - || ( $this->fokus !== "bilder" - && ($suma["name"]->__toString() === "qualigo" - || $suma["name"]->__toString() === "similar_product_ads" - || ( !$overtureEnabled && $suma["name"]->__toString() === "overtureAds" ) - ) - ) - ){ - if(!(isset($suma['disabled']) && $suma['disabled']->__toString() === "1")) - { - if($suma["name"]->__toString() === "overture" || $suma["name"]->__toString() === "overtureAds") - { - $overtureEnabled = TRUE; + } else { + foreach ($sumas as $suma) { + $types = explode(",", $suma["type"]); + if (in_array($this->fokus, $types) + || ($this->fokus !== "bilder" + && ($suma["name"]->__toString() === "qualigo" + || $suma["name"]->__toString() === "similar_product_ads" + || (!$overtureEnabled && $suma["name"]->__toString() === "overtureAds") + ) + ) + ) { + if (!(isset($suma['disabled']) && $suma['disabled']->__toString() === "1")) { + if ($suma["name"]->__toString() === "overture" || $suma["name"]->__toString() === "overtureAds") { + $overtureEnabled = true; } - if( $suma["name"]->__toString() !== "qualigo" && $suma["name"]->__toString() !== "similar_product_ads" && $suma["name"]->__toString() !== "overtureAds" ) + if ($suma["name"]->__toString() !== "qualigo" && $suma["name"]->__toString() !== "similar_product_ads" && $suma["name"]->__toString() !== "overtureAds") { $countSumas += 1; + } + $enabledSearchengines[] = $suma; } } @@ -442,71 +429,63 @@ class MetaGer # Sonderregelung für alle Suchmaschinen, die zu den Minisuchern gehören. Diese können alle gemeinsam über einen Link abgefragt werden $subcollections = []; - $tmp = []; - foreach($enabledSearchengines as $engine ) - { - if( isset($engine['minismCollection']) ) + $tmp = []; + foreach ($enabledSearchengines as $engine) { + if (isset($engine['minismCollection'])) { $subcollections[] = $engine['minismCollection']->__toString(); - else + } else { $tmp[] = $engine; + } + } $enabledSearchengines = $tmp; - if( sizeof($subcollections) > 0) - { - $count = sizeof($subcollections) * 10; - $minisucherEngine = $xml->xpath('suma[@name="minism"]')[0]; - $subcollections = urlencode("(" . implode(" OR ", $subcollections) . ")"); + if (sizeof($subcollections) > 0) { + $count = sizeof($subcollections) * 10; + $minisucherEngine = $xml->xpath('suma[@name="minism"]')[0]; + $subcollections = urlencode("(" . implode(" OR ", $subcollections) . ")"); $minisucherEngine["formData"] = str_replace("<<SUBCOLLECTIONS>>", $subcollections, $minisucherEngine["formData"]); $minisucherEngine["formData"] = str_replace("<<COUNT>>", $count, $minisucherEngine["formData"]); - $enabledSearchengines[] = $minisucherEngine; + $enabledSearchengines[] = $minisucherEngine; } #die(var_dump($enabledSearchengines)); - if( $countSumas <= 0 ) - { + if ($countSumas <= 0) { $this->errors[] = "Achtung: Sie haben in ihren Einstellungen keine Suchmaschine ausgewählt."; } - $engines = []; + $engines = []; $siteSearchFailed = false; - if( strlen($this->site) > 0 ) - { + if (strlen($this->site) > 0) { # Wenn eine Sitesearch durchgeführt werden soll, überprüfen wir ob eine der Suchmaschinen überhaupt eine Sitesearch unterstützt: $enginesWithSite = 0; - foreach($enabledSearchengines as $engine) - { - if( isset($engine['hasSiteSearch']) && $engine['hasSiteSearch']->__toString() === "1" ) - { + foreach ($enabledSearchengines as $engine) { + if (isset($engine['hasSiteSearch']) && $engine['hasSiteSearch']->__toString() === "1") { $enginesWithSite++; } } - if( $enginesWithSite === 0 ) - { - $this->errors[] = "Sie wollten eine Sitesearch auf " . $this->site . " durchführen. Leider unterstützen die eingestellten Suchmaschinen diese nicht. Sie können <a href=\"" . $this->generateSearchLink("web", false) . "\">hier</a> die Sitesearch im Web-Fokus durchführen. Es werden ihnen Ergebnisse ohne Sitesearch angezeigt."; + if ($enginesWithSite === 0) { + $this->errors[] = "Sie wollten eine Sitesearch auf " . $this->site . " durchführen. Leider unterstützen die eingestellten Suchmaschinen diese nicht. Sie können <a href=\"" . $this->generateSearchLink("web", false) . "\">hier</a> die Sitesearch im Web-Fokus durchführen. Es werden ihnen Ergebnisse ohne Sitesearch angezeigt."; $siteSearchFailed = true; - }else - { + } else { $this->warnings[] = "Sie führen eine Sitesearch durch. Es werden nur Ergebnisse von der Seite: <a href=\"http://" . $this->site . "\" target=\"_blank\">\"" . $this->site . "\"</a> angezeigt."; } } $typeslist = []; - $counter = 0; + $counter = 0; - foreach($enabledSearchengines as $engine){ + foreach ($enabledSearchengines as $engine) { + + if (!$siteSearchFailed && strlen($this->site) > 0 && (!isset($engine['hasSiteSearch']) || $engine['hasSiteSearch']->__toString() === "0")) { - if( !$siteSearchFailed && strlen($this->site) > 0 && ( !isset($engine['hasSiteSearch']) || $engine['hasSiteSearch']->__toString() === "0") ) - { - continue; } # Wenn diese Suchmaschine gar nicht eingeschaltet sein soll $path = "App\Models\parserSkripte\\" . ucfirst($engine["package"]->__toString()); - if( !file_exists(app_path() . "/Models/parserSkripte/" . ucfirst($engine["package"]->__toString()) . ".php")) - { + if (!file_exists(app_path() . "/Models/parserSkripte/" . ucfirst($engine["package"]->__toString()) . ".php")) { Log::error("Konnte " . $engine["name"] . " nicht abfragen, da kein Parser existiert"); continue; } @@ -516,42 +495,34 @@ class MetaGer try { $tmp = new $path($engine, $this); - } catch( \ErrorException $e) - { + } catch (\ErrorException $e) { Log::error("Konnte " . $engine["name"] . " nicht abfragen." . var_dump($e)); continue; } - if($tmp->enabled && isset($this->debug)) - { - $this->warnings[] = $tmp->service . " Connection_Time: " . $tmp->connection_time . " Write_Time: " . $tmp->write_time . " Insgesamt:" . ((microtime()-$time)/1000); + if ($tmp->enabled && isset($this->debug)) { + $this->warnings[] = $tmp->service . " Connection_Time: " . $tmp->connection_time . " Write_Time: " . $tmp->write_time . " Insgesamt:" . ((microtime() - $time) / 1000); } - if($tmp->isEnabled()) - { - $engines[] = $tmp; + if ($tmp->isEnabled()) { + $engines[] = $tmp; $this->sockets[$tmp->name] = $tmp->fp; } - } + } # Jetzt werden noch alle Kategorien der Settings durchgegangen und die jeweils enthaltenen namen der Suchmaschinen gespeichert. $foki = []; - foreach($sumas as $suma) - { - if( (!isset($suma['disabled']) || $suma['disabled'] === "") && ( !isset($suma['userSelectable']) || $suma['userSelectable']->__toString() === "1") ) - { - if( isset($suma['type']) ) - { + foreach ($sumas as $suma) { + if ((!isset($suma['disabled']) || $suma['disabled'] === "") && (!isset($suma['userSelectable']) || $suma['userSelectable']->__toString() === "1")) { + if (isset($suma['type'])) { $f = explode(",", $suma['type']->__toString()); - foreach($f as $tmp) - { - $name = $suma['name']->__toString(); + foreach ($f as $tmp) { + $name = $suma['name']->__toString(); $foki[$tmp][$suma['name']->__toString()] = $name; } - }else - { - $name = $suma['name']->__toString(); + } else { + $name = $suma['name']->__toString(); $foki["andere"][$suma['name']->__toString()] = $name; } } @@ -559,30 +530,30 @@ class MetaGer # Es werden auch die Namen der aktuell aktiven Suchmaschinen abgespeichert. $realEngNames = []; - foreach($enabledSearchengines as $realEng) { + foreach ($enabledSearchengines as $realEng) { $nam = $realEng["name"]->__toString(); - if($nam !== "qualigo" && $nam !== "overtureAds") { + if ($nam !== "qualigo" && $nam !== "overtureAds") { $realEngNames[] = $nam; } } # Anschließend werden diese beiden Listen verglichen (jeweils eine der Fokuslisten für jeden Fokus), um herauszufinden ob sie vielleicht identisch sind. Ist dies der Fall, so hat der Nutzer anscheinend Suchmaschinen eines kompletten Fokus eingestellt. Der Fokus wird dementsprechend angepasst. - foreach($foki as $fok => $engs) { - $isFokus = true; + foreach ($foki as $fok => $engs) { + $isFokus = true; $fokiEngNames = []; - foreach($engs as $eng) { + foreach ($engs as $eng) { $fokiEngNames[] = $eng; } - foreach($fokiEngNames as $fen) { - if(!in_array($fen, $realEngNames)) { + foreach ($fokiEngNames as $fen) { + if (!in_array($fen, $realEngNames)) { $isFokus = false; } } - foreach($realEngNames as $ren) { - if(!in_array($ren, $fokiEngNames)) { + foreach ($realEngNames as $ren) { + if (!in_array($ren, $fokiEngNames)) { $isFokus = false; } } - if($isFokus) { + if ($isFokus) { $this->fokus = $fok; } } @@ -595,104 +566,98 @@ class MetaGer # Wir zählen die Suchmaschinen, die durch den Cache beantwortet wurden: $enginesToLoad = 0; - $canBreak = false; - foreach($engines as $engine) - { - if( $engine->cached ) - { + $canBreak = false; + foreach ($engines as $engine) { + if ($engine->cached) { $enginesToLoad--; - if( $overtureEnabled && ( $engine->name === "overture" || $engine->name === "overtureAds" ) ) + if ($overtureEnabled && ($engine->name === "overture" || $engine->name === "overtureAds")) { $canBreak = true; + } + } } $enginesToLoad += count($engines); $loadedEngines = 0; - $timeStart = microtime(true); - while( true ) - { - $time = (microtime(true) - $timeStart) * 1000; + $timeStart = microtime(true); + while (true) { + $time = (microtime(true) - $timeStart) * 1000; $loadedEngines = intval(Redis::hlen('search.' . $this->getHashCode())); - if( $overtureEnabled && (Redis::hexists('search.' . $this->getHashCode(), 'overture') || Redis::hexists('search.' . $this->getHashCode(), 'overtureAds'))) + if ($overtureEnabled && (Redis::hexists('search.' . $this->getHashCode(), 'overture') || Redis::hexists('search.' . $this->getHashCode(), 'overtureAds'))) { $canBreak = true; + } # Abbruchbedingung - if($time < 500) - { - if(($enginesToLoad === 0 || $loadedEngines >= $enginesToLoad) && $canBreak) + if ($time < 500) { + if (($enginesToLoad === 0 || $loadedEngines >= $enginesToLoad) && $canBreak) { break; - }elseif( $time >= 500 && $time < $this->time) - { - if( ($enginesToLoad === 0 || ($loadedEngines / ($enginesToLoad * 1.0)) >= 0.8) && $canBreak ) + } + + } elseif ($time >= 500 && $time < $this->time) { + if (($enginesToLoad === 0 || ($loadedEngines / ($enginesToLoad * 1.0)) >= 0.8) && $canBreak) { break; - }else - { + } + + } else { break; } usleep(50000); } #exit; - foreach($engines as $engine) - { - if(!$engine->loaded) - { - try{ + foreach ($engines as $engine) { + if (!$engine->loaded) { + try { $engine->retrieveResults(); - } catch(\ErrorException $e) - { + } catch (\ErrorException $e) { Log::error($e); - + } } } - + # und verwerfen den Rest: - foreach( $engines as $engine ) - { - if( !$engine->loaded ) + foreach ($engines as $engine) { + if (!$engine->loaded) { $engine->shutdown(); + } + } $this->engines = $engines; - } - - public function parseFormData (Request $request) - { - if($request->input('encoding', '') !== "utf8") - { - # In früheren Versionen, als es den Encoding Parameter noch nicht gab, wurden die Daten in ISO-8859-1 übertragen - $input = $request->all(); - foreach($input as $key => $value) - { - $input[$key] = mb_convert_encoding("$value", "UTF-8", "ISO-8859-1"); - } - $request->replace($input); - } + } + + public function parseFormData(Request $request) + { + if ($request->input('encoding', '') !== "utf8") { + # In früheren Versionen, als es den Encoding Parameter noch nicht gab, wurden die Daten in ISO-8859-1 übertragen + $input = $request->all(); + foreach ($input as $key => $value) { + $input[$key] = mb_convert_encoding("$value", "UTF-8", "ISO-8859-1"); + } + $request->replace($input); + } $this->url = $request->url(); - # Zunächst überprüfen wir die eingegebenen Einstellungen: + # Zunächst überprüfen wir die eingegebenen Einstellungen: # FOKUS $this->fokus = trans('fokiNames.' - . $request->input('focus', 'web')); - if(strpos($this->fokus,".")) - { + . $request->input('focus', 'web')); + if (strpos($this->fokus, ".")) { $this->fokus = trans('fokiNames.web'); } # SUMA-FILE - if(App::isLocale("en")){ + if (App::isLocale("en")) { $this->sumaFile = config_path() . "/sumas.xml"; - }else{ + } else { $this->sumaFile = config_path() . "/sumas.xml"; } - if(!file_exists($this->sumaFile)) - { + if (!file_exists($this->sumaFile)) { die("Suma-File konnte nicht gefunden werden"); } # Sucheingabe: $this->eingabe = trim($request->input('eingabe', '')); - if(strlen($this->eingabe) === 0) - { + if (strlen($this->eingabe) === 0) { $this->warnings[] = 'Achtung: Sie haben keinen Suchbegriff eingegeben. Sie können ihre Suchbegriffe oben eingeben und es erneut versuchen.'; } $this->q = $this->eingabe; @@ -701,285 +666,263 @@ class MetaGer $this->ip = $request->ip(); # Language: - if( isset($_SERVER['HTTP_LANGUAGE']) ) - { + if (isset($_SERVER['HTTP_LANGUAGE'])) { $this->language = $_SERVER['HTTP_LANGUAGE']; - }else - { + } else { $this->language = ""; } # Category $this->category = $request->input('category', ''); # Request Times: $this->time = $request->input('time', 1000); - + # Page $this->page = $request->input('page', 1); # Lang $this->lang = $request->input('lang', 'all'); - if ( $this->lang !== "de" && $this->lang !== "en" && $this->lang !== "all" ) - { - $this->lang = "all"; + if ($this->lang !== "de" && $this->lang !== "en" && $this->lang !== "all") { + $this->lang = "all"; } - $this->agent = new Agent(); + $this->agent = new Agent(); $this->mobile = $this->agent->isMobile(); #Sprüche $this->sprueche = $request->input('sprueche', 'off'); - if($this->sprueche === "off" ) + if ($this->sprueche === "off") { $this->sprueche = true; - else + } else { $this->sprueche = false; + } + # Ergebnisse pro Seite: $this->resultCount = $request->input('resultCount', '20'); # Manchmal müssen wir Parameter anpassen um den Sucheinstellungen gerecht zu werden: - if( $request->has('dart') ) - { - $this->time = 10000; - $this->warnings[] = "Hinweis: Sie haben Dart-Europe aktiviert. Die Suche kann deshalb länger dauern und die maximale Suchzeit wurde auf 10 Sekunden hochgesetzt."; + if ($request->has('dart')) { + $this->time = 10000; + $this->warnings[] = "Hinweis: Sie haben Dart-Europe aktiviert. Die Suche kann deshalb länger dauern und die maximale Suchzeit wurde auf 10 Sekunden hochgesetzt."; } - if( $this->time <= 500 || $this->time > 20000 ) - { - $this->time = 1000; + if ($this->time <= 500 || $this->time > 20000) { + $this->time = 1000; } - if( $request->has('minism') && ( $request->has('fportal') || $request->has('harvest') ) ) - { - $input = $request->all(); - $newInput = []; - foreach($input as $key => $value) - { - if( $key !== "fportal" && $key !== "harvest" ) - { - $newInput[$key] = $value; - } - } - $request->replace($newInput); - } - if( App::isLocale("en") ) - { - $this->sprueche = "off"; + if ($request->has('minism') && ($request->has('fportal') || $request->has('harvest'))) { + $input = $request->all(); + $newInput = []; + foreach ($input as $key => $value) { + if ($key !== "fportal" && $key !== "harvest") { + $newInput[$key] = $value; + } + } + $request->replace($newInput); } - if($this->resultCount <= 0 || $this->resultCount > 200 ) - { - $this->resultCount = 1000; + if (App::isLocale("en")) { + $this->sprueche = "off"; } - if( $request->has('onenewspageAll') || $request->has('onenewspageGermanyAll') ) - { - $this->time = 5000; - $this->cache = "cache"; + if ($this->resultCount <= 0 || $this->resultCount > 200) { + $this->resultCount = 1000; } - if( $request->has('tab')) - { - if($request->input('tab') === "off") - { + if ($request->has('onenewspageAll') || $request->has('onenewspageGermanyAll')) { + $this->time = 5000; + $this->cache = "cache"; + } + if ($request->has('tab')) { + if ($request->input('tab') === "off") { $this->tab = "_blank"; - }else - { + } else { $this->tab = "_self"; } - }else - { + } else { $this->tab = "_blank"; } - if( $request->has('password') ) + if ($request->has('password')) { $this->password = $request->input('password'); - if( $request->has('quicktips') ) + } + + if ($request->has('quicktips')) { $this->quicktips = false; - else + } else { $this->quicktips = true; + } $this->out = $request->input('out', "html"); - if($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style") + if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style") { $this->out = "html"; + } + $this->request = $request; - } - - public function checkSpecialSearches (Request $request) - { - # Site Search: - if(preg_match("/(.*)\bsite:(\S+)(.*)/si", $this->q, $match)) - { - $this->site = $match[2]; - $this->q = $match[1] . $match[3]; - } - if( $request->has('site') ) - { + } + + public function checkSpecialSearches(Request $request) + { + # Site Search: + if (preg_match("/(.*)\bsite:(\S+)(.*)/si", $this->q, $match)) { + $this->site = $match[2]; + $this->q = $match[1] . $match[3]; + } + if ($request->has('site')) { $this->site = $request->input('site'); } - # Wenn die Suchanfrage um das Schlüsselwort "-host:*" ergänzt ist, sollen bestimmte Hosts nicht eingeblendet werden - # Wir prüfen, ob das hier der Fall ist: - while(preg_match("/(.*)(^|\s)-host:(\S+)(.*)/si", $this->q, $match)) - { - $this->hostBlacklist[] = $match[3]; - $this->q = $match[1] . $match[4]; - } - if( sizeof($this->hostBlacklist) > 0 ) - { - $hostString = ""; - foreach($this->hostBlacklist as $host) - { - $hostString .= $host . ", "; - } - $hostString = rtrim($hostString, ", "); - $this->warnings[] = "Ergebnisse von folgenden Hosts werden nicht angezeigt: \"" . $hostString . "\""; - } - # Wenn die Suchanfrage um das Schlüsselwort "-domain:*" ergänzt ist, sollen bestimmte Domains nicht eingeblendet werden - # Wir prüfen, ob das hier der Fall ist: - while(preg_match("/(.*)(^|\s)-domain:(\S+)(.*)/si", $this->q, $match)) - { - $this->domainBlacklist[] = $match[3]; - $this->q = $match[1] . $match[4]; - } - if( sizeof($this->domainBlacklist) > 0 ) - { - $domainString = ""; - foreach($this->domainBlacklist as $domain) - { - $domainString .= $domain . ", "; - } - $domainString = rtrim($domainString, ", "); - $this->warnings[] = "Ergebnisse von folgenden Domains werden nicht angezeigt: \"" . $domainString . "\""; - } - - # Alle mit "-" gepräfixten Worte sollen aus der Suche ausgeschlossen werden. - # Wir prüfen, ob das hier der Fall ist: - while(preg_match("/(.*)(^|\s)-(\S+)(.*)/si", $this->q, $match)) - { - $this->stopWords[] = $match[3]; - $this->q = $match[1] . $match[4]; - } - if( sizeof($this->stopWords) > 0 ) - { - $stopwordsString = ""; - foreach($this->stopWords as $stopword) - { - $stopwordsString .= $stopword . ", "; - } - $stopwordsString = rtrim($stopwordsString, ", "); - $this->warnings[] = "Sie machen eine Ausschlusssuche. Ergebnisse mit folgenden Wörtern werden nicht angezeigt: \"" . $stopwordsString . "\""; - } - - # Meldung über eine Phrasensuche - $p = ""; + # Wenn die Suchanfrage um das Schlüsselwort "-host:*" ergänzt ist, sollen bestimmte Hosts nicht eingeblendet werden + # Wir prüfen, ob das hier der Fall ist: + while (preg_match("/(.*)(^|\s)-host:(\S+)(.*)/si", $this->q, $match)) { + $this->hostBlacklist[] = $match[3]; + $this->q = $match[1] . $match[4]; + } + if (sizeof($this->hostBlacklist) > 0) { + $hostString = ""; + foreach ($this->hostBlacklist as $host) { + $hostString .= $host . ", "; + } + $hostString = rtrim($hostString, ", "); + $this->warnings[] = "Ergebnisse von folgenden Hosts werden nicht angezeigt: \"" . $hostString . "\""; + } + # Wenn die Suchanfrage um das Schlüsselwort "-domain:*" ergänzt ist, sollen bestimmte Domains nicht eingeblendet werden + # Wir prüfen, ob das hier der Fall ist: + while (preg_match("/(.*)(^|\s)-domain:(\S+)(.*)/si", $this->q, $match)) { + $this->domainBlacklist[] = $match[3]; + $this->q = $match[1] . $match[4]; + } + if (sizeof($this->domainBlacklist) > 0) { + $domainString = ""; + foreach ($this->domainBlacklist as $domain) { + $domainString .= $domain . ", "; + } + $domainString = rtrim($domainString, ", "); + $this->warnings[] = "Ergebnisse von folgenden Domains werden nicht angezeigt: \"" . $domainString . "\""; + } + + # Alle mit "-" gepräfixten Worte sollen aus der Suche ausgeschlossen werden. + # Wir prüfen, ob das hier der Fall ist: + while (preg_match("/(.*)(^|\s)-(\S+)(.*)/si", $this->q, $match)) { + $this->stopWords[] = $match[3]; + $this->q = $match[1] . $match[4]; + } + if (sizeof($this->stopWords) > 0) { + $stopwordsString = ""; + foreach ($this->stopWords as $stopword) { + $stopwordsString .= $stopword . ", "; + } + $stopwordsString = rtrim($stopwordsString, ", "); + $this->warnings[] = "Sie machen eine Ausschlusssuche. Ergebnisse mit folgenden Wörtern werden nicht angezeigt: \"" . $stopwordsString . "\""; + } + + # Meldung über eine Phrasensuche + $p = ""; $tmp = $this->q; - while(preg_match("/(.*)\"(.+)\"(.*)/si", $tmp, $match)){ - $tmp = $match[1] . $match[3]; + while (preg_match("/(.*)\"(.+)\"(.*)/si", $tmp, $match)) { + $tmp = $match[1] . $match[3]; $this->phrases[] = strtolower($match[2]); - } - foreach($this->phrases as $phrase) - { + } + foreach ($this->phrases as $phrase) { $p .= "\"$phrase\", "; } $p = rtrim($p, ", "); - if(sizeof($this->phrases) > 0) + if (sizeof($this->phrases) > 0) { $this->warnings[] = "Sie führen eine Phrasensuche durch: $p"; - } + } - public function getFokus () + } + + public function getFokus() { return $this->fokus; } - public function getIp () + public function getIp() { return $this->ip; } - public function getEingabe () + public function getEingabe() { return $this->eingabe; } - public function getQ () + public function getQ() { - return $this->q; + return $this->q; } - public function getUrl () + public function getUrl() { return $this->url; } - public function getTime () + public function getTime() { return $this->time; } - public function getLanguage () + public function getLanguage() { return $this->language; } - public function getLang () + public function getLang() { return $this->lang; } - public function getSprueche () + public function getSprueche() { return $this->sprueche; } - public function getCategory () + public function getCategory() { return $this->category; } - public function getPhrases () + public function getPhrases() { return $this->phrases; } - public function getSumaFile () + public function getSumaFile() { return $this->sumaFile; } - public function getUserHostBlacklist () + public function getUserHostBlacklist() { return $this->hostBlacklist; } - public function getUserDomainBlacklist () + public function getUserDomainBlacklist() { return $this->domainBlacklist; } - public function getDomainBlacklist () + public function getDomainBlacklist() { return $this->domainsBlacklisted; } - public function getUrlBlacklist () + public function getUrlBlacklist() { return $this->urlsBlacklisted; } - public function getLanguageDetect () + public function getLanguageDetect() { return $this->languageDetect; } - public function getStopWords () + public function getStopWords() { return $this->stopWords; } public function getHostCount($host) { - if(isset($this->addedHosts[$host])) - { + if (isset($this->addedHosts[$host])) { return $this->addedHosts[$host]; - }else - { + } else { return 0; } } public function addHostCount($host) { $hash = md5($host); - if(isset($this->addedHosts[$hash])) - { + if (isset($this->addedHosts[$hash])) { $this->addedHosts[$hash] += 1; - }else - { + } else { $this->addedHosts[$hash] = 1; } } @@ -989,19 +932,23 @@ class MetaGer } public function addLink($link) { - if(strpos($link, "http://") === 0) + if (strpos($link, "http://") === 0) { $link = substr($link, 7); - if(strpos($link, "https://") === 0) + } + + if (strpos($link, "https://") === 0) { $link = substr($link, 8); - if(strpos($link, "www.") === 0) + } + + if (strpos($link, "www.") === 0) { $link = substr($link, 4); + } + $link = trim($link, "/"); $hash = md5($link); - if(isset($this->addedLinks[$hash])) - { + if (isset($this->addedLinks[$hash])) { return false; - }else - { + } else { $this->addedLinks[$hash] = 1; return true; @@ -1010,12 +957,14 @@ class MetaGer public function generateSearchLink($fokus, $results = true) { - $requestData = $this->request->except('page'); + $requestData = $this->request->except('page'); $requestData['focus'] = $fokus; - if($results) + if ($results) { $requestData['out'] = "results"; - else + } else { $requestData['out'] = ""; + } + $link = action('MetaGerSearch@search', $requestData); return $link; } @@ -1029,55 +978,57 @@ class MetaGer public function generateSiteSearchLink($host) { - $host = urlencode($host); - $requestData = $this->request->except(['page','out']); + $host = urlencode($host); + $requestData = $this->request->except(['page', 'out']); $requestData['eingabe'] .= " site:$host"; $requestData['focus'] = "web"; - $link = action('MetaGerSearch@search', $requestData); + $link = action('MetaGerSearch@search', $requestData); return $link; } - public function generateRemovedHostLink ($host) + public function generateRemovedHostLink($host) { - $host = urlencode($host); - $requestData = $this->request->except(['page','out']); + $host = urlencode($host); + $requestData = $this->request->except(['page', 'out']); $requestData['eingabe'] .= " -host:$host"; $link = action('MetaGerSearch@search', $requestData); return $link; } - public function generateRemovedDomainLink ($domain) + public function generateRemovedDomainLink($domain) { - $domain = urlencode($domain); - $requestData = $this->request->except(['page','out']); + $domain = urlencode($domain); + $requestData = $this->request->except(['page', 'out']); $requestData['eingabe'] .= " -domain:$domain"; $link = action('MetaGerSearch@search', $requestData); return $link; } - public function getTab () + public function getTab() { return $this->tab; } - public function getResults () + public function getResults() { return $this->results; } public function popAd() { - if(count($this->ads) > 0) + if (count($this->ads) > 0) { return get_object_vars(array_shift($this->ads)); - else + } else { return null; + } + } public function getImageProxyLink($link) { - $requestData = []; + $requestData = []; $requestData["url"] = $link; - $link = action('Pictureproxy@get', $requestData); + $link = action('Pictureproxy@get', $requestData); return $link; } - public function showQuicktips () + public function showQuicktips() { return $this->quicktips; } diff --git a/app/Models/Result.php b/app/Models/Result.php index b8424d984..62bd865d0 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -2,256 +2,244 @@ namespace App\Models; - - class Result { - - function __construct ( \SimpleXMLElement $provider, $titel, $link, $anzeigeLink , $descr, $gefVon, $sourceRank, $partnershop = false, $image = "", $price = 0 ) - { - $this->titel = strip_tags(trim($titel)); - $this->link = trim($link); - $this->anzeigeLink = trim($anzeigeLink); - $this->descr = strip_tags(trim($descr), '<p>'); - $this->descr = preg_replace("/\n+/si", " ", $this->descr); - if( strlen($this->descr) > 250 ) - { - $this->descr = wordwrap($this->descr, 250); - $this->descr = substr($this->descr, 0, strpos($this->descr, "\n")); - - } - $this->gefVon = trim($gefVon); - $this->proxyLink = $this->generateProxyLink($this->link); - $this->sourceRank = $sourceRank; - if($this->sourceRank <= 0 || $this->sourceRank > 20) - $this->sourceRank = 20; - $this->sourceRank = 20 - $this->sourceRank; - if(isset($provider["engineBoost"])) - { - $this->engineBoost = floatval($provider["engineBoost"]->__toString()); - }else - { - $this->engineBoost = 1; - } - - $this->valid = true; - $this->host = @parse_url($link, PHP_URL_HOST); - $this->strippedHost = $this->getStrippedHost($this->anzeigeLink); - $this->strippedDomain = $this->getStrippedDomain($this->strippedHost); - $this->strippedLink = $this->getStrippedLink($this->anzeigeLink); - $this->rank = 0; - $this->partnershop = $partnershop; - $this->image = $image; - - #die($this->anzeigeLink . "\r\n" . $this->strippedHost); - } - - public function rank (\App\MetaGer $metager) - { - - $rank = 0; - $rank += ($this->sourceRank * 0.02); - - #URL-Boost - $link = $this->anzeigeLink; - if(strpos($link, "http") !== 0) - { - $link = "http://" . $link; - } - $link = @parse_url($link, PHP_URL_HOST) . @parse_url($link, PHP_URL_PATH); - $tmpLi = $link; - $tmpEingabe = $metager->getQ(); - $count = 0; - $tmpLink = ""; - - $regex = [ - "/\s+/si", - "/http:/si", - "/https:/si", - "/www\./si", - "/\//si", - "/\./si", - "/-/si" - ]; - foreach($regex as $reg) - { - $link = preg_replace($regex, "", $link); - $tmpEingabe = preg_replace($regex, "", $tmpEingabe); - } - #die($tmpLi . "<br>" . $link . "<br>" . $tmpEingabe . "<br><br>"); - foreach(str_split($tmpEingabe) as $char) - { - if( !$char || !$tmpEingabe || strlen($tmpEingabe) === 0 || strlen($char) === 0 ) - continue; - if(strpos(strtolower($tmpLink), strtolower($char)) >= 0) - { - $count++; - $tmpLink = str_replace(urlencode($char), "", $tmpLink); - } - if(strlen($this->descr) > 80 && strlen($link) > 0) - { - #$rank += $count /((strlen($link)) * 60); - } - } - - # Boost für Vorkommen der Suchwörter: - $maxRank = 0.1; - $tmpTitle = $this->titel; - $tmpDescription = $this->descr; - $isWithin = false; - $tmpRank = 0; - $tmpEingabe = $metager->getQ(); - $tmpEingabe = preg_replace("/\b\w{1,3}\b/si", "", $tmpEingabe); - $tmpEingabe = preg_replace("/\s+/si", " ", $tmpEingabe); - #die($tmpEingabe); - foreach(explode(" ", trim($tmpEingabe)) as $el) - { - if( strlen($tmpTitle) === 0 || strlen($el) === 0 || strlen($tmpDescription) === 0 ) - continue; - $el = preg_quote($el, "/"); - if(strlen($tmpTitle) > 0) - { - if(preg_match("/\b$el\b/si", $tmpTitle)) - { - $tmpRank += .7 * .6 * $maxRank; - }elseif (strpos($tmpTitle, $el) !== false) { - $tmpRank += .3 * .6 * $maxRank; - } - } - if( strlen($tmpDescription) > 0 ) - { - if(preg_match("/\b$el\b/si", $tmpDescription)) - { - $tmpRank += .7 * .4 * $maxRank; - }elseif (strpos($tmpDescription, $el) !== false) { - $tmpRank += .3 * .4 * $maxRank; - } - } - } - $tmpRank /= sizeof(explode(" ", trim($tmpEingabe))) * 10; - $rank += $tmpRank; - - if($this->engineBoost > 0) - { - $rank *= floatval($this->engineBoost); - } - - $this->rank = $rank; - } - - public function getRank () - { - return $this->rank; - } - - public function isValid (\App\MetaGer $metager) - { - # Zunächst die persönlich ( über URL-Parameter ) definierten Blacklists: - if(in_array($this->strippedHost, $metager->getUserHostBlacklist()) - || in_array($this->strippedDomain, $metager->getUserDomainBlacklist())) - return false; - - # Jetzt unsere URL und Domain Blacklist - if($this->strippedHost !== "" && (in_array($this->strippedHost, $metager->getDomainBlacklist()) || in_array($this->strippedLink, $metager->getUrlBlacklist()))) - { - return false; - } - - # Nun der Eventuelle Sprachfilter - if( $metager->getLang() !== "all" ) - { - $text = $this->titel . " " . $this->descr; - $path = app_path() . "/Models/lang.pl"; - $lang = exec("echo '$text' | $path"); - - if( $metager->getLang() !== $lang ) - return false; - } - - - - # Wir wenden die Stoppwortsuche an und schmeißen entsprechende Ergebnisse raus: - foreach($metager->getStopWords() as $stopWord) - { - $text = $this->titel . " " . $this->descr; - if(stripos($text, $stopWord) !== false) - { - return false; - } - } - - # Die Strinsuche: - $text = strtolower($this->titel) . " " . strtolower($this->descr); - foreach($metager->getPhrases() as $phrase) - { - if(strpos($text, $phrase) === FALSE) - return false; - } - - # Abschließend noch 2 Ãœberprüfungen. Einmal den Host filter, der Sicherstellt, dass von jedem Host maximal 3 Links angezeigt werden - # und dann noch den Dublettefilter, der sicher stellt, dass wir nach Möglichkeit keinen Link doppelt in der Ergebnisliste haben - # Diese Ãœberprüfung führen wir unter bestimmten Bedingungen nicht durch: - if($metager->getSite() === "" && - strpos($this->strippedHost, "ncbi.nlm.nih.gov") === false && - strpos($this->strippedHost, "twitter.com") === false && - strpos($this->strippedHost, "www.ladenpreis.net") === false && - strpos($this->strippedHost, "ncbi.nlm.nih.gov") === false && - strpos($this->strippedHost, "www.onenewspage.com") === false) - { - $count = $metager->getHostCount($this->strippedHost); - if($count >= 3) - { - return false; - } - } - - # Unabhängig davon unser Dublettenfilter: - if($metager->addLink($this->strippedLink)) - { - $metager->addHostCount($this->strippedHost); - return true; - }else - { - return false; - } - } - - private function getStrippedHost ($link) - { - if(strpos($link, "http") !== 0) - $link = "http://" . $link; - $link = @parse_url($link, PHP_URL_HOST); - $link = preg_replace("/^www\./si", "", $link); - return $link; - } - private function getStrippedLink ($link) - { - if(strpos($link, "http") !== 0) - $link = "http://" . $link; - $host = $this->strippedHost; - $path = @parse_url($link , PHP_URL_PATH); - return $host . $path; - } - - private function getStrippedDomain ($link) - { - if(preg_match("/([^\.]*\.[^\.]*)$/si", $link, $match)) - { - return $match[1]; - }else - { - return $link; - } - } - - private function generateProxyLink ($link) - { - if(!$link) - return ""; - $tmp = $link; - $tmp = preg_replace("/\r?\n$/s", "", $tmp); - $tmp = preg_replace("#^([\w+.-]+)://#s", "$1/", $tmp); - return "https://proxy.suma-ev.de/cgi-bin/nph-proxy.cgi/en/I0/" . $tmp; - - } + + public function __construct(\SimpleXMLElement $provider, $titel, $link, $anzeigeLink, $descr, $gefVon, $sourceRank, $partnershop = false, $image = "", $price = 0) + { + $this->titel = strip_tags(trim($titel)); + $this->link = trim($link); + $this->anzeigeLink = trim($anzeigeLink); + $this->descr = strip_tags(trim($descr), '<p>'); + $this->descr = preg_replace("/\n+/si", " ", $this->descr); + if (strlen($this->descr) > 250) { + $this->descr = wordwrap($this->descr, 250); + $this->descr = substr($this->descr, 0, strpos($this->descr, "\n")); + + } + $this->gefVon = trim($gefVon); + $this->proxyLink = $this->generateProxyLink($this->link); + $this->sourceRank = $sourceRank; + if ($this->sourceRank <= 0 || $this->sourceRank > 20) { + $this->sourceRank = 20; + } + + $this->sourceRank = 20 - $this->sourceRank; + if (isset($provider["engineBoost"])) { + $this->engineBoost = floatval($provider["engineBoost"]->__toString()); + } else { + $this->engineBoost = 1; + } + + $this->valid = true; + $this->host = @parse_url($link, PHP_URL_HOST); + $this->strippedHost = $this->getStrippedHost($this->anzeigeLink); + $this->strippedDomain = $this->getStrippedDomain($this->strippedHost); + $this->strippedLink = $this->getStrippedLink($this->anzeigeLink); + $this->rank = 0; + $this->partnershop = $partnershop; + $this->image = $image; + + #die($this->anzeigeLink . "\r\n" . $this->strippedHost); + } + + public function rank(\App\MetaGer $metager) + { + + $rank = 0; + $rank += ($this->sourceRank * 0.02); + + #URL-Boost + $link = $this->anzeigeLink; + if (strpos($link, "http") !== 0) { + $link = "http://" . $link; + } + $link = @parse_url($link, PHP_URL_HOST) . @parse_url($link, PHP_URL_PATH); + $tmpLi = $link; + $tmpEingabe = $metager->getQ(); + $count = 0; + $tmpLink = ""; + + $regex = [ + "/\s+/si", + "/http:/si", + "/https:/si", + "/www\./si", + "/\//si", + "/\./si", + "/-/si", + ]; + foreach ($regex as $reg) { + $link = preg_replace($regex, "", $link); + $tmpEingabe = preg_replace($regex, "", $tmpEingabe); + } + #die($tmpLi . "<br>" . $link . "<br>" . $tmpEingabe . "<br><br>"); + foreach (str_split($tmpEingabe) as $char) { + if (!$char || !$tmpEingabe || strlen($tmpEingabe) === 0 || strlen($char) === 0) { + continue; + } + + if (strpos(strtolower($tmpLink), strtolower($char)) >= 0) { + $count++; + $tmpLink = str_replace(urlencode($char), "", $tmpLink); + } + if (strlen($this->descr) > 80 && strlen($link) > 0) { + #$rank += $count /((strlen($link)) * 60); + } + } + + # Boost für Vorkommen der Suchwörter: + $maxRank = 0.1; + $tmpTitle = $this->titel; + $tmpDescription = $this->descr; + $isWithin = false; + $tmpRank = 0; + $tmpEingabe = $metager->getQ(); + $tmpEingabe = preg_replace("/\b\w{1,3}\b/si", "", $tmpEingabe); + $tmpEingabe = preg_replace("/\s+/si", " ", $tmpEingabe); + #die($tmpEingabe); + foreach (explode(" ", trim($tmpEingabe)) as $el) { + if (strlen($tmpTitle) === 0 || strlen($el) === 0 || strlen($tmpDescription) === 0) { + continue; + } + + $el = preg_quote($el, "/"); + if (strlen($tmpTitle) > 0) { + if (preg_match("/\b$el\b/si", $tmpTitle)) { + $tmpRank += .7 * .6 * $maxRank; + } elseif (strpos($tmpTitle, $el) !== false) { + $tmpRank += .3 * .6 * $maxRank; + } + } + if (strlen($tmpDescription) > 0) { + if (preg_match("/\b$el\b/si", $tmpDescription)) { + $tmpRank += .7 * .4 * $maxRank; + } elseif (strpos($tmpDescription, $el) !== false) { + $tmpRank += .3 * .4 * $maxRank; + } + } + } + $tmpRank /= sizeof(explode(" ", trim($tmpEingabe))) * 10; + $rank += $tmpRank; + + if ($this->engineBoost > 0) { + $rank *= floatval($this->engineBoost); + } + + $this->rank = $rank; + } + + public function getRank() + { + return $this->rank; + } + + public function isValid(\App\MetaGer $metager) + { + # Zunächst die persönlich ( über URL-Parameter ) definierten Blacklists: + if (in_array($this->strippedHost, $metager->getUserHostBlacklist()) + || in_array($this->strippedDomain, $metager->getUserDomainBlacklist())) { + return false; + } + + # Jetzt unsere URL und Domain Blacklist + if ($this->strippedHost !== "" && (in_array($this->strippedHost, $metager->getDomainBlacklist()) || in_array($this->strippedLink, $metager->getUrlBlacklist()))) { + return false; + } + + # Nun der Eventuelle Sprachfilter + if ($metager->getLang() !== "all") { + $text = $this->titel . " " . $this->descr; + $path = app_path() . "/Models/lang.pl"; + $lang = exec("echo '$text' | $path"); + + if ($metager->getLang() !== $lang) { + return false; + } + + } + + # Wir wenden die Stoppwortsuche an und schmeißen entsprechende Ergebnisse raus: + foreach ($metager->getStopWords() as $stopWord) { + $text = $this->titel . " " . $this->descr; + if (stripos($text, $stopWord) !== false) { + return false; + } + } + + # Die Strinsuche: + $text = strtolower($this->titel) . " " . strtolower($this->descr); + foreach ($metager->getPhrases() as $phrase) { + if (strpos($text, $phrase) === false) { + return false; + } + + } + + # Abschließend noch 2 Ãœberprüfungen. Einmal den Host filter, der Sicherstellt, dass von jedem Host maximal 3 Links angezeigt werden + # und dann noch den Dublettefilter, der sicher stellt, dass wir nach Möglichkeit keinen Link doppelt in der Ergebnisliste haben + # Diese Ãœberprüfung führen wir unter bestimmten Bedingungen nicht durch: + if ($metager->getSite() === "" && + strpos($this->strippedHost, "ncbi.nlm.nih.gov") === false && + strpos($this->strippedHost, "twitter.com") === false && + strpos($this->strippedHost, "www.ladenpreis.net") === false && + strpos($this->strippedHost, "ncbi.nlm.nih.gov") === false && + strpos($this->strippedHost, "www.onenewspage.com") === false) { + $count = $metager->getHostCount($this->strippedHost); + if ($count >= 3) { + return false; + } + } + + # Unabhängig davon unser Dublettenfilter: + if ($metager->addLink($this->strippedLink)) { + $metager->addHostCount($this->strippedHost); + return true; + } else { + return false; + } + } + + private function getStrippedHost($link) + { + if (strpos($link, "http") !== 0) { + $link = "http://" . $link; + } + + $link = @parse_url($link, PHP_URL_HOST); + $link = preg_replace("/^www\./si", "", $link); + return $link; + } + private function getStrippedLink($link) + { + if (strpos($link, "http") !== 0) { + $link = "http://" . $link; + } + + $host = $this->strippedHost; + $path = @parse_url($link, PHP_URL_PATH); + return $host . $path; + } + + private function getStrippedDomain($link) + { + if (preg_match("/([^\.]*\.[^\.]*)$/si", $link, $match)) { + return $match[1]; + } else { + return $link; + } + } + + private function generateProxyLink($link) + { + if (!$link) { + return ""; + } + + $tmp = $link; + $tmp = preg_replace("/\r?\n$/s", "", $tmp); + $tmp = preg_replace("#^([\w+.-]+)://#s", "$1/", $tmp); + return "https://proxy.suma-ev.de/cgi-bin/nph-proxy.cgi/en/I0/" . $tmp; + + } } diff --git a/app/Models/Searchengine.php b/app/Models/Searchengine.php index 3cf770a1b..a9c2c3638 100644 --- a/app/Models/Searchengine.php +++ b/app/Models/Searchengine.php @@ -1,282 +1,267 @@ <?php namespace App\Models; + +use App\Jobs\Search; use App\MetaGer; +use Cache; +use Illuminate\Foundation\Bus\DispatchesJobs; use Log; use Redis; -use App\Jobs\Search; -use Illuminate\Foundation\Bus\DispatchesJobs; -use Cache; - -abstract class Searchengine +abstract class Searchengine { - use DispatchesJobs; + use DispatchesJobs; - protected $ch; # Curl Handle zum erhalten der Ergebnisse - public $fp; - protected $getString = ""; - protected $engine; - protected $counter = 0; + protected $ch; # Curl Handle zum erhalten der Ergebnisse + public $fp; + protected $getString = ""; + protected $engine; + protected $counter = 0; protected $socketNumber = null; - public $enabled = true; - public $results = []; - public $ads = []; - public $write_time = 0; - public $connection_time = 0; - public $loaded = false; - public $cached = false; - - function __construct(\SimpleXMLElement $engine, MetaGer $metager) - { - foreach($engine->attributes() as $key => $value){ - $this->$key = $value->__toString(); - } - if( !isset($this->homepage) ) - $this->homepage = "https://metager.de"; - $this->engine = $engine; - - if( !isset($this->cacheDuration) ) - $this->cacheDuration = 60; - - # Wir registrieren die Benutzung dieser Suchmaschine - $this->uses = intval(Redis::hget($this->name, "uses")) + 1; - Redis::hset($this->name, "uses", $this->uses); - - # Eine Suchmaschine kann automatisch temporär deaktiviert werden, wenn es Verbindungsprobleme gab: - if(isset($this->disabled) && strtotime($this->disabled) <= time() ) - { - # In diesem Fall ist der Timeout der Suchmaschine abgelaufen. - $this->enable($metager->getSumaFile(), "Die Suchmaschine " . $this->name . " wurde wieder eingeschaltet."); - }elseif (isset($this->disabled) && strtotime($this->disabled) > time()) - { - $this->enabled = false; - return; + public $enabled = true; + public $results = []; + public $ads = []; + public $write_time = 0; + public $connection_time = 0; + public $loaded = false; + public $cached = false; + + public function __construct(\SimpleXMLElement $engine, MetaGer $metager) + { + foreach ($engine->attributes() as $key => $value) { + $this->$key = $value->__toString(); + } + if (!isset($this->homepage)) { + $this->homepage = "https://metager.de"; + } + + $this->engine = $engine; + + if (!isset($this->cacheDuration)) { + $this->cacheDuration = 60; + } + + # Wir registrieren die Benutzung dieser Suchmaschine + $this->uses = intval(Redis::hget($this->name, "uses")) + 1; + Redis::hset($this->name, "uses", $this->uses); + + # Eine Suchmaschine kann automatisch temporär deaktiviert werden, wenn es Verbindungsprobleme gab: + if (isset($this->disabled) && strtotime($this->disabled) <= time()) { + # In diesem Fall ist der Timeout der Suchmaschine abgelaufen. + $this->enable($metager->getSumaFile(), "Die Suchmaschine " . $this->name . " wurde wieder eingeschaltet."); + } elseif (isset($this->disabled) && strtotime($this->disabled) > time()) { + $this->enabled = false; + return; + } + + # User-Agent definieren: + $this->useragent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"; + $this->ip = $metager->getIp(); + $this->gefVon = "<a href=\"" . $this->homepage . "\" target=\"_blank\">" . $this->displayName . "</a>"; + $this->startTime = microtime(); + + $q = ""; + if (isset($this->hasSiteSearch) && $this->hasSiteSearch === "1") { + if (strlen($metager->getSite()) === 0) { + $q = $metager->getQ(); + } else { + $q = $metager->getQ() . " site:" . $metager->getSite(); + } + + } else { + $q = $metager->getQ(); + } + $this->getString = $this->generateGetString($q, $metager->getUrl(), $metager->getLanguage(), $metager->getCategory()); + $this->hash = md5($this->host . $this->getString . $this->port . $this->name); + $this->resultHash = $metager->getHashCode(); + if (Cache::has($this->hash)) { + $this->cached = true; + $this->retrieveResults(); + } else { + # Die Anfragen an die Suchmaschinen werden nun von der Laravel-Queue bearbeitet: + # Hinweis: solange in der .env der QUEUE_DRIVER auf "sync" gestellt ist, werden die Abfragen + # nacheinander abgeschickt. + # Sollen diese Parallel verarbeitet werden, muss ein anderer QUEUE_DRIVER verwendet werden. + # siehe auch: https://laravel.com/docs/5.2/queues + $this->dispatch(new Search($this->resultHash, $this->host, $this->port, $this->name, $this->getString, $this->useragent, $metager->getSumaFile())); + } + } + + abstract public function loadResults($result); + + public function rank(\App\MetaGer $metager) + { + foreach ($this->results as $result) { + $result->rank($metager); + } + } + + private function setStatistic($key, $val) + { + + $oldVal = floatval(Redis::hget($this->name, $key)) * $this->uses; + $newVal = ($oldVal + max($val, 0)) / $this->uses; + Redis::hset($this->name, $key, $newVal); + $this->$key = $newVal; + } + + public function enable($sumaFile, $message) + { + Log::info($message); + $xml = simplexml_load_file($sumaFile); + unset($xml->xpath("//sumas/suma[@name='" . $this->name . "']")['0']['disabled']); + $xml->saveXML($sumaFile); + } + + public function closeFp() + { + fclose($this->fp); + } + + public function getSocket() + { + $number = Redis::hget('search.' . $this->hash, $this->name); + if ($number === null) { + die("test"); + return null; + } else { + return pfsockopen($this->getHost() . ":" . $this->port . "/$number", $this->port, $errstr, $errno, 1); + } + } + + public function retrieveResults() + { + if ($this->loaded) { + return true; } - # User-Agent definieren: - $this->useragent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"; - $this->ip = $metager->getIp(); - $this->gefVon = "<a href=\"" . $this->homepage . "\" target=\"_blank\">" . $this->displayName . "</a>"; - $this->startTime = microtime(); - - $q = ""; - if( isset($this->hasSiteSearch) && $this->hasSiteSearch === "1") - { - if(strlen($metager->getSite()) === 0) - $q = $metager->getQ(); - else - $q = $metager->getQ() . " site:" . $metager->getSite(); - }else - { - $q = $metager->getQ(); - } - $this->getString = $this->generateGetString($q, $metager->getUrl(), $metager->getLanguage(), $metager->getCategory()); - $this->hash = md5($this->host . $this->getString . $this->port . $this->name); - $this->resultHash = $metager->getHashCode(); - if( Cache::has($this->hash) ) - { - $this->cached = true; - $this->retrieveResults(); - }else - { - # Die Anfragen an die Suchmaschinen werden nun von der Laravel-Queue bearbeitet: - # Hinweis: solange in der .env der QUEUE_DRIVER auf "sync" gestellt ist, werden die Abfragen - # nacheinander abgeschickt. - # Sollen diese Parallel verarbeitet werden, muss ein anderer QUEUE_DRIVER verwendet werden. - # siehe auch: https://laravel.com/docs/5.2/queues - $this->dispatch(new Search($this->resultHash, $this->host, $this->port, $this->name, $this->getString, $this->useragent, $metager->getSumaFile())); - } - } - - public abstract function loadResults($result); - - - - public function rank (\App\MetaGer $metager) - { - foreach($this->results as $result) - { - $result->rank($metager); - } - } - - - - private function setStatistic($key, $val) - { - - $oldVal = floatval(Redis::hget($this->name, $key)) * $this->uses; - $newVal = ($oldVal + max($val, 0)) / $this->uses; - Redis::hset($this->name, $key, $newVal); - $this->$key = $newVal; - } - - - - public function enable($sumaFile, $message) - { - Log::info($message); - $xml = simplexml_load_file($sumaFile); - unset($xml->xpath("//sumas/suma[@name='" . $this->name . "']")['0']['disabled']); - $xml->saveXML($sumaFile); - } - - public function closeFp() - { - fclose($this->fp); - } - - public function getSocket() - { - $number = Redis::hget('search.' . $this->hash, $this->name); - if( $number === null ) - { - die("test"); - return null; - }else - { - return pfsockopen($this->getHost() . ":" . $this->port . "/$number", $this->port, $errstr, $errno, 1); - } - } - - public function retrieveResults() - { - if( $this->loaded ) - return true; - $body = ""; - if( $this->cacheDuration > 0 && Cache::has($this->hash) ) - { - $body = Cache::get($this->hash); - }elseif ( Redis::hexists('search.' . $this->resultHash, $this->name) ) { - $body = Redis::hget('search.' . $this->resultHash, $this->name); - if( $this->cacheDuration > 0 ) - Cache::put($this->hash, $body, $this->cacheDuration); - } - - if( $body !== "" ) - { - $this->loadResults($body); - $this->loaded = true; - Redis::hdel('search.' . $this->hash, $this->name); - return true; - }else - { - return false; - } - } - - public function shutdown() - { - Redis::del($this->host . "." . $this->socketNumber); - } - - protected function getHost() - { - $return = ""; - if( $this->port === "443" ) - { - $return .= "tls://"; - }else - { - $return .= "tcp://"; - } - $return .= $this->host; - return $return; - } - - public function getCurlInfo() - { - return curl_getinfo($this->ch); - } - - public function getCurlErrors() - { - return curl_errno($this->ch); - } - - public function addCurlHandle ($mh) - { - curl_multi_add_handle($mh, $this->ch); - } - - public function removeCurlHandle ($mh) - { - curl_multi_remove_handle($mh, $this->ch); - } - - private function generateGetString($query, $url, $language, $category) - { - $getString = ""; - - # Skript: - if(strlen($this->skript) > 0) - $getString .= $this->skript; - else - $getString .= "/"; - # FormData: - if(strlen($this->formData) > 0) - $getString .= "?" . $this->formData; - - # Wir müssen noch einige Platzhalter in dem GET-String ersetzen: - if( strpos($getString, "<<USERAGENT>>") ){ - $getString = str_replace("<<USERAGENT>>", $this->urlEncode($this->useragent), $getString); - } - - if( strpos($getString, "<<QUERY>>") ) - { - $getString = str_replace("<<QUERY>>", $this->urlEncode($query), $getString); - } - - if( strpos($getString, "<<IP>>") ) - { - $getString = str_replace("<<IP>>", $this->urlEncode($this->ip), $getString); - } - - if( strpos($getString, "<<LANGUAGE>>") ) - { - $getString = str_replace("<<LANGUAGE>>", $this->urlEncode($language), $getString); - } - - if( strpos($getString, "<<CATEGORY>>") ) - { - $getString = str_replace("<<CATEGORY>>", $this->urlEncode($category), $getString); - } - - if( strpos($getString, "<<AFFILDATA>>") ) - { - $getString = str_replace("<<AFFILDATA>>", $this->getOvertureAffilData($url), $getString); - } - return $getString; - } - - protected function urlEncode($string) - { - if(isset($this->inputEncoding)) - { - return urlencode(mb_convert_encoding($string, $this->inputEncoding)); - }else - { - return urlencode($string); - } - } - - private function getOvertureAffilData($url) - { - $affil_data = 'ip=' . $this->ip; - $affil_data .= '&ua=' . $this->useragent; - if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) ) { - $affil_data .= '&xfip=' . $_SERVER['HTTP_X_FORWARDED_FOR']; - } - $affilDataValue = $this->urlEncode($affil_data); - # Wir benötigen die ServeUrl: - $serveUrl = $this->urlEncode($url); - - return "&affilData=" . $affilDataValue . "&serveUrl=" . $serveUrl; - } - - public function isEnabled () - { - return $this->enabled; - } -} \ No newline at end of file + $body = ""; + if ($this->cacheDuration > 0 && Cache::has($this->hash)) { + $body = Cache::get($this->hash); + } elseif (Redis::hexists('search.' . $this->resultHash, $this->name)) { + $body = Redis::hget('search.' . $this->resultHash, $this->name); + if ($this->cacheDuration > 0) { + Cache::put($this->hash, $body, $this->cacheDuration); + } + + } + + if ($body !== "") { + $this->loadResults($body); + $this->loaded = true; + Redis::hdel('search.' . $this->hash, $this->name); + return true; + } else { + return false; + } + } + + public function shutdown() + { + Redis::del($this->host . "." . $this->socketNumber); + } + + protected function getHost() + { + $return = ""; + if ($this->port === "443") { + $return .= "tls://"; + } else { + $return .= "tcp://"; + } + $return .= $this->host; + return $return; + } + + public function getCurlInfo() + { + return curl_getinfo($this->ch); + } + + public function getCurlErrors() + { + return curl_errno($this->ch); + } + + public function addCurlHandle($mh) + { + curl_multi_add_handle($mh, $this->ch); + } + + public function removeCurlHandle($mh) + { + curl_multi_remove_handle($mh, $this->ch); + } + + private function generateGetString($query, $url, $language, $category) + { + $getString = ""; + + # Skript: + if (strlen($this->skript) > 0) { + $getString .= $this->skript; + } else { + $getString .= "/"; + } + + # FormData: + if (strlen($this->formData) > 0) { + $getString .= "?" . $this->formData; + } + + # Wir müssen noch einige Platzhalter in dem GET-String ersetzen: + if (strpos($getString, "<<USERAGENT>>")) { + $getString = str_replace("<<USERAGENT>>", $this->urlEncode($this->useragent), $getString); + } + + if (strpos($getString, "<<QUERY>>")) { + $getString = str_replace("<<QUERY>>", $this->urlEncode($query), $getString); + } + + if (strpos($getString, "<<IP>>")) { + $getString = str_replace("<<IP>>", $this->urlEncode($this->ip), $getString); + } + + if (strpos($getString, "<<LANGUAGE>>")) { + $getString = str_replace("<<LANGUAGE>>", $this->urlEncode($language), $getString); + } + + if (strpos($getString, "<<CATEGORY>>")) { + $getString = str_replace("<<CATEGORY>>", $this->urlEncode($category), $getString); + } + + if (strpos($getString, "<<AFFILDATA>>")) { + $getString = str_replace("<<AFFILDATA>>", $this->getOvertureAffilData($url), $getString); + } + return $getString; + } + + protected function urlEncode($string) + { + if (isset($this->inputEncoding)) { + return urlencode(mb_convert_encoding($string, $this->inputEncoding)); + } else { + return urlencode($string); + } + } + + private function getOvertureAffilData($url) + { + $affil_data = 'ip=' . $this->ip; + $affil_data .= '&ua=' . $this->useragent; + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $affil_data .= '&xfip=' . $_SERVER['HTTP_X_FORWARDED_FOR']; + } + $affilDataValue = $this->urlEncode($affil_data); + # Wir benötigen die ServeUrl: + $serveUrl = $this->urlEncode($url); + + return "&affilData=" . $affilDataValue . "&serveUrl=" . $serveUrl; + } + + public function isEnabled() + { + return $this->enabled; + } +} diff --git a/app/Models/parserSkripte/Allesklar.php b/app/Models/parserSkripte/Allesklar.php index da5de2635..8e43b26dd 100644 --- a/app/Models/parserSkripte/Allesklar.php +++ b/app/Models/parserSkripte/Allesklar.php @@ -7,55 +7,50 @@ use Symfony\Component\DomCrawler\Crawler; class Allesklar extends Searchengine { - protected $tds = ""; - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - $crawler = new Crawler(utf8_decode($result)); - $crawler = $crawler - ->filter('table[width=585]') - ->reduce(function(Crawler $node, $i) { - if($i < 5) - { - return false; - } - }); - - $this->counter = 0; - $crawler->filter('table')->each(function (Crawler $node, $i) - { - try { - $this->string = ""; - $titleTag = $node->filter('tr > td > a')->first(); - $title = trim($titleTag->filter('a')->text()); - $link = $titleTag->filter('a')->attr('href'); - if($i === 0) - { - $descr = trim($node->filter('tr > td.bodytext')->eq(3)->text()); - }else - { - $descr = trim($node->filter('tr > td.bodytext')->eq(2)->text()); - } - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $link, - $descr, - $this->gefVon, - $this->counter - ); - } catch (\InvalidArgumentException $e) - { - - } - - }); - } - -} \ No newline at end of file + protected $tds = ""; + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $crawler = new Crawler(utf8_decode($result)); + $crawler = $crawler + ->filter('table[width=585]') + ->reduce(function (Crawler $node, $i) { + if ($i < 5) { + return false; + } + }); + + $this->counter = 0; + $crawler->filter('table')->each(function (Crawler $node, $i) { + try { + $this->string = ""; + $titleTag = $node->filter('tr > td > a')->first(); + $title = trim($titleTag->filter('a')->text()); + $link = $titleTag->filter('a')->attr('href'); + if ($i === 0) { + $descr = trim($node->filter('tr > td.bodytext')->eq(3)->text()); + } else { + $descr = trim($node->filter('tr > td.bodytext')->eq(2)->text()); + } + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $link, + $descr, + $this->gefVon, + $this->counter + ); + } catch (\InvalidArgumentException $e) { + + } + + }); + } + +} diff --git a/app/Models/parserSkripte/BASE.php b/app/Models/parserSkripte/BASE.php index 990fcce07..dc9d75cba 100644 --- a/app/Models/parserSkripte/BASE.php +++ b/app/Models/parserSkripte/BASE.php @@ -1,33 +1,34 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class BASE extends Searchengine +class BASE extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine,\App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { - public function loadResults ($result) - { - - $title = ""; - $link = ""; - $anzeigeLink = $link; - $descr = ""; + $title = ""; + $link = ""; + $anzeigeLink = $link; + $descr = ""; - /*$this->counter++; - $this->results[] = new \App\Models\Result( - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - );*/ - } -} \ No newline at end of file + /*$this->counter++; + $this->results[] = new \App\Models\Result( + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + );*/ + } +} diff --git a/app/Models/parserSkripte/Beammachine.php b/app/Models/parserSkripte/Beammachine.php index 102f08061..2dd2355b7 100644 --- a/app/Models/parserSkripte/Beammachine.php +++ b/app/Models/parserSkripte/Beammachine.php @@ -1,45 +1,43 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Beammachine extends Searchengine +class Beammachine extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - $results = trim($result); - - foreach( explode("\n", $results) as $result ) - { - $res = explode("|", $result); - if(sizeof($res) < 3) - { - continue; - } - $title = $res[0]; - $link = $res[1]; - $anzeigeLink = $link; - $descr = $res[2]; - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - - - } + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $results = trim($result); + + foreach (explode("\n", $results) as $result) { + $res = explode("|", $result); + if (sizeof($res) < 3) { + continue; + } + $title = $res[0]; + $link = $res[1]; + $anzeigeLink = $link; + $descr = $res[2]; + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + + } } diff --git a/app/Models/parserSkripte/Bing.php b/app/Models/parserSkripte/Bing.php index aeccd486d..8cf01e0e7 100644 --- a/app/Models/parserSkripte/Bing.php +++ b/app/Models/parserSkripte/Bing.php @@ -1,48 +1,45 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; use Symfony\Component\DomCrawler\Crawler; -class Bing extends Searchengine +class Bing extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - - try - { - $crawler = new Crawler($result); - $crawler->filter('ol#b_results > li.b_algo')->each(function (Crawler $node, $i) - { - $title = $node->filter('li h2 > a')->text(); - $link = $node->filter('li h2 > a')->attr('href'); - $anzeigeLink = $link; - $descr = $node->filter('li div > p')->text(); - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } ); - } catch ( \ErrorException $e) - { - return; - } - - - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + + try + { + $crawler = new Crawler($result); + $crawler->filter('ol#b_results > li.b_algo')->each(function (Crawler $node, $i) { + $title = $node->filter('li h2 > a')->text(); + $link = $node->filter('li h2 > a')->attr('href'); + $anzeigeLink = $link; + $descr = $node->filter('li div > p')->text(); + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + }); + } catch (\ErrorException $e) { + return; + } + + } +} diff --git a/app/Models/parserSkripte/Bing_bilder.php b/app/Models/parserSkripte/Bing_bilder.php index b7af2d187..c3ca26910 100644 --- a/app/Models/parserSkripte/Bing_bilder.php +++ b/app/Models/parserSkripte/Bing_bilder.php @@ -1,42 +1,42 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; use Symfony\Component\DomCrawler\Crawler; -class Bing_bilder extends Searchengine +class Bing_bilder extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $crawler = new Crawler($result); + $crawler->filter('div#b_content div.item')->each(function (Crawler $node, $i) { + $title = $node->filter('div.meta > a.tit')->text(); + $link = $node->filter('div.meta > a.tit')->attr("href"); + $anzeigeLink = $link; + $descr = $node->filter('div.meta > div.des')->text(); + $image = $node->filter('a.thumb img')->attr("src"); - public function loadResults ($result) - { - $crawler = new Crawler($result); - $crawler->filter('div#b_content div.item')->each(function (Crawler $node, $i) - { - $title = $node->filter('div.meta > a.tit')->text(); - $link = $node->filter('div.meta > a.tit')->attr("href"); - $anzeigeLink = $link; - $descr = $node->filter('div.meta > div.des')->text(); - $image = $node->filter('a.thumb img')->attr("src"); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + }); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image - ); - } ); - - } -} \ No newline at end of file + } +} diff --git a/app/Models/parserSkripte/Dart.php b/app/Models/parserSkripte/Dart.php index 1d0674aa5..86f601e71 100644 --- a/app/Models/parserSkripte/Dart.php +++ b/app/Models/parserSkripte/Dart.php @@ -1,63 +1,67 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; use Symfony\Component\DomCrawler\Crawler; -class Dart extends Searchengine +class Dart extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - - $crawler = new Crawler($result); - $crawler->filter('table#search-results > tr > td')->each(function (Crawler $node, $i) - { - $i = $i - ( 6 * $this->counter); - if($i === 0) - return; - if($i === 1) - { - $this->description = $node->text(); - $this->link = "http://www.dart-europe.eu/" . $node->filter('a')->attr('href'); - } - if($i === 2) - $this->title = $node->text(); - if($i === 3) - $this->title .= " (" . $node->text() . ")"; - if($i === 4) - $this->title .= " " . $node->text(); - if($i === 5) - { - $this->title .= "|" . $node->text(); - $title = $this->title; - $this->title = ""; - $link = $this->link; - $this->link = ""; - $anzeigeLink = $link; - $descr = $this->description; - $this->description = ""; - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } ); - - - - } + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + + $crawler = new Crawler($result); + $crawler->filter('table#search-results > tr > td')->each(function (Crawler $node, $i) { + $i = $i - (6 * $this->counter); + if ($i === 0) { + return; + } + + if ($i === 1) { + $this->description = $node->text(); + $this->link = "http://www.dart-europe.eu/" . $node->filter('a')->attr('href'); + } + if ($i === 2) { + $this->title = $node->text(); + } + + if ($i === 3) { + $this->title .= " (" . $node->text() . ")"; + } + + if ($i === 4) { + $this->title .= " " . $node->text(); + } + + if ($i === 5) { + $this->title .= "|" . $node->text(); + $title = $this->title; + $this->title = ""; + $link = $this->link; + $this->link = ""; + $anzeigeLink = $link; + $descr = $this->description; + $this->description = ""; + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + }); + + } } diff --git a/app/Models/parserSkripte/Dmoznebel.php b/app/Models/parserSkripte/Dmoznebel.php index 961157bf7..09354fe7a 100644 --- a/app/Models/parserSkripte/Dmoznebel.php +++ b/app/Models/parserSkripte/Dmoznebel.php @@ -1,46 +1,45 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Dmoznebel extends Searchengine +class Dmoznebel extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - - $result = mb_convert_encoding($result, "UTF-8", "ISO-8859-1"); - $results = trim($result); - - foreach( explode("\n", $results) as $result ) - { - $res = explode("|", $result); - if(sizeof($res) < 3) - { - continue; - } - $title = $res[1]; - $link = $res[2]; - $anzeigeLink = $link; - $descr = $res[3]; - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + + $result = mb_convert_encoding($result, "UTF-8", "ISO-8859-1"); + $results = trim($result); + + foreach (explode("\n", $results) as $result) { + $res = explode("|", $result); + if (sizeof($res) < 3) { + continue; + } + $title = $res[1]; + $link = $res[2]; + $anzeigeLink = $link; + $descr = $res[3]; + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + + } +} diff --git a/app/Models/parserSkripte/Dmoznebel_int.php b/app/Models/parserSkripte/Dmoznebel_int.php index a9a893ff8..cf2702461 100644 --- a/app/Models/parserSkripte/Dmoznebel_int.php +++ b/app/Models/parserSkripte/Dmoznebel_int.php @@ -1,34 +1,35 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Dmoznebel_int extends Searchengine +class Dmoznebel_int extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { - public function loadResults ($result) - { - - $title = ""; - $link = ""; - $anzeigeLink = $link; - $descr = ""; + $title = ""; + $link = ""; + $anzeigeLink = $link; + $descr = ""; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } -} \ No newline at end of file + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } +} diff --git a/app/Models/parserSkripte/Ebay.php b/app/Models/parserSkripte/Ebay.php index 0494cc9a4..f3c6de876 100644 --- a/app/Models/parserSkripte/Ebay.php +++ b/app/Models/parserSkripte/Ebay.php @@ -1,67 +1,68 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use DateTimeZone; -use DateTime; -class Ebay extends Searchengine +class Ebay extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } + + if (!$content) { + return; + } + $results = $content; + + $results = $results->{"searchResult"}; + $count = 0; + foreach ($results->{"item"} as $result) { + $title = $result->{"title"}->__toString(); + $link = $result->{"viewItemURL"}->__toString(); + $anzeigeLink = $link; + $time = $result->{"listingInfo"}->{"endTime"}->__toString(); + $time = date(DATE_RFC2822, strtotime($time)); + $price = intval($result->{"sellingStatus"}->{"convertedCurrentPrice"}->__toString()) * 100; + $descr = "<p>Preis: " . $result->{"sellingStatus"}->{"convertedCurrentPrice"}->__toString() . " €</p>"; + $descr .= "<p>Versandkosten: " . $result->{"shippingInfo"}->{"shippingServiceCost"}->__toString() . " €</p>"; + if (isset($result->{"listingInfo"}->{"listingType"})) { + $descr .= "<p>Auktionsart: " . $result->{"listingInfo"}->{"listingType"}->__toString() . "</p>"; + } + + $descr .= "<p>Auktionsende: " . $time . "</p>"; + if (isset($result->{"primaryCategory"}->{"categoryName"})) { + $descr .= "<p class=\"text-muted\">Kategorie: " . $result->{"primaryCategory"}->{"categoryName"}->__toString() . "</p>"; + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + $image = $result->{"galleryURL"}->__toString(); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image, + $price + ); + $count++; - public function loadResults ($result) - { - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content; - - $results = $results->{"searchResult"}; - $count = 0; - foreach($results->{"item"} as $result) - { - $title = $result->{"title"}->__toString(); - $link = $result->{"viewItemURL"}->__toString(); - $anzeigeLink = $link; - $time = $result->{"listingInfo"}->{"endTime"}->__toString(); - $time = date(DATE_RFC2822, strtotime($time)); - $price = intval($result->{"sellingStatus"}->{"convertedCurrentPrice"}->__toString()) * 100; - $descr = "<p>Preis: " . $result->{"sellingStatus"}->{"convertedCurrentPrice"}->__toString() . " €</p>"; - $descr .= "<p>Versandkosten: " . $result->{"shippingInfo"}->{"shippingServiceCost"}->__toString() . " €</p>"; - if( isset($result->{"listingInfo"}->{"listingType"})) - $descr .= "<p>Auktionsart: " . $result->{"listingInfo"}->{"listingType"}->__toString() . "</p>"; - $descr .= "<p>Auktionsende: " . $time . "</p>"; - if( isset($result->{"primaryCategory"}->{"categoryName"})) - $descr .= "<p class=\"text-muted\">Kategorie: " . $result->{"primaryCategory"}->{"categoryName"}->__toString() . "</p>"; - $image = $result->{"galleryURL"}->__toString(); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image, - $price - ); - $count++; + } - } - - } -} \ No newline at end of file + } +} diff --git a/app/Models/parserSkripte/Ecoshopper.php b/app/Models/parserSkripte/Ecoshopper.php index c5e74c27b..3b013d142 100644 --- a/app/Models/parserSkripte/Ecoshopper.php +++ b/app/Models/parserSkripte/Ecoshopper.php @@ -1,63 +1,62 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; use Log; -class Ecoshopper extends Searchengine +class Ecoshopper extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + Log::error("Ergebnisse von Ecoshopper konnten nicht eingelesen werden"); + return; + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + if (!$content) { + return; + } + $results = $content->xpath('//response/result[@name="response"]/doc'); + foreach ($results as $result) { + $result = simplexml_load_string($result->saveXML()); + $title = $result->xpath('//doc/str[@name="artikelName"]')[0]->__toString(); + $link = $result->xpath('//doc/str[@name="artikelDeeplink"]')[0]->__toString(); + $anzeigeLink = parse_url($link); + if (isset($anzeigeLink['query'])) { + parse_str($anzeigeLink['query'], $query); + if (isset($query['diurl'])) { + $anzeigeLink = $query['diurl']; + } else { + $anzeigeLink = $link; + } - public function loadResults ($result) - { - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - Log::error("Ergebnisse von Ecoshopper konnten nicht eingelesen werden"); - return; - } - - if(!$content) - { - return; - } - $results = $content->xpath('//response/result[@name="response"]/doc'); - foreach($results as $result) - { - $result = simplexml_load_string($result->saveXML()); - $title = $result->xpath('//doc/str[@name="artikelName"]')[0]->__toString(); - $link = $result->xpath('//doc/str[@name="artikelDeeplink"]')[0]->__toString(); - $anzeigeLink = parse_url($link); - if( isset($anzeigeLink['query']) ) - { - parse_str($anzeigeLink['query'], $query); - if( isset($query['diurl']) ) - $anzeigeLink = $query['diurl']; - else - $anzeigeLink = $link; - }else - { - $anzeigeLink = $link; - } - $descr = $result->xpath('//doc/str[@name="artikelBeschreibung"]')[0]->__toString(); - $image = $result->xpath('//doc/str[@name="artikelImageurl"]')[0]->__toString(); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image - ); - } - } + } else { + $anzeigeLink = $link; + } + $descr = $result->xpath('//doc/str[@name="artikelBeschreibung"]')[0]->__toString(); + $image = $result->xpath('//doc/str[@name="artikelImageurl"]')[0]->__toString(); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } } diff --git a/app/Models/parserSkripte/Europeana.php b/app/Models/parserSkripte/Europeana.php index 2da2db448..9715b8790 100644 --- a/app/Models/parserSkripte/Europeana.php +++ b/app/Models/parserSkripte/Europeana.php @@ -1,68 +1,66 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Symfony\Component\DomCrawler\Crawler; -class Europeana extends Searchengine +class Europeana extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = json_decode($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid json string"); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = json_decode($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid json string"); - } - - if(!$content) - { - return; - } + if (!$content) { + return; + } - $results = $content->items; - foreach($results as $result) - { - if(isset($result->edmPreview)) { - $title = $result->title[0]; + $results = $content->items; + foreach ($results as $result) { + if (isset($result->edmPreview)) { + $title = $result->title[0]; - if (preg_match("/(.+)\?.*/si", $result->guid, $match)){ - $link = $match[1]; - } else { - $link = ""; - } + if (preg_match("/(.+)\?.*/si", $result->guid, $match)) { + $link = $match[1]; + } else { + $link = ""; + } - $anzeigeLink = $link; - $descr = ""; + $anzeigeLink = $link; + $descr = ""; - /*if (preg_match("/(?:uri=)(.+)/si", urldecode($result->edmPreview[0]), $match)){ - $image = $match[1]; - } else { - $image = ""; - } - echo $image . " -";*/ - $image = urldecode($result->edmPreview[0]); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image - ); - } - } - } -} \ No newline at end of file + /*if (preg_match("/(?:uri=)(.+)/si", urldecode($result->edmPreview[0]), $match)){ + $image = $match[1]; + } else { + $image = ""; + } + echo $image . " + ";*/ + $image = urldecode($result->edmPreview[0]); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } + } +} diff --git a/app/Models/parserSkripte/Exalead.php b/app/Models/parserSkripte/Exalead.php index 9d2aed861..8f7d671f8 100644 --- a/app/Models/parserSkripte/Exalead.php +++ b/app/Models/parserSkripte/Exalead.php @@ -1,79 +1,76 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Log; -class Exalead extends Searchengine +class Exalead extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + if (!$content) { + return; + } + $results = $content; + $prefix = ""; + $namespace = ""; + foreach ($results->getDocNamespaces() as $strPrefix => $strNamespace) { + if (strlen($strPrefix) == 0) { + $prefix = "a"; //Assign an arbitrary namespace prefix. + } else { + $prefix = "a"; + } + $namespace = $strNamespace; + } + $results->registerXPathNamespace($prefix, $namespace); + try { + $results = $results->xpath("//a:searchResult/a:item"); + } catch (\ErrorException $e) { + return; + } + foreach ($results as $result) { + try { + $result->registerXPathNamespace($prefix, $namespace); + $title = $result->xpath("a:metas/a:Meta[@name='title']/a:MetaString[@name='value']")[0]->__toString(); + $link = $result->xpath("a:metas/a:Meta[@name='url']/a:MetaString[@name='value']")[0]->__toString(); + $anzeigeLink = $link; + $descr = ""; + if (sizeOf($result->xpath("a:metas/a:Meta[@name='metadesc']/a:MetaString[@name='value']")) === 0 && sizeOf($result->xpath("a:metas/a:Meta[@name='summary']/a:MetaText[@name='value']")) !== 0) { + $tmp = $result->xpath("a:metas/a:Meta[@name='summary']/a:MetaText[@name='value']"); + foreach ($tmp as $el) { + $descr .= strip_tags($el->asXML()); + } + } else { + $descr = $result->xpath("a:metas/a:Meta[@name='metadesc']/a:MetaString[@name='value']")[0]->__toString(); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content; - $prefix = ""; $namespace = ""; - foreach($results->getDocNamespaces() as $strPrefix => $strNamespace) { - if(strlen($strPrefix)==0) { - $prefix="a"; //Assign an arbitrary namespace prefix. - }else { - $prefix="a"; - } - $namespace = $strNamespace; - } - $results->registerXPathNamespace($prefix,$namespace); - try{ - $results = $results->xpath("//a:searchResult/a:item"); - } catch(\ErrorException $e) - { - return; - } - foreach($results as $result) - { - try{ - $result->registerXPathNamespace($prefix,$namespace); - $title = $result->xpath("a:metas/a:Meta[@name='title']/a:MetaString[@name='value']")[0]->__toString(); - $link = $result->xpath("a:metas/a:Meta[@name='url']/a:MetaString[@name='value']")[0]->__toString(); - $anzeigeLink = $link; - $descr = ""; - if(sizeOf($result->xpath("a:metas/a:Meta[@name='metadesc']/a:MetaString[@name='value']")) === 0 && sizeOf($result->xpath("a:metas/a:Meta[@name='summary']/a:MetaText[@name='value']")) !== 0) - { - $tmp = $result->xpath("a:metas/a:Meta[@name='summary']/a:MetaText[@name='value']"); - foreach($tmp as $el) - { - $descr .= strip_tags($el->asXML()); - } - }else - $descr = $result->xpath("a:metas/a:Meta[@name='metadesc']/a:MetaString[@name='value']")[0]->__toString(); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - }catch(\ErrorException $e) - { - continue; - } - } - } + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } catch (\ErrorException $e) { + continue; + } + } + } } diff --git a/app/Models/parserSkripte/Fairmondo.php b/app/Models/parserSkripte/Fairmondo.php index 270954a92..b18cd1bb3 100644 --- a/app/Models/parserSkripte/Fairmondo.php +++ b/app/Models/parserSkripte/Fairmondo.php @@ -1,53 +1,53 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Fairmondo extends Searchengine +class Fairmondo extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $results = json_decode($result, true); + $results = $results["articles"]; + foreach ($results as $result) { + if ($this->counter >= 10) { + break; + } - public function loadResults ($result) - { - $results = json_decode($result, true); - $results = $results["articles"]; - foreach($results as $result) - { - if( $this->counter >= 10 ) - break; - $title = $result["title"]; - $link = "https://www.fairmondo.de/articles/" . $result["id"]; - $anzeigeLink = $link; - $price = 0; - $descr = ""; - if( isset($result['price_cents'])) - { - $price = intval($result['price_cents']); - $descr .= "<p>Preis: " . (intval($result['price_cents']) / 100.0) . " €</p>"; - } - if( isset($result['title_image_url']) ) - { - $image = $result['title_image_url']; - } + $title = $result["title"]; + $link = "https://www.fairmondo.de/articles/" . $result["id"]; + $anzeigeLink = $link; + $price = 0; + $descr = ""; + if (isset($result['price_cents'])) { + $price = intval($result['price_cents']); + $descr .= "<p>Preis: " . (intval($result['price_cents']) / 100.0) . " €</p>"; + } + if (isset($result['title_image_url'])) { + $image = $result['title_image_url']; + } - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image, - $price - ); - } - } -} \ No newline at end of file + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image, + $price + ); + } + } +} diff --git a/app/Models/parserSkripte/Fastbot.php b/app/Models/parserSkripte/Fastbot.php index 8fd1c19b6..208d953c4 100644 --- a/app/Models/parserSkripte/Fastbot.php +++ b/app/Models/parserSkripte/Fastbot.php @@ -1,49 +1,48 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Fastbot extends Searchengine +class Fastbot extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + if (strpos($this->urlEncode($metager->getEingabe()), "%") !== false) { + $this->enabled = false; + return null; + } + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - if ( strpos($this->urlEncode($metager->getEingabe()), "%") !== FALSE ) - { - $this->enabled = false; - return null; - } - } + public function loadResults($result) + { + $result = utf8_encode($result); + $counter = 0; + foreach (explode("\n", $result) as $line) { + $line = trim($line); + if (strlen($line) > 0) { + # Hier bekommen wir jedes einzelne Ergebnis + $result = explode("|:|", $line); + $link = $result[1]; + $link = substr($link, strpos($link, "href=\"") + 6); + $link = substr($link, 0, strpos($link, "\"")); + $counter++; + $this->gefVon = "<a href=\"" . $this->homepage . "\" target=\"_blank\">" . $this->displayName . " " . trans('results.redirect') . "</a>"; + $this->results[] = new \App\Models\Result( + $this->engine, + trim(strip_tags($result[1])), + $link, + $result[3], + $result[2], + $this->gefVon, + $counter + ); + } - public function loadResults ($result) - { - $result = utf8_encode($result); - $counter = 0; - foreach( explode("\n", $result) as $line ) - { - $line = trim($line); - if( strlen($line) > 0 ){ - # Hier bekommen wir jedes einzelne Ergebnis - $result = explode("|:|", $line); - $link = $result[1]; - $link = substr($link, strpos($link, "href=\"") + 6); - $link = substr($link, 0, strpos($link, "\"")); - $counter++; - $this->gefVon = "<a href=\"" . $this->homepage . "\" target=\"_blank\">" . $this->displayName . " " . trans('results.redirect') . "</a>"; - $this->results[] = new \App\Models\Result( - $this->engine, - trim(strip_tags($result[1])), - $link, - $result[3], - $result[2], - $this->gefVon, - $counter - ); - } - - } + } - } -} \ No newline at end of file + } +} diff --git a/app/Models/parserSkripte/Fernsehsuche.php b/app/Models/parserSkripte/Fernsehsuche.php index d8058b2f7..f33ff8f3e 100644 --- a/app/Models/parserSkripte/Fernsehsuche.php +++ b/app/Models/parserSkripte/Fernsehsuche.php @@ -1,51 +1,50 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Fernsehsuche extends Searchengine +class Fernsehsuche extends Searchengine { - public $results = []; + public $results = []; - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = json_decode($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = json_decode($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } - if(!$content) - { - return; - } + if (!$content) { + return; + } - $results = $content->response->docs; - foreach($results as $result) - { - $title = $result->show . " : " . $result->title; - $link = urldecode($result->url); - $anzeigeLink = $link; - $descr = $result->description; - $image = "http://api-resources.fernsehsuche.de" . $result->thumbnail; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image - ); - } - } -} \ No newline at end of file + $results = $content->response->docs; + foreach ($results as $result) { + $title = $result->show . " : " . $result->title; + $link = urldecode($result->url); + $anzeigeLink = $link; + $descr = $result->description; + $image = "http://api-resources.fernsehsuche.de" . $result->thumbnail; + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } +} diff --git a/app/Models/parserSkripte/Flickr.php b/app/Models/parserSkripte/Flickr.php index 50be0cd4b..f657714bd 100644 --- a/app/Models/parserSkripte/Flickr.php +++ b/app/Models/parserSkripte/Flickr.php @@ -1,51 +1,49 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Symfony\Component\DomCrawler\Crawler; -class Flickr extends Searchengine +class Flickr extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content->xpath('//photos/photo'); - foreach($results as $result) - { - $title = $result["title"]->__toString(); - $link = "https://www.flickr.com/photos/" . $result["owner"]->__toString() . "/" . $result["id"]->__toString(); - $anzeigeLink = $link; - $descr = ""; - $image = "http://farm" . $result["farm"]->__toString() . ".staticflickr.com/" . $result["server"]->__toString() . "/" . $result["id"]->__toString() . "_" . $result["secret"]->__toString() . "_t.jpg"; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image - ); - } - } -} \ No newline at end of file + if (!$content) { + return; + } + $results = $content->xpath('//photos/photo'); + foreach ($results as $result) { + $title = $result["title"]->__toString(); + $link = "https://www.flickr.com/photos/" . $result["owner"]->__toString() . "/" . $result["id"]->__toString(); + $anzeigeLink = $link; + $descr = ""; + $image = "http://farm" . $result["farm"]->__toString() . ".staticflickr.com/" . $result["server"]->__toString() . "/" . $result["id"]->__toString() . "_" . $result["secret"]->__toString() . "_t.jpg"; + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } +} diff --git a/app/Models/parserSkripte/Goyax.php b/app/Models/parserSkripte/Goyax.php index ccade3a7e..9c21a4952 100644 --- a/app/Models/parserSkripte/Goyax.php +++ b/app/Models/parserSkripte/Goyax.php @@ -1,42 +1,40 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; use Symfony\Component\DomCrawler\Crawler; -class Goyax extends Searchengine +class Goyax extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - - $crawler = new Crawler($result); - $crawler->filter('tr.treffer')->each(function (Crawler $node, $i) - { - $title = $node->filter('td.name')->text(); - $link = "http://www.goyax.de" . $node->filter('td.name > a')->attr('href'); - $anzeigeLink = $link; - $descr = "Aktie: " . $node->filter('td.waehrung')->text() . " " . $node->filter('td.isin')->text(); - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } ); - - - - } + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + + $crawler = new Crawler($result); + $crawler->filter('tr.treffer')->each(function (Crawler $node, $i) { + $title = $node->filter('td.name')->text(); + $link = "http://www.goyax.de" . $node->filter('td.name > a')->attr('href'); + $anzeigeLink = $link; + $descr = "Aktie: " . $node->filter('td.waehrung')->text() . " " . $node->filter('td.isin')->text(); + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + }); + + } } diff --git a/app/Models/parserSkripte/Loklak.php b/app/Models/parserSkripte/Loklak.php index b0aea9ac1..04d005eaf 100644 --- a/app/Models/parserSkripte/Loklak.php +++ b/app/Models/parserSkripte/Loklak.php @@ -1,43 +1,43 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Log; -class Loklak extends Searchengine +class Loklak extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + if (!$result) { + return; + } + $results = json_decode($result, true); + if (!isset($results['statuses'])) { + return; + } - public function loadResults ($result) - { - if(!$result) - { - return; - } - $results = json_decode($result, true); - if( !isset($results['statuses']) ) - return; - foreach($results['statuses'] as $result) - { - $title = $result["screen_name"]; - $link = $result['link']; - $anzeigeLink = $link; - $descr = $result["text"]; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } + foreach ($results['statuses'] as $result) { + $title = $result["screen_name"]; + $link = $result['link']; + $anzeigeLink = $link; + $descr = $result["text"]; + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } } diff --git a/app/Models/parserSkripte/Mg_hochsch_de.php b/app/Models/parserSkripte/Mg_hochsch_de.php index 011642d25..6914c8100 100644 --- a/app/Models/parserSkripte/Mg_hochsch_de.php +++ b/app/Models/parserSkripte/Mg_hochsch_de.php @@ -1,45 +1,43 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Mg_hochsch_de extends Searchengine +class Mg_hochsch_de extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - $results = trim($result); - - foreach( explode("\n", $results) as $result ) - { - $res = explode("|", $result); - if(sizeof($res) < 3) - { - continue; - } - $title = $res[0]; - $link = $res[2]; - $anzeigeLink = $link; - $descr = $res[1]; - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $results = trim($result); + + foreach (explode("\n", $results) as $result) { + $res = explode("|", $result); + if (sizeof($res) < 3) { + continue; + } + $title = $res[0]; + $link = $res[2]; + $anzeigeLink = $link; + $descr = $res[1]; + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + + } +} diff --git a/app/Models/parserSkripte/Mg_produkt2.php b/app/Models/parserSkripte/Mg_produkt2.php index 6aba1210b..839a20025 100644 --- a/app/Models/parserSkripte/Mg_produkt2.php +++ b/app/Models/parserSkripte/Mg_produkt2.php @@ -1,54 +1,54 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; use Log; -class Mg_produkt2 extends Searchengine + +class Mg_produkt2 extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + Log::error("MG_Produkt konnte keine Ergebnisse bekommen"); + return; + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - Log::error("MG_Produkt konnte keine Ergebnisse bekommen"); - return; - } - - if(!$content) - { - return; - } - $results = $content->xpath('//response/result[@name="response"]/doc'); - foreach($results as $result) - { - $result = simplexml_load_string($result->saveXML()); - $title = $result->xpath('/doc/arr[@name="artikelName"]')[0]->{"str"}->__toString(); - $link = $result->xpath('/doc/arr[@name="artikelDeeplink"]')[0]->{"str"}->__toString(); - $anzeigeLink = parse_url($link); - parse_str($anzeigeLink['query'], $query); - $anzeigeLink = $query['diurl']; - $descr = $result->xpath('/doc/arr[@name="artikelBeschreibung"]')[0]->{"str"}->__toString(); - $image = $result->xpath('/doc/arr[@name="artikelImageurl"]')[0]->{"str"}->__toString(); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image - ); - } - } + if (!$content) { + return; + } + $results = $content->xpath('//response/result[@name="response"]/doc'); + foreach ($results as $result) { + $result = simplexml_load_string($result->saveXML()); + $title = $result->xpath('/doc/arr[@name="artikelName"]')[0]->{"str"}->__toString(); + $link = $result->xpath('/doc/arr[@name="artikelDeeplink"]')[0]->{"str"}->__toString(); + $anzeigeLink = parse_url($link); + parse_str($anzeigeLink['query'], $query); + $anzeigeLink = $query['diurl']; + $descr = $result->xpath('/doc/arr[@name="artikelBeschreibung"]')[0]->{"str"}->__toString(); + $image = $result->xpath('/doc/arr[@name="artikelImageurl"]')[0]->{"str"}->__toString(); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } } diff --git a/app/Models/parserSkripte/Minisucher.php b/app/Models/parserSkripte/Minisucher.php index c214f3ea6..36dc2c6ca 100644 --- a/app/Models/parserSkripte/Minisucher.php +++ b/app/Models/parserSkripte/Minisucher.php @@ -7,79 +7,73 @@ use App\Models\Searchengine; class Minisucher extends Searchengine { - function __construct (\SimpleXMLElement $engine,\App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - public function loadResults ($content) - { - try { - $content = simplexml_load_string($content); - } catch (\Exception $e) { - return; - } - if(!$content) - { - return; - } - $results = $content->xpath('//response/result/doc'); + public function loadResults($content) + { + try { + $content = simplexml_load_string($content); + } catch (\Exception $e) { + return; + } + if (!$content) { + return; + } + $results = $content->xpath('//response/result/doc'); - $string = ""; - - $counter = 0; - $providerCounter = []; - foreach($results as $result) - { - try{ - $counter++; - $result = simplexml_load_string($result->saveXML()); + $string = ""; - $title = $result->xpath('//doc/arr[@name="title"]/str')[0]->__toString(); - $link = $result->xpath('//doc/str[@name="url"]')[0]->__toString(); - $anzeigeLink = $link; - $descr = ""; - $descriptions = $content->xpath("//response/lst[@name='highlighting']/lst[@name='$link']/arr[@name='content']/str"); - foreach($descriptions as $description) - { - $descr .= $description->__toString(); - } - $descr = strip_tags($descr); - $provider = $result->xpath('//doc/str[@name="subcollection"]')[0]->__toString(); + $counter = 0; + $providerCounter = []; + foreach ($results as $result) { + try { + $counter++; + $result = simplexml_load_string($result->saveXML()); - if( isset($providerCounter[$provider]) && $providerCounter[$provider] > 10 ) - continue; - else - { - if( !isset($providerCounter[$provider]) ) - $providerCounter[$provider] = 0; - $providerCounter[$provider] += 1; - } + $title = $result->xpath('//doc/arr[@name="title"]/str')[0]->__toString(); + $link = $result->xpath('//doc/str[@name="url"]')[0]->__toString(); + $anzeigeLink = $link; + $descr = ""; + $descriptions = $content->xpath("//response/lst[@name='highlighting']/lst[@name='$link']/arr[@name='content']/str"); + foreach ($descriptions as $description) { + $descr .= $description->__toString(); + } + $descr = strip_tags($descr); + $provider = $result->xpath('//doc/str[@name="subcollection"]')[0]->__toString(); - if( isset($provider) ) - { - $gefVon = "<a href=\"https://metager.de\" target=\"_blank\">Minisucher: $provider</a>"; - }else - { - $gefVon = $this->gefVon; - } + if (isset($providerCounter[$provider]) && $providerCounter[$provider] > 10) { + continue; + } else { + if (!isset($providerCounter[$provider])) { + $providerCounter[$provider] = 0; + } - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $link, - $descr, - $gefVon, - $counter - ); - }catch(\ErrorException $e) - { - continue; - } - } - - - } + $providerCounter[$provider] += 1; + } -} \ No newline at end of file + if (isset($provider)) { + $gefVon = "<a href=\"https://metager.de\" target=\"_blank\">Minisucher: $provider</a>"; + } else { + $gefVon = $this->gefVon; + } + + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $link, + $descr, + $gefVon, + $counter + ); + } catch (\ErrorException $e) { + continue; + } + } + + } + +} diff --git a/app/Models/parserSkripte/Mnogosearch.php b/app/Models/parserSkripte/Mnogosearch.php index cd78a95a3..43f2ed81a 100644 --- a/app/Models/parserSkripte/Mnogosearch.php +++ b/app/Models/parserSkripte/Mnogosearch.php @@ -1,51 +1,48 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; use Symfony\Component\DomCrawler\Crawler; -class Mnogosearch extends Searchengine +class Mnogosearch extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - $counter = 0; - $crawler = new Crawler($result); - $crawler->filter('table[width=600]') - ->reduce(function (Crawler $node, $i) - { - if(strpos($node->text(), "Result pages:") !== FALSE) - { - return false; - } - }) - ->each(function(Crawler $node, $i) - { - $title = $node->filter('table > tr > td ')->eq(1)->filter('td > div')->text(); - $title = preg_replace("/\s+/si", " ", $title); - - $link = $node->filter('table > tr > td ')->eq(1)->filter('td > div > a')->attr('href'); - $anzeigeLink = $link; - $descr = $node->filter('table > tr > td ')->eq(1)->filter('td > div')->eq(1)->text(); - $this->counter++; - - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - }); - - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $counter = 0; + $crawler = new Crawler($result); + $crawler->filter('table[width=600]') + ->reduce(function (Crawler $node, $i) { + if (strpos($node->text(), "Result pages:") !== false) { + return false; + } + }) + ->each(function (Crawler $node, $i) { + $title = $node->filter('table > tr > td ')->eq(1)->filter('td > div')->text(); + $title = preg_replace("/\s+/si", " ", $title); + + $link = $node->filter('table > tr > td ')->eq(1)->filter('td > div > a')->attr('href'); + $anzeigeLink = $link; + $descr = $node->filter('table > tr > td ')->eq(1)->filter('td > div')->eq(1)->text(); + $this->counter++; + + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + }); + + } +} diff --git a/app/Models/parserSkripte/Nebel.php b/app/Models/parserSkripte/Nebel.php index a03356504..3dca04d3c 100644 --- a/app/Models/parserSkripte/Nebel.php +++ b/app/Models/parserSkripte/Nebel.php @@ -1,42 +1,43 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Nebel extends Searchengine +class Nebel extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine,\App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - $results = trim($result); - foreach( explode("\n", $results) as $result ) - { - $res = explode("|", $result); - if(sizeof($res) < 3) - continue; - $title = $res[2]; - $link = $res[0]; - $anzeigeLink = $link; - $descr = $res[1]; - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $results = trim($result); + foreach (explode("\n", $results) as $result) { + $res = explode("|", $result); + if (sizeof($res) < 3) { + continue; + } + + $title = $res[2]; + $link = $res[0]; + $anzeigeLink = $link; + $descr = $res[1]; + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + + } +} diff --git a/app/Models/parserSkripte/Onenewspage.php b/app/Models/parserSkripte/Onenewspage.php index 24e9e1da2..127378be6 100644 --- a/app/Models/parserSkripte/Onenewspage.php +++ b/app/Models/parserSkripte/Onenewspage.php @@ -1,45 +1,43 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Onenewspage extends Searchengine +class Onenewspage extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - $results = trim($result); - - foreach( explode("\n", $results) as $result ) - { - $res = explode("|", $result); - if(sizeof($res) < 3) - { - continue; - } - $title = $res[0]; - $link = $res[2]; - $anzeigeLink = $link; - $descr = $res[1]; - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $results = trim($result); + + foreach (explode("\n", $results) as $result) { + $res = explode("|", $result); + if (sizeof($res) < 3) { + continue; + } + $title = $res[0]; + $link = $res[2]; + $anzeigeLink = $link; + $descr = $res[1]; + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + + } +} diff --git a/app/Models/parserSkripte/Onenewspagegermany.php b/app/Models/parserSkripte/Onenewspagegermany.php index 5783538d6..14585dd8f 100644 --- a/app/Models/parserSkripte/Onenewspagegermany.php +++ b/app/Models/parserSkripte/Onenewspagegermany.php @@ -1,44 +1,43 @@ <?php namespace app\Models\parserSkripte; -use App\Models\Searchengine; + use App\Models\Result; +use App\Models\Searchengine; -class Onenewspagegermany extends Searchengine +class Onenewspagegermany extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $counter = 0; + foreach (explode("\n", $result) as $line) { + $line = trim($line); + if (strlen($line) > 0) { + # Hier bekommen wir jedes einzelne Ergebnis + $result = explode("|", $line); + if (sizeof($result) < 3) { + continue; + } + $counter++; + $this->results[] = new Result( + $this->engine, + trim(strip_tags($result[0])), + $result[2], + $result[2], + $result[1], + $this->gefVon, + $counter + ); + } - public function loadResults ($result) - { - $counter = 0; - foreach( explode("\n", $result) as $line ) - { - $line = trim($line); - if( strlen($line) > 0 ){ - # Hier bekommen wir jedes einzelne Ergebnis - $result = explode("|", $line); - if(sizeof($result) < 3) - { - continue; - } - $counter++; - $this->results[] = new Result( - $this->engine, - trim(strip_tags($result[0])), - $result[2], - $result[2], - $result[1], - $this->gefVon, - $counter - ); - } - - } + } - } -} \ No newline at end of file + } +} diff --git a/app/Models/parserSkripte/Onenewspagevideo.php b/app/Models/parserSkripte/Onenewspagevideo.php index b7e33ad31..52414dade 100644 --- a/app/Models/parserSkripte/Onenewspagevideo.php +++ b/app/Models/parserSkripte/Onenewspagevideo.php @@ -1,44 +1,42 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Onenewspagevideo extends Searchengine +class Onenewspagevideo extends Searchengine { - public $results = []; + public $results = []; - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - public function loadResults ($result) - { - $results = trim($result); - foreach( explode("\n", $results) as $result ) - { - $res = explode("|", $result); - if(sizeof($res) < 3) - { - continue; - } - $title = $res[0]; - $link = $res[2]; - $anzeigeLink = $link; - $descr = $res[1]; + public function loadResults($result) + { + $results = trim($result); + foreach (explode("\n", $results) as $result) { + $res = explode("|", $result); + if (sizeof($res) < 3) { + continue; + } + $title = $res[0]; + $link = $res[2]; + $anzeigeLink = $link; + $descr = $res[1]; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } - - } -} \ No newline at end of file + } +} diff --git a/app/Models/parserSkripte/Openclipart.php b/app/Models/parserSkripte/Openclipart.php index 73da73f02..d6674bc71 100644 --- a/app/Models/parserSkripte/Openclipart.php +++ b/app/Models/parserSkripte/Openclipart.php @@ -1,52 +1,50 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Symfony\Component\DomCrawler\Crawler; -class Openclipart extends Searchengine +class Openclipart extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = json_decode($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid json string"); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = json_decode($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid json string"); - } - - if(!$content) - { - return; - } + if (!$content) { + return; + } - $results = $content->payload; - foreach($results as $result) - { - $title = $result->title; - $link = $result->detail_link; - $anzeigeLink = $link; - $descr = $result->description; - $image = $result->svg->url; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image - ); - } - } -} \ No newline at end of file + $results = $content->payload; + foreach ($results as $result) { + $title = $result->title; + $link = $result->detail_link; + $anzeigeLink = $link; + $descr = $result->description; + $image = $result->svg->url; + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } +} diff --git a/app/Models/parserSkripte/Opencrawlastronomie.php b/app/Models/parserSkripte/Opencrawlastronomie.php index 5d886cf60..2cb36444d 100644 --- a/app/Models/parserSkripte/Opencrawlastronomie.php +++ b/app/Models/parserSkripte/Opencrawlastronomie.php @@ -1,52 +1,53 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Opencrawlastronomie extends Searchengine +class Opencrawlastronomie extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content->xpath('//rss/channel/item'); - $count = 0; - foreach($results as $result) - { - if($count > 10) - break; - $title = $result->{"title"}->__toString(); - $link = $result->{"link"}->__toString(); - $anzeigeLink = $link; - $descr = strip_tags($result->{"description"}->__toString()); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - $count++; - - } - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } + + if (!$content) { + return; + } + $results = $content->xpath('//rss/channel/item'); + $count = 0; + foreach ($results as $result) { + if ($count > 10) { + break; + } + + $title = $result->{"title"}->__toString(); + $link = $result->{"link"}->__toString(); + $anzeigeLink = $link; + $descr = strip_tags($result->{"description"}->__toString()); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + $count++; + + } + + } +} diff --git a/app/Models/parserSkripte/Opencrawlregengergie.php b/app/Models/parserSkripte/Opencrawlregengergie.php index 156c7a92f..e601ce52b 100644 --- a/app/Models/parserSkripte/Opencrawlregengergie.php +++ b/app/Models/parserSkripte/Opencrawlregengergie.php @@ -1,52 +1,53 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Opencrawlregengergie extends Searchengine +class Opencrawlregengergie extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content->xpath('//rss/channel/item'); - $count = 0; - foreach($results as $result) - { - if($count > 10) - break; - $title = $result->{"title"}->__toString(); - $link = $result->{"link"}->__toString(); - $anzeigeLink = $link; - $descr = strip_tags($result->{"description"}->__toString()); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - $count++; - - } - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } + + if (!$content) { + return; + } + $results = $content->xpath('//rss/channel/item'); + $count = 0; + foreach ($results as $result) { + if ($count > 10) { + break; + } + + $title = $result->{"title"}->__toString(); + $link = $result->{"link"}->__toString(); + $anzeigeLink = $link; + $descr = strip_tags($result->{"description"}->__toString()); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + $count++; + + } + + } +} diff --git a/app/Models/parserSkripte/Opencrawltauchen.php b/app/Models/parserSkripte/Opencrawltauchen.php index 0237f60eb..db07e29d1 100644 --- a/app/Models/parserSkripte/Opencrawltauchen.php +++ b/app/Models/parserSkripte/Opencrawltauchen.php @@ -1,51 +1,52 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Opencrawltauchen extends Searchengine +class Opencrawltauchen extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content->xpath('//rss/channel/item'); - $count = 0; - foreach($results as $result) - { - if($count > 10) - break; - $title = $result->{"title"}->__toString(); - $link = $result->{"link"}->__toString(); - $anzeigeLink = $link; - $descr = strip_tags($result->{"description"}->__toString()); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - $count++; - - } - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } + + if (!$content) { + return; + } + $results = $content->xpath('//rss/channel/item'); + $count = 0; + foreach ($results as $result) { + if ($count > 10) { + break; + } + + $title = $result->{"title"}->__toString(); + $link = $result->{"link"}->__toString(); + $anzeigeLink = $link; + $descr = strip_tags($result->{"description"}->__toString()); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + $count++; + + } + } +} diff --git a/app/Models/parserSkripte/Overture.php b/app/Models/parserSkripte/Overture.php index 2aa36de78..f806c0832 100644 --- a/app/Models/parserSkripte/Overture.php +++ b/app/Models/parserSkripte/Overture.php @@ -1,68 +1,65 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Log; -class Overture extends Searchengine +class Overture extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content->xpath('//Results/ResultSet[@id="inktomi"]/Listing'); - foreach($results as $result) - { - $title = $result["title"]; - $link = $result->{"ClickUrl"}->__toString(); - $anzeigeLink = $result["siteHost"]; - $descr = $result["description"]; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } + if (!$content) { + return; + } + $results = $content->xpath('//Results/ResultSet[@id="inktomi"]/Listing'); + foreach ($results as $result) { + $title = $result["title"]; + $link = $result->{"ClickUrl"}->__toString(); + $anzeigeLink = $result["siteHost"]; + $descr = $result["description"]; + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } - # Nun noch die Werbeergebnisse: - $ads = $content->xpath('//Results/ResultSet[@id="searchResults"]/Listing'); - foreach($ads as $ad) - { - $title = $ad["title"]; - $link = $ad->{"ClickUrl"}->__toString(); - $anzeigeLink = $ad["siteHost"]; - $descr = $ad["description"]; - $this->counter++; - $this->ads[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } -} \ No newline at end of file + # Nun noch die Werbeergebnisse: + $ads = $content->xpath('//Results/ResultSet[@id="searchResults"]/Listing'); + foreach ($ads as $ad) { + $title = $ad["title"]; + $link = $ad->{"ClickUrl"}->__toString(); + $anzeigeLink = $ad["siteHost"]; + $descr = $ad["description"]; + $this->counter++; + $this->ads[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } +} diff --git a/app/Models/parserSkripte/OvertureAds.php b/app/Models/parserSkripte/OvertureAds.php index f28f74dde..e48bc7ed6 100644 --- a/app/Models/parserSkripte/OvertureAds.php +++ b/app/Models/parserSkripte/OvertureAds.php @@ -7,43 +7,41 @@ use App\Models\Searchengine; class OvertureAds extends Searchengine { - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - - $ads = $content->xpath('//Results/ResultSet[@id="searchResults"]/Listing'); - foreach($ads as $ad) - { - $title = $ad["title"]; - $link = $ad->{"ClickUrl"}->__toString(); - $anzeigeLink = $ad["siteHost"]; - $descr = $ad["description"]; - $this->counter++; - $this->ads[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } - -} \ No newline at end of file + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } + + if (!$content) { + return; + } + + $ads = $content->xpath('//Results/ResultSet[@id="searchResults"]/Listing'); + foreach ($ads as $ad) { + $title = $ad["title"]; + $link = $ad->{"ClickUrl"}->__toString(); + $anzeigeLink = $ad["siteHost"]; + $descr = $ad["description"]; + $this->counter++; + $this->ads[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } + +} diff --git a/app/Models/parserSkripte/Pixabay.php b/app/Models/parserSkripte/Pixabay.php index 7753204e8..31f07dc46 100644 --- a/app/Models/parserSkripte/Pixabay.php +++ b/app/Models/parserSkripte/Pixabay.php @@ -1,52 +1,50 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Symfony\Component\DomCrawler\Crawler; -class Pixabay extends Searchengine +class Pixabay extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = json_decode($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid json string"); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = json_decode($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid json string"); - } - - if(!$content) - { - return; - } + if (!$content) { + return; + } - $results = $content->hits; - foreach($results as $result) - { - $title = $result->tags; - $link = $result->pageURL; - $anzeigeLink = $link; - $descr = ""; - $image = $result->previewURL; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter, - false, - $image - ); - } - } + $results = $content->hits; + foreach ($results as $result) { + $title = $result->tags; + $link = $result->pageURL; + $anzeigeLink = $link; + $descr = ""; + $image = $result->previewURL; + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } } diff --git a/app/Models/parserSkripte/Qip.php b/app/Models/parserSkripte/Qip.php index 79466600f..c043b7f27 100644 --- a/app/Models/parserSkripte/Qip.php +++ b/app/Models/parserSkripte/Qip.php @@ -1,48 +1,46 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Log; -class Qip extends Searchengine +class Qip extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content->xpath('//channel/item'); - foreach($results as $result) - { - $title = $result->{"title"}->__toString(); - $link = $result->{"link"}->__toString(); - $anzeigeLink = $link; - $descr = $result->{"description"}->__toString(); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } + if (!$content) { + return; + } + $results = $content->xpath('//channel/item'); + foreach ($results as $result) { + $title = $result->{"title"}->__toString(); + $link = $result->{"link"}->__toString(); + $anzeigeLink = $link; + $descr = $result->{"description"}->__toString(); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } } diff --git a/app/Models/parserSkripte/Qualigo.php b/app/Models/parserSkripte/Qualigo.php index 597f6ec80..ff240f802 100644 --- a/app/Models/parserSkripte/Qualigo.php +++ b/app/Models/parserSkripte/Qualigo.php @@ -7,41 +7,39 @@ use App\Models\Searchengine; class Qualigo extends Searchengine { - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - public function loadResults ($results) - { - try { - $content = simplexml_load_string($results); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content->xpath('//RL/RANK'); - foreach($results as $result) - { - $title = $result->{"TITLE"}->__toString(); - $link = $result->{"URL"}->__toString(); - $anzeigeLink = $result->{"ORIGURL"}->__toString(); - $descr = $result->{"ABSTRACT"}->__toString(); - $this->counter++; - $this->ads[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } + public function loadResults($results) + { + try { + $content = simplexml_load_string($results); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } -} \ No newline at end of file + if (!$content) { + return; + } + $results = $content->xpath('//RL/RANK'); + foreach ($results as $result) { + $title = $result->{"TITLE"}->__toString(); + $link = $result->{"URL"}->__toString(); + $anzeigeLink = $result->{"ORIGURL"}->__toString(); + $descr = $result->{"ABSTRACT"}->__toString(); + $this->counter++; + $this->ads[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } + +} diff --git a/app/Models/parserSkripte/Similar_product.php b/app/Models/parserSkripte/Similar_product.php index afd4cf042..4a5834029 100644 --- a/app/Models/parserSkripte/Similar_product.php +++ b/app/Models/parserSkripte/Similar_product.php @@ -1,38 +1,38 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Similar_product extends Searchengine +class Similar_product extends Searchengine { - public $results = []; + public $results = []; - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - public function loadResults ($result) - { - $results = json_decode($result); + public function loadResults($result) + { + $results = json_decode($result); - foreach($results->{"products"} as $result) - { - $title = $result->{"title"}; - $link = $result->{"product_url"}; - $anzeigeLink = $link; - $descr = $result->{"description"}; + foreach ($results->{"products"} as $result) { + $title = $result->{"title"}; + $link = $result->{"product_url"}; + $anzeigeLink = $link; + $descr = $result->{"description"}; - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } -} \ No newline at end of file + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } +} diff --git a/app/Models/parserSkripte/Similar_product_ads.php b/app/Models/parserSkripte/Similar_product_ads.php index 8db3b4882..a8d1f42c2 100644 --- a/app/Models/parserSkripte/Similar_product_ads.php +++ b/app/Models/parserSkripte/Similar_product_ads.php @@ -7,39 +7,37 @@ use App\Models\Searchengine; class Similar_product_ads extends Searchengine { - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - $tmp = $metager->getEingabe(); - $tmp = preg_replace("/\W/si", "", $tmp); - if(strlen($tmp) < 3) - { - $this->removeCurlHandle($mh); - } - } - - public function loadResults ($results) - { - $results = json_decode($result); - - foreach($results->{"products"} as $result) - { - $title = $result->{"title"}; - $link = $result->{"product_url"}; - $anzeigeLink = $link; - $descr = $result->{"description"}; - - $this->counter++; - $this->ads[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } - -} \ No newline at end of file + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + $tmp = $metager->getEingabe(); + $tmp = preg_replace("/\W/si", "", $tmp); + if (strlen($tmp) < 3) { + $this->removeCurlHandle($mh); + } + } + + public function loadResults($results) + { + $results = json_decode($result); + + foreach ($results->{"products"} as $result) { + $title = $result->{"title"}; + $link = $result->{"product_url"}; + $anzeigeLink = $link; + $descr = $result->{"description"}; + + $this->counter++; + $this->ads[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } + +} diff --git a/app/Models/parserSkripte/Suchticker.php b/app/Models/parserSkripte/Suchticker.php index 8d9b66ed6..14b004dee 100644 --- a/app/Models/parserSkripte/Suchticker.php +++ b/app/Models/parserSkripte/Suchticker.php @@ -1,45 +1,43 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Suchticker extends Searchengine +class Suchticker extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - $results = trim($result); - - foreach( explode("\n", $results) as $result ) - { - $res = explode("';'", $result); - if(sizeof($res) < 3) - { - continue; - } - $title = trim($res[0], "'"); - $link = trim($res[1], "'"); - $anzeigeLink = $link; - $descr = trim($res[2], "'"); - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + $results = trim($result); + + foreach (explode("\n", $results) as $result) { + $res = explode("';'", $result); + if (sizeof($res) < 3) { + continue; + } + $title = trim($res[0], "'"); + $link = trim($res[1], "'"); + $anzeigeLink = $link; + $descr = trim($res[2], "'"); + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + + } +} diff --git a/app/Models/parserSkripte/Tuhh.php b/app/Models/parserSkripte/Tuhh.php index e5614fb73..6c9150910 100644 --- a/app/Models/parserSkripte/Tuhh.php +++ b/app/Models/parserSkripte/Tuhh.php @@ -1,50 +1,51 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Tuhh extends Searchengine +class Tuhh extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $count = 0; - foreach($content->{"entry"} as $result) - { - if($count > 10) - break; - $title = $result->{"title"}->__toString(); - $link = $result->{"link"}["href"]->__toString(); - $anzeigeLink = $link; - $descr = strip_tags($result->{"summary"}->__toString()); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - $count++; - } - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } + + if (!$content) { + return; + } + $count = 0; + foreach ($content->{"entry"} as $result) { + if ($count > 10) { + break; + } + + $title = $result->{"title"}->__toString(); + $link = $result->{"link"}["href"]->__toString(); + $anzeigeLink = $link; + $descr = strip_tags($result->{"summary"}->__toString()); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + $count++; + } + + } +} diff --git a/app/Models/parserSkripte/Wikipedia.php b/app/Models/parserSkripte/Wikipedia.php index c52723d71..f1fdd6ecf 100644 --- a/app/Models/parserSkripte/Wikipedia.php +++ b/app/Models/parserSkripte/Wikipedia.php @@ -1,30 +1,31 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Wikipedia extends Searchengine +class Wikipedia extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine,\App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = utf8_decode($result); + $counter = 0; - public function loadResults ($result) - { - $result = utf8_decode($result); - $counter = 0; - - $this->results[] = new \App\Models\Result( - $this->engine, - trim(strip_tags($result[1])), - $link, - $result[3], - $result[2], - $this->gefVon, - $counter - ); - } -} \ No newline at end of file + $this->results[] = new \App\Models\Result( + $this->engine, + trim(strip_tags($result[1])), + $link, + $result[3], + $result[2], + $this->gefVon, + $counter + ); + } +} diff --git a/app/Models/parserSkripte/Witch.php b/app/Models/parserSkripte/Witch.php index d87851c7f..27d76a69b 100644 --- a/app/Models/parserSkripte/Witch.php +++ b/app/Models/parserSkripte/Witch.php @@ -1,36 +1,34 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Witch extends Searchengine +class Witch extends Searchengine { public $results = []; - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) { parent::__construct($engine, $metager); } - public function loadResults ($result) + public function loadResults($result) { $result = html_entity_decode(trim(utf8_encode($result))); - + $results = explode("\n", $result); array_shift($results); - foreach($results as $res) - { - + foreach ($results as $res) { + $res = explode(";", $res); - if(sizeof($res) !== 4 || $res[3] === "'Kein Ergebnis'") - { + if (sizeof($res) !== 4 || $res[3] === "'Kein Ergebnis'") { continue; } - $title = trim($res[0], "'"); - $link = trim($res[2], "'"); + $title = trim($res[0], "'"); + $link = trim($res[2], "'"); $anzeigeLink = $link; - $descr = trim($res[1], "'"); - + $descr = trim($res[1], "'"); $this->counter++; $this->results[] = new \App\Models\Result( @@ -45,4 +43,4 @@ class Witch extends Searchengine } } -} \ No newline at end of file +} diff --git a/app/Models/parserSkripte/Yacy.php b/app/Models/parserSkripte/Yacy.php index 3fc550a84..05ac7e562 100644 --- a/app/Models/parserSkripte/Yacy.php +++ b/app/Models/parserSkripte/Yacy.php @@ -1,37 +1,41 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Yacy extends Searchengine +class Yacy extends Searchengine { public $results = []; - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) { parent::__construct($engine, $metager); } - public function loadResults ($result) + public function loadResults($result) { - + try { $content = simplexml_load_string($result); } catch (\Exception $e) { abort(500, "$result is not a valid xml string"); } - if(!$content) + if (!$content) { return; + } + $results = $content->xpath("//rss/channel/item"); - if(!$results) + if (!$results) { return; - foreach($results as $res) - { - $title = $res->{"title"}; - $link = $res->{"link"}; + } + + foreach ($results as $res) { + $title = $res->{"title"}; + $link = $res->{"link"}; $anzeigeLink = $link; - $descr = $res->{"description"}; + $descr = $res->{"description"}; $this->counter++; $this->results[] = new \App\Models\Result( @@ -43,6 +47,6 @@ class Yacy extends Searchengine $this->gefVon, $this->counter ); - } + } } -} \ No newline at end of file +} diff --git a/app/Models/parserSkripte/Yacyunih.php b/app/Models/parserSkripte/Yacyunih.php index e9532d8f7..beefd276e 100644 --- a/app/Models/parserSkripte/Yacyunih.php +++ b/app/Models/parserSkripte/Yacyunih.php @@ -1,54 +1,57 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Yacyunih extends Searchengine +class Yacyunih extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content->xpath('//rss/channel/item'); - if(!$results) - return; - $count = 0; - foreach($results as $result) - { - if($count > 10) - break; - $title = $result->{"title"}->__toString(); - $link = $result->{"link"}->__toString(); - $anzeigeLink = $link; - $descr = strip_tags($result->{"description"}->__toString()); - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - $count++; - - } - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } + + if (!$content) { + return; + } + $results = $content->xpath('//rss/channel/item'); + if (!$results) { + return; + } + + $count = 0; + foreach ($results as $result) { + if ($count > 10) { + break; + } + + $title = $result->{"title"}->__toString(); + $link = $result->{"link"}->__toString(); + $anzeigeLink = $link; + $descr = strip_tags($result->{"description"}->__toString()); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + $count++; + + } + + } +} diff --git a/app/Models/parserSkripte/Yandex.php b/app/Models/parserSkripte/Yandex.php index c3cb2d013..2de70900a 100644 --- a/app/Models/parserSkripte/Yandex.php +++ b/app/Models/parserSkripte/Yandex.php @@ -1,58 +1,54 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -use Log; -class Yandex extends Searchengine +class Yandex extends Searchengine { - public $results = []; + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } + public function loadResults($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = simplexml_load_string($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid xml string"); + } - public function loadResults ($result) - { - $result = preg_replace("/\r\n/si", "", $result); - try { - $content = simplexml_load_string($result); - } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); - } - - if(!$content) - { - return; - } - $results = $content; - try{ - $results = $results->xpath("//yandexsearch/response/results/grouping/group"); - } catch(\ErrorException $e) - { - return; - } - foreach($results as $result) - { - $title = strip_tags($result->{"doc"}->{"title"}->asXML()); - $link = $result->{"doc"}->{"url"}->__toString(); - $anzeigeLink = $link; - $descr = strip_tags($result->{"doc"}->{"headline"}->asXML()); - if( !$descr ) - { - $descr = strip_tags($result->{"doc"}->{"passages"}->asXML()); - } - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - } + if (!$content) { + return; + } + $results = $content; + try { + $results = $results->xpath("//yandexsearch/response/results/grouping/group"); + } catch (\ErrorException $e) { + return; + } + foreach ($results as $result) { + $title = strip_tags($result->{"doc"}->{"title"}->asXML()); + $link = $result->{"doc"}->{"url"}->__toString(); + $anzeigeLink = $link; + $descr = strip_tags($result->{"doc"}->{"headline"}->asXML()); + if (!$descr) { + $descr = strip_tags($result->{"doc"}->{"passages"}->asXML()); + } + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } } diff --git a/app/Models/parserSkripte/Zeitde.php b/app/Models/parserSkripte/Zeitde.php index 99014cc0b..2a2f51619 100644 --- a/app/Models/parserSkripte/Zeitde.php +++ b/app/Models/parserSkripte/Zeitde.php @@ -1,45 +1,47 @@ <?php namespace app\Models\parserSkripte; + use App\Models\Searchengine; -class Zeitde extends Searchengine +class Zeitde extends Searchengine { - public $results = []; - - function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) - { - parent::__construct($engine, $metager); - } - - public function loadResults ($result) - { - - $results = json_decode($result); - if(!$results) - return; - foreach( $results->{"matches"} as $result ) - { - if( !isset($result->{"title"}) || !isset($result->{"href"}) || !isset($result->{"snippet"})) - continue; - $title = $result->{"title"}; - $link = $result->{"href"}; - $anzeigeLink = $link; - $descr = $result->{"snippet"}; - - $this->counter++; - $this->results[] = new \App\Models\Result( - $this->engine, - $title, - $link, - $anzeigeLink, - $descr, - $this->gefVon, - $this->counter - ); - } - - - - } -} \ No newline at end of file + public $results = []; + + public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults($result) + { + + $results = json_decode($result); + if (!$results) { + return; + } + + foreach ($results->{"matches"} as $result) { + if (!isset($result->{"title"}) || !isset($result->{"href"}) || !isset($result->{"snippet"})) { + continue; + } + + $title = $result->{"title"}; + $link = $result->{"href"}; + $anzeigeLink = $link; + $descr = $result->{"snippet"}; + + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + + } +} diff --git a/resources/lang/de/datenschutz.php b/resources/lang/de/datenschutz.php index 25a4c18f9..dccba9da7 100644 --- a/resources/lang/de/datenschutz.php +++ b/resources/lang/de/datenschutz.php @@ -1,33 +1,43 @@ <?php return [ - 'head' => 'Datenschutz und Privatsphäre', + 'head' => 'Datenschutz und Privatsphäre', - 'general.1' => 'Datenschutz und Privatsphäre gehören für uns zu den wichtigsten Gütern im Internet. Sie sind absolut schützenswert und dürfen keinesfalls kommerziell genutzt werden. Im Folgenden eine kurze Auflistung unserer Vorgehensweise. Eine ausführliche Darstellung mit Hintergrund-Informationen, warum wir die einzige wirklich sichere Suchmaschine betreiben, finden Sie', - 'general.2' => 'hier', + 'general.1' => 'Datenschutz und Privatsphäre gehören für uns zu den wichtigsten Gütern im Internet. Sie sind absolut schützenswert und dürfen keinesfalls kommerziell genutzt werden. Im Folgenden eine kurze Auflistung unserer Vorgehensweise. Eine ausführliche Darstellung mit Hintergrund-Informationen, warum wir die einzige wirklich sichere Suchmaschine betreiben, finden Sie', + 'general.2' => 'hier', + 'general.3' => 'Nur Software, die frei und quellcode-offen ist, kann von jedem überprüft +werden. In allen anderen Fällen müssen User GLAUBEN, was Betreiber oder +"Gütesiegel"-Verkäufer behaupten. MetaGer ist Freie Software unter +unter GNU-AGPLv3 Lizenz (siehe dazu Nachricht im Heise-Ticker: +<a href="http://heise.de/-3295586" target="_blank">http://heise.de/-3295586</a>).<br /> - 'policy.1' => 'Unsere Vorgehensweise/Policy:', - 'policy.2' => 'Wir speichern weder Ihre IP-Adresse, noch den', - 'policy.3' => '"Fingerabdruck" Ihres Browsers', - 'policy.4' => '(der Sie mit hoher Wahrscheinlichkeit ebenfalls eindeutig identifizieren könnte).', - 'policy.5' => 'Wir setzen keine Cookies oder benutzen Tracking-Pixel oder ähnliche Technologien, um unsere Nutzer zu "tracken" (tracken = Verfolgen der Bewegungen im Internet).', - 'policy.6' => 'Die Datenübertragung von MetaGer erfolgt ausschließlich automatisch verschlüsselt über das https-Protokoll.', - 'policy.7' => 'Wir bieten einen Zugang über das anonyme TOR-Netzwerk, den', - 'policy.8' => 'MetaGer-TOR-hidden Service.', - 'policy.9' => 'Da der Zugang über das TOR-Netzwerk vielen Nutzern kompliziert erscheint, manchmal auch langsam ist, haben wir einen weiteren Weg implementiert, auch die Ergebnis-Webseiten ebenfalls anonym erreichen zu können: durch Anklicken des Links "anonym öffnen". Dadurch sind Ihre persönlichen Daten beim Klick auf MetaGer-Ergebnisse und sogar bei allen Folge-Klicks danach geschützt.', - 'policy.10' => 'Wir machen möglichst wenig Werbung, kennzeichnen diese klar und eindeutig, und vertrauen für unsere Finanzierung auf unsere Nutzer, Ihre', - 'policy.11' => 'Spenden', - 'policy.12' => 'und Mitgliedsbeträge zum', - 'policy.13' => 'MetaGer wird von der deutschen gemeinnützigen Organisation', - 'policy.14' => 'in Zusammenarbeit mit der', - 'policy.15' => 'Leibniz Universität Hannover', - 'policy.16' => 'betrieben und weiterentwickelt.', - 'policy.17' => 'Unsere Server stehen ausschließlich in Deutschland. Sie unterliegen damit vollständig deutschem Datenschutzrecht, welches als das härteste der Welt gilt.', - 'policy.18' => 'Nach den', - 'policy.19' => 'Enthüllungen von Edward Snowden im Juni 2013', - 'policy.20' => 'positionierten sich etliche Suchmaschinen mit der Selbstbeschreibung, dass Suchen bei ihnen sicher sei, weil die IP-Adressen der Nutzer nicht gespeichert würden. So ehrenwert und auch ehrlich gemeint diese Selbstbeschreibungen sein mögen - Fakt ist, dass viele dieser Suchmaschinen zumindest einen Teil ihrer Server in den USA hosten. Das gilt auch für diejenigen, die von manchen Datenschützern immer noch als "besonders empfehlenswert" gelobt und als Empfehlung verbreitet werden. Denn diese Suchmaschinen', - 'policy.21' => 'unterliegen nach dem Patriot Act und US-Recht dem vollen Zugriff der dortigen Behörden.', - 'policy.22' => 'Sie können also gar keine geschützte Privatsphäre bieten (selbst dann nicht, wenn sie selber sich noch so sehr darum bemühen).', +Der MetaGer-Quellcode steht Ihnen unter folgendem Link zur Verfügung: +<a href="https://gitlab.metager3.de/open-source/MetaGer" target="_blank">https://gitlab.metager3.de/open-source/MetaGer</a><br /> - 'twitter' => 'Was andere über unser Privacy-Konzept auf Twitter sagen:', -]; \ No newline at end of file +Sie müssen uns nichts glauben: SIE können es selber kontrollieren!', + + 'policy.1' => 'Unsere Vorgehensweise/Policy:', + 'policy.2' => 'Wir speichern weder Ihre IP-Adresse, noch den', + 'policy.3' => '"Fingerabdruck" Ihres Browsers', + 'policy.4' => '(der Sie mit hoher Wahrscheinlichkeit ebenfalls eindeutig identifizieren könnte).', + 'policy.5' => 'Wir setzen keine Cookies oder benutzen Tracking-Pixel oder ähnliche Technologien, um unsere Nutzer zu "tracken" (tracken = Verfolgen der Bewegungen im Internet).', + 'policy.6' => 'Die Datenübertragung von MetaGer erfolgt ausschließlich automatisch verschlüsselt über das https-Protokoll.', + 'policy.7' => 'Wir bieten einen Zugang über das anonyme TOR-Netzwerk, den', + 'policy.8' => 'MetaGer-TOR-hidden Service.', + 'policy.9' => 'Da der Zugang über das TOR-Netzwerk vielen Nutzern kompliziert erscheint, manchmal auch langsam ist, haben wir einen weiteren Weg implementiert, auch die Ergebnis-Webseiten ebenfalls anonym erreichen zu können: durch Anklicken des Links "anonym öffnen". Dadurch sind Ihre persönlichen Daten beim Klick auf MetaGer-Ergebnisse und sogar bei allen Folge-Klicks danach geschützt.', + 'policy.10' => 'Wir machen möglichst wenig Werbung, kennzeichnen diese klar und eindeutig, und vertrauen für unsere Finanzierung auf unsere Nutzer, Ihre', + 'policy.11' => 'Spenden', + 'policy.12' => 'und Mitgliedsbeträge zum', + 'policy.13' => 'MetaGer wird von der deutschen gemeinnützigen Organisation', + 'policy.14' => 'in Zusammenarbeit mit der', + 'policy.15' => 'Leibniz Universität Hannover', + 'policy.16' => 'betrieben und weiterentwickelt.', + 'policy.17' => 'Unsere Server stehen ausschließlich in Deutschland. Sie unterliegen damit vollständig deutschem Datenschutzrecht, welches als das härteste der Welt gilt.', + 'policy.18' => 'Nach den', + 'policy.19' => 'Enthüllungen von Edward Snowden im Juni 2013', + 'policy.20' => 'positionierten sich etliche Suchmaschinen mit der Selbstbeschreibung, dass Suchen bei ihnen sicher sei, weil die IP-Adressen der Nutzer nicht gespeichert würden. So ehrenwert und auch ehrlich gemeint diese Selbstbeschreibungen sein mögen - Fakt ist, dass viele dieser Suchmaschinen zumindest einen Teil ihrer Server in den USA hosten. Das gilt auch für diejenigen, die von manchen Datenschützern immer noch als "besonders empfehlenswert" gelobt und als Empfehlung verbreitet werden. Denn diese Suchmaschinen', + 'policy.21' => 'unterliegen nach dem Patriot Act und US-Recht dem vollen Zugriff der dortigen Behörden.', + 'policy.22' => 'Sie können also gar keine geschützte Privatsphäre bieten (selbst dann nicht, wenn sie selber sich noch so sehr darum bemühen).', + + 'twitter' => 'Was andere über unser Privacy-Konzept auf Twitter sagen:', +]; diff --git a/resources/views/datenschutz.blade.php b/resources/views/datenschutz.blade.php index 80e12b17d..a31638df1 100644 --- a/resources/views/datenschutz.blade.php +++ b/resources/views/datenschutz.blade.php @@ -7,9 +7,10 @@ @section('content') <h1>{{ trans('datenschutz.head') }}</h1> <p>{{ trans('datenschutz.general.1') }} <a href="https://suma-ev.de/presse/Sicher-suchen-UND-finden-mit-MetaGer.html">{{ trans('datenschutz.general.2') }}</a></p> +<p>{!! trans('datenschutz.general.3') !!}</p> <h2>{{ trans('datenschutz.policy.1') }}</h2> <ul id="privacyList"> - <li>{{ trans('datenschutz.policy.2') }} + <li>{{ trans('datenschutz.policy.2') }} <a href="http://www.heise.de/security/meldung/Fingerprinting-Viele-Browser-sind-ohne-Cookies-identifizierbar-1982976.html" target="_blank">{{ trans('datenschutz.policy.3') }}</a> {{ trans('datenschutz.policy.4') }} </li> <li > @@ -38,4 +39,4 @@ <p>> 8.4.2014 stupidité pue @dummheitstinkt > wow, is this the MetaGer I used in the end 90s in internet cafes??? > "Anonymes Suchen und Finden mit MetaGer | heise"</p></pre> -@endsection \ No newline at end of file +@endsection -- GitLab