![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/public_html/ |
-- Security Intelligence Database Tables
-- Run this SQL to create the necessary tables for security monitoring
-- Security Events Table
CREATE TABLE IF NOT EXISTS security_events (
id INT AUTO_INCREMENT PRIMARY KEY,
event_type VARCHAR(100) NOT NULL,
user_id INT NULL,
admin_id INT NULL,
details TEXT,
ip_address VARCHAR(45),
user_agent TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL,
FOREIGN KEY (admin_id) REFERENCES users(id) ON DELETE SET NULL
);
-- Security Flags Table
CREATE TABLE IF NOT EXISTS security_flags (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
flag_type VARCHAR(50) NOT NULL,
details TEXT,
flagged_by INT NOT NULL,
is_resolved BOOLEAN DEFAULT FALSE,
resolved_at TIMESTAMP NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (flagged_by) REFERENCES users(id) ON DELETE CASCADE
);
-- IP Blacklist Table
CREATE TABLE IF NOT EXISTS ip_blacklist (
id INT AUTO_INCREMENT PRIMARY KEY,
ip_address VARCHAR(45) UNIQUE NOT NULL,
reason TEXT,
blocked_by INT NOT NULL,
blocked_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP NULL,
is_active BOOLEAN DEFAULT TRUE,
FOREIGN KEY (blocked_by) REFERENCES users(id) ON DELETE CASCADE
);
-- User Login History Table
CREATE TABLE IF NOT EXISTS user_login_history (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
ip_address VARCHAR(45),
user_agent TEXT,
login_success BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
-- Add security columns to users table
ALTER TABLE users
ADD COLUMN IF NOT EXISTS is_blocked BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS block_reason TEXT NULL,
ADD COLUMN IF NOT EXISTS blocked_at TIMESTAMP NULL,
ADD COLUMN IF NOT EXISTS failed_login_attempts INT DEFAULT 0,
ADD COLUMN IF NOT EXISTS last_failed_login TIMESTAMP NULL,
ADD COLUMN IF NOT EXISTS last_login_ip VARCHAR(45) NULL,
ADD COLUMN IF NOT EXISTS last_login_at TIMESTAMP NULL,
ADD COLUMN IF NOT EXISTS security_level ENUM('low', 'medium', 'high') DEFAULT 'low';
-- Create indexes for performance
CREATE INDEX IF NOT EXISTS idx_security_events_type ON security_events(event_type);
CREATE INDEX IF NOT EXISTS idx_security_events_user ON security_events(user_id);
CREATE INDEX IF NOT EXISTS idx_security_events_created ON security_events(created_at);
CREATE INDEX IF NOT EXISTS idx_security_flags_user ON security_flags(user_id);
CREATE INDEX IF NOT EXISTS idx_security_flags_type ON security_flags(flag_type);
CREATE INDEX IF NOT EXISTS idx_ip_blacklist_ip ON ip_blacklist(ip_address);
CREATE INDEX IF NOT EXISTS idx_user_login_history_user ON user_login_history(user_id);
CREATE INDEX IF NOT EXISTS idx_user_login_history_ip ON user_login_history(ip_address);
-- Insert sample security event types
INSERT IGNORE INTO security_events (event_type, details, ip_address, created_at) VALUES
('system_startup', 'Security monitoring system initialized', '127.0.0.1', NOW()),
('admin_login', 'Admin panel accessed', '127.0.0.1', NOW()),
('security_scan', 'Security vulnerability scan completed', '127.0.0.1', NOW());