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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jens Korte
MetaGer
Commits
71e9a166
Commit
71e9a166
authored
Jun 04, 2019
by
Dominik Hebeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix
parent
ea0eb011
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
36 deletions
+17
-36
app/Http/Controllers/HumanVerification.php
app/Http/Controllers/HumanVerification.php
+16
-5
app/Http/Middleware/HumanVerification.php
app/Http/Middleware/HumanVerification.php
+1
-31
No files found.
app/Http/Controllers/HumanVerification.php
View file @
71e9a166
...
...
@@ -110,7 +110,7 @@ class HumanVerification extends Controller
$redis
=
Redis
::
connection
(
'redisCache'
);
$ip
=
$request
->
ip
();
$id
=
""
;
if
(
HumanVerification
::
isTo
r
(
$ip
))
{
if
(
HumanVerification
::
couldBeSpamme
r
(
$ip
))
{
$id
=
hash
(
"sha512"
,
"999.999.999.999"
);
}
else
{
$id
=
hash
(
"sha512"
,
$ip
);
...
...
@@ -176,7 +176,7 @@ class HumanVerification extends Controller
{
$uid
=
""
;
$ip
=
$request
->
ip
();
if
(
HumanVerification
::
isTo
r
(
$ip
))
{
if
(
HumanVerification
::
couldBeSpamme
r
(
$ip
))
{
$uid
=
hash
(
"sha512"
,
"999.999.999.999"
.
$ip
.
$_SERVER
[
"AGENT"
]
.
"uid"
);
}
else
{
$uid
=
hash
(
"sha512"
,
$ip
.
$_SERVER
[
"AGENT"
]
.
"uid"
);
...
...
@@ -189,7 +189,7 @@ class HumanVerification extends Controller
}
}
p
rivate
static
function
isTo
r
(
$ip
)
p
ublic
static
function
couldBeSpamme
r
(
$ip
)
{
$serverAddress
=
empty
(
$_SERVER
[
'SERVER_ADDR'
])
?
"144.76.88.77"
:
$_SERVER
[
'SERVER_ADDR'
];
$queryUrl
=
"https://tor.metager.org?password="
.
urlencode
(
env
(
"TOR_PASSWORD"
))
.
"&ra="
.
urlencode
(
$ip
)
.
"&sa="
.
urlencode
(
$serverAddress
)
.
"&sp=443"
;
...
...
@@ -201,10 +201,21 @@ class HumanVerification extends Controller
$httpcode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
curl_close
(
$ch
);
$possibleSpammer
=
false
;
if
(
$httpcode
===
200
)
{
return
true
;
}
else
{
return
false
;
}
# Check for recent Spams
$eingabe
=
\
Request
::
input
(
'eingabe'
);
if
(
\
preg_match
(
"/^[
\\
d]
{
3
}
\s*chan.*$/si"
,
$eingabe
))
{
return
true
;
}
if
(
\
preg_match
(
"/^susimail\s+-site:[^\s]+\s-site:/si"
,
$eingabe
))
{
return
true
;
}
return
$possibleSpammer
;
}
}
app/Http/Middleware/HumanVerification.php
View file @
71e9a166
...
...
@@ -29,7 +29,7 @@ class HumanVerification
$ip
=
$request
->
ip
();
$id
=
""
;
$uid
=
""
;
if
(
$this
->
couldBeSpammer
(
$ip
))
{
if
(
\
App\Http\Controllers\HumanVerification
::
couldBeSpammer
(
$ip
))
{
$id
=
hash
(
"sha512"
,
"999.999.999.999"
);
$uid
=
hash
(
"sha512"
,
"999.999.999.999"
.
$ip
.
$_SERVER
[
"AGENT"
]
.
"uid"
);
}
else
{
...
...
@@ -188,34 +188,4 @@ class HumanVerification
return
$next
(
$request
);
}
private
function
couldBeSpammer
(
$ip
)
{
$serverAddress
=
empty
(
$_SERVER
[
'SERVER_ADDR'
])
?
"144.76.88.77"
:
$_SERVER
[
'SERVER_ADDR'
];
$queryUrl
=
"https://tor.metager.org?password="
.
urlencode
(
env
(
"TOR_PASSWORD"
))
.
"&ra="
.
urlencode
(
$ip
)
.
"&sa="
.
urlencode
(
$serverAddress
)
.
"&sp=443"
;
$ch
=
curl_init
(
$queryUrl
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
1
);
curl_exec
(
$ch
);
$httpcode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
curl_close
(
$ch
);
$possibleSpammer
=
false
;
if
(
$httpcode
===
200
)
{
return
true
;
}
# Check for recent Spams
$eingabe
=
\
Request
::
input
(
'eingabe'
);
if
(
\
preg_match
(
"/^[
\\
d]
{
3
}
\s*chan.*$/si"
,
$eingabe
))
{
return
true
;
}
if
(
\
preg_match
(
"/^susimail\s+-site:[^\s]+\s-site:/si"
,
$eingabe
))
{
return
true
;
}
return
$possibleSpammer
;
}
}
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