-$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("touch", $remoteglotconf::json_output);
+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);