Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/update_chat_welcome.php

<?php
/**
 * Add chat_welcome_message setting to existing chatbot installations
 */

require_once 'config/config.php';

if (!isLoggedIn() || !isSuperuser()) {
    die('Access denied. Superuser access required.');
}

$db = Database::getInstance()->getConnection();

try {
    // Check if setting already exists
    $stmt = $db->prepare("SELECT * FROM chatbot_settings WHERE setting_key = 'chat_welcome_message'");
    $stmt->execute();
    $existing = $stmt->fetch();
    
    if ($existing) {
        echo "<h2 style='color: green;'>✅ Setting Already Exists</h2>";
        echo "<p>Current value: <strong>" . htmlspecialchars($existing['setting_value']) . "</strong></p>";
    } else {
        // Add the setting
        $stmt = $db->prepare("
            INSERT INTO chatbot_settings (setting_key, setting_value) 
            VALUES ('chat_welcome_message', 'Need help? Chat with us!')
        ");
        $stmt->execute();
        
        echo "<h2 style='color: green;'>✅ Setting Added Successfully!</h2>";
        echo "<p>Default value: <strong>Need help? Chat with us!</strong></p>";
    }
    
    echo "<hr>";
    echo "<h3>What This Does:</h3>";
    echo "<ul>";
    echo "<li>✨ Wider welcome bubble (350px)</li>";
    echo "<li>📝 Shorter, cleaner message</li>";
    echo "<li>⚙️ Admin can customize the message</li>";
    echo "</ul>";
    
    echo "<hr>";
    echo "<h3>Next Steps:</h3>";
    echo "<ol>";
    echo "<li>Go to <strong>AI Chatbot → Settings</strong></li>";
    echo "<li>Find the <strong>\"Popup Welcome Message (bubble)\"</strong> field</li>";
    echo "<li>Customize your message (keep it short!)</li>";
    echo "<li>Click Save Settings</li>";
    echo "</ol>";
    
    echo "<hr>";
    echo "<p>";
    echo "<a href='modules/chatbot/settings.php' style='display: inline-block; background: linear-gradient(135deg, #1E40AF 0%, #9333EA 100%); color: white; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: bold; margin-right: 10px;'>Go to Chatbot Settings</a>";
    echo "<a href='index.php' style='display: inline-block; background: linear-gradient(135deg, #F97316 0%, #FBBF24 100%); color: white; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: bold;'>Test on Home Page</a>";
    echo "</p>";
    
    echo "<p style='color: #666; margin-top: 30px; font-size: 14px;'><strong>Note:</strong> You can delete this file (update_chat_welcome.php) after running it.</p>";
    
} catch (Exception $e) {
    echo "<h2 style='color: red;'>❌ Error</h2>";
    echo "<p>" . htmlspecialchars($e->getMessage()) . "</p>";
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Update Chat Welcome Message</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 50px auto;
            padding: 20px;
            background: #f5f5f5;
        }
        h2, h3 {
            color: #333;
        }
        ul, ol {
            line-height: 1.8;
        }
    </style>
</head>
<body>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists