Skip to content
GitLab
Menu
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
5cba2b67
Commit
5cba2b67
authored
Jan 20, 2021
by
Dominik Hebeler
Browse files
Merge branch '1096-generate-new-proxy-urls' into 'development'
Resolve "Generate new Proxy URLs" Closes
#1096
See merge request
!1808
parents
7cc3df20
cf7f4c42
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Models/Result.php
View file @
5cba2b67
...
...
@@ -360,17 +360,35 @@ class Result
# Erstellt aus einem Link einen Proxy-Link für unseren Proxy-Service
public
function
generateProxyLink
(
$link
)
{
if
(
!
$link
)
{
if
(
!
$link
||
empty
(
$link
)
)
{
return
""
;
}
# Link to our new Proxy software:
$pw
=
md5
(
env
(
'PROXY_PASSWORD'
)
.
$link
);
$parts
=
parse_url
(
$link
);
$proxyUrl
=
base64_encode
(
str_rot13
(
$link
));
$proxyUrl
=
urlencode
(
str_replace
(
"/"
,
"<<SLASH>>"
,
$proxyUrl
));
$proxyUrl
=
"https://proxy.metager.de/"
;
return
"https://proxy.metager.de/"
.
$pw
.
"/"
.
$proxyUrl
;
if
(
!
empty
(
$parts
[
"host"
])){
$proxyUrl
.
=
$parts
[
"host"
];
if
(
!
empty
(
$parts
[
"path"
])){
$proxyUrl
.
=
"/"
.
trim
(
$parts
[
"path"
],
"/"
);
}
}
// We need to generate the correct password for the Proxy URLs
// It's an hmac sha256 hash of the url having the proxy password as secret
$password
=
hash_hmac
(
"sha256"
,
$link
,
env
(
"PROXY_PASSWORD"
,
"unsecure_password"
));
$urlParameters
=
[
"url"
=>
$link
,
"password"
=>
$password
,
];
$params
=
http_build_query
(
$urlParameters
,
""
,
"&"
,
PHP_QUERY_RFC3986
);
$proxyUrl
.
=
"?"
.
$params
;
return
$proxyUrl
;
}
/* Liest aus einer URL alle Informationen aus
...
...
Write
Preview
Supports
Markdown
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