Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
open-source
MetaGer
Commits
d44392ae
Commit
d44392ae
authored
Jun 04, 2019
by
Dominik Hebeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed new bot protection
parent
b9d081c6
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
app/Http/Controllers/HumanVerification.php
app/Http/Controllers/HumanVerification.php
+22
-2
No files found.
app/Http/Controllers/HumanVerification.php
View file @
d44392ae
...
...
@@ -108,7 +108,7 @@ class HumanVerification extends Controller
private
static
function
removeUser
(
$request
,
$uid
)
{
$redis
=
Redis
::
connection
(
'redisCache'
);
$id
=
hash
(
"sha512"
,
$request
->
ip
(
));
$id
=
hash
(
"sha512"
,
HumanVerification
::
getIP
(
$request
));
$userList
=
$redis
->
smembers
(
HumanVerification
::
PREFIX
.
"."
.
$id
);
$pipe
=
$redis
->
pipeline
();
...
...
@@ -168,10 +168,30 @@ class HumanVerification extends Controller
private
static
function
checkId
(
$request
,
$id
)
{
if
(
hash
(
"sha512"
,
$request
->
ip
(
)
.
$_SERVER
[
"AGENT"
]
.
"uid"
)
===
$id
)
{
if
(
hash
(
"sha512"
,
HumanVerification
::
getIP
(
$request
)
.
$_SERVER
[
"AGENT"
]
.
"uid"
)
===
$id
)
{
return
true
;
}
else
{
return
false
;
}
}
private
static
function
getIP
(
$request
)
{
$ip
=
$request
->
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
);
if
(
$httpcode
===
200
)
{
return
"999.999.999.999"
;
}
else
{
return
$ip
;
}
}
}
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