mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-03-21 17:50:29 -05:00
The idea is to eventually move all client parts to their domain name subdirectory, for clarity and better organization. New Replays is just first. Anyway, yeah, minor updates to New Replays, but otherwise it's just getting deployed as-is, straight to https://replay.pokemonshowdown.com/ The old URLs are getting taken down; they were only used for development anyway.
52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
$username = @$_REQUEST['user'];
|
|
$username2 = @$_REQUEST['user2'];
|
|
$format = @$_REQUEST['format'];
|
|
$contains = (@$_REQUEST['contains']);
|
|
$byRating = isset($_REQUEST['rating']);
|
|
$isPrivate = isset($_REQUEST['private']);
|
|
|
|
header('Content-Type: application/json');
|
|
if (!$isPrivate) header('Access-Control-Allow-Origin: *');
|
|
|
|
require_once 'replays.lib.php';
|
|
include_once '../lib/ntbb-session.lib.php';
|
|
|
|
$username = $users->userid($username);
|
|
$isPrivateAllowed = ($username === $curuser['userid'] || $curuser['userid'] === 'zarel');
|
|
if ($isPrivate && !$isPrivateAllowed) {
|
|
die('"ERROR: access denied"');
|
|
}
|
|
|
|
$page = intval($_REQUEST['page'] ?? 0);
|
|
|
|
$replays = null;
|
|
if ($page > 25) {
|
|
die('"ERROR: page limit is 25"');
|
|
} else if ($username || $format) {
|
|
$replays = $Replays->search([
|
|
"username" => $username,
|
|
"username2" => $username2,
|
|
"format" => $format,
|
|
"byRating" => $byRating,
|
|
"isPrivate" => $isPrivate,
|
|
"page" => $page
|
|
]);
|
|
} else if ($contains) {
|
|
$replays = $Replays->fullSearch($contains, $page);
|
|
} else {
|
|
$replays = $Replays->recent();
|
|
}
|
|
|
|
if ($replays) {
|
|
foreach ($replays as &$replay) {
|
|
if ($replay['password'] ?? null) {
|
|
$replay['id'] .= '-' . $replay['password'];
|
|
}
|
|
unset($replay['password']);
|
|
}
|
|
}
|
|
|
|
echo json_encode($replays);
|