Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.action.switchPhpParam.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
16
class
ActionSwitchPhpParam
17
{
18
const
SWITCH_ON
=
'on'
;
19
const
SWITCH_OFF
=
'off'
;
20
26
public
function
__construct
($args)
27
{
28
global
$bearsamppLang
,
$bearsamppBins
, $bearsamppWinbinder;
29
30
// Check if the required arguments are provided and not empty
31
if
(isset($args[0]) && !empty($args[0]) && isset($args[1]) && !empty($args[1])) {
32
// Check if the PHP setting exists
33
if
(!
$bearsamppBins
->getPhp()->isSettingExists($args[0])) {
34
$bearsamppWinbinder->messageBoxError(
35
sprintf(
$bearsamppLang
->getValue(
Lang::SWITCH_PHP_SETTING_NOT_FOUND
), $args[0],
$bearsamppBins
->getPhp()->getVersion()),
36
$bearsamppLang
->getValue(
Lang::SWITCH_PHP_SETTING_TITLE
)
37
);
38
return
;
39
}
40
41
// Retrieve the current settings values
42
$settingsValues =
$bearsamppBins
->getPhp()->getSettingsValues();
43
if
(isset($settingsValues[$args[0]])) {
44
$onContent = $args[0] .
' = '
. $settingsValues[$args[0]][0];
45
$offContent = $args[0] .
' = '
. $settingsValues[$args[0]][1];
46
47
// Read the current PHP configuration file content
48
$phpiniContent = file_get_contents(
$bearsamppBins
->getPhp()->getConf());
49
if
($args[1] == self::SWITCH_ON) {
50
// Replace the off setting with the on setting
51
$phpiniContent = str_replace($offContent, $onContent, $phpiniContent);
52
} elseif ($args[1] == self::SWITCH_OFF) {
53
// Replace the on setting with the off setting
54
$phpiniContent = str_replace($onContent, $offContent, $phpiniContent);
55
}
56
57
// Write the updated content back to the PHP configuration file
58
file_put_contents(
$bearsamppBins
->getPhp()->getConf(), $phpiniContent);
59
}
60
}
61
}
62
}
63
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
ActionSwitchPhpParam
Definition
class.action.switchPhpParam.php:17
ActionSwitchPhpParam\__construct
__construct($args)
Definition
class.action.switchPhpParam.php:26
ActionSwitchPhpParam\SWITCH_OFF
const SWITCH_OFF
Definition
class.action.switchPhpParam.php:19
ActionSwitchPhpParam\SWITCH_ON
const SWITCH_ON
Definition
class.action.switchPhpParam.php:18
Lang\SWITCH_PHP_SETTING_TITLE
const SWITCH_PHP_SETTING_TITLE
Definition
class.lang.php:175
Lang\SWITCH_PHP_SETTING_NOT_FOUND
const SWITCH_PHP_SETTING_NOT_FOUND
Definition
class.lang.php:176
sandbox
core
classes
actions
class.action.switchPhpParam.php
Generated by
1.17.0