diff --git a/routes/_hkfcD_motm.py b/routes/_hkfcD_motm.py index 1f6dbf7..9b81348 100644 --- a/routes/_hkfcD_motm.py +++ b/routes/_hkfcD_motm.py @@ -231,13 +231,13 @@ def hkfcD_vote_thanks(): _fixed_comments = _comments.replace("'", "\\'") _matchDate = request.form['matchNumber'] _oppo = request.form['oppo'] - print(_matchDate) - + if _motm and _dotd and request.method == 'POST': prev_identity = request.cookies.get('sessionID') user_agent = request.headers.get('User-Agent') - warn("Previous identity found: "+prev_identity) + if prev_identity: + warn("Previous identity found: "+prev_identity) vote_query = "SELECT dotd_" + _matchDate + " FROM motmSessions WHERE sessionID='" + prev_identity + "'" vote_check = sql_read(vote_query) if not vote_check: @@ -276,8 +276,7 @@ def hkfcD_vote_thanks(): print("Identity: " + identity) print("User Agent: " + user_agent) warn("Identity and User-Agent set") - id_commit = "INSERT INTO motmSessions (sessionID) VALUES ('" + identity + "')" - ua_commit = "INSERT INTO motmSessions (userAgent) VALUES ('" + user_agent + "')" + id_commit = "INSERT INTO motmSessions (sessionID, userAgent, motm_" + _matchDate + ", dotd_" + _matchDate + ") VALUES ('" + identity + "', '" + user_agent + "', '" + _motm + "', '" + _dotd + "' )" sql_write(id_commit) sql = "INSERT INTO _hkfc_d_motm (playerNumber, playerName, motmTotal, motm_" + _matchDate + ") SELECT playerNumber, playerNickname, '1', '1' FROM _HKFC_players WHERE playerNumber='" + _motm + "' ON DUPLICATE KEY UPDATE motmTotal = motmTotal + 1, motm_" + _matchDate + " = motm_" + _matchDate + " + 1" sql2 = "INSERT INTO _hkfc_d_motm (playerNumber, playerName, dotdTotal, dotd_" + _matchDate + ") SELECT playerNumber, playerNickname, '1', '1' FROM _HKFC_players WHERE playerNumber='" + _dotd + "' ON DUPLICATE KEY UPDATE dotdTotal = dotdTotal + 1, dotd_" + _matchDate + " = dotd_" + _matchDate + " + 1"