<?php
echo "<h1>PHP Test Page</h1>";
echo "<p>PHP is working correctly!</p>";
echo "<p>PHP Version: " . phpversion() . "</p>";
echo "<p>Current directory: " . getcwd() . "</p>";
echo "<p>File: " . __FILE__ . "</p>";

// Check if we can include the database file
echo "<h2>Testing Database Connection...</h2>";
if (file_exists('config/database.php')) {
    echo "<p style='color: green;'>✓ Database config file exists</p>";
    require_once 'config/database.php';
    if (isset($pdo)) {
        echo "<p style='color: green;'>✓ Database connection established</p>";
    } else {
        echo "<p style='color: red;'>✗ Database connection failed</p>";
    }
} else {
    echo "<p style='color: red;'>✗ Database config file does not exist</p>";
}

// Check auth file
echo "<h2>Testing Auth File...</h2>";
if (file_exists('includes/auth.php')) {
    echo "<p style='color: green;'>✓ Auth file exists</p>";
} else {
    echo "<p style='color: red;'>✗ Auth file does not exist</p>";
}

// Check if session is working
session_start();
$_SESSION['test'] = 'working';
echo "<p>Session test: " . ($_SESSION['test'] ?? 'not working') . "</p>";

// List files in teachers directory
echo "<h2>Files in teachers directory:</h2>";
if (is_dir('teachers')) {
    $files = scandir('teachers');
    echo "<ul>";
    foreach ($files as $file) {
        if ($file !== '.' && $file !== '..') {
            $style = ($file === 'leave_application.php') ? 'style="color: blue; font-weight: bold;"' : '';
            echo "<li $style>$file</li>";
        }
    }
    echo "</ul>";
} else {
    echo "<p style='color: red;'>teachers directory does not exist</p>";
}

echo "<h2>Try these URLs:</h2>";
echo "<ul>";
echo "<li><a href='login.php'>Login Page</a></li>";
echo "<li><a href='index.php'>Home Page</a></li>";
echo "<li><a href='teachers/dashboard.php'>Teacher Dashboard</a></li>";
echo "<li><a href='teachers/leave_application.php'>Teacher Leave Application</a> (requires teacher login)</li>";
echo "</ul>";
?>