X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=www%2Fmanual-override.pl;fp=www%2Fmanual-override.pl;h=23f571f4c84105ef4dbd6a215ac296f2c60cf89c;hp=13333524a91b7a78eea44e067e17a015bd5d0a7e;hb=5a1f6c832883367ca4925443c63ed2aefb6514fd;hpb=6bc75bbe9c7b761ebce2844cf204c14c12bf5bf9 diff --git a/www/manual-override.pl b/www/manual-override.pl index 1333352..23f571f 100755 --- a/www/manual-override.pl +++ b/www/manual-override.pl @@ -20,14 +20,23 @@ if (!defined($password) || $password ne $remoteglotconf::adminpass) { exit; } -$dbh->do('INSERT INTO game_extensions ( fen, history, player_w, player_b, ts, next_move ) VALUES ( ?, ?, ?, ?, CURRENT_TIMESTAMP, ? )', - undef, - Encode::decode_utf8($cgi->param('fen')), - Encode::decode_utf8($cgi->param('history')), - Encode::decode_utf8($cgi->param('player_w')), - Encode::decode_utf8($cgi->param('player_b')), - Encode::decode_utf8($cgi->param('move'))); -system("sudo", "touch", $remoteglotconf::target); +if ($cgi->param('move') eq 'null') { + $dbh->do('DELETE FROM game_extensions WHERE fen=? AND history=? AND player_w=? AND player_b=?', + undef, + Encode::decode_utf8($cgi->param('fen')), + Encode::decode_utf8($cgi->param('history')), + Encode::decode_utf8($cgi->param('player_w')), + Encode::decode_utf8($cgi->param('player_b'))); +} else { + $dbh->do('INSERT INTO game_extensions ( fen, history, player_w, player_b, ts, next_move ) VALUES ( ?, ?, ?, ?, CURRENT_TIMESTAMP, ? )', + undef, + Encode::decode_utf8($cgi->param('fen')), + Encode::decode_utf8($cgi->param('history')), + Encode::decode_utf8($cgi->param('player_w')), + Encode::decode_utf8($cgi->param('player_b')), + Encode::decode_utf8($cgi->param('move'))); +} +system("sudo", "/usr/bin/touch", $remoteglotconf::target); print CGI->header(-type=>'text/plain; charset=utf-8'); print "OK\n";