File tree 2 files changed +21
-2
lines changed
replay.pokemonshowdown.com
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -150,8 +150,6 @@ function userid($username) {
150
150
$ replay ['private ' ] = intval ($ _POST ['private ' ]);
151
151
$ Replays ->edit ($ replay );
152
152
echo '<p>Edited.</p> ' ;
153
- } else {
154
- echo '<p>Editing privacy to ' .$ _POST ['private ' ]. 'failed. ' ;
155
153
}
156
154
?>
157
155
Change privacy: <form action="/<?= $ replay ['id ' ] ?> /manage" method="post" style="display: inline" data-target="replace">
Original file line number Diff line number Diff line change @@ -50,6 +50,27 @@ function genPassword() {
50
50
return $ password ;
51
51
}
52
52
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
+
53
74
function get ($ id , $ force = false ) {
54
75
if (!$ this ->db ) {
55
76
// if (!$force) return false;
You can’t perform that action at this time.
0 commit comments