Commit a53559e0 authored by Karl Hasselbring's avatar Karl Hasselbring
Browse files

Merge branch 'development' into 513-css-dateien-aufraumen

parents f80cc88f b1e1e657
...@@ -51,7 +51,6 @@ class Searcher implements ShouldQueue ...@@ -51,7 +51,6 @@ class Searcher implements ShouldQueue
$this->counter = 0; // Counts the number of answered jobs $this->counter = 0; // Counts the number of answered jobs
$time = microtime(true); $time = microtime(true);
while(true){ while(true){
Log:info("Durchlauf");
// Update the expire // Update the expire
Redis::expire($this->name, 5); Redis::expire($this->name, 5);
Redis::expire($this->name . ".stats", 5); Redis::expire($this->name . ".stats", 5);
......
...@@ -24,6 +24,7 @@ class MetaGer ...@@ -24,6 +24,7 @@ class MetaGer
protected $site; protected $site;
protected $hostBlacklist = []; protected $hostBlacklist = [];
protected $domainBlacklist = []; protected $domainBlacklist = [];
private $urlBlacklist = [];
protected $stopWords = []; protected $stopWords = [];
protected $phrases = []; protected $phrases = [];
protected $engines = []; protected $engines = [];
...@@ -1008,12 +1009,13 @@ class MetaGer ...@@ -1008,12 +1009,13 @@ class MetaGer
$this->searchCheckSitesearch($site); $this->searchCheckSitesearch($site);
$this->searchCheckHostBlacklist(); $this->searchCheckHostBlacklist();
$this->searchCheckDomainBlacklist(); $this->searchCheckDomainBlacklist();
$this->searchCheckUrlBlacklist();
$this->searchCheckPhrase(); $this->searchCheckPhrase();
$this->searchCheckStopwords(); $this->searchCheckStopwords();
$this->searchCheckNoSearch(); $this->searchCheckNoSearch();
} }
public function searchCheckSitesearch($site) private function searchCheckSitesearch($site)
{ {
// matches '[... ]site:test.de[ ...]' // matches '[... ]site:test.de[ ...]'
while (preg_match("/(^|.+\s)site:(\S+)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.+\s)site:(\S+)(?:\s(.+)|($))/si", $this->q, $match)) {
...@@ -1025,13 +1027,14 @@ class MetaGer ...@@ -1025,13 +1027,14 @@ class MetaGer
} }
} }
public function searchCheckHostBlacklist() private function searchCheckHostBlacklist()
{ {
// matches '[... ]-site:test.de[ ...]' // matches '[... ]-site:test.de[ ...]'
while (preg_match("/(^|.+\s)-site:([^\s\*]\S*)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.+\s)-site:([^\s\*]\S*)(?:\s(.+)|($))/si", $this->q, $match)) {
$this->hostBlacklist[] = $match[2]; $this->hostBlacklist[] = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
} }
// print the host blacklist as a user warning
if (sizeof($this->hostBlacklist) > 0) { if (sizeof($this->hostBlacklist) > 0) {
$hostString = ""; $hostString = "";
foreach ($this->hostBlacklist as $host) { foreach ($this->hostBlacklist as $host) {
...@@ -1042,13 +1045,14 @@ class MetaGer ...@@ -1042,13 +1045,14 @@ class MetaGer
} }
} }
public function searchCheckDomainBlacklist() private function searchCheckDomainBlacklist()
{ {
// matches '[... ]-site:*.test.de[ ...]' // matches '[... ]-site:*.test.de[ ...]'
while (preg_match("/(^|.+\s)-site:\*\.(\S+)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.+\s)-site:\*\.(\S+)(?:\s(.+)|($))/si", $this->q, $match)) {
$this->domainBlacklist[] = $match[2]; $this->domainBlacklist[] = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
} }
// print the domain blacklist as a user warning
if (sizeof($this->domainBlacklist) > 0) { if (sizeof($this->domainBlacklist) > 0) {
$domainString = ""; $domainString = "";
foreach ($this->domainBlacklist as $domain) { foreach ($this->domainBlacklist as $domain) {
...@@ -1059,13 +1063,32 @@ class MetaGer ...@@ -1059,13 +1063,32 @@ class MetaGer
} }
} }
public function searchCheckStopwords() private function searchCheckUrlBlacklist()
{
// matches '[... ]-site:*.test.de[ ...]'
while (preg_match("/(^|.+\s)-url:(\S+)(?:\s(.+)|($))/si", $this->q, $match)) {
$this->urlBlacklist[] = $match[2];
$this->q = $match[1] . $match[3];
}
// print the url blacklist as a user warning
if (sizeof($this->urlBlacklist) > 0) {
$urlString = "";
foreach ($this->urlBlacklist as $url) {
$urlString .= $url . ", ";
}
$urlString = rtrim($urlString, ", ");
$this->warnings[] = trans('metaGer.formdata.urlBlacklist', ['url' => $urlString]);
}
}
private function searchCheckStopwords()
{ {
// matches '[... ]-test[ ...]' // matches '[... ]-test[ ...]'
while (preg_match("/(^|.+\s)-(\S+)(?:\s(.+)|($))/si", $this->q, $match)) { while (preg_match("/(^|.+\s)-(\S+)(?:\s(.+)|($))/si", $this->q, $match)) {
$this->stopWords[] = $match[2]; $this->stopWords[] = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
} }
// print the stopwords as a user warning
if (sizeof($this->stopWords) > 0) { if (sizeof($this->stopWords) > 0) {
$stopwordsString = ""; $stopwordsString = "";
foreach ($this->stopWords as $stopword) { foreach ($this->stopWords as $stopword) {
...@@ -1076,7 +1099,7 @@ class MetaGer ...@@ -1076,7 +1099,7 @@ class MetaGer
} }
} }
public function searchCheckPhrase() private function searchCheckPhrase()
{ {
$p = ""; $p = "";
$tmp = $this->q; $tmp = $this->q;
...@@ -1094,7 +1117,7 @@ class MetaGer ...@@ -1094,7 +1117,7 @@ class MetaGer
} }
} }
public function searchCheckNoSearch() private function searchCheckNoSearch()
{ {
if ($this->q === "") { if ($this->q === "") {
$this->warnings[] = trans('metaGer.formdata.noSearch'); $this->warnings[] = trans('metaGer.formdata.noSearch');
...@@ -1433,6 +1456,11 @@ class MetaGer ...@@ -1433,6 +1456,11 @@ class MetaGer
return $this->domainBlacklist; return $this->domainBlacklist;
} }
public function getUserUrlBlacklist()
{
return $this->urlBlacklist;
}
public function getDomainBlacklist() public function getDomainBlacklist()
{ {
return $this->domainsBlacklisted; return $this->domainsBlacklisted;
......
...@@ -216,12 +216,17 @@ class Result ...@@ -216,12 +216,17 @@ class Result
# Überprüft ob das Ergebnis aus irgendwelchen Gründen unerwünscht ist. # Überprüft ob das Ergebnis aus irgendwelchen Gründen unerwünscht ist.
public function isValid(\App\MetaGer $metager) public function isValid(\App\MetaGer $metager)
{ {
# Perönliche URL und Domain Blacklist # Perönliche Host und Domain Blacklist
if (in_array($this->strippedHost, $metager->getUserHostBlacklist()) if (in_array(strtolower($this->strippedHost), $metager->getUserHostBlacklist())
|| in_array($this->strippedDomain, $metager->getUserDomainBlacklist())) { || in_array(strtolower($this->strippedDomain), $metager->getUserDomainBlacklist())) {
return false; return false;
} }
# Persönliche URL Blacklist
foreach ($metager->getUserUrlBlacklist() as $word) {
if (strpos(strtolower($this->link), $word)) return false;
}
# Allgemeine URL und Domain Blacklist # Allgemeine URL und Domain Blacklist
if ($this->strippedHost !== "" && (in_array($this->strippedHost, $metager->getDomainBlacklist()) || in_array($this->strippedLink, $metager->getUrlBlacklist()))) { if ($this->strippedHost !== "" && (in_array($this->strippedHost, $metager->getDomainBlacklist()) || in_array($this->strippedLink, $metager->getUrlBlacklist()))) {
return false; return false;
......
...@@ -22,7 +22,7 @@ elixir(function (mix) { ...@@ -22,7 +22,7 @@ elixir(function (mix) {
| scriptStartPage.js | scriptStartPage.js
| settings.js | settings.js
*/ */
mix.scripts(['lib/jquery.js', 'lib/bootstrap.js', 'lib/lightslider.js', 'lib/masonry.js', 'lib/imagesloaded.js', 'lib/openpgp.min.js', 'lib/iframeResizer.min.js'], 'public/js/lib.js') mix.scripts(['lib/jquery.js', 'lib/jquery-ui.min.js', 'lib/bootstrap.js', 'lib/lightslider.js', 'lib/masonry.js', 'lib/imagesloaded.js', 'lib/openpgp.min.js', 'lib/iframeResizer.min.js', 'lib/md5.js'], 'public/js/lib.js')
mix.scripts(['lib/jquery.js', 'lib/iframeResizer.contentWindow.min.js'], 'public/js/quicktips.js') mix.scripts(['lib/jquery.js', 'lib/iframeResizer.contentWindow.min.js'], 'public/js/quicktips.js')
mix.version(['css/themes/default.css', 'js/lib.js', 'js/quicktips.js']) mix.version(['css/themes/default.css', 'js/lib.js', 'js/quicktips.js'])
mix.less('metager/beitritt.less', 'public/css/beitritt.css') mix.less('metager/beitritt.less', 'public/css/beitritt.css')
......
This diff is collapsed.
$(document).ready(function () {
$('.hint').tooltip();
$('.language-text-area').each(function () {
auto_grow(this);
});
$('.language-text-area').keyup(function () {
auto_grow(this);
});
});
function auto_grow (element) {
element.style.height = '5px';
element.style.height = (element.scrollHeight + 10) + 'px';
}
$(document).ready(function() {
$(".hint").tooltip();
$(".language-text-area").each(function() {
auto_grow(this);
});
$(".language-text-area").keyup(function() {
auto_grow(this);
});
});
function auto_grow(element) {
element.style.height = "5px";
element.style.height = (element.scrollHeight + 10) + "px";
}
\ No newline at end of file
$(document).ready(function() { $(document).ready(function () {
switch (getLanguage()) { switch (getLanguage()) {
case "de": case 'de':
$(".encrypt-btn").html("Verschlüsseln und senden"); $('.encrypt-btn').html('Verschlüsseln und senden');
break; break;
case "en": case 'en':
$(".encrypt-btn").html("encrypt and send"); $('.encrypt-btn').html('encrypt and send');
break; break;
case "es": case 'es':
// $(".encrypt-btn").html(""); TODO // $(".encrypt-btn").html(""); TODO
break; break;
} }
$(".contact").submit(function() { $('.contact').submit(function () {
return encrypt(this); return encrypt(this);
}); });
}); });
//based on https://github.com/encrypt-to/secure.contactform.php // based on https://github.com/encrypt-to/secure.contactform.php
/* The MIT License (MIT) /* The MIT License (MIT)
Copyright (c) 2013 Jan Wiegelmann Copyright (c) 2013 Jan Wiegelmann
...@@ -32,39 +32,39 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR ...@@ -32,39 +32,39 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
function encrypt() { function encrypt () {
if (window.crypto && window.crypto.getRandomValues) { if (window.crypto && window.crypto.getRandomValues) {
var message = document.getElementById("message"); var message = document.getElementById('message');
if (message.value.indexOf("-----BEGIN PGP MESSAGE-----") !== -1 && message.value.indexOf("-----END PGP MESSAGE-----") !== -1) { if (message.value.indexOf('-----BEGIN PGP MESSAGE-----') !== -1 && message.value.indexOf('-----END PGP MESSAGE-----') !== -1) {
// encryption done // encryption done
} else {
var pub_key = openpgp.key.readArmored(document.getElementById("pubkey").innerHTML).keys[0];
var plaintext = message.value;
var ciphertext = openpgp.encryptMessage([pub_key], plaintext);
message.value = ciphertext;
return true;
}
} else { } else {
switch (getLanguage()) { var pub_key = openpgp.key.readArmored(document.getElementById('pubkey').innerHTML).keys[0];
case "de": var plaintext = message.value;
alert("Fehler: Ihr Browser wird nicht unterstützt. Bitte installieren Sie einen aktuellen Browser wie z.B. Mozilla Firefox."); var ciphertext = openpgp.encryptMessage([pub_key], plaintext);
break; message.value = ciphertext;
case "en": return true;
alert("Error: Your browser is not supported. Please install an up to date browser like Mozilla Firefox.");
break;
case "es":
// alert(""); TODO
break;
}
return false;
} }
} else {
switch (getLanguage()) {
case 'de':
alert('Fehler: Ihr Browser wird nicht unterstützt. Bitte installieren Sie einen aktuellen Browser wie z.B. Mozilla Firefox.');
break;
case 'en':
alert('Error: Your browser is not supported. Please install an up to date browser like Mozilla Firefox.');
break;
case 'es':
// alert(""); TODO
break;
}
return false;
}
} }
function getLanguage() { function getLanguage () {
var metaData = document.getElementsByTagName('meta'); var metaData = document.getElementsByTagName('meta');
for (var m in metaData) { for (var m in metaData) {
if (metaData[m]["httpEquiv"] == "language") { if (metaData[m]['httpEquiv'] == 'language') {
return metaData[m]["content"]; return metaData[m]['content'];
}
} }
} }
\ No newline at end of file }
This diff is collapsed.
$(document).ready(function () {
// Wenn LocalStorage verfügbar ist, geben wir die Möglichkeit die Einstellungen dort zu speichern
tickOptions();
if (localStorage) {
$('#save').removeClass('hidden');
$('#save').click(function () {
localStorage.setItem('pers', true);
$('input[type=checkbox]:checked, input[type=hidden]').each(function (el) {
localStorage.setItem($(this).attr('name'), $(this).val());
});
$('select').each(function (el) {
localStorage.setItem($(this).attr('name'), $(this).val());
});
document.location.href = $('#save').attr('data-href');
});
}
$('.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);
}
});
$('#unten').click(function () {
$('#settings-form').append('<input type="hidden" name="usage" value="once">');
switch (getLanguage()) {
case 'de':
alert('Auf der folgenden Startseite sind Ihre Einstellungen nun einmalig gespeichert. Nach Ihrer ersten Suche sind diese wieder verloren. Wenn Sie diese speichern möchten, können Sie sich allerdings ein Lesezeichen für die generierte Startseite einrichten.');
break;
case 'en':
alert('On the following startpage your settings are saved one-time. They will be lost after your first search. Though if you want to save them, you can create a bookmark for the generated startpage.');
break;
case 'es':
// alert(""); TODO
break;
}
});
$('#plugin').click(function () {
$('form').attr('action', $('#save').attr('data-href') + '#plugin-modal');
switch (getLanguage()) {
case 'de':
alert('Ihr Browserplugin mit den persönlichen Sucheinstellungen wurde generiert. Folgen Sie bitte der Anleitung auf der folgenden Seite um es zu installieren. Beachten Sie: Zuvor sollten Sie ein eventuell bereits installiertes MetaGer-Plugin entfernen.');
break;
case 'en':
alert('Your browser plugin with personal settings was generated. Please follow the instructions on the following page to install it. Notice that beforehand you might have to delete a former MetaGer plugin.');
break;
case 'es':
// alert(""); TODO
break;
}
});
$('#settings-focus').val('angepasst');
});
function tickOptions () {
if (localStorage && localStorage.getItem('pers')) {
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
var value = localStorage.getItem(key);
if (key.startsWith('param_')) {
if ($('input[name=' + key + ']').length) {
$('input[name=' + key + ']').attr('checked', '');
} else {
$('select[name=' + key + '] > option[value=' + value + ']').attr('selected', true);
}
}
}
} else {
$('div.web input').attr('checked', true);
}
}
function getLanguage () {
var metaData = document.getElementsByTagName('meta');
for (var m in metaData) {
if (metaData[m]['httpEquiv'] == 'language') {
return metaData[m]['content'];
}
}
}
$(document).ready(function() {
// Wenn LocalStorage verfügbar ist, geben wir die Möglichkeit die Einstellungen dort zu speichern
tickOptions();
if (localStorage) {
$("#save").removeClass("hidden");
$("#save").click(function() {
localStorage.setItem("pers", true);
$("input[type=checkbox]:checked, input[type=hidden]").each(function(el) {
localStorage.setItem($(this).attr("name"), $(this).val());
});
$("select").each(function(el) {
localStorage.setItem($(this).attr("name"), $(this).val());
});
document.location.href = $("#save").attr("data-href");
});
}
$(".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);
}
});
$("#unten").click(function() {
$("#settings-form").append("<input type=\"hidden\" name=\"usage\" value=\"once\">");
switch (getLanguage()) {
case "de":
alert("Auf der folgenden Startseite sind Ihre Einstellungen nun einmalig gespeichert. Nach Ihrer ersten Suche sind diese wieder verloren. Wenn Sie diese speichern möchten, können Sie sich allerdings ein Lesezeichen für die generierte Startseite einrichten.");
break;
case "en":
alert("On the following startpage your settings are saved one-time. They will be lost after your first search. Though if you want to save them, you can create a bookmark for the generated startpage.");
break;
case "es":
// alert(""); TODO
break;
}
});
$("#plugin").click(function() {
$("form").attr('action', $("#save").attr("data-href") + '#plugin-modal');
switch (getLanguage()) {
case "de":
alert("Ihr Browserplugin mit den persönlichen Sucheinstellungen wurde generiert. Folgen Sie bitte der Anleitung auf der folgenden Seite um es zu installieren. Beachten Sie: Zuvor sollten Sie ein eventuell bereits installiertes MetaGer-Plugin entfernen.");
break;
case "en":
alert("Your browser plugin with personal settings was generated. Please follow the instructions on the following page to install it. Notice that beforehand you might have to delete a former MetaGer plugin.");
break;
case "es":
// alert(""); TODO
break;
}
});
$("#settings-focus").val("angepasst");
});
function tickOptions() {
if (localStorage && localStorage.getItem("pers")) {
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
var value = localStorage.getItem(key);
if (key.startsWith("param_")) {
if ($("input[name=" + key + "]").length) {
$("input[name=" + key + "]").attr("checked", "");
} else {
$("select[name=" + key + "] > option[value=" + value + "]").attr("selected", true);
}
}
}
} else {
$("div.web input").attr("checked", true);
}
}
function getLanguage() {
var metaData = document.getElementsByTagName('meta');
for (var m in metaData) {
if (metaData[m]["httpEquiv"] == "language") {
return metaData[m]["content"];
}
}
}
\ No newline at end of file
function copyCode () {
$('#codesnippet').select();
try {
var successful = document.execCommand('copy');
if (successful) {
$('#copyButton').removeClass('btn-default');
$('#copyButton').addClass('btn-success');
} else {
$('#copyButton').removeClass('btn-default');
$('#copyButton').addClass('btn-danger');
}
} catch (err) {
$('#copyButton').removeClass('btn-default');
$('#copyButton').addClass('btn-danger');
}
}
window.onload = function () {
$('#copyButton').bind('click', copyCode);
};
function copyCode() {
$("#codesnippet").select();
try {
var successful = document.execCommand('copy');
if (successful) {
$('#copyButton').removeClass('btn-default');
$('#copyButton').addClass('btn-success');
} else {
$('#copyButton').removeClass('btn-default');
$('#copyButton').addClass('btn-danger');
}
} catch (err) {
$('#copyButton').removeClass('btn-default');
$('#copyButton').addClass('btn-danger');
}
}
window.onload = function() {
$('#copyButton').bind('click', copyCode);
};
\ No newline at end of file
{ {
"js/editLanguage.js": "js/editLanguage-7a1cbfb2ba.js", "js/editLanguage.js": "js/editLanguage-70b5475eac.js",
"js/kontakt.js": "js/kontakt-de49d68db3.js",