88 lines
4.1 KiB
PHP
88 lines
4.1 KiB
PHP
<?php
|
|
// ChurchTube Diagnostics Script
|
|
|
|
function check_status($condition, $success, $failure) {
|
|
if ($condition) {
|
|
echo "<li style='color: #4CAF50;'>[PASS] $success</li>";
|
|
} else {
|
|
echo "<li style='color: #f44336;'>[FAIL] $failure</li>";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>ChurchTube Diagnostics</title>
|
|
<link rel="stylesheet" href="assets/css/style.css">
|
|
<style>
|
|
.diag-box { background: #1e1e1e; padding: 30px; border-radius: 12px; margin-top: 50px; border: 1px solid #333; }
|
|
ul { list-style: none; padding: 0; }
|
|
li { padding: 12px; border-bottom: 1px solid #333; font-family: monospace; }
|
|
.advice { background: rgba(124, 77, 255, 0.1); padding: 15px; border-radius: 8px; margin-top: 20px; border-left: 4px solid var(--primary-color); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="centered-container" style="max-width: 800px;">
|
|
<h1 class="logo">ChurchTube Diagnostics</h1>
|
|
<div class="diag-box">
|
|
<h3>System Health Check</h3>
|
|
<ul>
|
|
<?php
|
|
// PHP Version
|
|
check_status(version_compare(PHP_VERSION, '7.4.0', '>='),
|
|
"PHP Version: " . PHP_VERSION,
|
|
"PHP Version: " . PHP_VERSION . " (Requires 7.4+)");
|
|
|
|
// Extensions
|
|
check_status(extension_loaded('pdo_mysql'), "PDO MySQL extension is loaded.", "PDO MySQL extension is MISSING.");
|
|
check_status(extension_loaded('curl'), "CURL extension is loaded.", "CURL extension is MISSING (required for external link validation).");
|
|
|
|
// Config File
|
|
$has_config = file_exists('includes/config.php');
|
|
if (check_status($has_config, "Configuration file exists.", "Configuration file (includes/config.php) is MISSING.")) {
|
|
require_once 'includes/config.php';
|
|
// DB Connection
|
|
try {
|
|
$pdo = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER, DB_PASS);
|
|
check_status(true, "Database connection established successfully.", "");
|
|
} catch (Exception $e) {
|
|
check_status(false, "", "Database connection failed: " . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
// Write Permissions
|
|
check_status(is_writable('uploads'), "Uploads directory is writable.", "Uploads directory is NOT writable. Run: chmod 777 uploads");
|
|
|
|
// PHP Settings
|
|
$upload_max = ini_get('upload_max_filesize');
|
|
$post_max = ini_get('post_max_size');
|
|
$is_low = (int)$upload_max < 100 || (int)$post_max < 100;
|
|
|
|
if ($is_low) {
|
|
echo "<li style='color: #ffab40;'>[WARN] Max Upload Size: $upload_max (Post Max: $post_max) - This is low for videos!</li>";
|
|
} else {
|
|
echo "<li style='color: #4CAF50;'>[PASS] Max Upload Size: $upload_max (Post Max: $post_max)</li>";
|
|
}
|
|
?>
|
|
</ul>
|
|
|
|
<div class="advice">
|
|
<h4>Pro-Tips & Fixes:</h4>
|
|
<ul style="border:none; margin-top: 10px;">
|
|
<li><strong>MySQL Issues?</strong> Run: <code>sudo systemctl status mysql</code>. If stopped, run <code>sudo systemctl start mysql</code>.</li>
|
|
<li><strong>Upload Limits?</strong> Edit <code>/etc/php/7.4/apache2/php.ini</code>. Look for <code>upload_max_filesize</code> and <code>post_max_size</code>. Set them to <code>500M</code> or more, then run <code>sudo systemctl restart apache2</code>.</li>
|
|
<li><strong>Permission Issues?</strong> Run: <code>sudo chmod -R 777 uploads/</code> to ensure the web server can save video files.</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div style="margin-top: 20px; text-align: center;">
|
|
<a href="index.php" class="btn btn-primary">Back to Site</a>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|