mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-09-13 14:29:25 -05:00
Add serverlist action to action.php
The `serverlist` action returns a list of registered servers. It accepts cross-domain requests, which is safe since it merely returns publicly available information.
This commit is contained in:
16
action.php
16
action.php
@@ -217,6 +217,22 @@ foreach ($reqs as $reqData) {
|
||||
$out = ($user['rating']['r']+$user['rating']['rpr'])/2;
|
||||
}
|
||||
break;
|
||||
case 'serverlist':
|
||||
if ($multiReqs) die(); // necessary for security purposes
|
||||
if (empty($PokemonServers)) die(); // shouldn't happen
|
||||
header('Access-Control-Allow-Origin: *'); // allow cross-domain requests
|
||||
$out['servers'] = array();
|
||||
foreach ($PokemonServers as &$i) {
|
||||
if (!empty($i['hidden'])) continue;
|
||||
$out['servers'][] = array(
|
||||
'serverid' => @$i['id'],
|
||||
'name' => @$i['name'],
|
||||
'server' => @$i['server'],
|
||||
'port' => @$i['port'],
|
||||
'protocol' => @$i['protocol']
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($multiReqs) $outArray[] = $out;
|
||||
|
||||
Reference in New Issue
Block a user