Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.action.switchPhpExtension.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
15
class
ActionSwitchPhpExtension
16
{
17
const
SWITCH_ON
=
'on'
;
18
const
SWITCH_OFF
=
'off'
;
19
25
public
function
__construct
($args)
26
{
27
global
$bearsamppBins
;
28
29
if
(isset($args[0]) && !empty($args[0]) && isset($args[1]) && !empty($args[1])) {
30
$onContent =
'extension='
. $args[0];
31
$offContent =
';extension='
. $args[0];
32
33
$phpiniContent = file_get_contents(
$bearsamppBins
->getPhp()->getConf());
34
if
($args[1] == self::SWITCH_ON) {
35
$phpiniContent = str_replace($offContent, $onContent, $phpiniContent);
36
} elseif ($args[1] == self::SWITCH_OFF) {
37
$phpiniContent = str_replace($onContent, $offContent, $phpiniContent);
38
}
39
40
$phpiniContentOr = file_get_contents(
$bearsamppBins
->getPhp()->getConf());
41
if
($phpiniContent == $phpiniContentOr && file_exists(
Path::getModuleSymlinkPath
(
$bearsamppBins
->getPhp()) .
'/ext/php_'
. $args[0] .
'.dll'
)) {
42
$extsIni =
$bearsamppBins
->getPhp()->getExtensionsFromConf();
43
$latestExt = (end($extsIni) ==
'0'
?
';'
:
''
);
44
$latestExt .=
'extension='
. key($extsIni);
45
$phpiniContent = str_replace(
46
$latestExt,
47
$latestExt . PHP_EOL . $onContent,
48
$phpiniContent
49
);
50
}
51
52
file_put_contents(
$bearsamppBins
->getPhp()->getConf(), $phpiniContent);
53
}
54
}
55
}
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
ActionSwitchPhpExtension
Definition
class.action.switchPhpExtension.php:16
ActionSwitchPhpExtension\__construct
__construct($args)
Definition
class.action.switchPhpExtension.php:25
ActionSwitchPhpExtension\SWITCH_OFF
const SWITCH_OFF
Definition
class.action.switchPhpExtension.php:18
ActionSwitchPhpExtension\SWITCH_ON
const SWITCH_ON
Definition
class.action.switchPhpExtension.php:17
Path\getModuleSymlinkPath
static getModuleSymlinkPath($module)
Definition
class.path.php:54
sandbox
core
classes
actions
class.action.switchPhpExtension.php
Generated by
1.17.0