Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
647507ce
Commit
647507ce
authored
Jul 04, 2016
by
Dominik Hebeler
Browse files
Merge remote-tracking branch 'origin/master' into 72-metager-plugin-popup-startseite-ubersetzen
parents
f2b3ae91
fd076267
Changes
75
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
647507ce
...
...
@@ -8,6 +8,7 @@ update(144.76.113.134):
-
which composer
-
which git
-
which php7.0
-
which sqlite3
script
:
# Pfad zum neu geklonten Repo
-
path=`pwd`
...
...
@@ -16,14 +17,15 @@ update(144.76.113.134):
-
git clone "$path" MetaGer_neu
-
cd MetaGer_neu
-
composer update
-
chmod -R 777 storage
-
chmod -R 777 bootstrap/cache
-
php artisan queue:restart
-
scp metager@metager3.de:~/.env .
-
scp metager@metager3.de:~/sumas.xml config/
-
scp metager@metager3.de:~/sumasEn.xml config/
-
scp metager@metager3.de:~/blacklistUrl.txt config/
-
scp metager@metager3.de:~/blacklistDomains.txt config/
-
chmod 777 config/sumas.xml config/sumasEn.xml
-
chmod -R 777 storage
-
chmod -R 777 bootstrap/cache
-
cd ~/
-
rm -rf MetaGer
-
mv MetaGer_neu MetaGer
...
...
@@ -38,6 +40,7 @@ update(metager3.de):
-
which composer
-
which git
-
which php7.0
-
which sqlite3
script
:
# Pfad zum neu geklonten Repo
-
path=`pwd`
...
...
@@ -46,14 +49,15 @@ update(metager3.de):
-
git clone "$path" MetaGer_neu
-
cd MetaGer_neu
-
composer update
-
chmod -R 777 storage
-
chmod -R 777 bootstrap/cache
-
php artisan queue:restart
-
scp metager@metager3.de:~/.env .
-
scp metager@metager3.de:~/sumas.xml config/
-
scp metager@metager3.de:~/sumasEn.xml config/
-
scp metager@metager3.de:~/blacklistUrl.txt config/
-
scp metager@metager3.de:~/blacklistDomains.txt config/
-
chmod 777 config/sumas.xml config/sumasEn.xml
-
chmod -R 777 storage
-
chmod -R 777 bootstrap/cache
-
cd ~/
-
rm -rf MetaGer
-
mv MetaGer_neu MetaGer
\ No newline at end of file
LICENSES.md
deleted
100644 → 0
View file @
f2b3ae91
This diff is collapsed.
Click to expand it.
app/Http/Controllers/SitesearchController.php
0 → 100644
View file @
647507ce
<?php
namespace
App\Http\Controllers
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Http\Request
;
use
App
;
class
SitesearchController
extends
Controller
{
public
function
loadPage
(
Request
$request
)
{
return
view
(
'widget.sitesearch'
)
->
with
(
'title'
,
trans
(
'titles.sitesearch'
))
->
with
(
'css'
,
'sitesearch.css'
)
->
with
(
'site'
,
$request
->
input
(
'site'
,
''
))
->
with
(
'navbarFocus'
,
'dienste'
);
}
}
\ No newline at end of file
app/Http/Controllers/StartpageController.php
View file @
647507ce
...
...
@@ -7,6 +7,7 @@ use Jenssegers\Agent\Agent;
use
App\Http\Controllers\Controller
;
use
Illuminate\Http\Request
;
use
Response
;
use
App
;
class
StartpageController
extends
Controller
{
...
...
@@ -48,7 +49,9 @@ class StartpageController extends Controller
->
with
(
'sprueche'
,
$request
->
input
(
'param_sprueche'
,
'off'
))
->
with
(
'tab'
,
$request
->
input
(
'param_sprueche'
,
'off'
))
->
with
(
'focusPages'
,
$focusPages
)
->
with
(
'browser'
,
$browser
);
->
with
(
'browser'
,
$browser
)
->
with
(
'navbarFocus'
,
'suche'
);
}
public
function
loadPage
(
$subpage
)
...
...
@@ -102,4 +105,51 @@ class StartpageController extends Controller
return
$response
;
return
$link
;
}
public
function
loadSettings
(
Request
$request
)
{
$sumaFile
=
""
;
if
(
App
::
isLocale
(
'en'
))
$sumaFile
=
config_path
()
.
"/sumasEn.xml"
;
else
$sumaFile
=
config_path
()
.
"/sumas.xml"
;
$xml
=
simplexml_load_file
(
$sumaFile
);
$sumas
=
$xml
->
xpath
(
"suma"
);
$foki
=
[];
foreach
(
$sumas
as
$suma
)
{
if
(
(
!
isset
(
$suma
[
'disabled'
])
||
$suma
[
'disabled'
]
===
""
)
&&
(
!
isset
(
$suma
[
'userSelectable'
])
||
$suma
[
'userSelectable'
]
->
__toString
()
===
"1"
)
)
{
if
(
isset
(
$suma
[
'type'
])
)
{
$f
=
explode
(
","
,
$suma
[
'type'
]
->
__toString
());
foreach
(
$f
as
$tmp
)
{
$displayName
=
$suma
[
'displayName'
]
->
__toString
();
$url
=
isset
(
$suma
[
'homepage'
])
?
$suma
[
'homepage'
]
->
__toString
()
:
"https://metager.de"
;
$service
=
$suma
[
'service'
]
->
__toString
();
$foki
[
$tmp
][
$suma
[
'name'
]
->
__toString
()]
=
[
'displayName'
=>
$displayName
,
'url'
=>
$url
,
'service'
=>
$service
];
}
}
else
{
$displayName
=
$suma
[
'displayName'
]
->
__toString
();
$url
=
isset
(
$suma
[
'homepage'
])
?
$suma
[
'homepage'
]
->
__toString
()
:
"https://metager.de"
;
$service
=
$suma
[
'service'
]
->
__toString
();
$foki
[
"andere"
][
$suma
[
'name'
]
->
__toString
()]
=
[
'displayName'
=>
$displayName
,
'url'
=>
$url
,
'service'
=>
$service
];
}
}
}
return
view
(
'settings1'
)
->
with
(
'foki'
,
$foki
)
->
with
(
'title'
,
'Einstellungen'
)
->
with
(
'css'
,
'settings.css'
)
->
with
(
'js'
,
[
'settings.js'
])
->
with
(
'navbarFocus'
,
'suche'
);
die
(
var_dump
(
$foki
));
return
$xml
->
saveXML
();
}
}
\ No newline at end of file
app/Http/Kernel.php
View file @
647507ce
...
...
@@ -50,5 +50,9 @@ class Kernel extends HttpKernel
'can'
=>
\
Illuminate\Foundation\Http\Middleware\Authorize
::
class
,
'guest'
=>
\
App\Http\Middleware\RedirectIfAuthenticated
::
class
,
'throttle'
=>
\
Illuminate\Routing\Middleware\ThrottleRequests
::
class
,
'localize'
=>
\
Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes
::
class
,
'localizationRedirect'
=>
\
Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter
::
class
,
'localeSessionRedirect'
=>
\
Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect
::
class
];
}
app/Http/routes.php
View file @
647507ce
...
...
@@ -11,96 +11,109 @@
|
*/
Route
::
group
([
'prefix'
=>
LaravelLocalization
::
setLocale
()],
function
()
{
/** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
/* Route::get('/', function()
{
return view('index', [
'title' => trans('titles.index'),
'homeIcon']);
}); */
Route
::
group
(
[
'prefix'
=>
LaravelLocalization
::
setLocale
()
/*,
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ]*/
],
function
()
{
/** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
Route
::
get
(
'/'
,
'StartpageController@loadStartPage'
);
Route
::
get
(
'/'
,
'StartpageController@loadStartPage'
);
Route
::
get
(
'impressum'
,
function
()
{
return
view
(
'impressum'
)
->
with
(
'title'
,
trans
(
'titles.impressum'
))
->
with
(
'css'
,
'impressum.css'
);
});
Route
::
get
(
'impressum'
,
function
()
{
return
view
(
'impressum'
)
->
with
(
'title'
,
trans
(
'titles.impressum'
))
->
with
(
'css'
,
'impressum.css'
)
->
with
(
'navbarFocus'
,
'kontakt'
);
});
Route
::
get
(
'about'
,
function
()
{
return
view
(
'about'
)
->
with
(
'title'
,
trans
(
'titles.about'
))
->
with
(
'css'
,
'about.css'
);
});
Route
::
get
(
'team'
,
function
()
{
return
view
(
'team.team'
)
->
with
(
'title'
,
trans
(
'titles.team'
))
->
with
(
'css'
,
'team.css'
);
});
Route
::
get
(
'team/pubkey-wsb'
,
function
()
{
return
view
(
'team.pubkey-wsb'
)
->
with
(
'title'
,
trans
(
'titles.team'
));
});
Route
::
get
(
'about'
,
function
()
{
return
view
(
'about'
)
->
with
(
'title'
,
trans
(
'titles.about'
))
->
with
(
'css'
,
'about.css'
)
->
with
(
'navbarFocus'
,
'kontakt'
);
});
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
()
{
return
view
(
'team.pubkey-wsb'
)
->
with
(
'title'
,
trans
(
'titles.team'
))
->
with
(
'navbarFocus'
,
'kontakt'
);
});
Route
::
get
(
'kontakt'
,
function
()
{
return
view
(
'kontakt.kontakt'
)
->
with
(
'title'
,
trans
(
'titles.kontakt'
))
->
with
(
'css'
,
'kontakt.css'
)
->
with
(
'js'
,
[
'openpgp.min.js'
,
'kontakt.js'
]);
});
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
(
'navbarFocus'
,
'kontakt'
);
});
Route
::
post
(
'kontakt'
,
'MailController@contactMail'
);
Route
::
post
(
'kontakt'
,
'MailController@contactMail'
);
Route
::
get
(
'spende'
,
function
()
{
return
view
(
'spende'
)
->
with
(
'title'
,
trans
(
'titles.spende'
))
->
with
(
'css'
,
'donation.css'
);
});
Route
::
post
(
'spende'
,
'MailController@donation'
);
Route
::
get
(
'spende'
,
function
()
{
return
view
(
'spende'
)
->
with
(
'title'
,
trans
(
'titles.spende'
))
->
with
(
'css'
,
'donation.css'
)
->
with
(
'navbarFocus'
,
'foerdern'
);
});
Route
::
post
(
'spende'
,
'MailController@donation'
);
Route
::
get
(
'datenschutz'
,
function
()
{
return
view
(
'datenschutz'
)
->
with
(
'title'
,
trans
(
'titles.datenschutz'
))
->
with
(
'css'
,
'privacy.css'
);
});
Route
::
get
(
'datenschutz'
,
function
()
{
return
view
(
'datenschutz'
)
->
with
(
'title'
,
trans
(
'titles.datenschutz'
))
->
with
(
'css'
,
'privacy.css'
)
->
with
(
'navbarFocus'
,
'datenschutz'
);
});
Route
::
get
(
'hilfe'
,
function
()
{
return
view
(
'hilfe'
)
->
with
(
'title'
,
trans
(
'titles.hilfe'
))
->
with
(
'css'
,
'help.css'
);
});
Route
::
get
(
'hilfe'
,
function
()
{
return
view
(
'hilfe'
)
->
with
(
'title'
,
trans
(
'titles.hilfe'
))
->
with
(
'css'
,
'help.css'
)
->
with
(
'navbarFocus'
,
'dienste'
);
});
Route
::
get
(
'widget'
,
function
()
{
return
view
(
'widget'
)
->
with
(
'title'
,
trans
(
'titles.widget'
))
->
with
(
'css'
,
'widget.css'
);
Route
::
get
(
'widget'
,
function
()
{
return
view
(
'widget.widget'
)
->
with
(
'title'
,
trans
(
'titles.widget'
))
->
with
(
'css'
,
'widget.css'
)
->
with
(
'navbarFocus'
,
'dienste'
);
});
Route
::
get
(
'settings'
,
function
()
Route
::
get
(
'sitesearch'
,
'SitesearchController@loadPage'
);
Route
::
get
(
'websearch'
,
function
()
{
return
view
(
'settings'
)
->
with
(
'title'
,
'Einstellungen'
)
// TODO Titel übersetzen
->
with
(
'css'
,
'settings.css'
)
->
with
(
'js'
,
[
'settings.js'
]);
});
return
view
(
'widget.websearch'
)
->
with
(
'title'
,
trans
(
'titles.websearch'
))
->
with
(
'css'
,
'websearch.css'
)
->
with
(
'navbarFocus'
,
'dienste'
);
});
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
(
'meta/meta.ger3'
,
'MetaGerSearch@search'
);
Route
::
get
(
'meta/picture'
,
'Pictureproxy@get'
);
Route
::
get
(
'clickstats'
,
'LogController@clicklog'
);
Route
::
get
(
'qt'
,
'MetaGerSearch@quicktips'
);
Route
::
get
(
'tips'
,
'MetaGerSearch@tips'
);
Route
::
get
(
'opensearch.xml'
,
'StartpageController@loadPlugin'
);
});
Route
::
get
(
'qt'
,
'MetaGerSearch@quicktips'
);
Route
::
get
(
'tips'
,
'MetaGerSearch@tips'
);
Route
::
get
(
'opensearch.xml'
,
'StartpageController@loadPlugin'
);
});
app/Jobs/Search.php
0 → 100644
View file @
647507ce
<?php
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
Redis
;
class
Search
extends
Job
implements
ShouldQueue
{
use
InteractsWithQueue
,
SerializesModels
;
protected
$hash
,
$host
,
$port
,
$name
,
$getString
,
$useragent
,
$fp
,
$sumaFile
;
protected
$buffer_length
=
8192
;
/**
* Create a new job instance.
*
* @return void
*/
public
function
__construct
(
$hash
,
$host
,
$port
,
$name
,
$getString
,
$useragent
,
$sumaFile
)
{
$this
->
hash
=
$hash
;
$this
->
host
=
$host
;
$this
->
port
=
$port
;
$this
->
name
=
$name
;
$this
->
getString
=
$getString
;
$this
->
useragent
=
$useragent
;
$this
->
sumaFile
=
$sumaFile
;
}
/**
* Execute the job.
*
* @return void
*/
public
function
handle
(
Request
$request
)
{
$this
->
fp
=
$this
->
getFreeSocket
();
if
(
!
$this
->
fp
)
{
$this
->
disable
(
$this
->
sumaFile
,
"Die Suchmaschine "
.
$this
->
name
.
" wurde für 1h deaktiviert, weil keine Verbindung aufgebaut werden konnte"
);
}
else
{
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
()
{
$time
=
microtime
(
true
);
$headers
=
''
;
$body
=
''
;
$length
=
0
;
if
(
!
$this
->
fp
)
{
return
;
}
// get headers FIRST
$c
=
0
;
stream_set_blocking
(
$this
->
fp
,
1
);
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
)
)
{
// break BEFORE OUTPUT
break
;
}
if
(
sizeof
((
$tmp
=
explode
(
": "
,
$data
)))
===
2
)
$headers
[
trim
(
$tmp
[
0
])]
=
trim
(
$tmp
[
1
]);
$c
++
;
}
while
(
true
);
// end of headers
if
(
sizeof
(
$headers
)
>
1
){
$bodySize
=
0
;
if
(
isset
(
$headers
[
"Transfer-Encoding"
])
&&
$headers
[
"Transfer-Encoding"
]
===
"chunked"
)
{
$body
=
$this
->
readChunked
();
}
elseif
(
isset
(
$headers
[
'Content-Length'
])
)
{
$length
=
trim
(
$headers
[
'Content-Length'
]);
if
(
is_numeric
(
$length
)
&&
$length
>=
1
)
$body
=
$this
->
readBody
(
$length
);
$bodySize
=
strlen
(
$body
);
}
else
{
exit
;
}
}
else
{
return
;
}
Redis
::
del
(
$this
->
host
.
"."
.
$this
->
socketNumber
);
if
(
isset
(
$headers
[
"Content-Encoding"
])
&&
$headers
[
'Content-Encoding'
]
===
"gzip"
)
{
$body
=
$this
->
gunzip
(
$body
);
}
Redis
::
hset
(
'search.'
.
$this
->
hash
,
$this
->
name
,
$body
);
Redis
::
expire
(
'search.'
.
$this
->
hash
,
5
);
}
private
function
readBody
(
$length
)
{
$theData
=
''
;
$done
=
false
;
stream_set_blocking
(
$this
->
fp
,
0
);
$startTime
=
time
();
$lastTime
=
$startTime
;
while
(
!
feof
(
$this
->
fp
)
&&
!
$done
&&
((
$startTime
+
1
)
>
time
())
&&
$length
!==
0
)
{
usleep
(
100
);
$theNewData
=
fgets
(
$this
->
fp
,
8192
);
$theData
.
=
$theNewData
;
$length
-=
strlen
(
$theNewData
);
$done
=
(
trim
(
$theNewData
)
===
'0'
);
}
return
$theData
;
}
private
function
readChunked
()
{
$body
=
''
;
// read from chunked stream
// loop though the stream
do
{
// NOTE: for chunked encoding to work properly make sure
// there is NOTHING (besides newlines) before the first hexlength
// get the line which has the length of this chunk (use fgets here)
$line
=
fgets
(
$this
->
fp
,
8192
);
// if it's only a newline this normally means it's read
// the total amount of data requested minus the newline
// continue to next loop to make sure we're done
if
(
$line
==
"
\r\n
"
)
{
continue
;
}
// the length of the block is sent in hex decode it then loop through
// that much data get the length
// NOTE: hexdec() ignores all non hexadecimal chars it finds
$length
=
hexdec
(
$line
);
if
(
!
is_int
(
$length
))
{
trigger_error
(
'Most likely not chunked encoding'
,
E_USER_ERROR
);
}
// 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
)
fgets
(
$this
->
fp
,
8192
);
// break out of the streams loop
break
;
}
// loop though the chunk
do
{
// read $length amount of data
// (use fread here)
$data
=
fread
(
$this
->
fp
,
$length
);
// remove the amount received from the total length on the next loop
// it'll attempt to read that much less data
$length
-=
strlen
(
$data
);
// PRINT out directly
// you could also save it directly to a file here
// store in string for later use
$body
.
=
$data
;
// zero or less or end of connection break
if
(
$length
<=
0
||
feof
(
$this
->
fp
))
{
// break out of the chunk loop
if
(
$length
<=
0
)
fgets
(
$this
->
fp
,
8192
);
break
;
}
}
while
(
true
);
// end of chunk loop
}
while
(
true
);
// end of stream loop
return
$body
;
}
private
function
gunzip
(
$zipped
)
{
$offset
=
0
;
if
(
substr
(
$zipped
,
0
,
2
)
==
"
\x1f\x8b
"
)
$offset
=
2
;
if
(
substr
(
$zipped
,
$offset
,
1
)
==
"
\x08
"
)
{
try
{
return
gzinflate
(
substr
(
$zipped
,
$offset
+
8
));
}
catch
(
\
Exception
$e
)
{
abort
(
500
,
"Fehler beim unzip des Ergebnisses von folgendem Anbieter: "
.
$this
->
name
);
}
}
return
"Unknown Format"
;
}
private
function
writeRequest
()
{
$out
=
"GET "
.
$this
->
getString
.
" HTTP/1.1
\r\n
"
;
$out
.
=
"Host: "
.
$this
->
host
.
"
\r\n
"
;
$out
.
=
"User-Agent: "
.
$this
->
useragent
.
"
\r\n
"
;
$out
.
=
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
\r\n
"
;
$out
.
=
"Accept-Language: de,en-US;q=0.7,en;q=0.3
\r\n
"
;
$out
.
=
"Accept-Encoding: gzip, deflate, br
\r\n
"
;
$out
.
=
"Connection: keep-alive
\r\n\r\n
"
;
# Anfrage senden:
$sent
=
0
;
$string
=
$out
;
$time
=
microtime
(
true
);
while
(
true
)
{
try
{
$tmp
=
fwrite
(
$this
->
fp
,
$string
);
}
catch
(
\
ErrorException
$e
)
{
# Irgendwas ist mit unserem Socket passiert. Wir brauchen einen neuen:
fclose
(
$this
->
fp
);
Redis
::
del
(
$this
->
name
.
"."
.
$this
->
socketNumber
);
$this
->
fp
=
$this
->
getFreeSocket
();
$sent
=
0
;
$string
=
$out
;
continue
;
}
if
(
$tmp
){
$sent
+=
$tmp
;
$string
=
substr
(
$string
,
$tmp
);
}
if
(
$sent
>=
strlen
(
$out
))
break
;
}
if
(
$sent
===
strlen
(
$out
)
)
{
return
true
;