Skip to content

Commit fbce665

Browse files
authored
Add files via upload
1 parent 9d339c8 commit fbce665

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

api/link_generating.php

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
3+
$req_url = $_POST["user_path_1"]??'';
4+
if ($req_url) {
5+
if (strlen($req_url)>500) {
6+
die("Formatted url data's length has exceeded!");
7+
}
8+
} else {
9+
die("Please input your formatted url data.");
10+
}
11+
$pattern4 = '/(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*)/';
12+
$pattern3 = '/(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*)/';
13+
$pattern2 = '/(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*?)\((([\w]{1,4})\-([\w]{1,4}))\)(.*)/';
14+
$pattern1 = '/(.*?)\((([\w]{1,6})\-([\w]{1,6}))\)(.*)/';
15+
if (preg_match($pattern4,$req_url,$match_arr)){//4阶循环
16+
$letters1 = match_16_0($match_arr,2);
17+
$letters2 = match_16_0($match_arr,6);
18+
$letters3 = match_16_0($match_arr,10);
19+
$letters4 = match_16_0($match_arr,14);
20+
foreach ($letters1 as $letter1) {
21+
foreach ($letters2 as $letter2) {
22+
foreach ($letters3 as $letter3) {
23+
foreach ($letters4 as $letter4) {
24+
echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].$letter4.$match_arr[17].PHP_EOL;
25+
}
26+
}
27+
}
28+
}
29+
} else if (preg_match($pattern3,$req_url,$match_arr)){//3阶循环
30+
$letters1 = match_16_0($match_arr,2);
31+
$letters2 = match_16_0($match_arr,6);
32+
$letters3 = match_16_0($match_arr,10);
33+
foreach ($letters1 as $letter1) {
34+
foreach ($letters2 as $letter2) {
35+
foreach ($letters3 as $letter3) {
36+
echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].PHP_EOL;
37+
}
38+
}
39+
}
40+
} else if (preg_match($pattern2,$req_url,$match_arr)){//2阶循环
41+
$letters1 = match_16_0($match_arr,2);
42+
$letters2 = match_16_0($match_arr,6);
43+
foreach ($letters1 as $letter1) {
44+
foreach ($letters2 as $letter2) {
45+
echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].PHP_EOL;
46+
}
47+
}
48+
} else if (preg_match($pattern1,$req_url,$match_arr)){//1阶循环
49+
$letters1 = match_16_0($match_arr,2);
50+
foreach ($letters1 as $letter1) {
51+
echo $match_arr[1].$letter1.$match_arr[5].PHP_EOL;
52+
}
53+
}
54+
}
55+
exit;
56+
57+
function match_16_0($match_arr,$subscript){
58+
$pattern16 = '/(([\d])\-([^\d]))/';
59+
$hexArray = array_map('dechex', range(0, 15));
60+
$letters = preg_match($pattern16,$match_arr[$subscript])?$hexArray:range($match_arr[$subscript+1],$match_arr[$subscript+2]);
61+
$pattern0 = '/((0[\d]+)\-(\d[\d]+))/';
62+
if (preg_match($pattern0,$match_arr[2])){
63+
$numDigits = strlen($match_arr[$subscript+2]);
64+
$resultArray = [];
65+
foreach ($letters as $letter) {
66+
$letter0 = sprintf("%0{$numDigits}d", $letter);
67+
$resultArray[] = $letter0;
68+
}
69+
return $resultArray;
70+
} else {
71+
return $letters;
72+
}
73+
}
74+
?>

0 commit comments

Comments
 (0)