X-Git-Url: http://git.shiar.nl/sc2-widget/blobdiff_plain/aa690a9c0c95e3121b747d77aa836fcd92654fb2..4d46f04b5ec1a9a7fbf8a5701fe7332f56080232:/widget.php diff --git a/widget.php b/widget.php index ddf9cb8..d1b3b88 100644 --- a/widget.php +++ b/widget.php @@ -18,7 +18,7 @@ function error($message, $status = 500) } $request = trim($_SERVER['PATH_INFO'], '/'); -$target = "$request.json"; +$target = "data/$request.json"; $last = file_exists($target) ? filemtime($target) : 0; if ($last < time() - 3600) { @@ -26,7 +26,14 @@ if ($last < time() - 3600) { if (is_numeric($request)) { $recipe = $request; } - elseif (!$last) { + elseif ($last) { + if ($data = json_decode(file_get_contents($target), true)) { + $profiles = array_column($data['members'], 'profileId'); + #TODO: reduce profiles by checking ladder presence + $recipe = join(' ', array_merge([$request], $profiles)); + } + } + else { error("Unknown profile request $request", 400); }