Commit 429749f8 authored by Karl Hasselbring's avatar Karl Hasselbring

Added Qualigo ads

parent 53b950d8
This diff is collapsed.
......@@ -86,7 +86,7 @@ abstract class Searchengine
}
$this->getString = $this->generateGetString($q);
$this->hash = md5($this->engine->host . $this->getString . $this->engine->port . $this->name);
$this->updateHash();
$this->resultHash = $metager->getSearchUid();
$this->canCache = $metager->canCache();
}
......@@ -95,9 +95,7 @@ abstract class Searchengine
# Standardimplementierung der getNext Funktion, damit diese immer verwendet werden kann
public function getNext(MetaGer $metager, $result)
{
}
{ }
# Prüft, ob die Suche bereits gecached ist, ansonsted wird sie als Job dispatched
public function startSearch(\App\MetaGer $metager)
......@@ -200,6 +198,11 @@ abstract class Searchengine
$this->resultHash = $hash;
}
public function updateHash()
{
$this->hash = md5($this->engine->host . $this->getString . $this->engine->port . $this->name);
}
# Fragt die Ergebnisse von Redis ab und lädt Sie
public function retrieveResults(MetaGer $metager)
{
......@@ -250,6 +253,8 @@ abstract class Searchengine
# Append the Query String
$getString .= "&" . $this->engine->{"query-parameter"} . "=" . $this->urlEncode($query);
$getString .= $this->getDynamicParamsString();
return $getString;
}
......@@ -262,4 +267,21 @@ abstract class Searchengine
return urlencode($string);
}
}
private function getDynamicParamsString()
{
$paramString = "";
$params = $this->getDynamicParams();
foreach ($params as $key => $value) {
$paramString .= sprintf("&%s=%s", urlencode($key), urlencode($value));
}
return $paramString;
}
protected function getDynamicParams()
{
return [];
}
}
<?php
namespace App\Models;
abstract class XmlSearchengine extends Searchengine
{
public function loadresults($results)
{
try {
$resultsXml = simplexml_load_string($results);
$this->loadXmlResults($resultsXml);
} catch (\Exception $e) {
abort(500, "\n~~~~~~~~\n$results\n~~~~~~~~\nis not a valid xml string");
}
}
protected abstract function loadXmlResults($resultsXml);
}
......@@ -14,7 +14,7 @@ class Overture extends Searchengine
parent::__construct($name, $engine, $metager);
# We need some Affil-Data for the advertisements
$this->getString .= $this->getOvertureAffilData($metager->getUrl());
$this->hash = md5($this->engine->host . $this->getString . $this->engine->port . $this->name);
$this->updateHash();
}
public function loadResults($result)
......
......@@ -2,9 +2,9 @@
namespace App\Models\parserSkripte;
use App\Models\Searchengine;
use App\Models\XmlSearchengine;
class Qualigo extends Searchengine
class Qualigo extends XmlSearchengine
{
public function __construct($name, \StdClass $engine, \App\MetaGer $metager)
......@@ -12,18 +12,9 @@ class Qualigo extends Searchengine
parent::__construct($name, $engine, $metager);
}
public function loadResults($results)
protected function loadXmlResults($resultsXml)
{
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');
$results = $resultsXml->xpath('//RL/RANK');
foreach ($results as $result) {
$title = $result->{"TITLE"}->__toString();
$link = $result->{"URL"}->__toString();
......@@ -36,10 +27,20 @@ class Qualigo extends Searchengine
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->engine->{"display-name"},
$this->engine->homepage,
$this->counter
);
}
}
protected function getDynamicParams()
{
$params = [];
$params["ip"] = $this->ip;
$params["agent"] = $this->useragent;
return $params;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment