import os import functools import hashlib import pymysql import pymysql.cursors from flask import Flask, request, session, redirect, url_for, render_template, flash from werkzeug.middleware.proxy_fix import ProxyFix app = Flask(__name__) app.secret_key = os.environ.get("ADMIN_SECRET_KEY", "dev-only-change-me") # Sits behind the webtools nginx container at /admin/ (see webtools/nginx.conf); # this reads X-Forwarded-Prefix/-Proto/-For so url_for()/redirect() produce # correct /admin/-prefixed URLs instead of root-relative ones. app.wsgi_app = ProxyFix(app.wsgi_app, x_prefix=1, x_proto=1, x_for=1, x_host=1) def hash_password(plaintext): # The game client MD5-hashes the password client-side before it ever # hits the wire, so accounts.password is always an MD5 hex digest -- # match that here so admin-created/changed passwords work in-game. return hashlib.md5(plaintext.encode("utf-8")).hexdigest() DB_HOST = os.environ.get("DB_HOST", "db") DB_PORT = int(os.environ.get("DB_PORT", "3306")) DB_USER = os.environ.get("DB_USER", "rose") DB_PASSWORD = os.environ.get("DB_PASSWORD", "change_me") DB_NAME = os.environ.get("DB_NAME", "ktrose") # Only accounts with accesslevel >= this may log in to the admin panel. ADMIN_MIN_ACCESSLEVEL = int(os.environ.get("ADMIN_MIN_ACCESSLEVEL", "900")) CHAR_STAT_FIELDS = [ "level", "zuly", "str", "con", "dex", "_int", "cha", "sen", "curHp", "curMp", "statp", "skillp", "stamina", "exp", "classid", ] # Column edited via its own