nano-pro/server-check.php
DJP f7ea6006db Fix config to always define SSO constants
Updated config.example.php to match working config structure:

Changes:
- Load env_loader.php with file_exists check
- Always define SSO_ENABLED, SSO_TENANT_ID, SSO_CLIENT_ID
- Use !defined() checks to prevent redefinition errors
- Defaults to false/empty if .env not found
- Added error reporting settings

Server-check.php improvements:
- Shows actual SSO constant values (TRUE/FALSE/EMPTY)
- Better diagnostic output

DEPLOYMENT FIX:
On server, update config.php to match config.example.php structure.
This ensures SSO constants are always defined.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-16 11:23:47 -05:00

154 lines
6.5 KiB
PHP

<?php
/**
* Server Diagnostic Script
* Visit this page to see what's wrong with the deployment
*/
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
<head>
<title>Server Diagnostic - Nano Banana Pro</title>
<style>
body { font-family: monospace; background: #000; color: #0f0; padding: 20px; }
.section { background: #1a1a1a; padding: 15px; margin: 10px 0; border-left: 4px solid #0f0; }
.error { border-left-color: #f00; color: #f00; }
.warning { border-left-color: #ff0; color: #ff0; }
.success { border-left-color: #0f0; color: #0f0; }
h1 { color: #0ff; }
h2 { color: #ff0; }
pre { margin: 5px 0; }
</style>
</head>
<body>
<h1>=== NANO BANANA PRO SERVER DIAGNOSTIC ===</h1>
<div class="section">
<h2>1. PHP Information</h2>
<pre>PHP Version: <?php echo phpversion(); ?></pre>
<pre>Server: <?php echo $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown'; ?></pre>
<pre>Document Root: <?php echo $_SERVER['DOCUMENT_ROOT'] ?? 'Unknown'; ?></pre>
<pre>Current Directory: <?php echo __DIR__; ?></pre>
</div>
<div class="section <?php echo file_exists(__DIR__ . '/vendor') ? 'success' : 'error'; ?>">
<h2>2. Composer Dependencies (vendor/)</h2>
<?php if (file_exists(__DIR__ . '/vendor')): ?>
<pre>✓ vendor/ directory EXISTS</pre>
<pre>✓ Autoload: <?php echo file_exists(__DIR__ . '/vendor/autoload.php') ? 'EXISTS' : 'MISSING'; ?></pre>
<pre>✓ Firebase JWT: <?php echo file_exists(__DIR__ . '/vendor/firebase') ? 'INSTALLED' : 'MISSING'; ?></pre>
<?php else: ?>
<pre>✗ vendor/ directory MISSING</pre>
<pre>✗ FIX: Run 'composer install' on the server</pre>
<?php endif; ?>
</div>
<div class="section <?php echo file_exists(__DIR__ . '/config.php') ? 'success' : 'error'; ?>">
<h2>3. Configuration Files</h2>
<pre>config.php: <?php echo file_exists(__DIR__ . '/config.php') ? '✓ EXISTS' : '✗ MISSING'; ?></pre>
<pre>.env: <?php echo file_exists(__DIR__ . '/.env') ? '✓ EXISTS' : '⚠ MISSING (optional)'; ?></pre>
<pre>.env.example: <?php echo file_exists(__DIR__ . '/.env.example') ? '✓ EXISTS' : '✗ MISSING'; ?></pre>
</div>
<div class="section">
<h2>4. Critical Files Check</h2>
<?php
$criticalFiles = [
'index.php',
'api.php',
'auth.php',
'AuthMiddleware.php',
'JWTValidator.php',
'session_manager.php',
'env_loader.php',
'enhance_prompt.php'
];
foreach ($criticalFiles as $file):
?>
<pre><?php echo $file; ?>: <?php echo file_exists(__DIR__ . '/' . $file) ? '✓' : '✗ MISSING'; ?></pre>
<?php endforeach; ?>
</div>
<div class="section">
<h2>5. Directory Permissions</h2>
<?php
$uploads = __DIR__ . '/uploads';
$sessions = __DIR__ . '/uploads/sessions';
?>
<pre>uploads/: <?php echo is_dir($uploads) ? (is_writable($uploads) ? '✓ Writable' : '⚠ Not writable') : '✗ Missing'; ?></pre>
<pre>uploads/sessions/: <?php echo is_dir($sessions) ? (is_writable($sessions) ? '✓ Writable' : '⚠ Not writable') : '✗ Missing'; ?></pre>
</div>
<div class="section">
<h2>6. Testing File Loads</h2>
<?php
echo "<pre>Testing env_loader.php...</pre>";
try {
if (file_exists(__DIR__ . '/env_loader.php')) {
require_once __DIR__ . '/env_loader.php';
echo "<pre class='success'>✓ env_loader.php loaded successfully</pre>";
} else {
echo "<pre class='error'>✗ env_loader.php missing</pre>";
}
} catch (Exception $e) {
echo "<pre class='error'>✗ Error: " . htmlspecialchars($e->getMessage()) . "</pre>";
}
echo "<pre>Testing config.php...</pre>";
try {
if (file_exists(__DIR__ . '/config.php')) {
require_once __DIR__ . '/config.php';
echo "<pre class='success'>✓ config.php loaded successfully</pre>";
echo "<pre> GEMINI_API_KEY: " . (defined('GEMINI_API_KEY') && !empty(GEMINI_API_KEY) ? '✓ SET' : '✗ NOT SET') . "</pre>";
echo "<pre> SSO_ENABLED: " . (defined('SSO_ENABLED') ? (SSO_ENABLED ? 'TRUE' : 'FALSE') : '✗ NOT DEFINED') . "</pre>";
echo "<pre> SSO_TENANT_ID: " . (defined('SSO_TENANT_ID') ? (SSO_TENANT_ID ? '✓ SET' : 'EMPTY') : '✗ NOT DEFINED') . "</pre>";
echo "<pre> SSO_CLIENT_ID: " . (defined('SSO_CLIENT_ID') ? (SSO_CLIENT_ID ? '✓ SET' : 'EMPTY') : '✗ NOT DEFINED') . "</pre>";
} else {
echo "<pre class='error'>✗ config.php missing</pre>";
}
} catch (Exception $e) {
echo "<pre class='error'>✗ Error: " . htmlspecialchars($e->getMessage()) . "</pre>";
}
echo "<pre>Testing AuthMiddleware.php...</pre>";
try {
if (file_exists(__DIR__ . '/AuthMiddleware.php')) {
require_once __DIR__ . '/AuthMiddleware.php';
echo "<pre class='success'>✓ AuthMiddleware.php loaded successfully</pre>";
} else {
echo "<pre class='error'>✗ AuthMiddleware.php missing</pre>";
}
} catch (Exception $e) {
echo "<pre class='error'>✗ Error: " . htmlspecialchars($e->getMessage()) . "</pre>";
}
?>
</div>
<div class="section">
<h2>7. Next Steps</h2>
<?php if (!file_exists(__DIR__ . '/vendor')): ?>
<pre class="error">ACTION REQUIRED: Run 'composer install' on the server</pre>
<?php endif; ?>
<?php if (!file_exists(__DIR__ . '/config.php')): ?>
<pre class="error">ACTION REQUIRED: Copy config.example.php to config.php and add API key</pre>
<?php endif; ?>
<?php if (file_exists(__DIR__ . '/vendor') && file_exists(__DIR__ . '/config.php')): ?>
<pre class="success">✓ All critical files present - check error logs for specific PHP error</pre>
<?php endif; ?>
</div>
<h2>Deployment Checklist:</h2>
<pre>
1. git pull origin master
2. composer install
3. cp config.example.php config.php
4. Edit config.php (add Gemini API key)
5. cp .env.example .env
6. mkdir -p uploads/sessions
7. chmod 755 uploads/sessions
8. Visit index.php
</pre>
</body>
</html>