Organize directory, add build script

This commit is contained in:
Ahrimdon 2024-03-02 21:05:13 -05:00
parent 85e3519823
commit 0e275ba886
24 changed files with 1469 additions and 1448 deletions

21
build.py Normal file
View File

@ -0,0 +1,21 @@
import os
import PyInstaller.__main__
from distutils.sysconfig import get_python_lib
site_packages_path = get_python_lib()
NAME = "IW4MAdmin_DB_Parser"
SCRIPT = "combine_db.py"
PyInstaller.__main__.run([
"{}".format(SCRIPT),
'--name', f"{NAME}",
"--noconfirm",
"--onefile",
"--windowed",
])
# create symbolic hardlink to main directory
if os.path.exists("combine_db.exe"):
os.remove("combine_db.exe")
os.link('dist/IW4MAdmin_DB_Parser.exe', 'IW4MAdmin_DB_Parser.exe')

View File

@ -1,82 +1,82 @@
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the modified ClientConnectionHistory table in the new database # Create the modified ClientConnectionHistory table in the new database
new_cur.execute(""" new_cur.execute("""
CREATE TABLE "ClientConnectionHistory" ( CREATE TABLE "ClientConnectionHistory" (
"ConnectionId" INTEGER NOT NULL, "ConnectionId" INTEGER NOT NULL,
"Client" TEXT NOT NULL, "Client" TEXT NOT NULL,
"ConnectionTime" TEXT NOT NULL, "ConnectionTime" TEXT NOT NULL,
"ConnectionType" TEXT NOT NULL, "ConnectionType" TEXT NOT NULL,
"Server" TEXT, "Server" TEXT,
CONSTRAINT "PK_ClientConnectionHistory" PRIMARY KEY("ConnectionId" AUTOINCREMENT) CONSTRAINT "PK_ClientConnectionHistory" PRIMARY KEY("ConnectionId" AUTOINCREMENT)
) )
""") """)
# Fetch data from existing EFClientConnectionHistory # Fetch data from existing EFClientConnectionHistory
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFClientConnectionHistory.ClientConnectionId, EFClientConnectionHistory.ClientConnectionId,
EFClientConnectionHistory.ClientId, EFClientConnectionHistory.ClientId,
EFClientConnectionHistory.CreatedDateTime, EFClientConnectionHistory.CreatedDateTime,
EFClientConnectionHistory.ConnectionType, EFClientConnectionHistory.ConnectionType,
EFClientConnectionHistory.ServerId EFClientConnectionHistory.ServerId
FROM FROM
EFClientConnectionHistory EFClientConnectionHistory
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
for row in rows: for row in rows:
client_id = row[1] client_id = row[1]
server_id = row[4] server_id = row[4]
# Retrieve client name # Retrieve client name
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFClients EFClients
JOIN EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId JOIN EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId
WHERE WHERE
EFClients.ClientId = ? EFClients.ClientId = ?
""", (client_id,)) """, (client_id,))
client_name = existing_cur.fetchone() client_name = existing_cur.fetchone()
if client_name: if client_name:
client_name = client_name[0].replace('^7', '') client_name = client_name[0].replace('^7', '')
else: else:
client_name = 'Unknown' client_name = 'Unknown'
# Retrieve server hostname # Retrieve server hostname
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFServers.HostName EFServers.HostName
FROM FROM
EFServers EFServers
WHERE WHERE
EFServers.ServerId = ? EFServers.ServerId = ?
""", (server_id,)) """, (server_id,))
server_hostname = existing_cur.fetchone() server_hostname = existing_cur.fetchone()
if server_hostname: if server_hostname:
server_hostname = server_hostname[0] server_hostname = server_hostname[0]
else: else:
server_hostname = 'Unknown' server_hostname = 'Unknown'
# Map ConnectionType values to their corresponding text # Map ConnectionType values to their corresponding text
connection_type_map = {0: "Connect", 1: "Disconnect"} connection_type_map = {0: "Connect", 1: "Disconnect"}
connection_type = connection_type_map[row[3]] connection_type = connection_type_map[row[3]]
# Insert the modified row into the new ClientConnectionHistory table # Insert the modified row into the new ClientConnectionHistory table
new_row = (row[0], client_name, row[2], connection_type, server_hostname) new_row = (row[0], client_name, row[2], connection_type, server_hostname)
new_cur.execute("INSERT INTO ClientConnectionHistory (ConnectionId, Client, ConnectionTime, ConnectionType, Server) VALUES (?, ?, ?, ?, ?)", new_row) new_cur.execute("INSERT INTO ClientConnectionHistory (ConnectionId, Client, ConnectionTime, ConnectionType, Server) VALUES (?, ?, ?, ?, ?)", new_row)
# Commit the changes and close the connections # Commit the changes and close the connections
new_conn.commit() new_conn.commit()
existing_conn.close() existing_conn.close()
new_conn.close() new_conn.close()

View File

@ -1,32 +1,32 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the ClientConnectionHistory table sorted by ConnectionTime in descending order # Fetch data from the ClientConnectionHistory table sorted by ConnectionTime in descending order
new_cur.execute(""" new_cur.execute("""
SELECT ConnectionId, Client, ConnectionTime, ConnectionType, Server SELECT ConnectionId, Client, ConnectionTime, ConnectionType, Server
FROM ClientConnectionHistory FROM ClientConnectionHistory
ORDER BY ConnectionTime DESC ORDER BY ConnectionTime DESC
""") """)
client_connection_history = new_cur.fetchall() client_connection_history = new_cur.fetchall()
# Create a list of dictionaries representing the client connection history # Create a list of dictionaries representing the client connection history
client_connection_history_list = [] client_connection_history_list = []
for row in client_connection_history: for row in client_connection_history:
client_connection_history_list.append({ client_connection_history_list.append({
"ConnectionId": row[0], "ConnectionId": row[0],
"Client": row[1], "Client": row[1],
"ConnectionTime": row[2], "ConnectionTime": row[2],
"ConnectionType": row[3], "ConnectionType": row[3],
"Server": row[4] "Server": row[4]
}) })
# Write the client connection history to a JSON file # Write the client connection history to a JSON file
with open("ClientConnectionHistory.json", "w") as f: with open("ClientConnectionHistory.json", "w") as f:
json.dump(client_connection_history_list, f, indent=2) json.dump(client_connection_history_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,78 +1,78 @@
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the modified ClientMessages table in the new database # Create the modified ClientMessages table in the new database
new_cur.execute(""" new_cur.execute("""
CREATE TABLE "ClientMessages" ( CREATE TABLE "ClientMessages" (
"MessageId" INTEGER NOT NULL, "MessageId" INTEGER NOT NULL,
"Client" TEXT NOT NULL, "Client" TEXT NOT NULL,
"Message" TEXT NOT NULL, "Message" TEXT NOT NULL,
"TimeSent" TEXT NOT NULL, "TimeSent" TEXT NOT NULL,
"Server" TEXT, "Server" TEXT,
CONSTRAINT "PK_ClientMessages" PRIMARY KEY("MessageId" AUTOINCREMENT) CONSTRAINT "PK_ClientMessages" PRIMARY KEY("MessageId" AUTOINCREMENT)
) )
""") """)
# Fetch data from existing EFClientMessages # Fetch data from existing EFClientMessages
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFClientMessages.MessageId, EFClientMessages.MessageId,
EFClientMessages.ClientId, EFClientMessages.ClientId,
EFClientMessages.Message, EFClientMessages.Message,
EFClientMessages.TimeSent, EFClientMessages.TimeSent,
EFClientMessages.ServerId EFClientMessages.ServerId
FROM FROM
EFClientMessages EFClientMessages
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
for row in rows: for row in rows:
client_id = row[1] client_id = row[1]
server_id = row[4] server_id = row[4]
# Retrieve client name # Retrieve client name
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFClients EFClients
JOIN EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId JOIN EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId
WHERE WHERE
EFClients.ClientId = ? EFClients.ClientId = ?
""", (client_id,)) """, (client_id,))
client_name = existing_cur.fetchone() client_name = existing_cur.fetchone()
if client_name: if client_name:
client_name = client_name[0].replace('^7', '') client_name = client_name[0].replace('^7', '')
else: else:
client_name = 'Unknown' client_name = 'Unknown'
# Retrieve server hostname # Retrieve server hostname
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFServers.HostName EFServers.HostName
FROM FROM
EFServers EFServers
WHERE WHERE
EFServers.ServerId = ? EFServers.ServerId = ?
""", (server_id,)) """, (server_id,))
server_hostname = existing_cur.fetchone() server_hostname = existing_cur.fetchone()
if server_hostname: if server_hostname:
server_hostname = server_hostname[0] server_hostname = server_hostname[0]
else: else:
server_hostname = 'Unknown' server_hostname = 'Unknown'
# Insert the modified row into the new ClientMessages table # Insert the modified row into the new ClientMessages table
new_row = (row[0], client_name, row[2], row[3], server_hostname) new_row = (row[0], client_name, row[2], row[3], server_hostname)
new_cur.execute("INSERT INTO ClientMessages (MessageId, Client, Message, TimeSent, Server) VALUES (?, ?, ?, ?, ?)", new_row) new_cur.execute("INSERT INTO ClientMessages (MessageId, Client, Message, TimeSent, Server) VALUES (?, ?, ?, ?, ?)", new_row)
# Commit the changes and close the connections # Commit the changes and close the connections
new_conn.commit() new_conn.commit()
existing_conn.close() existing_conn.close()
new_conn.close() new_conn.close()

View File

@ -1,32 +1,32 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the ClientMessages table # Fetch data from the ClientMessages table
new_cur.execute(""" new_cur.execute("""
SELECT MessageId, Client, Message, TimeSent, Server SELECT MessageId, Client, Message, TimeSent, Server
FROM ClientMessages FROM ClientMessages
ORDER BY TimeSent DESC ORDER BY TimeSent DESC
""") """)
client_messages = new_cur.fetchall() client_messages = new_cur.fetchall()
# Create a list of dictionaries representing the client messages # Create a list of dictionaries representing the client messages
client_messages_list = [] client_messages_list = []
for row in client_messages: for row in client_messages:
client_messages_list.append({ client_messages_list.append({
"MessageId": row[0], "MessageId": row[0],
"Client": row[1], "Client": row[1],
"Message": row[2], "Message": row[2],
"TimeSent": row[3], "TimeSent": row[3],
"Server": row[4] "Server": row[4]
}) })
# Write the client messages to a JSON file # Write the client messages to a JSON file
with open("ClientMessages.json", "w") as f: with open("ClientMessages.json", "w") as f:
json.dump(client_messages_list, f, indent=2) json.dump(client_messages_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,46 +1,46 @@
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
conn = sqlite3.connect("Database.db") conn = sqlite3.connect("Database.db")
cur = conn.cursor() cur = conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
def fetch_client_info(src_cur): def fetch_client_info(src_cur):
src_cur.execute(""" src_cur.execute("""
SELECT Name, SearchableIPAddress, DateAdded FROM EFAlias SELECT Name, SearchableIPAddress, DateAdded FROM EFAlias
""") """)
client_info = [] client_info = []
for row in src_cur.fetchall(): for row in src_cur.fetchall():
name = row[0].replace('^7', '') # Remove '^7' from the Name column name = row[0].replace('^7', '') # Remove '^7' from the Name column
client_info.append((name, row[1], row[2])) client_info.append((name, row[1], row[2]))
return client_info return client_info
# Fetch client info from EFAlias table in the existing database # Fetch client info from EFAlias table in the existing database
client_info = fetch_client_info(cur) client_info = fetch_client_info(cur)
# Create the new table # Create the new table
new_cur.execute(""" new_cur.execute("""
CREATE TABLE IF NOT EXISTS "IPAddresses" ( CREATE TABLE IF NOT EXISTS "IPAddresses" (
Name TEXT NOT NULL, Name TEXT NOT NULL,
SearchableIPAddress TEXT, SearchableIPAddress TEXT,
DateAdded TEXT NOT NULL DateAdded TEXT NOT NULL
) )
""") """)
# Insert the fetched data into the new table # Insert the fetched data into the new table
new_cur.executemany(""" new_cur.executemany("""
INSERT INTO "IPAddresses" ( INSERT INTO "IPAddresses" (
Name, SearchableIPAddress, DateAdded Name, SearchableIPAddress, DateAdded
) VALUES (?, ?, ?) ) VALUES (?, ?, ?)
""", client_info) """, client_info)
# Commit and close the new database # Commit and close the new database
new_conn.commit() new_conn.commit()
new_conn.close() new_conn.close()
# Close the existing database # Close the existing database
conn.close() conn.close()

View File

@ -1,29 +1,29 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the ClientInfo table sorted by DateAdded in descending order # Fetch data from the ClientInfo table sorted by DateAdded in descending order
new_cur.execute(""" new_cur.execute("""
SELECT Name, SearchableIPAddress, DateAdded FROM "IPAddresses" SELECT Name, SearchableIPAddress, DateAdded FROM "IPAddresses"
ORDER BY DateAdded DESC ORDER BY DateAdded DESC
""") """)
client_info = new_cur.fetchall() client_info = new_cur.fetchall()
# Create a list of dictionaries representing the client info # Create a list of dictionaries representing the client info
client_info_list = [] client_info_list = []
for row in client_info: for row in client_info:
client_info_list.append({ client_info_list.append({
"Name": row[0], "Name": row[0],
"SearchableIPAddress": row[1], "SearchableIPAddress": row[1],
"DateAdded": row[2] "DateAdded": row[2]
}) })
# Write the client info to a JSON file # Write the client info to a JSON file
with open("IPAddresses.json", "w") as f: with open("IPAddresses.json", "w") as f:
json.dump(client_info_list, f, indent=2) json.dump(client_info_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,93 +1,93 @@
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the modified AuditLog table in the new database # Create the modified AuditLog table in the new database
new_cur.execute(""" new_cur.execute("""
CREATE TABLE "AuditLog" ( CREATE TABLE "AuditLog" (
"ChangeHistoryId" INTEGER NOT NULL, "ChangeHistoryId" INTEGER NOT NULL,
"TypeOfChange" TEXT NOT NULL, "TypeOfChange" TEXT NOT NULL,
"Time" TEXT NOT NULL, "Time" TEXT NOT NULL,
"Data" TEXT, "Data" TEXT,
"Command" TEXT, "Command" TEXT,
"Origin" TEXT, "Origin" TEXT,
"Target" TEXT, "Target" TEXT,
CONSTRAINT "PK_AuditLog" PRIMARY KEY("ChangeHistoryId" AUTOINCREMENT) CONSTRAINT "PK_AuditLog" PRIMARY KEY("ChangeHistoryId" AUTOINCREMENT)
) )
""") """)
# Fetch data from existing EFChangeHistory, EFClients, and EFAlias tables # Fetch data from existing EFChangeHistory, EFClients, and EFAlias tables
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFChangeHistory.ChangeHistoryId, EFChangeHistory.ChangeHistoryId,
EFChangeHistory.TypeOfChange, EFChangeHistory.TypeOfChange,
EFChangeHistory.TimeChanged, EFChangeHistory.TimeChanged,
EFChangeHistory.Comment, EFChangeHistory.Comment,
EFChangeHistory.CurrentValue, EFChangeHistory.CurrentValue,
EFChangeHistory.OriginEntityId, EFChangeHistory.OriginEntityId,
EFChangeHistory.TargetEntityId EFChangeHistory.TargetEntityId
FROM FROM
EFChangeHistory EFChangeHistory
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
# Prepare a dictionary to store ClientId to Name mapping # Prepare a dictionary to store ClientId to Name mapping
client_name_map = {} client_name_map = {}
for row in rows: for row in rows:
origin_entity_id = row[5] origin_entity_id = row[5]
target_entity_id = row[6] target_entity_id = row[6]
if origin_entity_id not in client_name_map: if origin_entity_id not in client_name_map:
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFClients EFClients
JOIN EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId JOIN EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId
WHERE WHERE
EFClients.ClientId = ? EFClients.ClientId = ?
""", (origin_entity_id,)) """, (origin_entity_id,))
origin_name = existing_cur.fetchone() origin_name = existing_cur.fetchone()
if origin_name: if origin_name:
client_name_map[origin_entity_id] = origin_name[0].replace('^7', '') client_name_map[origin_entity_id] = origin_name[0].replace('^7', '')
else: else:
client_name_map[origin_entity_id] = 'Unknown' client_name_map[origin_entity_id] = 'Unknown'
if target_entity_id not in client_name_map: if target_entity_id not in client_name_map:
if target_entity_id == 0: if target_entity_id == 0:
client_name_map[target_entity_id] = None client_name_map[target_entity_id] = None
else: else:
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFClients EFClients
JOIN EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId JOIN EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId
WHERE WHERE
EFClients.ClientId = ? EFClients.ClientId = ?
""", (target_entity_id,)) """, (target_entity_id,))
target_name = existing_cur.fetchone() target_name = existing_cur.fetchone()
if target_name: if target_name:
client_name_map[target_entity_id] = target_name[0].replace('^7', '') client_name_map[target_entity_id] = target_name[0].replace('^7', '')
else: else:
client_name_map[target_entity_id] = 'Unknown' client_name_map[target_entity_id] = 'Unknown'
# Map TypeOfChange values to their corresponding text # Map TypeOfChange values to their corresponding text
type_of_change_map = {0: "Console", 1: "Punishment", 2: "Client"} type_of_change_map = {0: "Console", 1: "Punishment", 2: "Client"}
type_of_change = type_of_change_map[row[1]] type_of_change = type_of_change_map[row[1]]
# Insert the modified row into the new AuditLog table # Insert the modified row into the new AuditLog table
new_row = (row[0], type_of_change, row[2], row[3], row[4], client_name_map[origin_entity_id], client_name_map[target_entity_id]) new_row = (row[0], type_of_change, row[2], row[3], row[4], client_name_map[origin_entity_id], client_name_map[target_entity_id])
new_cur.execute("INSERT INTO \"AuditLog\" (ChangeHistoryId, TypeOfChange, Time, Data, Command, Origin, Target) VALUES (?, ?, ?, ?, ?, ?, ?)", new_row) new_cur.execute("INSERT INTO \"AuditLog\" (ChangeHistoryId, TypeOfChange, Time, Data, Command, Origin, Target) VALUES (?, ?, ?, ?, ?, ?, ?)", new_row)
# Commit the changes and close the connections # Commit the changes and close the connections
new_conn.commit() new_conn.commit()
existing_conn.close() existing_conn.close()
new_conn.close() new_conn.close()

View File

@ -1,33 +1,33 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the EFChangeHistory table sorted by Time in descending order # Fetch data from the EFChangeHistory table sorted by Time in descending order
new_cur.execute(""" new_cur.execute("""
SELECT ChangeHistoryId, TypeOfChange, Time, Data, Command, Origin, Target FROM AuditLog SELECT ChangeHistoryId, TypeOfChange, Time, Data, Command, Origin, Target FROM AuditLog
ORDER BY Time DESC ORDER BY Time DESC
""") """)
ef_change_history = new_cur.fetchall() ef_change_history = new_cur.fetchall()
# Create a list of dictionaries representing the EFChangeHistory data # Create a list of dictionaries representing the EFChangeHistory data
ef_change_history_list = [] ef_change_history_list = []
for row in ef_change_history: for row in ef_change_history:
ef_change_history_list.append({ ef_change_history_list.append({
"ChangeHistoryId": row[0], "ChangeHistoryId": row[0],
"TypeOfChange": row[1], "TypeOfChange": row[1],
"Time": row[2], "Time": row[2],
"Data": row[3], "Data": row[3],
"Command": row[4], "Command": row[4],
"Origin": row[5], "Origin": row[5],
"Target": row[6] "Target": row[6]
}) })
# Write the EFChangeHistory data to a JSON file # Write the EFChangeHistory data to a JSON file
with open("AuditLog.json", "w") as f: with open("AuditLog.json", "w") as f:
json.dump(ef_change_history_list, f, indent=2) json.dump(ef_change_history_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,86 +1,86 @@
# EFClients # EFClients
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
new_cur.execute(""" new_cur.execute("""
CREATE TABLE "Clients" ( CREATE TABLE "Clients" (
"Connections" INTEGER NOT NULL, "Connections" INTEGER NOT NULL,
"Name" TEXT NOT NULL, "Name" TEXT NOT NULL,
"FirstConnection" TEXT NOT NULL, "FirstConnection" TEXT NOT NULL,
"Game" TEXT NOT NULL, "Game" TEXT NOT NULL,
"LastConnection" TEXT NOT NULL, "LastConnection" TEXT NOT NULL,
"Level" TEXT NOT NULL, "Level" TEXT NOT NULL,
"Masked" INTEGER NOT NULL, "Masked" INTEGER NOT NULL,
"TotalConnectionTime" INTEGER NOT NULL, "TotalConnectionTime" INTEGER NOT NULL,
"IP" TEXT "IP" TEXT
) )
""") """)
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFClients.Connections, EFClients.Connections,
EFClients.CurrentAliasId, EFClients.CurrentAliasId,
EFClients.FirstConnection, EFClients.FirstConnection,
EFClients.GameName, EFClients.GameName,
EFClients.LastConnection, EFClients.LastConnection,
EFClients.Level, EFClients.Level,
EFClients.Masked, EFClients.Masked,
EFClients.TotalConnectionTime, EFClients.TotalConnectionTime,
EFAlias.SearchableIPAddress EFAlias.SearchableIPAddress
FROM FROM
EFClients EFClients
JOIN JOIN
EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId EFAlias ON EFClients.CurrentAliasId = EFAlias.AliasId
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
for row in rows: for row in rows:
connections = row[0] connections = row[0]
current_alias_id = row[1] current_alias_id = row[1]
first_connection = row[2] first_connection = row[2]
game_name = row[3] game_name = row[3]
last_connection = row[4] last_connection = row[4]
level = row[5] level = row[5]
masked = row[6] masked = row[6]
total_connection_time = row[7] total_connection_time = row[7]
ip_address = row[8] ip_address = row[8]
# Retrieve client name # Retrieve client name
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFAlias EFAlias
WHERE WHERE
EFAlias.AliasId = ? EFAlias.AliasId = ?
""", (current_alias_id,)) """, (current_alias_id,))
client_name = existing_cur.fetchone() client_name = existing_cur.fetchone()
if client_name: if client_name:
client_name = client_name[0].replace('^7', '') client_name = client_name[0].replace('^7', '')
else: else:
client_name = 'Unknown' client_name = 'Unknown'
# Map Level values to their corresponding text # Map Level values to their corresponding text
level_map = {-1: "Banned", 0: "User", 1: "Trusted", 2: "Moderator", 3: "Administrator", 4: "Senior Administrator", 5: "Owner", 6: "Creator", 7: "Console"} level_map = {-1: "Banned", 0: "User", 1: "Trusted", 2: "Moderator", 3: "Administrator", 4: "Senior Administrator", 5: "Owner", 6: "Creator", 7: "Console"}
level = level_map.get(level, f"Unknown Level ({level})") level = level_map.get(level, f"Unknown Level ({level})")
# Map GameName values to their corresponding text # Map GameName values to their corresponding text
game_map = {5: "WaW", 6: "BO", 7: "BO2", 3: "MW3"} game_map = {5: "WaW", 6: "BO", 7: "BO2", 3: "MW3"}
game = game_map.get(game_name, f"Unknown Game ({game_name})") game = game_map.get(game_name, f"Unknown Game ({game_name})")
# Insert the modified row into the new Clients table # Insert the modified row into the new Clients table
new_row = (connections, client_name, first_connection, game, last_connection, level, masked, total_connection_time, ip_address) new_row = (connections, client_name, first_connection, game, last_connection, level, masked, total_connection_time, ip_address)
new_cur.execute("INSERT INTO Clients (Connections, Name, FirstConnection, Game, LastConnection, Level, Masked, TotalConnectionTime, IP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", new_row) new_cur.execute("INSERT INTO Clients (Connections, Name, FirstConnection, Game, LastConnection, Level, Masked, TotalConnectionTime, IP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", new_row)
# Commit the changes and close the connections # Commit the changes and close the connections
new_conn.commit() new_conn.commit()
existing_conn.close() existing_conn.close()
new_conn.close() new_conn.close()

View File

@ -1,35 +1,35 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the EFClients table # Fetch data from the EFClients table
new_cur.execute(""" new_cur.execute("""
SELECT Connections, Name, FirstConnection, Game, LastConnection, Level, Masked, TotalConnectionTime SELECT Connections, Name, FirstConnection, Game, LastConnection, Level, Masked, TotalConnectionTime
FROM Clients FROM Clients
ORDER BY LastConnection DESC ORDER BY LastConnection DESC
""") """)
clients = new_cur.fetchall() clients = new_cur.fetchall()
# Create a list of dictionaries representing the clients # Create a list of dictionaries representing the clients
clients_list = [] clients_list = []
for row in clients: for row in clients:
clients_list.append({ clients_list.append({
"Connections": row[0], "Connections": row[0],
"Name": row[1], "Name": row[1],
"FirstConnection": row[2], "FirstConnection": row[2],
"Game": row[3], "Game": row[3],
"LastConnection": row[4], "LastConnection": row[4],
"Level": row[5], "Level": row[5],
"Masked": row[6], "Masked": row[6],
"TotalConnectionTime": row[7] "TotalConnectionTime": row[7]
}) })
# Write the clients to a JSON file # Write the clients to a JSON file
with open("Clients.json", "w") as f: with open("Clients.json", "w") as f:
json.dump(clients_list, f, indent=2) json.dump(clients_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,50 +1,50 @@
# EFMaps # EFMaps
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the Maps table in the new_database.db # Create the Maps table in the new_database.db
new_cur.execute(""" new_cur.execute("""
CREATE TABLE IF NOT EXISTS "Maps" ( CREATE TABLE IF NOT EXISTS "Maps" (
"MapId" INTEGER NOT NULL, "MapId" INTEGER NOT NULL,
"CreatedDateTime" TEXT NOT NULL, "CreatedDateTime" TEXT NOT NULL,
"Name" TEXT NOT NULL, "Name" TEXT NOT NULL,
"Game" TEXT NOT NULL, "Game" TEXT NOT NULL,
CONSTRAINT "PK_Maps" PRIMARY KEY("MapId" AUTOINCREMENT) CONSTRAINT "PK_Maps" PRIMARY KEY("MapId" AUTOINCREMENT)
) )
""") """)
# Fetch data from the existing EFMaps table # Fetch data from the existing EFMaps table
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
MapId, CreatedDateTime, Name, Game MapId, CreatedDateTime, Name, Game
FROM FROM
EFMaps EFMaps
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
# Modify the data according to the requirements # Modify the data according to the requirements
modified_rows = [] modified_rows = []
for row in rows: for row in rows:
game_map = {5: "WaW", 6: "BO", 7: "BO2", 3: "MW3"} game_map = {5: "WaW", 6: "BO", 7: "BO2", 3: "MW3"}
game = game_map.get(row[3], f"Unknown Game ({row[3]})") game = game_map.get(row[3], f"Unknown Game ({row[3]})")
modified_rows.append((row[0], row[1], row[2], game)) modified_rows.append((row[0], row[1], row[2], game))
# Insert the modified data into the Maps table in the new_database.db # Insert the modified data into the Maps table in the new_database.db
new_cur.executemany(""" new_cur.executemany("""
INSERT INTO "Maps" ( INSERT INTO "Maps" (
MapId, CreatedDateTime, Name, Game MapId, CreatedDateTime, Name, Game
) VALUES (?, ?, ?, ?) ) VALUES (?, ?, ?, ?)
""", modified_rows) """, modified_rows)
# Commit the changes and close the connections # Commit the changes and close the connections
new_conn.commit() new_conn.commit()
existing_conn.close() existing_conn.close()
new_conn.close() new_conn.close()

View File

@ -1,35 +1,35 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new_database.db # Connect to the new_database.db
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the Maps table sorted by MapId DESC # Fetch data from the Maps table sorted by MapId DESC
new_cur.execute(""" new_cur.execute("""
SELECT SELECT
MapId, CreatedDateTime, Name, Game MapId, CreatedDateTime, Name, Game
FROM FROM
Maps Maps
ORDER BY ORDER BY
MapId DESC MapId DESC
""") """)
rows = new_cur.fetchall() rows = new_cur.fetchall()
# Convert fetched data into a list of dictionaries # Convert fetched data into a list of dictionaries
maps_list = [] maps_list = []
for row in rows: for row in rows:
map_dict = { map_dict = {
"MapId": row[0], "MapId": row[0],
"CreatedDateTime": row[1], "CreatedDateTime": row[1],
"Name": row[2], "Name": row[2],
"Game": row[3] "Game": row[3]
} }
maps_list.append(map_dict) maps_list.append(map_dict)
# Write the list of dictionaries to a JSON file # Write the list of dictionaries to a JSON file
with open("maps_export.json", "w") as json_file: with open("maps_export.json", "w") as json_file:
json.dump(maps_list, json_file, indent=4) json.dump(maps_list, json_file, indent=4)
# Close the connection # Close the connection
new_conn.close() new_conn.close()

View File

@ -1,84 +1,84 @@
# EFMeta # EFMeta
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the modified Metadata table in the new database # Create the modified Metadata table in the new database
new_cur.execute(""" new_cur.execute("""
CREATE TABLE "Metadata" ( CREATE TABLE "Metadata" (
"MetaId" INTEGER NOT NULL, "MetaId" INTEGER NOT NULL,
"Name" TEXT NOT NULL, "Name" TEXT NOT NULL,
"Timestamp" TEXT NOT NULL, "Timestamp" TEXT NOT NULL,
"Note" TEXT NOT NULL, "Note" TEXT NOT NULL,
"Value" TEXT NOT NULL "Value" TEXT NOT NULL
) )
""") """)
# Fetch data from existing EFMeta # Fetch data from existing EFMeta
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFMeta.MetaId, EFMeta.MetaId,
EFMeta.ClientId, EFMeta.ClientId,
EFMeta.Created, EFMeta.Created,
EFMeta.Key, EFMeta.Key,
EFMeta.Value EFMeta.Value
FROM FROM
EFMeta EFMeta
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
for row in rows: for row in rows:
meta_id = row[0] meta_id = row[0]
client_id = row[1] client_id = row[1]
created = row[2] created = row[2]
key = row[3] key = row[3]
value = row[4] value = row[4]
# Retrieve CurrentAliasId for the ClientId # Retrieve CurrentAliasId for the ClientId
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFClients.CurrentAliasId EFClients.CurrentAliasId
FROM FROM
EFClients EFClients
WHERE WHERE
EFClients.ClientId = ? EFClients.ClientId = ?
""", (client_id,)) """, (client_id,))
current_alias_id = existing_cur.fetchone() current_alias_id = existing_cur.fetchone()
if current_alias_id: if current_alias_id:
current_alias_id = current_alias_id[0] current_alias_id = current_alias_id[0]
else: else:
current_alias_id = None current_alias_id = None
# Retrieve client name # Retrieve client name
if current_alias_id: if current_alias_id:
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFAlias EFAlias
WHERE WHERE
EFAlias.AliasId = ? EFAlias.AliasId = ?
""", (current_alias_id,)) """, (current_alias_id,))
client_name = existing_cur.fetchone() client_name = existing_cur.fetchone()
if client_name: if client_name:
client_name = client_name[0].replace('^7', '') client_name = client_name[0].replace('^7', '')
else: else:
client_name = 'Unknown' client_name = 'Unknown'
else: else:
client_name = 'Unknown' client_name = 'Unknown'
# Insert the modified row into the new Metadata table # Insert the modified row into the new Metadata table
new_row = (meta_id, client_name, created, key, value) new_row = (meta_id, client_name, created, key, value)
new_cur.execute("INSERT INTO Metadata (MetaId, Name, Timestamp, Note, Value) VALUES (?, ?, ?, ?, ?)", new_row) new_cur.execute("INSERT INTO Metadata (MetaId, Name, Timestamp, Note, Value) VALUES (?, ?, ?, ?, ?)", new_row)
# Commit the changes and close the connections # Commit the changes and close the connections
new_conn.commit() new_conn.commit()
existing_conn.close() existing_conn.close()
new_conn.close() new_conn.close()

View File

@ -1,32 +1,32 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the Metadata table # Fetch data from the Metadata table
new_cur.execute(""" new_cur.execute("""
SELECT MetaId, Name, Timestamp, Note, Value SELECT MetaId, Name, Timestamp, Note, Value
FROM Metadata FROM Metadata
ORDER BY Timestamp DESC ORDER BY Timestamp DESC
""") """)
metadata = new_cur.fetchall() metadata = new_cur.fetchall()
# Create a list of dictionaries representing the metadata # Create a list of dictionaries representing the metadata
metadata_list = [] metadata_list = []
for row in metadata: for row in metadata:
metadata_list.append({ metadata_list.append({
"MetaId": row[0], "MetaId": row[0],
"Name": row[1], "Name": row[1],
"Timestamp": row[2], "Timestamp": row[2],
"Note": row[3], "Note": row[3],
"Value": row[4] "Value": row[4]
}) })
# Write the metadata to a JSON file # Write the metadata to a JSON file
with open("Metadata.json", "w") as f: with open("Metadata.json", "w") as f:
json.dump(metadata_list, f, indent=2) json.dump(metadata_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,133 +1,133 @@
import sqlite3 import sqlite3
import re import re
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the modified Penalties table in the new database # Create the modified Penalties table in the new database
new_cur.execute(""" new_cur.execute("""
CREATE TABLE "Penalties" ( CREATE TABLE "Penalties" (
"PenaltyId" INTEGER NOT NULL, "PenaltyId" INTEGER NOT NULL,
"AutomatedOffense" TEXT NOT NULL, "AutomatedOffense" TEXT NOT NULL,
"Expires" INTEGER, -- This line is modified to allow NULL values "Expires" INTEGER, -- This line is modified to allow NULL values
"EvadedOffense" TEXT NOT NULL, "EvadedOffense" TEXT NOT NULL,
"Offender" TEXT NOT NULL, "Offender" TEXT NOT NULL,
"Offense" TEXT NOT NULL, "Offense" TEXT NOT NULL,
"Punisher" TEXT NOT NULL, "Punisher" TEXT NOT NULL,
"Type" TEXT NOT NULL, "Type" TEXT NOT NULL,
"Timestamp" INTEGER NOT NULL "Timestamp" INTEGER NOT NULL
) )
""") """)
# Fetch data from existing EFPenalties # Fetch data from existing EFPenalties
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFPenalties.PenaltyId, EFPenalties.PenaltyId,
EFPenalties.AutomatedOffense, EFPenalties.AutomatedOffense,
EFPenalties.Expires, EFPenalties.Expires,
EFPenalties.IsEvadedOffense, EFPenalties.IsEvadedOffense,
EFPenalties.OffenderId, EFPenalties.OffenderId,
EFPenalties.Offense, EFPenalties.Offense,
EFPenalties.PunisherId, EFPenalties.PunisherId,
EFPenalties.Type, EFPenalties.Type,
EFPenalties."When" EFPenalties."When"
FROM FROM
EFPenalties EFPenalties
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
for row in rows: for row in rows:
penalty_id = row[0] penalty_id = row[0]
automated_offense = row[1] automated_offense = row[1]
expires = row[2] expires = row[2]
evaded_offense = row[3] evaded_offense = row[3]
offender_id = row[4] offender_id = row[4]
offense = row[5] offense = row[5]
punisher_id = row[6] punisher_id = row[6]
penalty_type = row[7] penalty_type = row[7]
timestamp = row[8] timestamp = row[8]
# Retrieve offender name # Retrieve offender name
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFAlias EFAlias
INNER JOIN INNER JOIN
EFClients ON EFAlias.AliasId = EFClients.CurrentAliasId EFClients ON EFAlias.AliasId = EFClients.CurrentAliasId
WHERE WHERE
EFClients.ClientId = ? EFClients.ClientId = ?
""", (offender_id,)) """, (offender_id,))
offender_name = existing_cur.fetchone() offender_name = existing_cur.fetchone()
if offender_name: if offender_name:
offender_name = offender_name[0].replace('^7', '') offender_name = offender_name[0].replace('^7', '')
else: else:
offender_name = 'Unknown' offender_name = 'Unknown'
# Retrieve punisher name # Retrieve punisher name
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFAlias EFAlias
INNER JOIN INNER JOIN
EFClients ON EFAlias.AliasId = EFClients.CurrentAliasId EFClients ON EFAlias.AliasId = EFClients.CurrentAliasId
WHERE WHERE
EFClients.ClientId = ? EFClients.ClientId = ?
""", (punisher_id,)) """, (punisher_id,))
punisher_name = existing_cur.fetchone() punisher_name = existing_cur.fetchone()
if punisher_name: if punisher_name:
punisher_name = punisher_name[0].replace('^7', '') punisher_name = punisher_name[0].replace('^7', '')
else: else:
punisher_name = 'Unknown' punisher_name = 'Unknown'
# Replace Type values # Replace Type values
type_map = {0: "Report", 1: "Warning", 2: "Flag", 3: "Kick", 4: "Temp Ban", 5: "Perm Ban", 6: "Unban", 8: "Unflag"} type_map = {0: "Report", 1: "Warning", 2: "Flag", 3: "Kick", 4: "Temp Ban", 5: "Perm Ban", 6: "Unban", 8: "Unflag"}
penalty_type = type_map.get(penalty_type, f"Unknown Type ({penalty_type})") penalty_type = type_map.get(penalty_type, f"Unknown Type ({penalty_type})")
# Set AutomatedOffense value to 'Yes' or 'No' # Set AutomatedOffense value to 'Yes' or 'No'
automated_offense_patterns = [r"VPNs are not allowed", automated_offense_patterns = [r"VPNs are not allowed",
r"Ping is too high!", r"Ping is too high!",
r"name is not allowed"] # Simplified the patterns r"name is not allowed"] # Simplified the patterns
# Search the 'Offense' field for specified patterns # Search the 'Offense' field for specified patterns
for pattern in automated_offense_patterns: for pattern in automated_offense_patterns:
if re.search(pattern, offense): # Using re.search with 'offense' instead of 'automated_offense' if re.search(pattern, offense): # Using re.search with 'offense' instead of 'automated_offense'
automated_offense = "Yes" automated_offense = "Yes"
break break
else: else:
automated_offense = "No" automated_offense = "No"
# Set EvadedOffense values to 'Yes' or 'No' # Set EvadedOffense values to 'Yes' or 'No'
evaded_offense = "Yes" if evaded_offense == 1 else "No" evaded_offense = "Yes" if evaded_offense == 1 else "No"
# Set Expires value to 'Never' if it is NULL # Set Expires value to 'Never' if it is NULL
expires = "Never" if expires is None else expires expires = "Never" if expires is None else expires
# Insert the modified row into the new Penalties table # Insert the modified row into the new Penalties table
new_cur.execute(""" new_cur.execute("""
INSERT INTO Penalties ( INSERT INTO Penalties (
PenaltyId, PenaltyId,
AutomatedOffense, AutomatedOffense,
Expires, Expires,
EvadedOffense, EvadedOffense,
Offender, Offender,
Offense, Offense,
Punisher, Punisher,
Type, Type,
Timestamp Timestamp
) )
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (penalty_id, automated_offense, expires, evaded_offense, offender_name, offense, punisher_name, penalty_type, timestamp)) """, (penalty_id, automated_offense, expires, evaded_offense, offender_name, offense, punisher_name, penalty_type, timestamp))
# Commit changes and close the new database # Commit changes and close the new database
new_conn.commit() new_conn.commit()
new_conn.close() new_conn.close()
# Close the existing database # Close the existing database
existing_conn.close() existing_conn.close()

View File

@ -1,36 +1,36 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the Penalties table # Fetch data from the Penalties table
new_cur.execute(""" new_cur.execute("""
SELECT PenaltyId, AutomatedOffense, Expires, EvadedOffense, Offender, Offense, Punisher, Type, Timestamp SELECT PenaltyId, AutomatedOffense, Expires, EvadedOffense, Offender, Offense, Punisher, Type, Timestamp
FROM Penalties FROM Penalties
ORDER BY Timestamp DESC ORDER BY Timestamp DESC
""") """)
penalties = new_cur.fetchall() penalties = new_cur.fetchall()
# Create a list of dictionaries representing the penalties # Create a list of dictionaries representing the penalties
penalties_list = [] penalties_list = []
for row in penalties: for row in penalties:
penalties_list.append({ penalties_list.append({
"PenaltyId": row[0], "PenaltyId": row[0],
"AutomatedOffense": row[1], "AutomatedOffense": row[1],
"Expires": row[2], "Expires": row[2],
"EvadedOffense": row[3], "EvadedOffense": row[3],
"Offender": row[4], "Offender": row[4],
"Offense": row[5], "Offense": row[5],
"Punisher": row[6], "Punisher": row[6],
"Type": row[7], "Type": row[7],
"Timestamp": row[8] "Timestamp": row[8]
}) })
# Write the penalties to a JSON file # Write the penalties to a JSON file
with open("Penalties.json", "w") as f: with open("Penalties.json", "w") as f:
json.dump(penalties_list, f, indent=2) json.dump(penalties_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,71 +1,71 @@
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the modified EFPenaltyIdentifiers table in the new database # Create the modified EFPenaltyIdentifiers table in the new database
new_cur.execute(""" new_cur.execute("""
CREATE TABLE "PenaltyIdentifiers" ( CREATE TABLE "PenaltyIdentifiers" (
"PenaltyIdentifierId" INTEGER NOT NULL, "PenaltyIdentifierId" INTEGER NOT NULL,
"PenaltyId" INTEGER NOT NULL, "PenaltyId" INTEGER NOT NULL,
"Created" TEXT NOT NULL, "Created" TEXT NOT NULL,
"Client" TEXT NOT NULL "Client" TEXT NOT NULL
) )
""") """)
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFPenaltyIdentifiers.PenaltyIdentifierId, EFPenaltyIdentifiers.PenaltyIdentifierId,
EFPenaltyIdentifiers.PenaltyId, EFPenaltyIdentifiers.PenaltyId,
EFPenaltyIdentifiers.CreatedDateTime, EFPenaltyIdentifiers.CreatedDateTime,
EFPenaltyIdentifiers.NetworkId EFPenaltyIdentifiers.NetworkId
FROM FROM
EFPenaltyIdentifiers EFPenaltyIdentifiers
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
for row in rows: for row in rows:
penalty_identifier_id = row[0] penalty_identifier_id = row[0]
penalty_id = row[1] penalty_id = row[1]
created = row[2] created = row[2]
network_id = row[3] network_id = row[3]
existing_cur.execute(""" existing_cur.execute("""
SELECT SELECT
EFAlias.Name EFAlias.Name
FROM FROM
EFAlias EFAlias
INNER JOIN INNER JOIN
EFClients ON EFAlias.AliasId = EFClients.CurrentAliasId EFClients ON EFAlias.AliasId = EFClients.CurrentAliasId
WHERE WHERE
EFClients.NetworkId = ? EFClients.NetworkId = ?
""", (network_id,)) """, (network_id,))
client_name = existing_cur.fetchone() client_name = existing_cur.fetchone()
if client_name: if client_name:
client_name = client_name[0].replace('^7', '') client_name = client_name[0].replace('^7', '')
else: else:
client_name = 'Unknown' client_name = 'Unknown'
new_cur.execute(""" new_cur.execute("""
INSERT INTO PenaltyIdentifiers ( INSERT INTO PenaltyIdentifiers (
PenaltyIdentifierId, PenaltyIdentifierId,
PenaltyId, PenaltyId,
Created, Created,
Client Client
) )
VALUES (?, ?, ?, ?) VALUES (?, ?, ?, ?)
""", (penalty_identifier_id, penalty_id, created, client_name)) """, (penalty_identifier_id, penalty_id, created, client_name))
# Commit changes and close the new database # Commit changes and close the new database
new_conn.commit() new_conn.commit()
new_conn.close() new_conn.close()
# Close the existing database # Close the existing database
existing_conn.close() existing_conn.close()

View File

@ -1,26 +1,26 @@
import sqlite3 import sqlite3
import json import json
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
new_cur.execute(""" new_cur.execute("""
SELECT PenaltyIdentifierId, PenaltyId, Created, Client SELECT PenaltyIdentifierId, PenaltyId, Created, Client
FROM PenaltyIdentifiers FROM PenaltyIdentifiers
ORDER BY Created DESC ORDER BY Created DESC
""") """)
penalty_identifiers = new_cur.fetchall() penalty_identifiers = new_cur.fetchall()
penalty_identifiers_list = [] penalty_identifiers_list = []
for row in penalty_identifiers: for row in penalty_identifiers:
penalty_identifiers_list.append({ penalty_identifiers_list.append({
"PenaltyIdentifierId": row[0], "PenaltyIdentifierId": row[0],
"PenaltyId": row[1], "PenaltyId": row[1],
"Created": row[2], "Created": row[2],
"Client": row[3] "Client": row[3]
}) })
with open("PenaltyIdentifiers.json", "w") as f: with open("PenaltyIdentifiers.json", "w") as f:
json.dump(penalty_identifiers_list, f, indent=2) json.dump(penalty_identifiers_list, f, indent=2)
new_conn.close() new_conn.close()

View File

@ -1,67 +1,67 @@
# EFServers # EFServers
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the modified Servers table in the new database # Create the modified Servers table in the new database
new_cur.execute(""" new_cur.execute("""
CREATE TABLE "Servers" ( CREATE TABLE "Servers" (
"ServerId" INTEGER NOT NULL, "ServerId" INTEGER NOT NULL,
"Active" INTEGER NOT NULL, "Active" INTEGER NOT NULL,
"Port" INTEGER NOT NULL, "Port" INTEGER NOT NULL,
"Endpoint" TEXT NOT NULL, "Endpoint" TEXT NOT NULL,
"Game" TEXT NOT NULL, "Game" TEXT NOT NULL,
"ServerName" TEXT NOT NULL, "ServerName" TEXT NOT NULL,
"Password" TEXT NOT NULL "Password" TEXT NOT NULL
) )
""") """)
# Fetch data from existing EFServers # Fetch data from existing EFServers
existing_cur.execute(""" existing_cur.execute("""
SELECT ServerId, Active, Port, Endpoint, GameName, HostName, IsPasswordProtected SELECT ServerId, Active, Port, Endpoint, GameName, HostName, IsPasswordProtected
FROM EFServers FROM EFServers
""") """)
rows = existing_cur.fetchall() rows = existing_cur.fetchall()
# Define the game name mapping # Define the game name mapping
game_mapping = {5: "WaW", 7: "BO2", 6: "BO", 3: "MW3"} game_mapping = {5: "WaW", 7: "BO2", 6: "BO", 3: "MW3"}
for row in rows: for row in rows:
server_id = row[0] server_id = row[0]
active = row[1] active = row[1]
port = row[2] port = row[2]
endpoint = row[3] endpoint = row[3]
game_name = row[4] game_name = row[4]
server_name = row[5] server_name = row[5]
is_password_protected = row[6] is_password_protected = row[6]
# Replace the game_name with corresponding text # Replace the game_name with corresponding text
game_name = game_mapping.get(game_name, game_name) game_name = game_mapping.get(game_name, game_name)
# Replace the IsPasswordProtected values with 'Yes' or 'No' # Replace the IsPasswordProtected values with 'Yes' or 'No'
password = "Yes" if is_password_protected == 1 else "No" password = "Yes" if is_password_protected == 1 else "No"
# Insert the modified row into the new Servers table # Insert the modified row into the new Servers table
new_cur.execute(""" new_cur.execute("""
INSERT INTO Servers ( INSERT INTO Servers (
ServerId, ServerId,
Active, Active,
Port, Port,
Endpoint, Endpoint,
Game, Game,
ServerName, ServerName,
Password Password
) VALUES (?, ?, ?, ?, ?, ?, ?) ) VALUES (?, ?, ?, ?, ?, ?, ?)
""", (server_id, active, port, endpoint, game_name, server_name, password)) """, (server_id, active, port, endpoint, game_name, server_name, password))
# Commit the changes and close the connections # Commit the changes and close the connections
new_conn.commit() new_conn.commit()
existing_conn.close() existing_conn.close()
new_conn.close() new_conn.close()

View File

@ -1,33 +1,33 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Database.db") new_conn = sqlite3.connect("Database.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the Servers table # Fetch data from the Servers table
new_cur.execute(""" new_cur.execute("""
SELECT ServerId, Active, Port, Endpoint, Game, ServerName, Password SELECT ServerId, Active, Port, Endpoint, Game, ServerName, Password
FROM Servers FROM Servers
""") """)
servers = new_cur.fetchall() servers = new_cur.fetchall()
# Create a list of dictionaries representing the servers # Create a list of dictionaries representing the servers
servers_list = [] servers_list = []
for row in servers: for row in servers:
servers_list.append({ servers_list.append({
"ServerId": row[0], "ServerId": row[0],
"Active": row[1], "Active": row[1],
"Port": row[2], "Port": row[2],
"Endpoint": row[3], "Endpoint": row[3],
"Game": row[4], "Game": row[4],
"ServerName": row[5], "ServerName": row[5],
"Password": row[6] "Password": row[6]
}) })
# Write the servers data to a JSON file # Write the servers data to a JSON file
with open("Servers.json", "w") as f: with open("Servers.json", "w") as f:
json.dump(servers_list, f, indent=2) json.dump(servers_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,56 +1,56 @@
import sqlite3 import sqlite3
# Connect to the existing database # Connect to the existing database
existing_conn = sqlite3.connect("Database.db") existing_conn = sqlite3.connect("Database.db")
existing_cur = existing_conn.cursor() existing_cur = existing_conn.cursor()
# Create a new database # Create a new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Create the new InboxMessagesModified table # Create the new InboxMessagesModified table
new_cur.execute(""" new_cur.execute("""
CREATE TABLE InboxMessagesModified ( CREATE TABLE InboxMessagesModified (
InboxMessageId INTEGER PRIMARY KEY, InboxMessageId INTEGER PRIMARY KEY,
Created TEXT, Created TEXT,
Origin TEXT, Origin TEXT,
Target TEXT, Target TEXT,
ServerId INTEGER, ServerId INTEGER,
Message TEXT, Message TEXT,
Read TEXT Read TEXT
) )
""") """)
# Fetch data from the InboxMessages table # Fetch data from the InboxMessages table
existing_cur.execute("SELECT * FROM InboxMessages") existing_cur.execute("SELECT * FROM InboxMessages")
inbox_messages = existing_cur.fetchall() inbox_messages = existing_cur.fetchall()
# Iterate through the InboxMessages and insert modified data into the new table # Iterate through the InboxMessages and insert modified data into the new table
for msg in inbox_messages: for msg in inbox_messages:
msg_id, created, _, source_client_id, dest_client_id, server_id, message, is_delivered = msg msg_id, created, _, source_client_id, dest_client_id, server_id, message, is_delivered = msg
# Find the SourceClientId and DestinationClientId names # Find the SourceClientId and DestinationClientId names
for client_id in (source_client_id, dest_client_id): for client_id in (source_client_id, dest_client_id):
existing_cur.execute("SELECT CurrentAliasId FROM EFClients WHERE ClientId = ?", (client_id,)) existing_cur.execute("SELECT CurrentAliasId FROM EFClients WHERE ClientId = ?", (client_id,))
alias_id = existing_cur.fetchone()[0] alias_id = existing_cur.fetchone()[0]
existing_cur.execute("SELECT Name FROM EFAlias WHERE AliasId = ?", (alias_id,)) existing_cur.execute("SELECT Name FROM EFAlias WHERE AliasId = ?", (alias_id,))
name = existing_cur.fetchone()[0].replace('^7', '') name = existing_cur.fetchone()[0].replace('^7', '')
if client_id == source_client_id: if client_id == source_client_id:
origin = name origin = name
else: else:
target = name target = name
# Update Read status # Update Read status
read = "Yes" if is_delivered == 1 else "No" read = "Yes" if is_delivered == 1 else "No"
# Insert the modified data into the new table # Insert the modified data into the new table
new_cur.execute(""" new_cur.execute("""
INSERT INTO InboxMessagesModified (InboxMessageId, Created, Origin, Target, ServerId, Message, Read) INSERT INTO InboxMessagesModified (InboxMessageId, Created, Origin, Target, ServerId, Message, Read)
VALUES (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
""", (msg_id, created, origin, target, server_id, message, read)) """, (msg_id, created, origin, target, server_id, message, read))
# Commit the changes and close the connections # Commit the changes and close the connections
new_conn.commit() new_conn.commit()
existing_conn.close() existing_conn.close()
new_conn.close() new_conn.close()

View File

@ -1,34 +1,34 @@
import sqlite3 import sqlite3
import json import json
# Connect to the new database # Connect to the new database
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# Fetch data from the InboxMessagesModified table # Fetch data from the InboxMessagesModified table
new_cur.execute(""" new_cur.execute("""
SELECT InboxMessageId, Created, Origin, Target, ServerId, Message, Read SELECT InboxMessageId, Created, Origin, Target, ServerId, Message, Read
FROM InboxMessagesModified FROM InboxMessagesModified
ORDER BY Created DESC ORDER BY Created DESC
""") """)
inbox_messages = new_cur.fetchall() inbox_messages = new_cur.fetchall()
# Create a list of dictionaries representing the inbox messages # Create a list of dictionaries representing the inbox messages
inbox_messages_list = [] inbox_messages_list = []
for row in inbox_messages: for row in inbox_messages:
inbox_messages_list.append({ inbox_messages_list.append({
"InboxMessageId": row[0], "InboxMessageId": row[0],
"Created": row[1], "Created": row[1],
"Origin": row[2], "Origin": row[2],
"Target": row[3], "Target": row[3],
"ServerId": row[4], "ServerId": row[4],
"Message": row[5], "Message": row[5],
"Read": row[6] "Read": row[6]
}) })
# Write the inbox messages to a JSON file # Write the inbox messages to a JSON file
with open("InboxMessages.json", "w") as f: with open("InboxMessages.json", "w") as f:
json.dump(inbox_messages_list, f, indent=2) json.dump(inbox_messages_list, f, indent=2)
# Close the new database # Close the new database
new_conn.close() new_conn.close()

View File

@ -1,265 +1,265 @@
# Exports the newly created ClientConnectionHistory, IPAddresses, AuditLog, ClientConnectionHistory, ClientMessages, Clients, Maps, Metadata, Penalties, PenaltyIdentifiers, Servers & InboxMessages Tables to separate files in .json format. # Exports the newly created ClientConnectionHistory, IPAddresses, AuditLog, ClientConnectionHistory, ClientMessages, Clients, Maps, Metadata, Penalties, PenaltyIdentifiers, Servers & InboxMessages Tables to separate files in .json format.
# Created by Ahrimdon aided by GPT-4 # Created by Ahrimdon aided by GPT-4
import sqlite3 import sqlite3
import json import json
new_conn = sqlite3.connect("Plutonium_Servers.db") new_conn = sqlite3.connect("Plutonium_Servers.db")
new_cur = new_conn.cursor() new_cur = new_conn.cursor()
# ------------------- IPAddresses Table ------------------- # ------------------- IPAddresses Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT Name, SearchableIPAddress, DateAdded FROM "IPAddresses" SELECT Name, SearchableIPAddress, DateAdded FROM "IPAddresses"
ORDER BY DateAdded DESC ORDER BY DateAdded DESC
""") """)
client_info = new_cur.fetchall() client_info = new_cur.fetchall()
client_info_list = [] client_info_list = []
for row in client_info: for row in client_info:
client_info_list.append({ client_info_list.append({
"Name": row[0], "Name": row[0],
"SearchableIPAddress": row[1], "SearchableIPAddress": row[1],
"DateAdded": row[2] "DateAdded": row[2]
}) })
with open("IPAddresses.json", "w") as f: with open("IPAddresses.json", "w") as f:
json.dump(client_info_list, f, indent=2) json.dump(client_info_list, f, indent=2)
# ------------------- AuditLog Table ------------------- # ------------------- AuditLog Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT ChangeHistoryId, TypeOfChange, Time, Data, Command, Origin, Target FROM AuditLog SELECT ChangeHistoryId, TypeOfChange, Time, Data, Command, Origin, Target FROM AuditLog
ORDER BY Time DESC ORDER BY Time DESC
""") """)
ef_change_history = new_cur.fetchall() ef_change_history = new_cur.fetchall()
ef_change_history_list = [] ef_change_history_list = []
for row in ef_change_history: for row in ef_change_history:
ef_change_history_list.append({ ef_change_history_list.append({
"ChangeHistoryId": row[0], "ChangeHistoryId": row[0],
"TypeOfChange": row[1], "TypeOfChange": row[1],
"Time": row[2], "Time": row[2],
"Data": row[3], "Data": row[3],
"Command": row[4], "Command": row[4],
"Origin": row[5], "Origin": row[5],
"Target": row[6] "Target": row[6]
}) })
with open("AuditLog.json", "w") as f: with open("AuditLog.json", "w") as f:
json.dump(ef_change_history_list, f, indent=2) json.dump(ef_change_history_list, f, indent=2)
# ------------------- ClientConnectionHistory Table ------------------- # ------------------- ClientConnectionHistory Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT ConnectionId, Client, ConnectionTime, ConnectionType, Server SELECT ConnectionId, Client, ConnectionTime, ConnectionType, Server
FROM ClientConnectionHistory FROM ClientConnectionHistory
ORDER BY ConnectionTime DESC ORDER BY ConnectionTime DESC
""") """)
client_connection_history = new_cur.fetchall() client_connection_history = new_cur.fetchall()
client_connection_history_list = [] client_connection_history_list = []
for row in client_connection_history: for row in client_connection_history:
client_connection_history_list.append({ client_connection_history_list.append({
"ConnectionId": row[0], "ConnectionId": row[0],
"Client": row[1], "Client": row[1],
"ConnectionTime": row[2], "ConnectionTime": row[2],
"ConnectionType": row[3], "ConnectionType": row[3],
"Server": row[4] "Server": row[4]
}) })
with open("ClientConnectionHistory.json", "w") as f: with open("ClientConnectionHistory.json", "w") as f:
json.dump(client_connection_history_list, f, indent=2) json.dump(client_connection_history_list, f, indent=2)
# ------------------- Messages Table ------------------- # ------------------- Messages Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT MessageId, Client, Message, TimeSent, Server SELECT MessageId, Client, Message, TimeSent, Server
FROM ClientMessages FROM ClientMessages
ORDER BY TimeSent DESC ORDER BY TimeSent DESC
""") """)
client_messages = new_cur.fetchall() client_messages = new_cur.fetchall()
client_messages_list = [] client_messages_list = []
for row in client_messages: for row in client_messages:
client_messages_list.append({ client_messages_list.append({
"MessageId": row[0], "MessageId": row[0],
"Client": row[1], "Client": row[1],
"Message": row[2], "Message": row[2],
"TimeSent": row[3], "TimeSent": row[3],
"Server": row[4] "Server": row[4]
}) })
with open("ClientMessages.json", "w") as f: with open("ClientMessages.json", "w") as f:
json.dump(client_messages_list, f, indent=2) json.dump(client_messages_list, f, indent=2)
# ------------------- Clients Table ------------------- # ------------------- Clients Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT Connections, Name, FirstConnection, Game, LastConnection, Level, Masked, TotalConnectionTime SELECT Connections, Name, FirstConnection, Game, LastConnection, Level, Masked, TotalConnectionTime
FROM Clients FROM Clients
ORDER BY LastConnection DESC ORDER BY LastConnection DESC
""") """)
clients = new_cur.fetchall() clients = new_cur.fetchall()
clients_list = [] clients_list = []
for row in clients: for row in clients:
clients_list.append({ clients_list.append({
"Connections": row[0], "Connections": row[0],
"Name": row[1], "Name": row[1],
"FirstConnection": row[2], "FirstConnection": row[2],
"Game": row[3], "Game": row[3],
"LastConnection": row[4], "LastConnection": row[4],
"Level": row[5], "Level": row[5],
"Masked": row[6], "Masked": row[6],
"TotalConnectionTime": row[7] "TotalConnectionTime": row[7]
}) })
with open("Clients.json", "w") as f: with open("Clients.json", "w") as f:
json.dump(clients_list, f, indent=2) json.dump(clients_list, f, indent=2)
# ------------------- Maps Table ------------------- # ------------------- Maps Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT SELECT
MapId, CreatedDateTime, Name, Game MapId, CreatedDateTime, Name, Game
FROM FROM
Maps Maps
ORDER BY ORDER BY
MapId DESC MapId DESC
""") """)
rows = new_cur.fetchall() rows = new_cur.fetchall()
maps_list = [] maps_list = []
for row in rows: for row in rows:
map_dict = { map_dict = {
"MapId": row[0], "MapId": row[0],
"CreatedDateTime": row[1], "CreatedDateTime": row[1],
"Name": row[2], "Name": row[2],
"Game": row[3] "Game": row[3]
} }
maps_list.append(map_dict) maps_list.append(map_dict)
with open("maps_export.json", "w") as json_file: with open("maps_export.json", "w") as json_file:
json.dump(maps_list, json_file, indent=4) json.dump(maps_list, json_file, indent=4)
# ------------------- Meta Table ------------------- # ------------------- Meta Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT MetaId, Name, Timestamp, Note, Value SELECT MetaId, Name, Timestamp, Note, Value
FROM Metadata FROM Metadata
ORDER BY Timestamp DESC ORDER BY Timestamp DESC
""") """)
metadata = new_cur.fetchall() metadata = new_cur.fetchall()
metadata_list = [] metadata_list = []
for row in metadata: for row in metadata:
metadata_list.append({ metadata_list.append({
"MetaId": row[0], "MetaId": row[0],
"Name": row[1], "Name": row[1],
"Timestamp": row[2], "Timestamp": row[2],
"Note": row[3], "Note": row[3],
"Value": row[4] "Value": row[4]
}) })
with open("Metadata.json", "w") as f: with open("Metadata.json", "w") as f:
json.dump(metadata_list, f, indent=2) json.dump(metadata_list, f, indent=2)
# ------------------- Penalties Table ------------------- # ------------------- Penalties Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT PenaltyId, AutomatedOffense, Expires, EvadedOffense, Offender, Offense, Punisher, Type, Timestamp SELECT PenaltyId, AutomatedOffense, Expires, EvadedOffense, Offender, Offense, Punisher, Type, Timestamp
FROM Penalties FROM Penalties
ORDER BY Timestamp DESC ORDER BY Timestamp DESC
""") """)
penalties = new_cur.fetchall() penalties = new_cur.fetchall()
penalties_list = [] penalties_list = []
for row in penalties: for row in penalties:
penalties_list.append({ penalties_list.append({
"PenaltyId": row[0], "PenaltyId": row[0],
"AutomatedOffense": row[1], "AutomatedOffense": row[1],
"Expires": row[2], "Expires": row[2],
"EvadedOffense": row[3], "EvadedOffense": row[3],
"Offender": row[4], "Offender": row[4],
"Offense": row[5], "Offense": row[5],
"Punisher": row[6], "Punisher": row[6],
"Type": row[7], "Type": row[7],
"Timestamp": row[8] "Timestamp": row[8]
}) })
with open("Penalties.json", "w") as f: with open("Penalties.json", "w") as f:
json.dump(penalties_list, f, indent=2) json.dump(penalties_list, f, indent=2)
# ------------------- PenaltyIdentifiers Table ------------------- # ------------------- PenaltyIdentifiers Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT PenaltyIdentifierId, PenaltyId, Created, Client SELECT PenaltyIdentifierId, PenaltyId, Created, Client
FROM PenaltyIdentifiers FROM PenaltyIdentifiers
ORDER BY Created DESC ORDER BY Created DESC
""") """)
penalty_identifiers = new_cur.fetchall() penalty_identifiers = new_cur.fetchall()
penalty_identifiers_list = [] penalty_identifiers_list = []
for row in penalty_identifiers: for row in penalty_identifiers:
penalty_identifiers_list.append({ penalty_identifiers_list.append({
"PenaltyIdentifierId": row[0], "PenaltyIdentifierId": row[0],
"PenaltyId": row[1], "PenaltyId": row[1],
"Created": row[2], "Created": row[2],
"Client": row[3] "Client": row[3]
}) })
with open("PenaltyIdentifiers.json", "w") as f: with open("PenaltyIdentifiers.json", "w") as f:
json.dump(penalty_identifiers_list, f, indent=2) json.dump(penalty_identifiers_list, f, indent=2)
# ------------------- Servers Table ------------------- # ------------------- Servers Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT ServerId, Active, Port, Endpoint, Game, ServerName, Password SELECT ServerId, Active, Port, Endpoint, Game, ServerName, Password
FROM Servers FROM Servers
""") """)
servers = new_cur.fetchall() servers = new_cur.fetchall()
servers_list = [] servers_list = []
for row in servers: for row in servers:
servers_list.append({ servers_list.append({
"ServerId": row[0], "ServerId": row[0],
"Active": row[1], "Active": row[1],
"Port": row[2], "Port": row[2],
"Endpoint": row[3], "Endpoint": row[3],
"Game": row[4], "Game": row[4],
"ServerName": row[5], "ServerName": row[5],
"Password": row[6] "Password": row[6]
}) })
with open("Servers.json", "w") as f: with open("Servers.json", "w") as f:
json.dump(servers_list, f, indent=2) json.dump(servers_list, f, indent=2)
# ------------------- InboxMessages Table ------------------- # ------------------- InboxMessages Table -------------------
new_cur.execute(""" new_cur.execute("""
SELECT InboxMessageId, Created, Origin, Target, ServerId, Message, Read SELECT InboxMessageId, Created, Origin, Target, ServerId, Message, Read
FROM InboxMessagesModified FROM InboxMessagesModified
ORDER BY Created DESC ORDER BY Created DESC
""") """)
inbox_messages = new_cur.fetchall() inbox_messages = new_cur.fetchall()
inbox_messages_list = [] inbox_messages_list = []
for row in inbox_messages: for row in inbox_messages:
inbox_messages_list.append({ inbox_messages_list.append({
"InboxMessageId": row[0], "InboxMessageId": row[0],
"Created": row[1], "Created": row[1],
"Origin": row[2], "Origin": row[2],
"Target": row[3], "Target": row[3],
"ServerId": row[4], "ServerId": row[4],
"Message": row[5], "Message": row[5],
"Read": row[6] "Read": row[6]
}) })
with open("InboxMessages.json", "w") as f: with open("InboxMessages.json", "w") as f:
json.dump(inbox_messages_list, f, indent=2) json.dump(inbox_messages_list, f, indent=2)
# ------------------- End ------------------- # ------------------- End -------------------
new_conn.close() new_conn.close()