Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
MetaGer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
56
Issues
56
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
open-source
MetaGer
Commits
bc5fa0ab
Commit
bc5fa0ab
authored
Aug 10, 2018
by
Karl Hasselbring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All variants seem to work again
parent
23cda137
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
30 deletions
+34
-30
app/MetaGer.php
app/MetaGer.php
+31
-30
resources/assets/less/metager/searchbar.less
resources/assets/less/metager/searchbar.less
+3
-0
No files found.
app/MetaGer.php
View file @
bc5fa0ab
...
...
@@ -3,12 +3,12 @@ namespace App;
use
App
;
use
Cache
;
use
Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Redis
;
use
Jenssegers\Agent\Agent
;
use
LaravelLocalization
;
use
Log
;
use
Carbon
;
use
Predis\Connection\ConnectionException
;
class
MetaGer
...
...
@@ -453,10 +453,11 @@ class MetaGer
return
$results
;
}
public
function
humanVerification
(
$results
){
public
function
humanVerification
(
$results
)
{
# Let's check if we need to implement a redirect for human verification
if
(
$this
->
verificationCount
>
10
)
{
foreach
(
$results
as
$result
)
{
if
(
$this
->
verificationCount
>
10
)
{
foreach
(
$results
as
$result
)
{
$link
=
$result
->
link
;
$day
=
Carbon
::
now
()
->
day
;
$pw
=
md5
(
$this
->
verificationId
.
$day
.
$link
.
env
(
"PROXY_PASSWORD"
));
...
...
@@ -464,7 +465,7 @@ class MetaGer
$result
->
link
=
$url
;
}
return
$results
;
}
else
{
}
else
{
return
$results
;
}
}
...
...
@@ -955,7 +956,7 @@ class MetaGer
}
# Sucheingabe
$this
->
eingabe
=
trim
(
$request
->
input
(
'eingabe'
,
''
));
$this
->
q
=
$this
->
eingabe
;
$this
->
q
=
$this
->
eingabe
;
# IP
$this
->
ip
=
$request
->
ip
();
# Unser erster Schritt wird sein, IP-Adresse und USER-Agent zu anonymisieren, damit
...
...
@@ -1083,19 +1084,37 @@ class MetaGer
public
function
checkSpecialSearches
(
Request
$request
)
{
$this
->
searchCheckPhrase
();
$this
->
searchCheckSitesearch
(
$request
);
$this
->
searchCheckHostBlacklist
(
$request
);
$this
->
searchCheckDomainBlacklist
(
$request
);
$this
->
searchCheckUrlBlacklist
();
$this
->
searchCheckPhrase
();
$this
->
searchCheckStopwords
(
$request
);
$this
->
searchCheckNoSearch
();
}
private
function
searchCheckPhrase
()
{
$p
=
""
;
$tmp
=
$this
->
q
;
// matches '[... ]"test satz"[ ...]'
while
(
preg_match
(
"/(^|.*?\s)
\"
(\S+)
\"
(\s.*|$)/si"
,
$tmp
,
$match
))
{
$tmp
=
$match
[
1
]
.
$match
[
3
];
$this
->
phrases
[]
=
$match
[
2
];
}
foreach
(
$this
->
phrases
as
$phrase
)
{
$p
.
=
"
\"
$phrase
\"
, "
;
}
$p
=
rtrim
(
$p
,
", "
);
if
(
sizeof
(
$this
->
phrases
)
>
0
)
{
$this
->
warnings
[]
=
trans
(
'metaGer.formdata.phrase'
,
[
'phrase'
=>
$p
]);
}
}
private
function
searchCheckSitesearch
(
$request
)
{
// 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
->
site
=
$match
[
2
];
$this
->
q
=
$match
[
1
]
.
$match
[
3
];
}
...
...
@@ -1108,7 +1127,7 @@ class MetaGer
private
function
searchCheckHostBlacklist
(
$request
)
{
// 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
->
q
=
$match
[
1
]
.
$match
[
3
];
}
...
...
@@ -1143,7 +1162,7 @@ class MetaGer
private
function
searchCheckDomainBlacklist
(
$request
)
{
// 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
->
q
=
$match
[
1
]
.
$match
[
3
];
}
...
...
@@ -1177,7 +1196,7 @@ class MetaGer
private
function
searchCheckUrlBlacklist
()
{
// matches '[... ]-site:*.test.de[ ...]'
while
(
preg_match
(
"/(^|.
+\s)-url:(\S+)(?:\s(.+)|($)
)/si"
,
$this
->
q
,
$match
))
{
while
(
preg_match
(
"/(^|.
*?\s)-url:(\S+)(\s.*|$
)/si"
,
$this
->
q
,
$match
))
{
$this
->
urlBlacklist
[]
=
$match
[
2
];
$this
->
q
=
$match
[
1
]
.
$match
[
3
];
}
...
...
@@ -1195,7 +1214,7 @@ class MetaGer
private
function
searchCheckStopwords
(
$request
)
{
// matches '[... ]-test[ ...]'
while
(
preg_match
(
"/(^|
[^\s]+\s)-(\S+)(?:\s(.+)|($)
)/si"
,
$this
->
q
,
$match
))
{
while
(
preg_match
(
"/(^|
.*?\s)-(\S+)(\s.*|$
)/si"
,
$this
->
q
,
$match
))
{
$this
->
stopWords
[]
=
$match
[
2
];
$this
->
q
=
$match
[
1
]
.
$match
[
3
];
}
...
...
@@ -1224,24 +1243,6 @@ class MetaGer
}
}
private
function
searchCheckPhrase
()
{
$p
=
""
;
$tmp
=
$this
->
q
;
// matches '[... ]"test satz"[ ...]'
while
(
preg_match
(
"/(^|.+\s)
\"
(.+)
\"
(?:\s(.+)|($))/si"
,
$tmp
,
$match
))
{
$tmp
=
$match
[
1
]
.
$match
[
3
];
$this
->
phrases
[]
=
$match
[
2
];
}
foreach
(
$this
->
phrases
as
$phrase
)
{
$p
.
=
"
\"
$phrase
\"
, "
;
}
$p
=
rtrim
(
$p
,
", "
);
if
(
sizeof
(
$this
->
phrases
)
>
0
)
{
$this
->
warnings
[]
=
trans
(
'metaGer.formdata.phrase'
,
[
'phrase'
=>
$p
]);
}
}
private
function
searchCheckNoSearch
()
{
if
(
$this
->
q
===
""
)
{
...
...
resources/assets/less/metager/searchbar.less
View file @
bc5fa0ab
...
...
@@ -182,6 +182,9 @@
display: none;
}
}
.search-input input {
padding-right: 35px; // Makes it so the overlayed delete button does not hide the text belowF
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment