This commit is contained in:
rald 2023-08-04 23:58:20 +08:00
parent 8e52711c43
commit 1a3ac2353b
7 changed files with 36 additions and 21 deletions

Binary file not shown.

View File

@ -1,15 +0,0 @@
#!/usr/bin/env python3
import os
import random
from helpers import get_query_string, get_client_cert,show_header_ok,show_query_string_required
QUERY_STRING=os.getenv("QUERY_STRING")
if not QUERY_STRING:
print("30 guess.cgi",end='\r\n')
show_header_ok()
print(QUERY_STRING)

3
db.py
View File

@ -177,9 +177,6 @@ def create_new_game(conn,board,words,graph):
conn.commit()
return cur.lastrowid
def set_current_game(user_id,game_id):
conn = create_connection()
with conn:

View File

@ -107,6 +107,7 @@ if stats=='PLAY':
elif stats=='STOP':
print("game is finished")
print("=> lobby.cgi lobby")
print("=> new_game.cgi new game")
print("=> rank.cgi ranking")
print("=> lobby.cgi lobby")
print("=> login.cgi login")

View File

@ -9,11 +9,15 @@ TLS_CLIENT_HASH = get_client_cert()
user_id = check_hash(TLS_CLIENT_HASH)
user_name = get_name(user_id) or "[Not Set]"
print("# Lobby")
print("username:",user_name)
print("score:",get_score(user_id))
print()
print("=> login.cgi login")
print("=> new_game.cgi new game")
print("=> rank.cgi ranking")
print("=> login.cgi login")
print()

View File

@ -30,7 +30,7 @@ print("=> add-cert.cgi Add another cert to your account (with auth code)")
print()
print("=> new_game.cgi new game")
print("=> rank.cgi ranking")
print("=> lobby.cgi lobby")
#vim:fenc=utf-8:ts=4:sw=4:sta:noet:sts=4:fdm=marker:ai

28
rank.cgi Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import random
from helpers import get_client_cert
from db import *
TLS_CLIENT_HASH = get_client_cert()
user_id = check_hash(TLS_CLIENT_HASH)
user_name = get_name(user_id) or "[Not Set]"
print("=> new_game.cgi new game")
print("=> lobby.cgi lobby")
print("=> login.cgi login")
conn=create_connection()
with conn:
cur = conn.cursor()
cur.execute("SELECT name,score FROM users ORDER BY score DESC")
rows = cur.fetchall()
print("# Ranking")
print("```")
rank=1
print(f"rank score name")
for row in rows:
print(f"{rank:4d} {row[1]:5d} {row[0]:32s}")
rank+=1
print("```")