MMCT TEAM
Server IP : 103.191.208.50  /  Your IP : 216.73.216.53
Web Server : LiteSpeed
System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64
User : celkcksm ( 1031)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, popen, exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/celkcksm/ecampus.ncriptech.com/../acadevo.in/config/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/celkcksm/ecampus.ncriptech.com/../acadevo.in/config/dashboard.php
<?php
// Include config.php to load variables
include 'config.php';

// Handle form submissions
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Load the entire config.php content
    $config_content = file_get_contents('config.php');

    if (isset($_POST['site_form'])) {
        // Update site settings
        $new_site_name = $_POST['site_name'] ?? $site_name;
        $new_site_short_name = $_POST['site_short_name'] ?? $site_short_name;

        // Update site_name and site_short_name
        $config_content = preg_replace(
            '/\$site_name\s*=\s*"[^"]*";/',
            '$site_name = "' . addslashes($new_site_name) . '";',
            $config_content
        );
        $config_content = preg_replace(
            '/\$site_short_name\s*=\s*"[^"]*";/',
            '$site_short_name = "' . addslashes($new_site_short_name) . '";',
            $config_content
        );
    } elseif (isset($_POST['page_form'])) {
        // Update or add page settings
        $page_key = $_POST['page_key'] ?? '';
        $new_title = $_POST['page_title'] ?? '';
        $new_description = $_POST['page_description'] ?? '';
        $new_keywords = $_POST['page_keywords'] ?? '';

        if ($page_key) {
            // Update arrays in memory
            $page_title[$page_key] = $new_title;
            $page_description[$page_key] = $new_description;
            $page_keywords[$page_key] = $new_keywords;

            // Format arrays as PHP code
            $page_title_export = var_export($page_title, true);
            $page_description_export = var_export($page_description, true);
            $page_keywords_export = var_export($page_keywords, true);

            // Replace array definitions in config.php
            $config_content = preg_replace(
                '/\$page_title\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_title = ' . $page_title_export . ';',
                $config_content
            );
            $config_content = preg_replace(
                '/\$page_description\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_description = ' . $page_description_export . ';',
                $config_content
            );
            $config_content = preg_replace(
                '/\$page_keywords\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_keywords = ' . $page_keywords_export . ';',
                $config_content
            );
        }
    } elseif (isset($_POST['delete_page_form'])) {
        // Delete page settings
        $page_key = $_POST['page_key'] ?? '';

        if ($page_key && isset($page_title[$page_key])) {
            // Remove entries from arrays
            unset($page_title[$page_key]);
            unset($page_description[$page_key]);
            unset($page_keywords[$page_key]);

            // Format arrays as PHP code
            $page_title_export = var_export($page_title, true);
            $page_description_export = var_export($page_description, true);
            $page_keywords_export = var_export($page_keywords, true);

            // Replace array definitions in config.php
            $config_content = preg_replace(
                '/\$page_title\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_title = ' . $page_title_export . ';',
                $config_content
            );
            $config_content = preg_replace(
                '/\$page_description\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_description = ' . $page_description_export . ';',
                $config_content
            );
            $config_content = preg_replace(
                '/\$page_keywords\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_keywords = ' . $page_keywords_export . ';',
                $config_content
            );
        }
    } elseif (isset($_POST['heading_form'])) {
        // Update or add page_heading and page_heading2
        $page_key = $_POST['page_key'] ?? '';
        $new_heading = $_POST['page_heading'] ?? '';
        $new_heading2 = $_POST['page_heading2'] ?? '';

        if ($page_key) {
            // Update arrays in memory
            $page_heading[$page_key]['page_heading'] = $new_heading;
            $page_heading2[$page_key]['page_heading2'] = $new_heading2;

            // Format arrays as PHP code
            $page_heading_export = var_export($page_heading, true);
            $page_heading2_export = var_export($page_heading2, true);

            // Replace array definitions in config.php
            $config_content = preg_replace(
                '/\$page_heading\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_heading = ' . $page_heading_export . ';',
                $config_content
            );
            $config_content = preg_replace(
                '/\$page_heading2\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_heading2 = ' . $page_heading2_export . ';',
                $config_content
            );
        }
    } elseif (isset($_POST['delete_heading_form'])) {
        // Delete page_heading and page_heading2
        $page_key = $_POST['page_key'] ?? '';

        if ($page_key && isset($page_heading[$page_key])) {
            // Remove entries from arrays
            unset($page_heading[$page_key]);
            unset($page_heading2[$page_key]);

            // Format arrays as PHP code
            $page_heading_export = var_export($page_heading, true);
            $page_heading2_export = var_export($page_heading2, true);

            // Replace array definitions in config.php
            $config_content = preg_replace(
                '/\$page_heading\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_heading = ' . $page_heading_export . ';',
                $config_content
            );
            $config_content = preg_replace(
                '/\$page_heading2\s*=\s*array\s*\(\s*[\s\S]*?\);/s',
                '$page_heading2 = ' . $page_heading2_export . ';',
                $config_content
            );
        }
    }

    // Write back to config.php with error handling
    if (file_put_contents('config.php', $config_content) === false) {
        error_log('Failed to write to config.php: ' . error_get_last()['message']);
        die('Error: Unable to update configuration file. Check file permissions and server logs.');
    }

    // Redirect to refresh the page
    header("Location: dashboard.php");
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Acadevo Site Management Dashboard</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <style>
        body {
            background-color: #f4f6f9;
            font-family: 'Arial', sans-serif;
        }
        .sidebar {
            background-color: #2c3e50;
            min-height: 100vh;
            padding-top: 20px;
            position: fixed;
            width: 250px;
            transition: all 0.3s;
        }
        .sidebar .nav-link {
            color: #ecf0f1;
            margin: 10px 15px;
            border-radius: 5px;
            padding: 12px;
            font-size: 16px;
            transition: all 0.3s;
        }
        .sidebar .nav-link:hover, .sidebar .nav-link.active {
            background-color: #1abc9c;
            color: #fff;
        }
        .content {
            margin-left: 250px;
            padding: 30px;
        }
        .card {
            border: none;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        }
        .card-header {
            background-color: #2c3e50;
            color: #fff;
            border-radius: 12px 12px 0 0;
        }
        .form-control {
            border-radius: 8px;
        }
        .form-control:focus {
            border-color: #1abc9c;
            box-shadow: 0 0 5px rgba(26, 188, 156, 0.5);
        }
        .btn-primary {
            background-color: #1abc9c;
            border-color: #1abc9c;
            border-radius: 8px;
        }
        .btn-primary:hover {
            background-color: #16a085;
            border-color: #16a085;
        }
        .btn-danger {
            border-radius: 8px;
        }
        .table {
            border-radius: 12px;
            overflow: hidden;
        }
        .table thead {
            background-color: #2c3e50;
            color: #fff;
        }
        .modal-content {
            border-radius: 12px;
        }
        .modal-header {
            background-color: #2c3e50;
            color: #fff;
        }
        @media (max-width: 768px) {
            .sidebar {
                width: 100%;
                position: static;
            }
            .content {
                margin-left: 0;
            }
        }
    </style>
</head>
<body>
    <!-- Sidebar -->
    <div class="sidebar">
        <div class="text-center mb-4">
            <img src="public/assets/images/logo-4.png" alt="Logo" class="img-fluid" style="max-width: 150px;">
        </div>
        <nav class="nav flex-column px-3">
            <a href="#site-settings" class="nav-link active"><i class="fas fa-cog me-2"></i> Site Settings</a>
            <a href="#page-settings" class="nav-link"><i class="fas fa-file-alt me-2"></i> Page Settings</a>
            <a href="#heading-settings" class="nav-link"><i class="fas fa-heading me-2"></i> Page Headings</a>
            <a href="#logout" class="nav-link"><i class="fas fa-sign-out-alt me-2"></i> Logout</a>
        </nav>
    </div>

    <!-- Content -->
    <div class="content">
        <h1 class="mb-4">Acadevo Dashboard</h1>

        <!-- Site Settings -->
        <div id="site-settings" class="card mb-5">
            <div class="card-header">
                <h5 class="mb-0">Site Configuration</h5>
            </div>
            <div class="card-body">
                <form action="dashboard.php" method="POST">
                    <input type="hidden" name="site_form" value="1">
                    <div class="mb-3">
                        <label for="site_name" class="form-label">Site Name</label>
                        <input type="text" class="form-control" id="site_name" name="site_name" value="<?php echo htmlspecialchars($site_name); ?>" required>
                    </div>
                    <div class="mb-3">
                        <label for="site_short_name" class="form-label">Site Short Name</label>
                        <input type="text" class="form-control" id="site_short_name" name="site_short_name" value="<?php echo htmlspecialchars($site_short_name); ?>" required>
                    </div>
                    <button type="submit" class="btn btn-primary">Save Changes</button>
                </form>
            </div>
        </div>

        <!-- Page Settings (Title, Description, Keywords) -->
        <div id="page-settings" class="card mb-5">
            <div class="card-header">
                <h5 class="mb-0">Page Configuration</h5>
            </div>
            <div class="card-body">
                <div class="mb-3">
                    <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addPageModal">Add New Page</button>
                </div>
                <div class="table-responsive">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>Page</th>
                                <th>Title</th>
                                <th>Description</th>
                                <th>Keywords</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($page_title as $page => $title): ?>
                                <tr>
                                    <td><?php echo htmlspecialchars($page); ?></td>
                                    <td><?php echo htmlspecialchars($title); ?></td>
                                    <td><?php echo htmlspecialchars($page_description[$page] ?? 'N/A'); ?></td>
                                    <td><?php echo htmlspecialchars($page_keywords[$page] ?? 'N/A'); ?></td>
                                    <td>
                                        <button class="btn btn-sm btn-primary edit-page" 
                                                data-page="<?php echo htmlspecialchars($page); ?>" 
                                                data-title="<?php echo htmlspecialchars($title); ?>" 
                                                data-description="<?php echo htmlspecialchars($page_description[$page] ?? ''); ?>"
                                                data-keywords="<?php echo htmlspecialchars($page_keywords[$page] ?? ''); ?>"
                                                data-bs-toggle="modal" 
                                                data-bs-target="#editPageModal">Edit</button>
                                        <form action="dashboard.php" method="POST" style="display:inline;">
                                            <input type="hidden" name="delete_page_form" value="1">
                                            <input type="hidden" name="page_key" value="<?php echo htmlspecialchars($page); ?>">
                                            <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this page?')">Delete</button>
                                        </form>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <!-- Page Headings (Combined Heading and Sub Heading) -->
        <div id="heading-settings" class="card mb-5">
            <div class="card-header">
                <h5 class="mb-0">Page Headings</h5>
            </div>
            <div class="card-body">
                <div class="mb-3">
                    <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addHeadingModal">Add New Heading</button>
                </div>
                <div class="table-responsive">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>Page</th>
                                <th>Heading</th>
                                <th>Sub Heading</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($page_heading as $page => $data): ?>
                                <tr>
                                    <td><?php echo htmlspecialchars($page); ?></td>
                                    <td><?php echo htmlspecialchars($data['page_heading'] ?? 'N/A'); ?></td>
                                    <td><?php echo htmlspecialchars($page_heading2[$page]['page_heading2'] ?? 'N/A'); ?></td>
                                    <td>
                                        <button class="btn btn-sm btn-primary edit-heading" 
                                                data-page="<?php echo htmlspecialchars($page); ?>" 
                                                data-heading="<?php echo htmlspecialchars($data['page_heading'] ?? ''); ?>"
                                                data-heading2="<?php echo htmlspecialchars($page_heading2[$page]['page_heading2'] ?? ''); ?>"
                                                data-bs-toggle="modal" 
                                                data-bs-target="#editHeadingModal">Edit</button>
                                        <form action="dashboard.php" method="POST" style="display:inline;">
                                            <input type="hidden" name="delete_heading_form" value="1">
                                            <input type="hidden" name="page_key" value="<?php echo htmlspecialchars($page); ?>">
                                            <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this heading?')">Delete</button>
                                        </form>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- Add Page Modal -->
    <div class="modal fade" id="addPageModal" tabindex="-1" aria-labelledby="addPageModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="addPageModalLabel">Add New Page</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form action="dashboard.php" method="POST">
                        <input type="hidden" name="page_form" value="1">
                        <div class="mb-3">
                            <label for="add_page_key" class="form-label">Page Key (e.g., contact)</label>
                            <input type="text" class="form-control" id="add_page_key" name="page_key" required pattern="[a-zA-Z0-9\-]+" title="Only letters, numbers, and hyphens are allowed">
                        </div>
                        <div class="mb-3">
                            <label for="add_page_title" class="form-label">Page Title</label>
                            <input type="text" class="form-control" id="add_page_title" name="page_title" required>
                        </div>
                        <div class="mb-3">
                            <label for="add_page_description" class="form-label">Page Description</label>
                            <textarea class="form-control" id="add_page_description" name="page_description" rows="4" required></textarea>
                        </div>
                        <div class="mb-3">
                            <label for="add_page_keywords" class="form-label">Page Keywords</label>
                            <textarea class="form-control" id="add_page_keywords" name="page_keywords" rows="4" required></textarea>
                        </div>
                        <button type="submit" class="btn btn-primary">Add Page</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Edit Page Modal -->
    <div class="modal fade" id="editPageModal" tabindex="-1" aria-labelledby="editPageModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="editPageModalLabel">Edit Page Settings</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form action="dashboard.php" method="POST">
                        <input type="hidden" name="page_form" value="1">
                        <input type="hidden" id="page_key" name="page_key">
                        <div class="mb-3">
                            <label for="page_title" class="form-label">Page Title</label>
                            <input type="text" class="form-control" id="page_title" name="page_title" required>
                        </div>
                        <div class="mb-3">
                            <label for="page_description" class="form-label">Page Description</label>
                            <textarea class="form-control" id="page_description" name="page_description" rows="4" required></textarea>
                        </div>
                        <div class="mb-3">
                            <label for="page_keywords" class="form-label">Page Keywords</label>
                            <textarea class="form-control" id="page_keywords" name="page_keywords" rows="4" required></textarea>
                        </div>
                        <button type="submit" class="btn btn-primary">Save Changes</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Add Heading Modal -->
    <div class="modal fade" id="addHeadingModal" tabindex="-1" aria-labelledby="addHeadingModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="addHeadingModalLabel">Add New Heading</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form action="dashboard.php" method="POST">
                        <input type="hidden" name="heading_form" value="1">
                        <div class="mb-3">
                            <label for="add_heading_page_key" class="form-label">Page Key (e.g., contact)</label>
                            <input type="text" class="form-control" id="add_heading_page_key" name="page_key" required pattern="[a-zA-Z0-9\-]+" title="Only letters, numbers, and hyphens are allowed">
                        </div>
                        <div class="mb-3">
                            <label for="add_page_heading" class="form-label">Page Heading</label>
                            <input type="text" class="form-control" id="add_page_heading" name="page_heading" required>
                        </div>
                        <div class="mb-3">
                            <label for="add_page_heading2" class="form-label">Page Sub Heading</label>
                            <input type="text" class="form-control" id="add_page_heading2" name="page_heading2" required>
                        </div>
                        <button type="submit" class="btn btn-primary">Add Heading</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Edit Heading Modal -->
    <div class="modal fade" id="editHeadingModal" tabindex="-1" aria-labelledby="editHeadingModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="editHeadingModalLabel">Edit Page Headings</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form action="dashboard.php" method="POST">
                        <input type="hidden" name="heading_form" value="1">
                        <input type="hidden" id="heading_page_key" name="page_key">
                        <div class="mb-3">
                            <label for="page_heading" class="form-label">Page Heading</label>
                            <input type="text" class="form-control" id="page_heading" name="page_heading" required>
                        </div>
                        <div class="mb-3">
                            <label for="page_heading2" class="form-label">Page Sub Heading</label>
                            <input type="text" class="form-control" id="page_heading2" name="page_heading2" required>
                        </div>
                        <button type="submit" class="btn btn-primary">Save Changes</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Bootstrap JS and Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Custom JS -->
    <script>
        $(document).ready(function() {
            // Smooth scroll for sidebar navigation
            $('.nav-link').click(function(e) {
                e.preventDefault();
                $('.nav-link').removeClass('active');
                $(this).addClass('active');
                const target = $(this).attr('href');
                $('html, body').animate({
                    scrollTop: $(target).offset().top
                }, 500);
            });

            // Populate page settings modal for editing
            $('.edit-page').click(function() {
                $('#page_key').val($(this).data('page'));
                $('#page_title').val($(this).data('title'));
                $('#page_description').val($(this).data('description'));
                $('#page_keywords').val($(this).data('keywords'));
            });

            // Populate heading modal for editing
            $('.edit-heading').click(function() {
                $('#heading_page_key').val($(this).data('page'));
                $('#page_heading').val($(this).data('heading'));
                $('#page_heading2').val($(this).data('heading2'));
            });

            // Clear add page modal fields when opened
            $('#addPageModal').on('show.bs.modal', function() {
                $('#add_page_key').val('');
                $('#add_page_title').val('');
                $('#add_page_description').val('');
                $('#add_page_keywords').val('');
            });

            // Clear add heading modal fields when opened
            $('#addHeadingModal').on('show.bs.modal', function() {
                $('#add_heading_page_key').val('');
                $('#add_page_heading').val('');
                $('#add_page_heading2').val('');
            });
        });
    </script>
</body>
</html>

MMCT - 2023