Bearsampp
2026.7.11
Toggle main menu visibility
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
23
header(
'Content-Type: application/json'
);
24
25
// Initialize response array
26
$response
= array();
27
28
// Check if this is a POST request
29
if
($_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
Log::debug
(
"Applying config for module: $moduleName, version: $version"
);
38
39
// Update the configuration file
40
$configKey = $moduleName .
'Version'
;
41
$bearsamppConfig
->replace($configKey, $version);
42
43
Log::info
(
"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
62
echo json_encode(
$response
);
63
exit
;
64
exit
exit
Definition
ajax.apply.moduleconfig.php:63
$response
$response
Definition
ajax.apply.moduleconfig.php:26
Log\info
static info($data, $file=null)
Definition
class.log.php:627
Log\debug
static debug($data, $file=null)
Definition
class.log.php:616
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:41
sandbox
core
resources
homepage
ajax
ajax.apply.moduleconfig.php
Generated by
1.17.0