Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
ajax.apply.moduleconfig.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2022-2025 Bearsampp
5 * * License: GNU General Public License version 3 or later; see LICENSE.txt
6 * * Website: https://bearsampp.com
7 * * Github: https://github.com/Bearsampp
8 *
9 */
10
21
22// Set appropriate headers for AJAX response
23header('Content-Type: application/json');
24
25// Initialize response array
26$response = array();
27
28// Check if this is a POST request
29if ($_SERVER['REQUEST_METHOD'] === 'POST') {
30 $moduleName = isset($_POST['moduleName']) ? $_POST['moduleName'] : null;
31 $version = isset($_POST['version']) ? $_POST['version'] : null;
32
33 if ($moduleName && $version) {
34 try {
35 global $bearsamppConfig;
36
37 Util::logDebug("Applying config for module: $moduleName, version: $version");
38
39 // Update the configuration file
40 $configKey = $moduleName . 'Version';
41 $bearsamppConfig->replace($configKey, $version);
42
43 Util::logInfo("Successfully updated $moduleName version to $version in bearsampp.conf");
44
45 $response = [
46 'success' => true,
47 'message' => "Configuration updated successfully!\n\n✓ Set $moduleName" . "Version = \"$version\"\n\nNow right-click the Bearsampp tray icon and select 'Reload' to activate the new version."
48 ];
49
50 } catch (Exception $e) {
51 $response = ['error' => 'Failed to update configuration: ' . $e->getMessage()];
52 error_log('Exception in apply module config: ' . $e->getMessage());
53 }
54 } else {
55 $response = ['error' => 'Invalid module name or version.'];
56 }
57} else {
58 $response = ['error' => 'Invalid request method.'];
59}
60
61// Send the JSON response
62echo json_encode($response);
static logInfo($data, $file=null)
static logDebug($data, $file=null)
global $bearsamppConfig
Definition homepage.php:41