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
$this->counter = 0; // Counts the number of answered jobs
$time = microtime(true);
while(true){
Log:info("Durchlauf");
// Update the expire
Redis::expire($this->name, 5);
Redis::expire($this->name . ".stats", 5);
......
......@@ -24,6 +24,7 @@ class MetaGer
protected $site;
protected $hostBlacklist = [];
protected $domainBlacklist = [];
private $urlBlacklist = [];
protected $stopWords = [];
protected $phrases = [];
protected $engines = [];
......@@ -1008,12 +1009,13 @@ class MetaGer
$this->searchCheckSitesearch($site);
$this->searchCheckHostBlacklist();
$this->searchCheckDomainBlacklist();
$this->searchCheckUrlBlacklist();
$this->searchCheckPhrase();
$this->searchCheckStopwords();
$this->searchCheckNoSearch();
}
public function searchCheckSitesearch($site)
private function searchCheckSitesearch($site)
{
// matches '[... ]site:test.de[ ...]'
while (preg_match("/(^|.+\s)site:(\S+)(?:\s(.+)|($))/si", $this->q, $match)) {
......@@ -1025,13 +1027,14 @@ class MetaGer
}
}
public function searchCheckHostBlacklist()
private function searchCheckHostBlacklist()
{
// matches '[... ]-site:test.de[ ...]'
while (preg_match("/(^|.+\s)-site:([^\s\*]\S*)(?:\s(.+)|($))/si", $this->q, $match)) {
$this->hostBlacklist[] = $match[2];
$this->q = $match[1] . $match[3];
}
// print the host blacklist as a user warning
if (sizeof($this->hostBlacklist) > 0) {
$hostString = "";
foreach ($this->hostBlacklist as $host) {
......@@ -1042,13 +1045,14 @@ class MetaGer
}
}
public function searchCheckDomainBlacklist()
private function searchCheckDomainBlacklist()
{
// matches '[... ]-site:*.test.de[ ...]'
while (preg_match("/(^|.+\s)-site:\*\.(\S+)(?:\s(.+)|($))/si", $this->q, $match)) {
$this->domainBlacklist[] = $match[2];
$this->q = $match[1] . $match[3];
}
// print the domain blacklist as a user warning
if (sizeof($this->domainBlacklist) > 0) {
$domainString = "";
foreach ($this->domainBlacklist as $domain) {
......@@ -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[ ...]'
while (preg_match("/(^|.+\s)-(\S+)(?:\s(.+)|($))/si", $this->q, $match)) {
$this->stopWords[] = $match[2];
$this->q = $match[1] . $match[3];
}
// print the stopwords as a user warning
if (sizeof($this->stopWords) > 0) {
$stopwordsString = "";
foreach ($this->stopWords as $stopword) {
......@@ -1076,7 +1099,7 @@ class MetaGer
}
}
public function searchCheckPhrase()
private function searchCheckPhrase()
{
$p = "";
$tmp = $this->q;
......@@ -1094,7 +1117,7 @@ class MetaGer
}
}
public function searchCheckNoSearch()
private function searchCheckNoSearch()
{
if ($this->q === "") {
$this->warnings[] = trans('metaGer.formdata.noSearch');
......@@ -1433,6 +1456,11 @@ class MetaGer
return $this->domainBlacklist;
}
public function getUserUrlBlacklist()
{
return $this->urlBlacklist;
}
public function getDomainBlacklist()
{
return $this->domainsBlacklisted;
......
......@@ -216,12 +216,17 @@ class Result
# Überprüft ob das Ergebnis aus irgendwelchen Gründen unerwünscht ist.
public function isValid(\App\MetaGer $metager)
{
# Perönliche URL und Domain Blacklist
if (in_array($this->strippedHost, $metager->getUserHostBlacklist())
|| in_array($this->strippedDomain, $metager->getUserDomainBlacklist())) {
# Perönliche Host und Domain Blacklist
if (in_array(strtolower($this->strippedHost), $metager->getUserHostBlacklist())
|| in_array(strtolower($this->strippedDomain), $metager->getUserDomainBlacklist())) {
return false;
}
# Persönliche URL Blacklist
foreach ($metager->getUserUrlBlacklist() as $word) {
if (strpos(strtolower($this->link), $word)) return false;
}
# Allgemeine URL und Domain Blacklist
if ($this->strippedHost !== "" && (in_array($this->strippedHost, $metager->getDomainBlacklist()) || in_array($this->strippedLink, $metager->getUrlBlacklist()))) {
return false;
......
......@@ -22,7 +22,7 @@ elixir(function (mix) {
| scriptStartPage.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.version(['css/themes/default.css', 'js/lib.js', 'js/quicktips.js'])
mix.less('metager/beitritt.less', 'public/css/beitritt.css')
......
This source diff could not be displayed because it is too large. You can view the blob instead.
$(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() {
switch (getLanguage()) {
case "de":
$(".encrypt-btn").html("Verschlüsseln und senden");
break;
case "en":
$(".encrypt-btn").html("encrypt and send");
break;
case "es":
// $(".encrypt-btn").html(""); TODO
break;
}
$(".contact").submit(function() {
return encrypt(this);
});
$(document).ready(function () {
switch (getLanguage()) {
case 'de':
$('.encrypt-btn').html('Verschlüsseln und senden');
break;
case 'en':
$('.encrypt-btn').html('encrypt and send');
break;
case 'es':
// $(".encrypt-btn").html(""); TODO
break;
}
$('.contact').submit(function () {
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)
Copyright (c) 2013 Jan Wiegelmann
......@@ -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
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.*/
function encrypt() {
if (window.crypto && window.crypto.getRandomValues) {
var message = document.getElementById("message");
if (message.value.indexOf("-----BEGIN PGP MESSAGE-----") !== -1 && message.value.indexOf("-----END PGP MESSAGE-----") !== -1) {
// 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;
}
function encrypt () {
if (window.crypto && window.crypto.getRandomValues) {
var message = document.getElementById('message');
if (message.value.indexOf('-----BEGIN PGP MESSAGE-----') !== -1 && message.value.indexOf('-----END PGP MESSAGE-----') !== -1) {
// encryption done
} 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;
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 {
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() {
var metaData = document.getElementsByTagName('meta');
for (var m in metaData) {
if (metaData[m]["httpEquiv"] == "language") {
return metaData[m]["content"];
}
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
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
$(document).ready(function () {
activateJSOnlyContent()
activateJSOnlyContent();
createCustomFocuses();
var focus = $('#foki > li.active > a').attr('aria-controls');
var custom = $('#foki > li.active').hasClass('custom-focus-tab-selector');
getDocumentReadyForUse(focus, custom);
botProtection();
})
new Results(); // Adds the saved Results if they are present
});
function activateJSOnlyContent() {
$('#searchplugin').removeClass('hide')
$('.options').removeClass('hide')
function activateJSOnlyContent () {
$('#searchplugin').removeClass('hide');
$('.options').removeClass('hide');
}
function tabs () {
$('#foki > li.tab-selector > a').each(function () {
if ($(this).attr('target') != '_blank') {
$(this).attr('href', '#' + $(this).attr('aria-controls'))
$(this).attr('role', 'tab')
$(this).attr('data-toggle', 'tab')
$(this).attr('href', '#' + $(this).attr('aria-controls'));
$(this).attr('role', 'tab');
$(this).attr('data-toggle', 'tab');
}
})
$('#foki > li.tab-selector > a').off()
});
$('#foki > li.tab-selector > a').off();
$('#foki > li.tab-selector > a').on('show.bs.tab', function (e) {
var fokus = $(this).attr('aria-controls')
var link = $('#' + fokus + 'TabSelector a').attr('data-href')
var fokus = $(this).attr('aria-controls');
var link = $('#' + fokus + 'TabSelector a').attr('data-href');
if ($('#' + fokus + 'TabSelector').attr('data-loaded') != '1') {
$.get(link, function (data) {
$('#' + fokus + 'TabSelector').attr('data-loaded', '1')
$('#' + fokus).html(data)
$('input[name=focus]').val($('#foki li.active a').attr('aria-controls'))
getDocumentReadyForUse(fokus)
})
$('#' + fokus + 'TabSelector').attr('data-loaded', '1');
$('#' + fokus).html(data);
$('input[name=focus]').val($('#foki li.active a').attr('aria-controls'));
getDocumentReadyForUse(fokus);
});
} else {
getDocumentReadyForUse(fokus)
getDocumentReadyForUse(fokus);
}
})
});
}
function getDocumentReadyForUse (fokus, custom = false) {
......@@ -54,33 +55,35 @@ function getDocumentReadyForUse (fokus, custom = false) {
function pluginInfo () {
if (localStorage) {
if (localStorage.getItem('pluginInfo') == 'off') $('#searchplugin').css('display', 'none')
if (localStorage.getItem('pluginInfo') == 'off') $('#searchplugin').css('display', 'none');
$('#searchplugin').on('close.bs.alert', function () {
$.get('/pluginClose')
localStorage.setItem('pluginInfo', 'off')
})
$.get('/pluginClose');
localStorage.setItem('pluginInfo', 'off');
});
$('#searchplugin a.btn').click(function () {
$.get('/pluginInstall')
})
$.get('/pluginInstall');
});
}
}
function theme () {
if (localStorage) {
var theme = localStorage.getItem('theme')
var theme = localStorage.getItem('theme');
if (theme != null) {
if ((theme.match(/,/g) || []).length != 3) {
localStorage.removeItem('theme')
localStorage.removeItem('theme');
} else {
theme = theme.split(',')
$('#theme').attr('href', '/css/theme.css.php?r=' + theme[0] + '&g=' + theme[1] + '&b=' + theme[2] + '&a=' + theme[3])
theme = theme.split(',');
$('#theme').attr('href', '/css/theme.css.php?r=' + theme[0] + '&g=' + theme[1] + '&b=' + theme[2] + '&a=' + theme[3]);
}
}
}
}
function clickLog () {
$('.result a.title, .result div.link-link a').off()
$('.result a.title, .result div.link-link a').off();
$('.result a.title, .result div.link-link a').click(function () {
$.get('/clickstats', {
i: $('meta[name=p]').attr('content'),
......@@ -88,81 +91,81 @@ function clickLog () {
q: $('meta[name=q]').attr('content'),
p: $(this).attr('data-count'),
url: $(this).attr('href')
})
})
});
});
}
function botProtection() {
if ($("meta[name=pqr]").length > 0) {
var link = atob($("meta[name=pqr]").attr("content"));
var hash = $("meta[name=pq]").attr("content");
document.location.href = link + "&bot=" + hash;
}
function botProtection () {
if ($('meta[name=pqr]').length > 0) {
var link = atob($('meta[name=pqr]').attr('content'));
var hash = $('meta[name=pq]').attr('content');
document.location.href = link + '&bot=' + hash;
}
}
function popovers () {
$('[data-toggle=popover]').each(function (e) {
$(this).popover('destroy')
$(this).popover('destroy');
$(this).popover({
// html : true,
// title : "<i class="fa fa-cog" aria-hidden="true"></i> Optionen",
content: $(this).parent().find('.content').html()
})
})
});
});
}
function pagination () {
$('.pagination li:not(.active) > a').attr('href', '#')
$('.pagination li.disabled > a').removeAttr('href')
$('.pagination li:not(.active) > a').off()
$('.pagination li:not(.active) > a').click(paginationHandler)
$('.pagination li:not(.active) > a').attr('href', '#');
$('.pagination li.disabled > a').removeAttr('href');
$('.pagination li:not(.active) > a').off();
$('.pagination li:not(.active) > a').click(paginationHandler);
}
function paginationHandler () {
var link = $(this).attr('data-href')
var link = $(this).attr('data-href');
if (link.length == 0) {
return
return;
}
var tabPane = $('.tab-pane.active')
$(tabPane).html('<div class="loader"><img src="/img/ajax-loader.gif" alt="" /></div>')
var tabPane = $('.tab-pane.active');
$(tabPane).html('<div class="loader"><img src="/img/ajax-loader.gif" alt="" /></div>');
$.get(link, function (data) {
$(tabPane).html(data)
$('.pagination li:not(.active) > a').attr('href', '#')
$('.pagination li.disabled > a').removeAttr('href')
$('.pagination li:not(.active) > a').off()
$('.pagination li:not(.active) > a').click(paginationHandler)
getDocumentReadyForUse()
})
$(tabPane).html(data);
$('.pagination li:not(.active) > a').attr('href', '#');
$('.pagination li.disabled > a').removeAttr('href');
$('.pagination li:not(.active) > a').off();
$('.pagination li:not(.active) > a').click(paginationHandler);
getDocumentReadyForUse();
});
}
function imageLoader () {
if (typeof $('#container').masonry == 'undefined') {
return
return;
}
var $grid = $('#container').masonry({
columnWidth: 150,
itemSelector: '.item',
gutter: 10,
isFitWidth: true
})
});
$grid.imagesLoaded().progress(function (instance, image) {
$grid.masonry('layout')
})
$grid.masonry('layout');
});
}
function eliminateHost (host) {
$('.result:not(.ad)').each(function (e) {
var host2 = $(this).find('.link-link > a').attr('data-host')
var host2 = $(this).find('.link-link > a').attr('data-host');
if (host2.indexOf(host) === 0) {
$(this).css('display', 'none')
$(this).css('display', 'none');
}
})
});
}
function fokiChanger () {
$('#fokiChanger ul > li').click(function () {
document.location.href = $(this).attr('data-href')
})
document.location.href = $(this).attr('data-href');
});
}
// Polyfill for form attribute
(function ($) {
......@@ -170,11 +173,11 @@ function fokiChanger () {
* polyfill for html5 form attr
*/
// detect if browser supports this
var sampleElement = $('[form]').get(0)
var isIE11 = !(window.ActiveXObject) && 'ActiveXObject' in window
var sampleElement = $('[form]').get(0);
var isIE11 = !(window.ActiveXObject) && 'ActiveXObject' in window;
if (sampleElement && window.HTMLFormElement && sampleElement.form instanceof HTMLFormElement && !isIE11) {
// browser supports it, no need to fix
return
return;
}
/**
* Append a field to a form
......@@ -182,60 +185,60 @@ function fokiChanger () {
*/
$.fn.appendField = function (data) {
// for form only
if (!this.is('form')) return
if (!this.is('form')) return;
// wrap data
if (!$.isArray(data) && data.name && data.value) {
data = [data]
data = [data];
}
var $form = this
var $form = this;
// attach new params
$.each(data, function (i, item) {
$('<input/>').attr('type', 'hidden').attr('name', item.name).val(item.value).appendTo($form)
})
return $form
}
$('<input/>').attr('type', 'hidden').attr('name', item.name).val(item.value).appendTo($form);
});
return $form;
};
/**
* Find all input fields with form attribute point to jQuery object
*
*/
$('form[id]').submit(function (e) {
var $form = $(this)
var $form = $(this);
// serialize data
var data = $('[form=' + $form.attr('id') + ']').serializeArray()
var data = $('[form=' + $form.attr('id') + ']').serializeArray();
// append data to form
$form.appendField(data)
$form.appendField(data);
}).each(function () {
var form = this,
$form = $(form),
$fields = $('[form=' + $form.attr('id') + ']')
$fields = $('[form=' + $form.attr('id') + ']');
$fields.filter('button, input').filter('[type=reset],[type=submit]').click(function () {
var type = this.type.toLowerCase()
var type = this.type.toLowerCase();