316581dd8f
- Introduced mobile compatibility utilities in mobile_compatibility.js for better handling of file uploads and image previews on mobile devices. - Created base.html as a foundational template with responsive design and mobile compatibility features. - Developed login.html for user authentication with a password toggle feature. - Added main.html for displaying license keys and HWIDs with options to generate new keys and upload backups. - Implemented a test script (test.sh) for validating license information via API. - Created verify.py for license key validation and management, including functions for loading, checking, and registering keys. - Added version.txt to track the current version of the application.
61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
import json
|
|
import os
|
|
import secrets
|
|
|
|
LICENSES_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), "licenses.json"))
|
|
|
|
|
|
def load_file() -> dict:
|
|
with open(LICENSES_FILE, "r") as f:
|
|
data = json.load(f)
|
|
return data
|
|
|
|
def check(license_key, hwid_uuid) -> bool:
|
|
data = load_file()
|
|
for i in data:
|
|
if str(i["license_key"]) == str(license_key):
|
|
if str(i["hwid_uuid"]) == str(hwid_uuid):
|
|
return True
|
|
elif str(i["hwid_uuid"]) == "":
|
|
i["hwid_uuid"] = str(hwid_uuid)
|
|
register_new_Key(data)
|
|
return True
|
|
return False
|
|
|
|
def register_new_Key(data_stream):
|
|
with open(LICENSES_FILE, "w") as f:
|
|
json.dump(data_stream, f, indent=2)
|
|
|
|
def new_key() -> str:
|
|
data = load_file()
|
|
existing_ids = []
|
|
for item in data:
|
|
user_id = str(item.get("user_id", "")).strip()
|
|
if user_id.isdigit():
|
|
existing_ids.append(int(user_id))
|
|
|
|
next_id = (max(existing_ids) + 1) if existing_ids else 1
|
|
generated_key = key_generator()
|
|
data.append(
|
|
{
|
|
"user_id": f"{next_id:04d}",
|
|
"license_key": generated_key,
|
|
"hwid_uuid": "",
|
|
}
|
|
)
|
|
register_new_Key(data)
|
|
return generated_key
|
|
|
|
|
|
def remove_key(user_id: str) -> bool:
|
|
data = load_file()
|
|
filtered = [item for item in data if str(item.get("user_id", "")) != str(user_id)]
|
|
|
|
if len(filtered) == len(data):
|
|
return False
|
|
|
|
register_new_Key(filtered)
|
|
return True
|
|
|
|
def key_generator():
|
|
return secrets.token_urlsafe(32) |