Path : /home/vishqocm/pcib.in/debug/
File Upload :
Current File : //home/vishqocm/pcib.in/debug/index.php

<?php
/**
 * Debug Tools Dashboard
 * 
 * This page provides access to various database maintenance and debugging tools.
 * 
 * IMPORTANT: For security reasons, this directory should not be accessible in production,
 * or should be protected with admin authentication.
 */

// Start session for authentication
session_start();

// Require authentication for security (uncomment for production)
/*
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
    header('Location: ../admin/login.php');
    exit();
}
*/

// Include database configuration if needed
// require_once '../admin/database/db_config.php';

// List of available tools
$tools = [
    [
        'id' => 'update_users_table',
        'name' => 'Update Users Table',
        'description' => 'Updates the users table with any missing required columns.',
        'path' => 'database/update_users_table.php',
        'icon' => 'fa-user-gear'
    ],
    [
        'id' => 'add_profile_image',
        'name' => 'Add Profile Image',
        'description' => 'Adds profile_image field to users table if missing.',
        'path' => 'database/add_profile_image.php',
        'icon' => 'fa-image'
    ],
    [
        'id' => 'add_team_columns',
        'name' => 'Add Team Management Columns',
        'description' => 'Adds columns for team management including social media links.',
        'path' => 'database/add_team_columns.php',
        'icon' => 'fa-users-gear'
    ],
    [
        'id' => 'create_theme_settings',
        'name' => 'Create Theme Settings',
        'description' => 'Creates the site_settings table and adds theme-related settings.',
        'path' => 'database/create_theme_settings.php',
        'icon' => 'fa-palette'
    ],
    [
        'id' => 'fix_enrollments',
        'name' => 'Fix Enrollments & Payments Tables',
        'description' => 'Fixes the enrollments and payments tables by adding or renaming student_id column to user_id. Resolves "Unknown column \'e.student_id\'" error.',
        'path' => 'database/fix_enrollments_table.php',
        'icon' => 'fa-table'
    ],
    [
        'id' => 'fix_enrollments_date',
        'name' => 'Fix Enrollments Date Column',
        'description' => 'Adds the missing enrollment_date column to the enrollments table. Resolves "Unknown column \'e.enrollment_date\'" error.',
        'path' => 'database/fix_enrollments_date.php',
        'icon' => 'fa-calendar'
    ],
    [
        'id' => 'fix_payments_date',
        'name' => 'Fix Payments Date Column',
        'description' => 'Adds the missing payment_date column to the payments table. Resolves "Unknown column \'p.payment_date\'" error.',
        'path' => 'database/fix_payments_date.php',
        'icon' => 'fa-credit-card'
    ],
    [
        'id' => 'fix_conn_variable',
        'name' => 'Fix Database Connection',
        'description' => 'Fixes "Undefined variable $conn" errors by ensuring proper database connection inclusion in header files.',
        'path' => 'database/fix_conn_variable.php',
        'icon' => 'fa-link'
    ],
    [
        'id' => 'create_default_assets',
        'name' => 'Create Default Assets',
        'description' => 'Creates required directories and default images.',
        'path' => 'database/create_default_assets.php',
        'icon' => 'fa-folder-plus'
    ],
    [
        'id' => 'add_user_roles',
        'name' => 'Add User Roles',
        'description' => 'Adds "Director" and "Developer" roles to the user roles in the database.',
        'path' => 'database/add_user_roles.php',
        'icon' => 'fa-user-tag'
    ],
    [
        'id' => 'create_oauth_providers_table',
        'name' => 'OAuth Providers Setup',
        'description' => 'Creates the oauth_providers table needed for Google and other social login methods.',
        'path' => 'database/create_oauth_providers_table.php',
        'icon' => 'fa-key'
    ],
    // Add more tools as needed
];

// Check if a backup was requested
if (isset($_GET['backup']) && $_GET['backup'] === 'db') {
    $backup_file = 'database_backup_' . date('Y-m-d_H-i-s') . '.sql';
    // This is just a placeholder - actual implementation would require server access
    echo "Database backup functionality requires server access and would be implemented here.";
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Debug & Maintenance Tools</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        body {
            background-color: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        .container {
            max-width: 1000px;
            margin: 50px auto;
        }
        .header {
            background: #343a40;
            color: white;
            padding: 20px;
            border-radius: 8px 8px 0 0;
            margin-bottom: 0;
        }
        .header h1 {
            margin: 0;
            font-size: 24px;
        }
        .warning-box {
            background-color: #fff3cd;
            border-left: 4px solid #ffc107;
            padding: 15px;
            margin-bottom: 20px;
            color: #856404;
        }
        .card {
            border: none;
            box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
            margin-bottom: 20px;
            transition: transform 0.2s;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
        }
        .card-header {
            background-color: #f1f8ff;
            border-bottom: 1px solid rgba(0,0,0,.125);
            font-weight: 600;
        }
        .tool-icon {
            background: #e9ecef;
            width: 60px;
            height: 60px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 15px;
            color: #495057;
            font-size: 24px;
        }
        .actions {
            background: #f8f9fa;
            padding: 15px;
            border-radius: 0 0 8px 8px;
            margin-top: 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header d-flex justify-content-between align-items-center">
            <h1><i class="fas fa-screwdriver-wrench me-2"></i> Debug & Maintenance Tools</h1>
            <div>
                <a href="../admin/index.php" class="btn btn-outline-light btn-sm"><i class="fas fa-tachometer-alt me-1"></i> Admin Dashboard</a>
                <a href="../index.php" class="btn btn-outline-light btn-sm ms-2"><i class="fas fa-home me-1"></i> Homepage</a>
            </div>
        </div>
        
        <div class="bg-white p-4 shadow-sm">
            <div class="warning-box mb-4">
                <h5><i class="fas fa-exclamation-triangle me-2"></i> Warning</h5>
                <p class="mb-0">These tools are for maintenance purposes and should be used with caution. Make sure to backup your database before making any changes.</p>
            </div>
            
            <div class="d-flex justify-content-end mb-4">
                <a href="?backup=db" class="btn btn-warning btn-sm"><i class="fas fa-database me-1"></i> Backup Database</a>
            </div>
            
            <h4 class="mb-3">Available Tools</h4>
            <div class="row">
                <?php foreach ($tools as $tool): ?>
                <div class="col-md-6">
                    <div class="card">
                        <div class="card-header d-flex align-items-center">
                            <div class="tool-icon">
                                <i class="fas <?php echo $tool['icon']; ?>"></i>
                            </div>
                            <div>
                                <?php echo $tool['name']; ?>
                            </div>
                        </div>
                        <div class="card-body">
                            <p class="card-text"><?php echo $tool['description']; ?></p>
                            <a href="<?php echo $tool['path']; ?>" class="btn btn-primary btn-sm">Run Tool</a>
                        </div>
                    </div>
                </div>
                <?php endforeach; ?>
            </div>
        </div>
        
        <div class="actions d-flex justify-content-between">
            <div>
                <a href="#" onclick="window.history.back()" class="btn btn-secondary btn-sm"><i class="fas fa-arrow-left me-1"></i> Back</a>
            </div>
            <div>
                <span class="text-muted">Last updated: <?php echo date("Y-m-d H:i:s"); ?></span>
            </div>
        </div>
    </div>
    
    <!-- Bootstrap JS Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>