From b0eab60a015bf30bd90b2607cba174f788b5c9df Mon Sep 17 00:00:00 2001 From: UnitedAirforce Date: Thu, 6 Feb 2025 18:21:05 +0800 Subject: [PATCH] Bug fixing, bcrypt -> passlib for easier android dependency --- 7001.py | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 101 insertions(+), 11 deletions(-) diff --git a/7001.py b/7001.py index 987a89e..d63c517 100644 --- a/7001.py +++ b/7001.py @@ -3,13 +3,14 @@ from config import Config import os import sqlite3 import binascii -import bcrypt +from passlib.hash import bcrypt import re from datetime import datetime import xml.etree.ElementTree as ET from Crypto.Cipher import AES import urllib.parse import json +import requests try: with open("song_list.json", 'r', encoding="utf-8") as file: @@ -83,6 +84,49 @@ title_lists = { 3: god_titles, } +fmax_res = [] +fmax_ver = 0 + +def get_4max_version_string(): + url = "https://studio.code.org/v3/sources/3-aKHy16Y5XaAPXQHI95RnFOKlyYT2O95ia2HN2jKIs/main.json" + global fmax_ver + try: + with open("./files/4max_ver.txt", 'r') as file: + fmax_ver = file.read().strip() + except Exception as e: + print(f"An unexpected error occurred when loading files/4max_ver.txt: {e}") + + def fetch(): + global fmax_res + try: + response = requests.get(url) + if 200 <= response.status_code <= 207: + try: + fmax_res = json.loads(json.loads(response.text)['source']) + except (json.JSONDecodeError, KeyError): + fmax_res = 500 + else: + fmax_res = response.status_code + except requests.RequestException: + fmax_res = 400 + + fetch() + +if (os.path.isfile('./files/dlc_4max.html')): + get_4max_version_string() + +def parse_res(res): + parsed_data = [] + if isinstance(res, int): + return "Failed to fetch version info: Error " + str(res) + + for item in res: + if item.get("isOpen"): + version = item.get("version", "Unknown Version") + changelog = "
".join(item.get("changeLog", {}).get("en", [])) + parsed_data.append(f"Version: {version}

Changelog:
{changelog}

") + return "".join(parsed_data) + app = Flask(__name__) app.config.from_object(Config) @@ -162,12 +206,10 @@ def crc32_decimal(data): return int(crc32_hex & 0xFFFFFFFF) def hash_password(password): - salt = bcrypt.gensalt() - hashed_password = bcrypt.hashpw(password.encode('utf-8'), salt) - return hashed_password + return bcrypt.hash(password) def verify_password(password, hashed_password): - return bcrypt.checkpw(password.encode('utf-8'), hashed_password) + return bcrypt.verify(password, hashed_password) def is_alphanumeric(username): pattern = r"^[a-zA-Z0-9]+$" @@ -621,8 +663,8 @@ def result(): do_update_sid = False do_update_vid = False last_row_id = 0 - - if (int(id) not in range(616, 1000) or int(mode) not in range(10, 14)): + print(int(id), int(mode)) + if (int(id) not in range(616, 1000) or int(mode) not in range(0, 4)): # Increment coin for user, if track is not 4max dlx pack mobile difficulty. with sqlite3.connect(DATABASE) as connection: cursor = connection.cursor() @@ -786,6 +828,7 @@ def web_shop(): cnt_type = decrypted_fields[b'cnt_type'][0].decode() device_id = decrypted_fields[b'vid'][0].decode() inc = 0 + fmax_inc = 0 buttons_html = "" # Define the path for the HTML template html_path = f"files/web_shop_{cnt_type}.html" @@ -808,6 +851,14 @@ def web_shop():
""" + fmax_inc = 1 + + elif (700 in my_stage and os.path.isfile('./files/dlc_4max.html')): + buttons_html += """ + + +
+ """ for idx, i in enumerate(range(100, 616)): if i not in my_stage: @@ -850,7 +901,7 @@ def web_shop(): if (idx + 1) % 4 == 0: buttons_html += "
" - if (inc == 0): + if (inc == 0 and fmax_inc == 0): buttons_html += f"""
Everything has been purchased!
""" # Read and format the HTML template with open(html_path, "r", encoding="utf-8") as file: @@ -881,7 +932,7 @@ def web_shop_detail(): html = "" if (cnt_type == "1"): - if (cnt_id != -1): + if (cnt_id > -1): song = song_list[cnt_id] difficulty_levels = "/".join(map(str, song.get("difficulty_levels", []))) song_stage_price = stage_price @@ -901,6 +952,41 @@ def web_shop_detail(): {song_stage_price} """ + else: + if cnt_id == -2: + log = parse_res(fmax_res) + html = f""" +
+

You have unlocked the GC4MAX expansion!

+

Please report bugs/missing tracks to Discord: #AnTcfgss, or QQ 3421587952.

+
+ This server has version {fmax_ver}. +

Update log:

+

{log}


+

+ """ + elif cnt_id == -1: + html = f""" +
+

Experience the arcade with the GC4MAX expansion! This DLC unlocks 320+ exclusive songs for your 2OS experience.

+

Note that these songs don't have mobile difficulties. A short placeholder is used, and GCoin reward is not available for playing them. You must clear the Normal difficulty to unlock AC content.

+

Due to technical limitations, Extra level charts cannot be ported as of now. After purchasing, you will have access to support information and update logs.

+
+ + +

+ + """ elif (cnt_type == "2"): avatar = next((item for item in avatar_list if item.get("id") == cnt_id), None) @@ -942,7 +1028,7 @@ def web_shop_detail(): else: html = "

Item not found.

" - if (cnt_type == "1" and cnt_id == -1): + if (cnt_type == "1" and cnt_id < 0): source_html = f"files/dlc_4max.html" else: source_html = f"files/web_shop_detail.html" @@ -1144,6 +1230,10 @@ def ranking_detail(): button_labels.extend(["AC-Easy", "AC-Normal", "AC-Hard"]) button_modes.extend([11, 12, 13]) + if song_id > 615: + button_modes = [x for x in button_modes if x not in [1, 2, 3]] + button_labels = [x for x in button_labels if x not in ["Easy", "Normal", "Hard"]] + row_start = '
' row_end = '
' row_content = [] @@ -1394,7 +1484,7 @@ def status(): query = "SELECT * FROM daily_reward WHERE device_id = ?" cursor.execute(query, (device_id,)) user_data = cursor.fetchone() - user_name = user_data[1] + user_name = "Guest(" + user_data[1][-6:] + ")" query = "SELECT username FROM user WHERE device_id = ?" cursor.execute(query, (user_data[1],))