|
| 1 | +#!/usr/bin/env php |
| 2 | +<?php /* vim: set colorcolumn=: */ |
| 3 | +/** |
| 4 | + * @project bnetdocs-web <https://github.com/BNETDocs/bnetdocs-web/> |
| 5 | + * |
| 6 | + * Dec 5 2020 - Generate strings that might resolve, for Blizzard Classic Battle.net servers and other interesting servers. |
| 7 | + */ |
| 8 | +declare(strict_types=1); |
| 9 | + |
| 10 | +$regions = [ 'account', 'apac', 'api', 'bot', 'cn', 'emea', 'eu', 'eur', 'forever', 'kor', 'kr', 'na', 'par', 'use', 'usw' ]; |
| 11 | +$envs = [ 'live', 'ptr' ]; |
| 12 | +$domains = [ 'classic.blizzard.com', 'blizzard.com' ]; |
| 13 | + |
| 14 | +$patterns = [ |
| 15 | + 'connect.{domain}', |
| 16 | + 'connect-{env}.{domain}', |
| 17 | + 'connect-{region}.{domain}', |
| 18 | + 'connect-{env}-{region}-[ab].{domain}', |
| 19 | +]; |
| 20 | + |
| 21 | +$names = []; |
| 22 | + |
| 23 | +foreach ($patterns as $pattern) |
| 24 | +{ |
| 25 | + foreach ($domains as $domain) |
| 26 | + { |
| 27 | + foreach ($regions as $region) |
| 28 | + { |
| 29 | + foreach ($envs as $env) |
| 30 | + { |
| 31 | + $name = $pattern; |
| 32 | + |
| 33 | + $name = str_replace('{domain}', $domain, $name); |
| 34 | + $name = str_replace('{region}', $region, $name); |
| 35 | + $name = str_replace('{env}', $env, $name); |
| 36 | + |
| 37 | + if (stripos($name, '[ab]') !== false) |
| 38 | + { |
| 39 | + $names[str_ireplace('[ab]', 'a', $name)] = true; |
| 40 | + $names[str_ireplace('[ab]', 'b', $name)] = true; |
| 41 | + $name = str_ireplace('-[ab]', '', $name); |
| 42 | + } |
| 43 | + |
| 44 | + $names[$name] = true; |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +$names = array_keys($names); |
| 51 | +sort($names); |
| 52 | + |
| 53 | +echo json_encode($names, JSON_PRETTY_PRINT) . PHP_EOL; |
| 54 | + |
0 commit comments