🐘
Error.php
Back
📝 Php ⚡ Executable Ctrl+S: Save • Ctrl+R: Run • Ctrl+F: Find
<?php // errorlog.php - Put this in your web root // Access it at: https://devbrewing.com/errorlog.php // Security: Add password protection $password = "devbrewing123"; // Change this! session_start(); if (!isset($_SESSION['logged_in'])) { if (isset($_POST['password']) && $_POST['password'] === $password) { $_SESSION['logged_in'] = true; } else { ?> <!DOCTYPE html> <html> <head> <title>Error Log Viewer</title> <style> body { font-family: monospace; background: #1e293b; color: #e2e8f0; padding: 40px; } input, button { padding: 10px; margin: 10px; font-size: 16px; } </style> </head> <body> <h2>Error Log Viewer - Login Required</h2> <form method="POST"> <input type="password" name="password" placeholder="Enter password" required> <button type="submit">Login</button> </form> </body> </html> <?php exit; } } // Logged in - show error log ?> <!DOCTYPE html> <html> <head> <title>PHP Error Log Viewer</title> <style> body { font-family: 'Courier New', monospace; background: #0f172a; color: #e2e8f0; padding: 20px; margin: 0; } h1 { color: #60a5fa; margin-bottom: 20px; } .controls { background: #1e293b; padding: 15px; border-radius: 8px; margin-bottom: 20px; } button { background: #3b82f6; color: white; border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; margin-right: 10px; } button:hover { opacity: 0.8; } .log-container { background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 20px; max-height: 80vh; overflow-y: auto; } .log-line { padding: 5px 0; border-bottom: 1px solid #334155; line-height: 1.6; } .error { color: #ef4444; } .warning { color: #f59e0b; } .notice { color: #60a5fa; } .info { color: #10b981; } .timestamp { color: #94a3b8; } .empty { color: #94a3b8; font-style: italic; text-align: center; padding: 40px; } </style> </head> <body> <h1>📋 PHP Error Log Viewer</h1> <div class="controls"> <button onclick="location.reload()">🔄 Refresh</button> <button onclick="clearLog()">🗑️ Clear Log</button> <button onclick="location.href='?logout=1'">🚪 Logout</button> <span style="margin-left: 20px; color: #94a3b8;"> Last updated: <?= date('Y-m-d H:i:s') ?> </span> </div> <div class="log-container" id="logContainer"> <?php // Logout handler if (isset($_GET['logout'])) { session_destroy(); header('Location: errorlog.php'); exit; } // Find PHP error log $logFiles = [ ini_get('error_log'), '/var/log/apache2/error.log', '/var/log/php/error.log', '/var/log/httpd/error_log', __DIR__ . '/php_errors.log', '/tmp/php_errors.log' ]; $logFile = null; foreach ($logFiles as $file) { if ($file && file_exists($file) && is_readable($file)) { $logFile = $file; break; } } if (!$logFile) { echo '<div class="empty">❌ Could not find PHP error log file.</div>'; echo '<div class="empty">Checked locations:<br>'; foreach ($logFiles as $file) { if ($file) echo htmlspecialchars($file) . '<br>'; } echo '</div>'; echo '<div class="empty">Current error_log setting: ' . htmlspecialchars(ini_get('error_log')) . '</div>'; } else { echo '<div class="empty" style="font-style: normal; color: #10b981;"> ✓ Reading from: ' . htmlspecialchars($logFile) . '</div>'; // Read last 200 lines $lines = file($logFile); if ($lines === false || count($lines) === 0) { echo '<div class="empty">Log file is empty or unreadable.</div>'; } else { $lines = array_slice($lines, -200); $lines = array_reverse($lines); foreach ($lines as $line) { $line = htmlspecialchars($line); $class = 'log-line'; if (stripos($line, 'error') !== false) $class .= ' error'; elseif (stripos($line, 'warning') !== false) $class .= ' warning'; elseif (stripos($line, 'notice') !== false) $class .= ' notice'; else $class .= ' info'; // Highlight newfile.php entries if (stripos($line, 'newfile.php') !== false) { $line = '<strong style="background: #374151; padding: 2px 4px; border-radius: 3px;">' . $line . '</strong>'; } echo '<div class="' . $class . '">' . $line . '</div>'; } } } ?> </div> <script> function clearLog() { if (confirm('Are you sure you want to clear the error log?')) { fetch('?clear=1') .then(() => location.reload()); } } // Auto-refresh every 10 seconds setTimeout(() => location.reload(), 10000); </script> </body> </html> <?php // Handle clear log request if (isset($_GET['clear']) && $logFile && is_writable($logFile)) { file_put_contents($logFile, ''); exit('cleared'); } ?>