Commit b2c8fe20 authored by Karl's avatar Karl
Browse files

Merge mit Development.

Die Seiten müssen noch überprüft werden, aber es fehlt ohnehin noch Funktionalität
parents 0c6db8c2 9b91d58f
......@@ -15,6 +15,13 @@ class StartpageController extends Controller
* @param int $id
* @return Response
*/
/* public function loadStartPage($locale = "de")
{
\App::setLocale($locale);
return view('index', [
'title' => 'MetaGer: Sicher suchen & finden, Privatsphäre schützen',
'homeIcon']);
} */
public function loadStartPage(Request $request)
{
......
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ZitatController extends Controller
{
public function zitatSuche(Request $request)
{
$validResults = [];
if ($request->has("q")) {
# The user searched for something
$fileName = storage_path() . "/app/public/zitate.txt";
$fileContent = file_get_contents($fileName);
# Die Suchworte sind UND verknüpft, müssen aber nicht als gesamtes Wort vorkommen
$all = explode(PHP_EOL, $fileContent);
$words = preg_split("/\s+/", $request->input('q'));
# Loop through all
foreach ($all as $zitat) {
$valid = true;
# A Result isn't valid when it doesn't Contain every search word
foreach ($words as $word) {
if (stripos($zitat, $word) === false) {
$valid = false;
break;
}
}
if ($valid) {
# This Result is valid. We'll add it Sorted by author
if (preg_match("/^\"([^\"]+)\"\s(.*)$/", $zitat, $matches)) {
$quote = trim($matches[1]);
$author = trim($matches[2]);
if (isset($validResults[$author])) {
$validResults[$author][] = $quote;
} else {
$validResults[$author] = [$quote];
}
}
}
}
}
return view('zitatsuche')
->with('title', 'Zitatsuche MetaGer')
->with('navbarFocus', 'dienste')
->with('results', $validResults)
->with('q', $request->input('q', ''));
}
}
......@@ -35,7 +35,6 @@ class MetaGer
protected $addedHosts = [];
protected $startCount = 0;
protected $canCache = false;
protected $canCustomSearch = false;
# Daten über die Abfrage
protected $ip;
protected $language;
......@@ -141,6 +140,13 @@ class MetaGer
->with('suspendheader', "yes")
->with('browser', (new Agent())->browser());
break;
case 'rss20':
return view('metager3resultsrss20')
->with('results', $viewResults)
->with('eingabe', $this->eingabe)
->with('metager', $this)
->with('resultcount', sizeof($viewResults));
break;
case 'result-count':
# Wir geben die Ergebniszahl und die benötigte Zeit zurück:
return sizeof($viewResults) . ";" . round((microtime(true) - $this->starttime), 2);
......@@ -499,25 +505,40 @@ class MetaGer
$subcollections = [];
$tmp = [];
foreach ($enabledSearchengines as $engine) {
if (isset($engine['minismCollection'])) {
$subcollections[] = $engine['minismCollection']->__toString();
} else {
$tmp[] = $engine;
// Es gibt den Schalter "minism=on" Dieser soll bewirken, dass alle Minisucher angeschaltet werden.
// Wenn also "minism=on" ist, dann durchsuchen wir statt den tatsächlich angeschalteten Suchmaschinen,
// alle Suchmaschinen nach "minismCollection"
if ($request->input("minism", "off") === "on") {
// Wir laden alle Minisucher
foreach ($sumas as $engine) {
if (isset($engine["minismCollection"])) {
$subcollections[] = $engine["minismCollection"]->__toString();
}
}
# Nur noch alle eventuell angeschalteten Minisucher deaktivieren
foreach ($enabledSearchengines as $index => $engine) {
if (!isset($engine["minismCollection"])) {
$tmp[] = $engine;
}
}
} else {
// Wir schalten eine Teilmenge, oder aber gar keine an
foreach ($enabledSearchengines as $engine) {
if (isset($engine['minismCollection'])) {
$subcollections[] = $engine['minismCollection']->__toString();
} else {
$tmp[] = $engine;
}
}
}
$enabledSearchengines = $tmp;
if (sizeof($subcollections) > 0) {
$enabledSearchengines[] = $this->loadMiniSucher($xml, $subcollections);
}
if ($sumaCount <= 0) {
$this->errors[] = trans('metaGer.settings.noneSelected');
}
$engines = [];
# Wenn eine Sitesearch durchgeführt werden soll, überprüfen wir ob überhaupt eine der Suchmaschinen eine Sitesearch unterstützt
$siteSearchFailed = $this->checkCanNotSitesearch($enabledSearchengines);
......@@ -592,6 +613,9 @@ class MetaGer
continue;
}
if (!isset($engine["package"])) {
die(var_dump($engine));
}
# Setze Pfad zu Parser
$path = "App\Models\parserSkripte\\" . ucfirst($engine["package"]->__toString());
......@@ -870,7 +894,7 @@ class MetaGer
}
# Sucheingabe
$this->eingabe = trim($request->input('eingabe', ''));
$this->q = strtolower($this->eingabe);
$this->q = mb_strtolower($this->eingabe, "UTF-8");
# IP
$this->ip = $request->ip();
# Unser erster Schritt wird sein, IP-Adresse und USER-Agent zu anonymisieren, damit
......@@ -904,7 +928,6 @@ class MetaGer
} else {
$this->sprueche = false;
}
# Maps
$this->maps = $request->input('maps', 'off');
if ($this->maps === "on") {
$this->maps = true;
......@@ -917,13 +940,6 @@ class MetaGer
} else {
$this->newtab = "_self";
}
# Custom Search
$this->canCustomSearch = $request->input('canCustomSearch', 'false');
if ($this->canCustomSearch === "true") {
$this->canCustomSearch = true;
} else {
$this->canCustomSearch = false;
}
# Theme
$this->theme = preg_replace("/[^[:alnum:][:space:]]/u", '', $request->input('theme', 'default'));
# Ergebnisse pro Seite:
......@@ -966,7 +982,7 @@ class MetaGer
}
$this->out = $request->input('out', "html");
# Standard output format html
if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style" && $this->out !== "result-count") {
if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style" && $this->out !== "result-count" && $this->out !== "rss20") {
$this->out = "html";
}
# Wir schalten den Cache aus, wenn die Ergebniszahl überprüft werden soll
......@@ -1238,7 +1254,7 @@ class MetaGer
}
}
# Generators
# Generators
public function generateSearchLink($fokus, $results = true)
{
......@@ -1299,11 +1315,6 @@ class MetaGer
# Komplexe Getter
public function canCustomSearch()
{
return $this->canCustomSearch;
}
public function getHostCount($host)
{
$hash = md5($host);
......
......@@ -11,7 +11,8 @@ class Result
public $titel; # Der Groß Angezeigte Name für das Suchergebnis
public $link; # Der Link auf die Ergebnisseite
public $anzeigeLink; # Der tatsächlich angezeigte Link (rein optisch)
public $descr; # Die Beschreibung des Suchergebnisses
public $descr; # Die eventuell gekürzte Beschreibung des Suchergebnisses
public $longDescr; # Die ungekürzte Beschreibung des Suchergebnisses
public $gefVon; # Das bei Suchergebnissen angezeigte von ... mitsamt Verlinkung
public $sourceRank; # Das Ranking für dieses Suchergebnis von der Seite, die es geliefert hat (implizit durch Ergebnisreihenfolge: 20 - Position in Ergebnisliste)
public $partnershop; # Ist das Ergebnis von einem Partnershop? (bool)
......@@ -35,6 +36,7 @@ class Result
$this->anzeigeLink = trim($anzeigeLink);
$this->descr = strip_tags(trim($descr), '<p>');
$this->descr = preg_replace("/\n+/si", " ", $this->descr);
$this->longDescr = $this->descr;
if (strlen($this->descr) > 250) {
$this->descr = wordwrap($this->descr, 250);
$this->descr = substr($this->descr, 0, strpos($this->descr, "\n"));
......@@ -225,8 +227,8 @@ class Result
}
# Eventueller Sprachfilter
if ($metager->getLang() !== "all" && isset($this->langCode)) {
if ($metager->getLang() !== $this->langCode) {
if ($metager->getLang() !== "all") {
if (!isset($this->langCode) || $this->langCode === null || $metager->getLang() !== $this->langCode) {
return false;
}
......@@ -240,14 +242,15 @@ class Result
}
}
/*
# Phrasensuche:
$text = strtolower($this->titel) . " " . strtolower($this->descr);
foreach ($metager->getPhrases() as $phrase) {
if (strpos($text, $phrase) === false) {
return false;
}
if (strpos($text, $phrase) === false) {
return false;
}
}
*/
/* Der Host-Filter der sicherstellt,
* dass von jedem Host maximal 3 Links angezeigt werden.
* Diese Überprüfung führen wir unter bestimmten Bedingungen nicht durch.
......@@ -315,17 +318,25 @@ class Result
return "";
}
$tmp = $link;
$tmp = preg_replace("/\r?\n$/s", "", $tmp);
$tmp = str_replace("=", "=3d", $tmp);
$tmp = str_replace("?", "=3f", $tmp);
$tmp = str_replace("%", "=25", $tmp);
$tmp = str_replace("&", "=26", $tmp);
$tmp = str_replace(";", "=3b", $tmp);
$tmp = preg_replace("#^([\w+.-]+)://#s", "$1/", $tmp);
$tmp = str_replace("//", "/=2f", $tmp);
return "https://proxy.suma-ev.de/mger/nph-proxy.cgi/en/w0/" . $tmp;
# Link to our new Proxy software:
$pw = md5(env('PROXY_PASSWORD') . $link);
$proxyUrl = base64_encode(str_rot13($link));
$proxyUrl = urlencode(str_replace("/", "<<SLASH>>", $proxyUrl));
return "https://proxy.suma-ev.de/" . $pw . "/" . $proxyUrl;
/*
$tmp = $link;
$tmp = preg_replace("/\r?\n$/s", "", $tmp);
$tmp = str_replace("=", "=3d", $tmp);
$tmp = str_replace("?", "=3f", $tmp);
$tmp = str_replace("%", "=25", $tmp);
$tmp = str_replace("&", "=26", $tmp);
$tmp = str_replace(";", "=3b", $tmp);
$tmp = preg_replace("#^([\w+.-]+)://#s", "$1/", $tmp);
$tmp = str_replace("//", "/=2f", $tmp);
return "https://proxy.suma-ev.de/mger/nph-proxy.cgi/en/w0/" . $tmp;
*/
}
/* Liest aus einer URL alle Informationen aus
......
......@@ -55,8 +55,7 @@ class BASE extends Searchengine
}
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
Log::error("A problem occurred parsing results from $this->name:\n" . $e->getMessage() . "\n" . $result);
return;
}
}
......
......@@ -22,10 +22,10 @@ class Nebel extends Searchengine
continue;
}
$title = $res[2];
$title = $res[1];
$link = $res[0];
$anzeigeLink = $link;
$descr = $res[1];
$descr = $res[2];
$this->counter++;
$this->results[] = new \App\Models\Result(
......
......@@ -4,7 +4,7 @@ namespace app\Models\parserSkripte;
use App\Models\Searchengine;
class Opencrawltauchen extends Searchengine
class Opencrawlpolitik extends Searchengine
{
public $results = [];
......@@ -32,7 +32,7 @@ class Opencrawltauchen extends Searchengine
$title = $result->{"title"}->__toString();
$link = $result->{"link"}->__toString();
$anzeigeLink = $link;
$descr = strip_tags($result->{"description"}->__toString());
$descr = strip_tags(htmlspecialchars_decode($result->{"description"}->__toString()));
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
......
......@@ -44,8 +44,7 @@ class Yandex extends Searchengine
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
Log::error("A problem occurred parsing results from $this->name:\n" . $e->getMessage() . "\n" . $result);
return;
}
}
......@@ -58,8 +57,11 @@ class Yandex extends Searchengine
if (!$content) {
return;
}
$resultCount = intval($content->xpath('//yandexsearch/response/results/grouping/found[@priority="all"]')[0]->__toString());
$resultCount = $content->xpath('//yandexsearch/response/results/grouping/found[@priority="all"]');
if(!$resultCount || sizeof($resultCount) <= 0){
return;
}
$resultCount = intval($resultCount[0]->__toString());
$pageLast = $content->xpath('//yandexsearch/response/results/grouping/page')[0];
$pageLast = intval($pageLast["last"]->__toString());
if (count($this->results) <= 0 || $pageLast >= $resultCount) {
......@@ -69,8 +71,7 @@ class Yandex extends Searchengine
$next->getString .= "&page=" . ($metager->getPage() + 1);
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
Log::error("A problem occurred parsing results from $this->name:\n" . $e->getMessage() . "\n" . $result);
return;
}
}
......
......@@ -52,7 +52,7 @@ return [
//'ewo' => ['name' => 'Ewondo', 'script' => 'Latn', 'native' => 'ewondo', 'regional' => ''],
//'ee' => ['name' => 'Ewe', 'script' => 'Latn', 'native' => 'eʋegbe', 'regional' => ''],
//'fil' => ['name' => 'Filipino', 'script' => 'Latn', 'native' => 'Filipino', 'regional' => 'fil_PH'],
//'fr' => ['name' => 'French', 'script' => 'Latn', 'native' => 'français', 'regional' => 'fr_FR'],
'fr' => ['name' => 'French', 'script' => 'Latn', 'native' => 'français', 'regional' => 'fr_FR'],
//'fr-CA' => ['name' => 'Canadian French', 'script' => 'Latn', 'native' => 'français canadien', 'regional' => 'fr_CA'],
//'fy' => ['name' => 'Western Frisian', 'script' => 'Latn', 'native' => 'frysk', 'regional' => 'fy_DE'],
//'fur' => ['name' => 'Friulian', 'script' => 'Latn', 'native' => 'furlan', 'regional' => 'fur_IT'],
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
$(document).ready(function() {
// checkPlugin();
if (location.href.indexOf("#plugin-modal") > -1) {
$("#plugin-modal").modal("show");
}
......@@ -37,7 +38,6 @@ function setActionListeners() {
window.location = "./settings/";
} else {
window.location = "./?focus=" + focus;
//$("#mobileFoki > option:selected").val());
}
});
if ($("fieldset#foki.mobile").length) {
......@@ -46,19 +46,13 @@ function setActionListeners() {
});
}
$("#addFocusBtn").click(function() {
showFocusCreateDialog("")
showFocusCreateDialog("");
});
$("#save-focus-btn").click(saveFocus);
$("#delete-focus-btn").click(deleteFocus);
}
function setSettings() {
if (canCustomSearch()) {
$("#foki input[type=radio]#angepasst").attr("checked", true);
$("#foki label#anpassen-label").removeClass("hide");
$("#foki button#reset-settings-btn").removeClass("hide");
$("#searchForm").append("<input type=\"hidden\" name=\"canCustomSearch\" value=\"true\">");
}
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
var value = localStorage.getItem(key);
......@@ -66,6 +60,7 @@ function setSettings() {
key = key.substring(key.indexOf("param_") + 6);
$("#searchForm").append("<input type=\"hidden\" name=\"" + key + "\" value=\"" + value + "\">");
}
$("#foki input[type=radio]#angepasst").attr("checked", true);
}
if (localStorage.getItem("param_lang") !== null) {
var value = localStorage.getItem("param_lang");
......@@ -87,7 +82,7 @@ function setSettings() {
$("fieldset.mobile label#anpassen-label span.content").html("angepasst");
}
}
// Polyfill for form attribute
//Polyfill for form attribute
(function($) {
/**
* polyfill for html5 form attr
......@@ -101,6 +96,7 @@ function setSettings() {
}
/**
* Append a field to a form
*
*/
$.fn.appendField = function(data) {
// for form only
......@@ -118,6 +114,7 @@ function setSettings() {
};
/**
* Find all input fields with form attribute point to jQuery object
*
*/
$('form[id]').submit(function(e) {
var $form = $(this);
......@@ -170,48 +167,11 @@ var isBlink = (isChrome || isOpera) && !!window.CSS;
function isUseOnce() {
var url = document.location.search;
var pos = url.indexOf("usage=");
if (pos >= 0 && url.substring(pos + 6, pos + 11) == "once") return true;
return false;
}
function softResetOptions() {
// localStorage.removeItem("pers");
localStorage.removeItem("focus");
var keys = [];
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i)
keys.push(key);
}
var metaParams = ["param_sprueche", "param_maps", "param_newtab", "param_lang", "param_autocomplete"];
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key.startsWith("param_" || key.startsWith("focus"))) {
if (metaParams.indexOf(key) === -1) {
localStorage.removeItem(key);
}
}
}
}
function canCustomSearch() {
if (localStorage.key("focus") === "eigene") {
if (pos >= 0 && url.substring(pos + 6, pos + 11) == "once") {
return true;
} else {
return false;
}
var metaParams = ["param_sprueche", "param_maps", "param_newtab", "param_lang", "param_autocomplete"];
var keys = [];
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i)
keys.push(key);
}
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key.startsWith("param_")) {
if (metaParams.indexOf(key) === -1) {
return true;
}
}
}
return false;
}
function loadInitialCustomFocuses() {
......
$(document).ready(function() {
pageCanJS(); // Einige Inhalte der Seite sollen mit Javascript anders aussehen
tickOptions();
// Wenn LocalStorage verfügbar ist, geben wir die Möglichkeit die Einstellungen dort zu speichern
// Checker listener
$(".checker").click(function() {
var selector = "." + $(this).attr("data-type");
if ($(selector + " input:checked").length) {
$(selector + " input").prop("checked", false);
} else {
$(selector + " input").prop("checked", true);
}
});
tickOptions();
$(".allUnchecker").click(uncheckAll);
// Button listener
if (localStorage) {
$("#save").removeClass("hidden");
if (localStorage.getItem("pers")) {
......@@ -34,7 +23,18 @@ $(document).ready(function() {
document.location.href = $("#save").attr("data-href");
});
}
$("#save-once").click(function() {
$(".checker").click(function() {
var selector = "." + $(this).attr("data-type");
if ($(selector + " input:checked").length) {
$(selector + " input").prop("checked", false);
} else {
$(selector + " input").prop("checked", true);
}
});
$(".allUnchecker").click(function() {
$(".focusCheckbox").prop("checked", false);
});
$("#unten").click(function() {
$("#settings-form").append("<input type=\"hidden\" name=\"usage\" value=\"once\">");
switch (getLanguage()) {
case "de":
......@@ -81,7 +81,7 @@ function tickOptions() {
}
}
} else {
// $("div.web input").attr("checked", true);
$("div.web input").attr("checked", true);
}
}
......@@ -92,13 +92,10 @@ function resetOptions() {
var key = localStorage.key(i)
keys.push(key);
}
var metaParams = ["param_sprueche", "param_maps", "param_newtab", "param_lang", "param_autocomplete"];
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key.startsWith("param_" || key.startsWith("focus"))) {
if (metaParams.indexOf(key) === -1) {
localStorage.removeItem(key);
}
localStorage.removeItem(key);
}
}
}
......@@ -111,12 +108,7 @@ function getLanguage() {
}
}
}
function pageCanJS() {
$("#collapse-engines-div").removeClass("in");
$("#collapse-engines-btn").removeClass("hide");
}
function uncheckAll() {
$(".focusCheckbox").prop("checked", false);
}
\ No newline at end of file
$(".focusCheckbox").prop("checked", false);
\ No newline at end of file
......@@ -2,7 +2,7 @@
"js/editLanguage.js": "js/editLanguage-7a1cbfb2ba.js",
"js/kontakt.js": "js/kontakt-de49d68db3.js",
"js/scriptResultPage.js": "js/scriptResultPage-991a866191.js",
"js/scriptStartPage.js": "js/scriptStartPage-f696ba3f4a.js",
"js/settings.js": "js/settings-583eb0dfc1.js",
"js/scriptStartPage.js": "js/scriptStartPage-01079f6b22.js",
"js/settings.js": "js/settings-e16aea51e9.js",
"js/widgets.js": "js/widgets-866379dd63.js"
}
\ No newline at end of file
......@@ -50,7 +50,7 @@ input[type=text]:focus, textarea:focus, input[type=email]:focus, input[type=tel]
color: <?=$color?>;
}
.navbar {
.navbar, #navbar-static-pages {
border-bottom: 3px solid <?=$color?>;
box-shadow: 1px 1px 5px 1px rgba(0, 0, 0, 0.2);
}
......
......@@ -4124,7 +4124,7 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
}
.navbar {
position: relative;
min-height: 50px;
min-height: 40px;