|
1 | 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!"); |
| 2 | +if ($_SERVER["REQUEST_METHOD"] !== "POST") die(header('HTTP/1.1 403')); |
| 3 | +$req_url = $_POST["user_path_1"]??''; |
| 4 | +if ($req_url) { |
| 5 | + if (strlen($req_url)>500) die("Formatted url data's length has exceeded!"); |
| 6 | +} else { |
| 7 | + die("Please input your formatted url data."); |
| 8 | +} |
| 9 | +preg_match_all('/\([\w]{1,6}\-[\w]{1,6}\)/',$req_url,$variables); |
| 10 | +$variables_count = count($variables[0]); |
| 11 | +switch ($variables_count) { |
| 12 | + case '1': |
| 13 | + $pattern1 = '/(.*?)\((([\w]+)\-([\w]+))\)(.*)/'; |
| 14 | + preg_match($pattern1,$req_url,$match_arr);//1阶循环 |
| 15 | + //$url = $match_arr[1].$match_arr[3-4].$match_arr[5]; |
| 16 | + //print_r($match_arr); |
| 17 | + $letters1 = match_16_0($match_arr,2); |
| 18 | + if(strpos($req_url,'(1)')!==false){ |
| 19 | + foreach ($letters1 as $letter1) { |
| 20 | + echo str_replace('(1)',$letter1,$match_arr[1].$letter1.$match_arr[5]).PHP_EOL; |
| 21 | + } |
| 22 | + } else { |
| 23 | + foreach ($letters1 as $letter1) { |
| 24 | + echo $match_arr[1].$letter1.$match_arr[5].PHP_EOL; |
| 25 | + } |
7 | 26 | }
|
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 |
| - //$url = $match_arr[1].$match_arr[3-4].$match_arr[5].$match_arr[7-8].$match_arr[9].$match_arr[11-12].$match_arr[13].$match_arr[15-16].$match_arr[17]; |
| 27 | + break; |
| 28 | + case '2': |
| 29 | + $pattern2 = '/(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*)/'; |
| 30 | + preg_match($pattern2,$req_url,$match_arr);//2阶循环 |
| 31 | + //$url = $match_arr[1].$match_arr[3-4].$match_arr[5].$match_arr[7-8].$match_arr[9]; |
17 | 32 | //print_r($match_arr);
|
18 | 33 | $letters1 = match_16_0($match_arr,2);
|
19 | 34 | $letters2 = match_16_0($match_arr,6);
|
20 |
| - $letters3 = match_16_0($match_arr,10); |
21 |
| - $letters4 = match_16_0($match_arr,14); |
22 |
| - foreach ($letters1 as $letter1) { |
23 |
| - foreach ($letters2 as $letter2) { |
24 |
| - foreach ($letters3 as $letter3) { |
25 |
| - foreach ($letters4 as $letter4) { |
26 |
| - echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].$letter4.$match_arr[17].PHP_EOL; |
27 |
| - } |
| 35 | + if(strpos($req_url,'(1)')!==false && strpos($req_url,'(2)')!==false){ |
| 36 | + foreach ($letters1 as $letter1) { |
| 37 | + foreach ($letters2 as $letter2) { |
| 38 | + $result = str_replace('(1)',$letter1,$match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9]); |
| 39 | + echo str_replace('(2)',$letter2,$result).PHP_EOL; |
| 40 | + } |
| 41 | + } |
| 42 | + } else if(strpos($req_url,'(1)')!==false){ |
| 43 | + foreach ($letters1 as $letter1) { |
| 44 | + foreach ($letters2 as $letter2) { |
| 45 | + echo str_replace('(1)',$letter1,$match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9]).PHP_EOL; |
| 46 | + } |
| 47 | + } |
| 48 | + } else if(strpos($req_url,'(2)')!==false){ |
| 49 | + foreach ($letters1 as $letter1) { |
| 50 | + foreach ($letters2 as $letter2) { |
| 51 | + echo str_replace('(2)',$letter2,$match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9]).PHP_EOL; |
| 52 | + } |
| 53 | + } |
| 54 | + } else { |
| 55 | + foreach ($letters1 as $letter1) { |
| 56 | + foreach ($letters2 as $letter2) { |
| 57 | + echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].PHP_EOL; |
28 | 58 | }
|
29 | 59 | }
|
30 | 60 | }
|
31 |
| - } else if (preg_match($pattern3,$req_url,$match_arr)){//3阶循环 |
| 61 | + break; |
| 62 | + case '3': |
| 63 | + $pattern3 = '/(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*)/'; |
| 64 | + preg_match($pattern3,$req_url,$match_arr);//3阶循环 |
32 | 65 | //$url = $match_arr[1].$match_arr[3-4].$match_arr[5].$match_arr[7-8].$match_arr[9].$match_arr[11-12].$match_arr[13];
|
33 | 66 | //print_r($match_arr);
|
34 | 67 | $letters1 = match_16_0($match_arr,2);
|
35 | 68 | $letters2 = match_16_0($match_arr,6);
|
36 | 69 | $letters3 = match_16_0($match_arr,10);
|
37 |
| - foreach ($letters1 as $letter1) { |
38 |
| - foreach ($letters2 as $letter2) { |
39 |
| - foreach ($letters3 as $letter3) { |
40 |
| - echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].PHP_EOL; |
| 70 | + preg_match('/\([1-3]\)/',$req_url,$reuse); |
| 71 | + $reused = count($reuse); |
| 72 | + if ($reused) { |
| 73 | + foreach ($letters1 as $letter1) { |
| 74 | + foreach ($letters2 as $letter2) { |
| 75 | + foreach ($letters3 as $letter3) { |
| 76 | + $result = str_replace('(1)',$letter1,$match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13]); |
| 77 | + $result = str_replace('(2)',$letter2,$result); |
| 78 | + echo str_replace('(3)',$letter3,$result).PHP_EOL; |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + } else { |
| 83 | + foreach ($letters1 as $letter1) { |
| 84 | + foreach ($letters2 as $letter2) { |
| 85 | + foreach ($letters3 as $letter3) { |
| 86 | + echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].PHP_EOL; |
| 87 | + } |
41 | 88 | }
|
42 | 89 | }
|
43 | 90 | }
|
44 |
| - } else if (preg_match($pattern2,$req_url,$match_arr)){//2阶循环 |
45 |
| - //$url = $match_arr[1].$match_arr[3-4].$match_arr[5].$match_arr[7-8].$match_arr[9]; |
| 91 | + break; |
| 92 | + case '4': |
| 93 | + $pattern4 = '/(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*)/'; |
| 94 | + preg_match($pattern4,$req_url,$match_arr);//4阶循环 |
| 95 | + //$url = $match_arr[1].$match_arr[3-4].$match_arr[5].$match_arr[7-8].$match_arr[9].$match_arr[11-12].$match_arr[13].$match_arr[15-16].$match_arr[17]; |
46 | 96 | //print_r($match_arr);
|
47 | 97 | $letters1 = match_16_0($match_arr,2);
|
48 | 98 | $letters2 = match_16_0($match_arr,6);
|
49 |
| - foreach ($letters1 as $letter1) { |
50 |
| - foreach ($letters2 as $letter2) { |
51 |
| - echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].PHP_EOL; |
| 99 | + $letters3 = match_16_0($match_arr,10); |
| 100 | + $letters4 = match_16_0($match_arr,14); |
| 101 | + preg_match('/\([1-4]\)/',$req_url,$reuse); |
| 102 | + $reused = count($reuse); |
| 103 | + if ($reused) { |
| 104 | + foreach ($letters1 as $letter1) { |
| 105 | + foreach ($letters2 as $letter2) { |
| 106 | + foreach ($letters3 as $letter3) { |
| 107 | + foreach ($letters4 as $letter4) { |
| 108 | + $result = str_replace('(1)',$letter1,$match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].$letter4.$match_arr[17]); |
| 109 | + $result = str_replace('(2)',$letter2,$result); |
| 110 | + $result = str_replace('(3)',$letter3,$result); |
| 111 | + echo str_replace('(4)',$letter4,$result).PHP_EOL; |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + } else { |
| 117 | + foreach ($letters1 as $letter1) { |
| 118 | + foreach ($letters2 as $letter2) { |
| 119 | + foreach ($letters3 as $letter3) { |
| 120 | + foreach ($letters4 as $letter4) { |
| 121 | + echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].$letter4.$match_arr[17].PHP_EOL; |
| 122 | + } |
| 123 | + } |
| 124 | + } |
52 | 125 | }
|
53 | 126 | }
|
54 |
| - } else if (preg_match($pattern1,$req_url,$match_arr)){//1阶循环 |
55 |
| - //$url = $match_arr[1].$match_arr[3-4].$match_arr[5]; |
56 |
| - //print_r($match_arr); |
| 127 | + break; |
| 128 | + case '5': |
| 129 | + $pattern5 = '/(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*?)\((([\w]+)\-([\w]+))\)(.*)/'; |
| 130 | + preg_match($pattern5,$req_url,$match_arr);//5阶循环 |
57 | 131 | $letters1 = match_16_0($match_arr,2);
|
58 |
| - foreach ($letters1 as $letter1) { |
59 |
| - echo $match_arr[1].$letter1.$match_arr[5].PHP_EOL; |
| 132 | + $letters2 = match_16_0($match_arr,6); |
| 133 | + $letters3 = match_16_0($match_arr,10); |
| 134 | + $letters4 = match_16_0($match_arr,14); |
| 135 | + $letters5 = match_16_0($match_arr,18); |
| 136 | + preg_match('/\([1-5]\)/',$req_url,$reuse); |
| 137 | + $reused = count($reuse); |
| 138 | + if ($reused) { |
| 139 | + foreach ($letters1 as $letter1) { |
| 140 | + foreach ($letters2 as $letter2) { |
| 141 | + foreach ($letters3 as $letter3) { |
| 142 | + foreach ($letters4 as $letter4) { |
| 143 | + foreach ($letters5 as $letter5) { |
| 144 | + $result = str_replace('(1)',$letter1,$match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].$letter4.$match_arr[17].$letter5.$match_arr[21]); |
| 145 | + $result = str_replace('(2)',$letter2,$result); |
| 146 | + $result = str_replace('(3)',$letter3,$result); |
| 147 | + $result = str_replace('(4)',$letter4,$result); |
| 148 | + echo str_replace('(5)',$letter5,$result).PHP_EOL; |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | + } else { |
| 155 | + foreach ($letters1 as $letter1) { |
| 156 | + foreach ($letters2 as $letter2) { |
| 157 | + foreach ($letters3 as $letter3) { |
| 158 | + foreach ($letters4 as $letter4) { |
| 159 | + foreach ($letters5 as $letter5) { |
| 160 | + echo $match_arr[1].$letter1.$match_arr[5].$letter2.$match_arr[9].$letter3.$match_arr[13].$letter4.$match_arr[17].$letter5.$match_arr[21].PHP_EOL; |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | + } |
| 165 | + } |
60 | 166 | }
|
61 |
| - } |
| 167 | + break; |
| 168 | + default: |
| 169 | + die("Unsupported format."); |
| 170 | + break; |
62 | 171 | }
|
63 | 172 | exit;
|
64 | 173 |
|
|
0 commit comments