Commit 0b60987a authored by Karl's avatar Karl
Browse files

Merge remote-tracking branch 'origin/development' into 110-deutsche-seite-hilfe-faq-uberarbeiten

parents 598a5142 378af725
......@@ -2,7 +2,7 @@ update(144.76.113.134):
tags:
- 144.76.113.134
only:
- master
- master@open-source/MetaGer
before_script:
# Abhängigkeiten überprüfen
- which composer
......@@ -39,7 +39,7 @@ update(metager2):
tags:
- metager2
only:
- master
- master@open-source/MetaGer
before_script:
# Abhängigkeiten überprüfen
- which composer
......@@ -76,7 +76,7 @@ update(metager3.de):
tags:
- metager3
only:
- development
- development@open-source/MetaGer
before_script:
# Abhängigkeiten überprüfen
- which composer
......
......@@ -26,4 +26,22 @@ class LogController extends Controller
return '';
}
function pluginClose()
{
$redis = Redis::connection('redisLogs');
if( $redis )
{
$redis->incr('logs.plugin.close');
}
}
function pluginInstall()
{
$redis = Redis::connection('redisLogs');
if( $redis )
{
$redis->incr('logs.plugin.install');
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use LaravelLocalization;
use Mail;
class MailController extends Controller
......@@ -14,35 +15,36 @@ class MailController extends Controller
* @param int $id
* @return Response
*/
public function contactMail(Request $request){
public function contactMail(Request $request)
{
# Nachricht, die wir an den Nutzer weiterleiten:
$messageType = ""; # [success|error]
$returnMessage = '';
$replyTo = $request->input('email', 'noreply@metager.de');
if($replyTo === ""){
if ($replyTo === "") {
$replyTo = "noreply@metager.de";
}else{
} else {
$replyTo = $request->input('email');
}
if(!$request->has('message')){
if (!$request->has('message')) {
$messageType = "error";
$returnMessage = "Tut uns leid, aber leider haben wir mit Ihrer Kontaktanfrage keine Daten erhalten. Die Email wurde nicht versand";
}else{
} else {
# Wir versenden die Mail des Benutzers an uns:
$message = $request->input('message');
$subject = "[Ticket " . date("Y") . date("d") . date("m") . date("H") . date("i") . date("s") . "] MetaGer - Kontaktanfrage";
if( Mail::send(['text' => 'kontakt.mail'], ['messageText'=>$message], function($message) use($replyTo, $subject){
if (Mail::send(['text' => 'kontakt.mail'], ['messageText' => $message], function ($message) use ($replyTo, $subject) {
$message->to("office@suma-ev.de", $name = null);
$message->from($replyTo, $name = null);
$message->replyTo($replyTo, $name = null);
$message->subject($subject);
}) ){
})) {
# Mail erfolgreich gesendet
$messageType = "success";
$returnMessage = 'Ihre Email wurde uns erfolgreich zugestellt. Vielen Dank dafür! Wir werden diese schnellstmöglich bearbeiten und uns dann ggf. wieder bei Ihnen melden.';
}else{
} else {
# Fehler beim senden der Email
$messageType = "error";
$returnMessage = 'Beim Senden Ihrer Email ist ein Fehler aufgetreten. Bitte schicken Sie eine Email an: office@suma-ev.de, damit wir uns darum kümmern können.';
......@@ -51,12 +53,11 @@ class MailController extends Controller
$messageType = "success";
}
return view('kontakt.kontakt')
->with('title', 'Kontakt')
->with('css', 'kontakt.css')
->with('js', ['openpgp.min.js','kontakt.js'])
->with( $messageType, $returnMessage );
->with('js', ['openpgp.min.js', 'kontakt.js'])
->with($messageType, $returnMessage);
}
public function donation(Request $request)
......@@ -72,10 +73,10 @@ class MailController extends Controller
# Kontonummer ( IBAN )
# Bankleitzahl ( BIC )
# Nachricht
if(!$request->has('Kontonummer') || !$request->has('Bankleitzahl') || !$request->has('Nachricht')){
if (!$request->has('Kontonummer') || !$request->has('Bankleitzahl') || !$request->has('Nachricht')) {
$messageToUser = "Sie haben eins der folgenden Felder nicht ausgefüllt: IBAN, BIC, Nachricht. Bitte korrigieren Sie Ihre Eingabe und versuchen es erneut.\n";
$messageType = "error";
}else{
} else {
$message = "\r\nName: " . $request->input('Name', 'Keine Angabe');
$message .= "\r\nTelefon: " . $request->input('Telefon', 'Keine Angabe');
$message .= "\r\nKontonummer: " . $request->input('Kontonummer');
......@@ -87,29 +88,35 @@ class MailController extends Controller
$messageToUser .= "Die eingegebene Email-Addresse ($replyTo) scheint nicht korrekt zu sein.";
}
try{
if(Mail::send(['text' => 'kontakt.mail'], ['messageText'=>$message], function($message) use($replyTo){
try {
if (Mail::send(['text' => 'kontakt.mail'], ['messageText' => $message], function ($message) use ($replyTo) {
$message->to("office@suma-ev.de", $name = null);
$message->from($replyTo, $name = null);
$message->replyTo($replyTo, $name = null);
$message->subject("MetaGer - Spende");
})) {
$messageType = "success";
$messageToUser = "Wir haben Ihre Spendenbenachrichtigung dankend erhalten. Eine persönliche Nachricht erhalten Sie in nächster Zeit, falls sie Ihre Kontaktdaten angegeben haben.";
}else{
$messageToUser = "Herzlichen Dank!! Wir haben Ihre Spendenbenachrichtigung erhalten.";
} else {
$messageType = "error";
$messageToUser = 'Beim Senden Ihrer Spendenbenachrichtigung ist ein Fehler auf unserer Seite aufgetreten. Bitte schicken Sie eine Email an: office@suma-ev.de, damit wir uns darum kümmern können.';
}
} catch( \Swift_TransportException $e ){
} catch (\Swift_TransportException $e) {
$messageType = "error";
$messageToUser = 'Beim Senden Ihrer Spendenbenachrichtigung ist ein Fehler auf unserer Seite aufgetreten. Bitte schicken Sie eine Email an: office@suma-ev.de, damit wir uns darum kümmern können.';
}
}
return view('spende.spende')
if ($messageType === "error") {
return view('spende.danke')
->with('title', 'Kontakt')
->with('css', 'donation.css')
->with($messageType,$messageToUser);
->with($messageType, $messageToUser);
} else {
$data = ['name' => $request->input('Name', 'Keine Angabe'), 'telefon' => $request->input('Telefon', 'Keine Angabe'), 'kontonummer' => $request->input('Kontonummer'), 'bankleitzahl' => $request->input('Bankleitzahl'), 'email' => $request->input('email', 'anonymous-user@metager.de'), 'nachricht' => $request->input('Nachricht')];
$data = base64_encode(serialize($data));
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route("danke", ['data' => $data])));
}
}
}
......@@ -4,9 +4,6 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
#use App\MetaGer\Forwarder;
#use App\MetaGer\Results;
#use App\MetaGer\Search;
use App;
use App\MetaGer;
......
......@@ -75,9 +75,10 @@ class StartpageController extends Controller
return loadPage($subpage);
}
public function loadPlugin(Request $request, $locale = "de")
public function loadPlugin($params, $locale = "de")
{
$requests = $request->all();
$params = unserialize(base64_decode($params));
$requests = $params;
$params = [];
foreach($requests as $key => $value)
{
......@@ -94,9 +95,9 @@ class StartpageController extends Controller
$params['encoding'] = 'utf8';
if(!isset($params['lang']))
$params['lang'] = 'all';
$params["eingabe"] = "";
array_forget($params, 'eingabe');
array_forget($params, 'out');
array_forget($params, 'page');
$link = action('MetaGerSearch@search', $params);
$response = Response::make(
......
......@@ -9,89 +9,94 @@
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
*/
Route::group(
Route::group(
[
'prefix' => LaravelLocalization::setLocale()/*,
'prefix' => LaravelLocalization::setLocale(), /*,
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ]*/
],
function()
{
function () {
/** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
Route::get('/', 'StartpageController@loadStartPage');
Route::get('img/piwik.png', 'ImageController@generateImage');
Route::get('impressum', function()
{
Route::get('impressum', function () {
return view('impressum')
->with('title', trans('titles.impressum'))
->with('css', 'impressum.css')
->with('navbarFocus', 'kontakt');
});
Route::get('impressum.html', function () {
return redirect(url('impressum'));
});
Route::get('about', function()
{
Route::get('about', function () {
return view('about')
->with('title', trans('titles.about'))
->with('css', 'about.css')
->with('navbarFocus', 'kontakt');
});
Route::get('team', function()
{
Route::get('team', function () {
return view('team.team')
->with('title', trans('titles.team'))
->with('css', 'team.css')
->with('navbarFocus', 'kontakt');
});
Route::get('team/pubkey-wsb', function()
{
Route::get('team/pubkey-wsb', function () {
return view('team.pubkey-wsb')
->with('title', trans('titles.team'))
->with('navbarFocus', 'kontakt');
});
Route::get('kontakt', function()
{
Route::get('kontakt', function () {
return view('kontakt.kontakt')
->with('title', trans('titles.kontakt'))
->with('css', 'kontakt.css')
->with('js', ['openpgp.min.js','kontakt.js'])
->with('js', ['openpgp.min.js', 'kontakt.js'])
->with('navbarFocus', 'kontakt');
});
Route::post('kontakt', 'MailController@contactMail');
Route::get('tor', function()
{
Route::get('tor', function () {
return view('tor')
->with('title', 'tor hidden service - MetaGer')
->with('navbarFocus', 'dienste');
});
Route::get('spende', function()
{
Route::get('spende', function () {
return view('spende.spende')
->with('title', trans('titles.spende'))
->with('css', 'donation.css')
->with('navbarFocus', 'foerdern');
});
Route::get('beitritt', function ()
{
Route::get('spende/danke/{data}', ['as' => 'danke', function ($data) {
return view('spende.danke')
->with('title', trans('titles.spende'))
->with('css', ['donation.css', 'danke.css'])
->with('navbarFocus', 'foerdern')
->with('data', unserialize(base64_decode($data)));
}]);
Route::get('partnershops', function () {
return view('spende.partnershops')
->with('title', trans('titles.partnershops'))
->with('navbarFocus', 'foerdern')
->with('css', 'partnershops.css');
});
Route::get('beitritt', function () {
return view('spende.beitritt')
->with('title', trans('titles.beitritt'))
->with('css', 'beitritt.css')
->with('navbarFocus', 'foerdern');
});
Route::get('bform1.htm', function()
{
Route::get('bform1.htm', function () {
return redirect('beitritt');
});
Route::get('spendenaufruf', function()
{
Route::get('spendenaufruf', function () {
return view('spende.spendenaufruf')
->with('title', 'Spendenaufruf - MetaGer')
->with('navbarFocus', 'foerdern');
......@@ -99,17 +104,14 @@
Route::post('spende', 'MailController@donation');
Route::get('datenschutz', function()
{
Route::get('datenschutz', function () {
return view('datenschutz')
->with('title', trans('titles.datenschutz'))
->with('css', 'privacy.css')
->with('navbarFocus', 'datenschutz');
});
Route::get('hilfe', function()
{
Route::get('hilfe', function () {
return view('hilfe')
->with('title', trans('titles.hilfe'))
->with('css', 'help.css')
......@@ -124,8 +126,7 @@
->with('navbarFocus', 'hilfe');
});
Route::get('widget', function()
{
Route::get('widget', function () {
return view('widget.widget')
->with('title', trans('titles.widget'))
->with('css', 'widget.css')
......@@ -134,8 +135,7 @@
Route::get('sitesearch', 'SitesearchController@loadPage');
Route::get('websearch', function()
{
Route::get('websearch', function () {
return view('widget.websearch')
->with('title', trans('titles.websearch'))
->with('css', 'websearch.css')
......@@ -148,16 +148,16 @@
Route::get('settings', 'StartpageController@loadSettings');
Route::get('meta/meta.ger3', 'MetaGerSearch@search');
Route::get('meta/picture', 'Pictureproxy@get');
Route::get('clickstats', 'LogController@clicklog');
Route::get('pluginClose', 'LogController@pluginClose');
Route::get('pluginInstall', 'LogController@pluginInstall');
Route::get('qt', 'MetaGerSearch@quicktips');
Route::get('tips', 'MetaGerSearch@tips');
Route::get('opensearch.xml', 'StartpageController@loadPlugin');
Route::get('owi', function()
{
Route::get('/plugins/{params}/opensearch.xml', 'StartpageController@loadPlugin');
Route::get('owi', function () {
return redirect('https://metager.de/klassik/en/owi/');
});
});
......@@ -3,17 +3,17 @@
namespace App\Jobs;
use App\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Http\Request;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Redis;
class Search extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
protected $hash, $host, $port, $name, $getString, $useragent, $fp, $sumaFile;
protected $hash, $host, $port, $name, $getString, $useragent, $fp;
protected $buffer_length = 8192;
/**
......@@ -21,7 +21,7 @@ class Search extends Job implements ShouldQueue
*
* @return void
*/
public function __construct($hash, $host, $port, $name, $getString, $useragent, $sumaFile)
public function __construct($hash, $host, $port, $name, $getString, $useragent)
{
$this->hash = $hash;
$this->host = $host;
......@@ -29,7 +29,6 @@ class Search extends Job implements ShouldQueue
$this->name = $name;
$this->getString = $getString;
$this->useragent = $useragent;
$this->sumaFile = $sumaFile;
}
/**
......@@ -41,78 +40,65 @@ class Search extends Job implements ShouldQueue
{
$this->fp = $this->getFreeSocket();
if($this->fp)
{
if($this->writeRequest())
{
if ($this->fp) {
if ($this->writeRequest()) {
$this->readAnswer();
}
}
}
public function disable($sumaFile, $message)
{
$xml = simplexml_load_file($sumaFile);
$xml->xpath("//sumas/suma[@name='" . $this->name . "']")['0']['disabled'] = date(DATE_RFC822, mktime(date("H")+1,date("i"), date("s"), date("m"), date("d"), date("Y")));
$xml->saveXML($sumaFile);
}
private function readAnswer ()
private function readAnswer()
{
$time = microtime(true);
$headers = '';
$body = '';
$length = 0;
if(!$this->fp)
{
if (!$this->fp) {
return;
}
// get headers FIRST
$c = 0;
stream_set_blocking($this->fp, 1);
do
{
do {
// use fgets() not fread(), fgets stops reading at first newline
// or buffer which ever one is reached first
$data = fgets($this->fp, 8192);
// a sincle CRLF indicates end of headers
if ($data === false || $data == "\r\n" || feof($this->fp) ) {
if ($data === false || $data == "\r\n" || feof($this->fp)) {
// break BEFORE OUTPUT
break;
}
if( sizeof(($tmp = explode(": ", $data))) === 2 )
if (sizeof(($tmp = explode(": ", $data))) === 2) {
$headers[strtolower(trim($tmp[0]))] = trim($tmp[1]);
$c++;
}
while (true);
$c++;
} while (true);
// end of headers
if(sizeof($headers) > 1){
if (sizeof($headers) > 1) {
$bodySize = 0;
if( isset($headers["transfer-encoding"]) && $headers["transfer-encoding"] === "chunked" )
{
if (isset($headers["transfer-encoding"]) && $headers["transfer-encoding"] === "chunked") {
$body = $this->readChunked();
}elseif( isset($headers['content-length']) )
{
} elseif (isset($headers['content-length'])) {
$length = trim($headers['content-length']);
if(is_numeric($length) && $length >= 1)
if (is_numeric($length) && $length >= 1) {
$body = $this->readBody($length);
}
$bodySize = strlen($body);
}else
{
} else {
exit;
}
}else
{
} else {
return;
}
Redis::del($this->host . "." . $this->socketNumber);
if( isset($headers["content-encoding"]) && $headers['content-encoding'] === "gzip")
{
if (isset($headers["content-encoding"]) && $headers['content-encoding'] === "gzip") {
$body = $this->gunzip($body);
}
Redis::hset('search.' . $this->hash, $this->name, $body);
......@@ -126,8 +112,7 @@ class Search extends Job implements ShouldQueue
stream_set_blocking($this->fp, 0);
$startTime = time();
$lastTime = $startTime;
while (!feof($this->fp) && !$done && (($startTime + 1) > time()) && $length !== 0)
{
while (!feof($this->fp) && !$done && (($startTime + 1) > time()) && $length !== 0) {
usleep(100);
$theNewData = fgets($this->fp, 8192);
$theData .= $theNewData;
......@@ -143,8 +128,7 @@ class Search extends Job implements ShouldQueue
$body = '';
// read from chunked stream
// loop though the stream
do
{
do {
// NOTE: for chunked encoding to work properly make sure
// there is NOTHING (besides newlines) before the first hexlength
......@@ -170,15 +154,16 @@ class Search extends Job implements ShouldQueue
// zero is sent when at the end of the chunks
// or the end of the stream or error
if ($line === false || $length < 1 || feof($this->fp)) {
if($length <= 0)
if ($length <= 0) {
fgets($this->fp, 8192);
}
// break out of the streams loop
break;
}
// loop though the chunk
do
{
do {
// read $length amount of data
// (use fread here)
$data = fread($this->fp, $length);
......@@ -194,40 +179,40 @@ class Search extends Job implements ShouldQueue
$body .= $data;
// zero or less or end of connection break
if ($length <= 0 || feof($this->fp))
{
if ($length <= 0 || feof($this->fp)) {
// break out of the chunk loop
if($length <= 0)
if ($length <= 0) {
fgets($this->fp, 8192);
break;
}
break;
}
while (true);
} while (true);
// end of chunk loop
}
while (true);
} while (true);
// end of stream loop
return $body;
}
private function gunzip($zipped) {
private function gunzip($zipped)
{
$offset = 0;
if (substr($zipped,0,2) == "\x1f\x8b")
if (substr($zipped, 0, 2) == "\x1f\x8b") {
$offset = 2;
if (substr($zipped,$offset,1) == "\x08")
{
}
if (substr($zipped, $offset, 1) == "\x08") {
try
{
return gzinflate(substr($zipped, $offset + 8));
} catch (\Exception $e)
{
} catch (\Exception $e) {
abort(500, "Fehler beim unzip des Ergebnisses von folgendem Anbieter: " . $this->name);
}
}
return "Unknown Format";
}
private function writeRequest ()