🌙 File Manager - @r3dc0d3r1337-WORDPRESS
PHP:
8.1.34
Server:
LiteSpeed
OS:
Linux 5.14.0-611.34.1.el9_7.x86_64
User:
fastear1
Navigate
Upload:
Upload
New File
New Folder
Editing: update_db.php
<?php /** * Database Update Script * Run this file ONCE to add missing columns to existing database * Access: http://localhost/222/fast-earn-limited/update_db.php */ require_once 'includes/config.php'; echo "<!DOCTYPE html> <html> <head> <title>Database Update</title> <style> body { font-family: Arial, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; background: #f5f5f5; } .success { background: #d4edda; color: #155724; padding: 15px; border-radius: 5px; margin: 10px 0; } .error { background: #f8d7da; color: #721c24; padding: 15px; border-radius: 5px; margin: 10px 0; } .info { background: #d1ecf1; color: #0c5460; padding: 15px; border-radius: 5px; margin: 10px 0; } h1 { color: #333; } pre { background: #fff; padding: 10px; border-radius: 5px; overflow-x: auto; } </style> </head> <body> <h1>🔧 Database Update Script</h1> "; try { echo "<div class='info'>Starting database update...</div>"; // Check if columns already exist $stmt = $pdo->query("SHOW COLUMNS FROM users LIKE 'username'"); $usernameExists = $stmt->rowCount() > 0; $stmt = $pdo->query("SHOW COLUMNS FROM users LIKE 'role'"); $roleExists = $stmt->rowCount() > 0; // Add username column if it doesn't exist if (!$usernameExists) { echo "<div class='info'>Adding 'username' column...</div>"; $pdo->exec("ALTER TABLE users ADD COLUMN username VARCHAR(50) UNIQUE DEFAULT NULL COMMENT 'Username for admin login' AFTER id"); echo "<div class='success'>✓ Added 'username' column</div>"; } else { echo "<div class='info'>✓ 'username' column already exists</div>"; } // Add role column if it doesn't exist if (!$roleExists) { echo "<div class='info'>Adding 'role' column...</div>"; $pdo->exec("ALTER TABLE users ADD COLUMN role ENUM('user', 'admin') DEFAULT 'user' COMMENT 'User role' AFTER password"); echo "<div class='success'>✓ Added 'role' column</div>"; } else { echo "<div class='info'>✓ 'role' column already exists</div>"; } // Update admin user (ID = 1) echo "<div class='info'>Updating admin user...</div>"; $stmt = $pdo->prepare("UPDATE users SET username = ?, role = ?, full_name = ? WHERE id = 1"); $stmt->execute(['admin', 'admin', 'Administrator']); echo "<div class='success'>✓ Admin user updated (username: admin, role: admin)</div>"; // Set all other users to role 'user' echo "<div class='info'>Setting role for existing users...</div>"; $pdo->exec("UPDATE users SET role = 'user' WHERE id != 1 AND (role IS NULL OR role = '')"); echo "<div class='success'>✓ All users updated with role='user'</div>"; // Show admin credentials echo "<div class='success'> <h2>✅ Database Update Complete!</h2> <p><strong>Admin Login Credentials:</strong></p> <pre> URL: http://localhost/222/fast-earn-limited/admin/login.php Username: admin Email: admin@fastearn.com Phone: 03000000000 Password: admin123 </pre> <p><strong>User Login:</strong></p> <pre> URL: http://localhost/222/fast-earn-limited/login.php </pre> </div>"; echo "<div class='info'> <strong>⚠️ IMPORTANT:</strong> For security, please delete this file (update_db.php) after running it. </div>"; echo "<div style='margin-top: 20px;'> <a href='admin/login.php' style='display: inline-block; background: #007bff; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; margin-right: 10px;'> Go to Admin Login </a> <a href='login.php' style='display: inline-block; background: #28a745; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px;'> Go to User Login </a> </div>"; } catch (PDOException $e) { echo "<div class='error'> <h3>❌ Error:</h3> <pre>" . htmlspecialchars($e->getMessage()) . "</pre> </div>"; } echo "</body></html>"; ?>
Save Changes
Cancel
Create New File
Create New Folder