diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 0000000..dbd990c --- /dev/null +++ b/server/.gitignore @@ -0,0 +1,2 @@ +transfer_service.db +locked_ips.txt diff --git a/server/__pycache__/security.cpython-311.pyc b/server/__pycache__/security.cpython-311.pyc index cb17c8d..2ee662a 100644 Binary files a/server/__pycache__/security.cpython-311.pyc and b/server/__pycache__/security.cpython-311.pyc differ diff --git a/server/locked_ips.txt b/server/locked_ips.txt deleted file mode 100644 index b999c3a..0000000 --- a/server/locked_ips.txt +++ /dev/null @@ -1 +0,0 @@ -10.0.0.235 diff --git a/server/reset_db.py b/server/reset_db.py new file mode 100644 index 0000000..da52edb --- /dev/null +++ b/server/reset_db.py @@ -0,0 +1,41 @@ +import os +import sqlite3 +from contextlib import closing + +DATABASE = 'transfer_service.db' + +def reset_database(): + # Remove the existing database file + if os.path.exists(DATABASE): + os.remove(DATABASE) + print(f"Removed existing database '{DATABASE}'.") + + # Recreate the database structure + with closing(sqlite3.connect(DATABASE)) as conn, conn, closing(conn.cursor()) as c: + # Create users table + c.execute(''' + CREATE TABLE IF NOT EXISTS users ( + id INTEGER PRIMARY KEY, + username TEXT UNIQUE NOT NULL, + password TEXT NOT NULL, + salt TEXT NOT NULL, -- Added salt column + login_attempts INTEGER DEFAULT 0 + ) + ''') + + # Create uploads table for storing links, files, and images + c.execute(''' + CREATE TABLE IF NOT EXISTS uploads ( + id INTEGER PRIMARY KEY, + uploader TEXT NOT NULL, + file_type TEXT NOT NULL, -- 'link', 'file', or 'image' + content TEXT NOT NULL, -- The actual link, filename, or file path + uploaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ) + ''') + + conn.commit() + print("Database initialized successfully.") + +if __name__ == '__main__': + reset_database() diff --git a/server/transfer_service.db b/server/transfer_service.db deleted file mode 100644 index be135b7..0000000 Binary files a/server/transfer_service.db and /dev/null differ