Skip to content

Commit da039e6

Browse files
Merge remote-tracking branch 'origin/master' into RPTL
2 parents 6aaee05 + 1389866 commit da039e6

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

pokemonshowdown.com/credits.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<li><p><strong>Andrew Werner</strong> [HoeenHero] <small>&ndash; Development</small></p></li>
5959
<li><p><strong>Annika L.</strong> [Annika] <small>&ndash; Development</small></p></li>
6060
<li><p><a href="http://monsan.to/" target="_blank" class="subtle"><strong>Chris Monsanto</strong> [chaos]</a> <small>&ndash; Development, Sysadmin</small></p></li>
61-
<li><p><strong>Kris Johnson</strong> [dhelmise] <small>&ndash; Development</small></p></li>
61+
<li><p><strong>Kris Johnson</strong> [dhelmise] <small>&ndash; Development, Art (battle animations)</small></p></li>
6262
<li><p><strong>Leonard Craft III</strong> [DaWoblefet] <small>&ndash; Research (game mechanics)</small></p></li>
6363
<li><p><strong>Mathieu Dias-Martins</strong> [Marty] <small>&ndash; Research (game mechanics), Development</small></p></li>
6464
<li><p><strong>Mia A.</strong> [Hecate] <small>&ndash; Development</small></p></li>
@@ -106,7 +106,7 @@
106106
<li><p>[<strong>Honko</strong>] <small>&ndash; Development (damage calculator)</small></p></li>
107107
<li><p><strong>Ian Clail</strong> [Layell] <small>&ndash; Art (battle graphics, sprites)</small></p></li>
108108
<li><p><strong>Jacob McLemore</strong> <small>&ndash; Development</small></p></li>
109-
<li><p><strong>Erik Bruce</strong> [Kalalokki] <small>&ndash; Art (minisprite resizing)</small></p></li>
109+
<li><p><a href="https://www.behance.net/erik-bruce" target="_blank" class="subtle"><strong>Erik Bruce</strong> [Kalalokki]</a> <small>&ndash; Art (minisprite resizing), Research (game mechanics)</small></p></li>
110110
<li><p><a href="https://panpawn.github.io/" target="_blank" class="subtle"><strong>Jeremy Piemonte</strong> [panpawn]</a> <small>&ndash; Development</small></p></li>
111111
<li><p><strong>Karthik Bandagonda</strong> <small>&ndash; Development</small></p></li>
112112
<li><p><a href="http://leparagon.deviantart.com/" target="_blank" class="subtle">[<strong>leparagon</strong>]</a> <small>&ndash; Art (sprites, minisprite resizing)</small></p></li>

replay.pokemonshowdown.com/replay-manage.php

+17-13
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
$manage = false;
1818
$csrfOk = false;
1919

20-
if (isset($_REQUEST['manage'])) {
21-
require_once '../lib/ntbb-session.lib.php';
22-
if (!$users->isLeader()) die("access denied");
23-
$csrfOk = !!$users->csrfCheck();
24-
$manage = true;
25-
header('Cache-Control: max-age=0, no-cache, no-store, must-revalidate');
26-
}
20+
// this no longer needs to be in an if block, since the only reason to access
21+
// this at /manage is for managing. just assume they're always doing that
22+
require_once '../lib/ntbb-session.lib.php';
23+
if (!$users->isLeader()) die("access denied");
24+
$csrfOk = !!$users->csrfCheck();
25+
$manage = true;
26+
header('Cache-Control: max-age=0, no-cache, no-store, must-revalidate');
2727

2828
if (preg_match('/[^A-Za-z0-9-]/', $id)) die("access denied");
2929

@@ -66,16 +66,16 @@
6666
if (!$password && !$manage) {
6767
header('Cache-Control: max-age=0, no-cache, no-store, must-revalidate');
6868
require_once '../lib/ntbb-session.lib.php';
69-
if ($curuser['userid'] !== $replay['p1id'] && $curuser['userid'] !== $replay['p2id']) {
70-
die("Access denied (you must be logged into " . $replay['p1id'] . " or " . $replay['p2id'] . ")");
69+
if ($curuser['userid'] !== $p1id && $curuser['userid'] !== $p2id) {
70+
die("Access denied (you must be logged into " . $p1id . " or " . $p2id . ")");
7171
}
7272
$url = '/' . $id . '-' . $replay['password'] . 'pw';
7373
echo '<p>This private replay now has a new harder-to-guess URL:</p>';
7474
echo '<p><a href="' . $url . '" data-target="replace">https://' . $psconfig['routes']['replays'] . $url . '</a></p>';
7575
die();
7676
}
7777
if ($password !== $replay['password'] && !$manage) {
78-
die("Access denied (please ask " . $replay['p1id'] . " or " . $replay['p2id'] . " for the password)");
78+
die("Access denied (please ask " . $p1id . " or " . $p2id . " for the password)");
7979
}
8080
}
8181

@@ -95,9 +95,13 @@ function userid($username) {
9595
$matchSuccess = preg_match('/\\n\\|tier\\|([^|]*)\\n/', $replay['log'], $matches);
9696
$format = $replay['format'];
9797
if ($matchSuccess) $format = $matches[1];
98+
$p1 = $replay['players'][0];
99+
$p2 = $replay['players'][1];
100+
$p1id = $users->userid($p1);
101+
$p2id = $users->userid($p2);
98102

99-
$panels->setPageTitle($format.' replay: '.$replay['p1'].' vs. '.$replay['p2']);
100-
$panels->setPageDescription('Watch a replay of a Pokémon battle between ' . $replay['p1'] . ' and ' . $replay['p2'] . ' (' . $format . ')');
103+
$panels->setPageTitle($format.' replay: '.$p1.' vs. '.$p2);
104+
$panels->setPageDescription('Watch a replay of a Pokémon battle between ' . $p1 . ' and ' . $p2 . ' (' . $format . ')');
101105
$panels->setTab('replay');
102106
$panels->start();
103107

@@ -134,7 +138,7 @@ function userid($username) {
134138

135139
<pre class="urlbox" style="word-wrap: break-word;"><?php echo htmlspecialchars('https://'.$psconfig['routes']['replays'].'/'.$fullid); ?></pre>
136140

137-
<h1 style="font-weight:normal;text-align:left"><strong><?= htmlspecialchars($format) ?></strong>: <a href="//<?= $psconfig['routes']['users'] ?>/<?= userid($replay['p1']) ?>" class="subtle"><?= htmlspecialchars($replay['p1']) ?></a> vs. <a href="//<?= $psconfig['routes']['users'] ?>/<?= userid($replay['p2']) ?>" class="subtle"><?= htmlspecialchars($replay['p2']) ?></a></h1>
141+
<h1 style="font-weight:normal;text-align:left"><strong><?= htmlspecialchars($format) ?></strong>: <a href="//<?= $psconfig['routes']['users'] ?>/<?= userid($p1) ?>" class="subtle"><?= htmlspecialchars($p1) ?></a> vs. <a href="//<?= $psconfig['routes']['users'] ?>/<?= userid($p2) ?>" class="subtle"><?= htmlspecialchars($p2) ?></a></h1>
138142
<p style="padding:0 1em;margin-top:0">
139143
<small class="uploaddate" data-timestamp="<?= @$replay['uploadtime'] ?? @$replay['date'] ?>"><em>Uploaded:</em> <?php echo date("M j, Y", @$replay['uploadtime'] ?? @$replay['date']); ?><?= @$replay['rating'] ? ' | <em>Rating:</em> ' . $replay['rating'] : '' ?></small>
140144
</p>

replay.pokemonshowdown.com/replays.lib.php

+21
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,27 @@ function genPassword() {
5050
return $password;
5151
}
5252

53+
function edit($replay) {
54+
if ($replay['private'] === 3) {
55+
$replay['private'] = 3;
56+
$res = $this->db->prepare("UPDATE replays SET private = 3, password = NULL WHERE id = ? LIMIT 1");
57+
$res->execute([$replay['id']]);
58+
} else if ($replay['private'] === 2) {
59+
$replay['private'] = 1;
60+
$replay['password'] = NULL;
61+
$res = $this->db->prepare("UPDATE replays SET private = 1, password = NULL WHERE id = ? LIMIT 1");
62+
$res->execute([$replay['id']]);
63+
} else if ($replay['private']) {
64+
if (!$replay['password']) $replay['password'] = $this->genPassword();
65+
$res = $this->db->prepare("UPDATE replays SET private = 1, password = ? WHERE id = ? LIMIT 1");
66+
$res->execute([$replay['password'], $replay['id']]);
67+
} else {
68+
$res = $this->db->prepare("UPDATE replays SET private = 0, password = NULL WHERE id = ? LIMIT 1");
69+
$res->execute([$replay['id']]);
70+
}
71+
return;
72+
}
73+
5374
function get($id, $force = false) {
5475
if (!$this->db) {
5576
// if (!$force) return false;

0 commit comments

Comments
 (0)