mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
feat: Replace with a random string when the subscription domain contains *&Replace with the user uuid when the subscription domain contains {uuid}
This commit is contained in:
parent
43bac89d3a
commit
a550fd1436
@ -110,11 +110,20 @@ class Helper
|
|||||||
|
|
||||||
public static function getSubscribeUrl(string $token, $subscribeUrl = null)
|
public static function getSubscribeUrl(string $token, $subscribeUrl = null)
|
||||||
{
|
{
|
||||||
|
$strs = 'QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm';
|
||||||
|
$randstr = substr(str_shuffle($strs), 0, rand(4,8));
|
||||||
|
|
||||||
$path = route('client.subscribe', ['token' => $token], false);
|
$path = route('client.subscribe', ['token' => $token], false);
|
||||||
if(!$subscribeUrl){
|
if(!$subscribeUrl){
|
||||||
$subscribeUrls = explode(',', admin_setting('subscribe_url'));
|
$subscribeUrls = explode(',', admin_setting('subscribe_url'));
|
||||||
$subscribeUrl = \Arr::random($subscribeUrls);
|
$subscribeUrl = \Arr::random($subscribeUrls);
|
||||||
$subscribeUrl = self::replaceByPattern($subscribeUrl);
|
$subscribeUrl = self::replaceByPattern($subscribeUrl);
|
||||||
|
if (strpos($subscribeUrl, "*") !== false) {
|
||||||
|
$subscribeUrl = str_replace("*", $randstr, $subscribeUrl);
|
||||||
|
} elseif (strpos($subscribeUrl, '{uuid}') !== false) {
|
||||||
|
$user = User::where('token', $token)->first();
|
||||||
|
$subscribeUrl = str_replace('{uuid}', $user->uuid, $subscribeUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $subscribeUrl ? rtrim($subscribeUrl, '/') . $path : url($path);
|
return $subscribeUrl ? rtrim($subscribeUrl, '/') . $path : url($path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user