Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.action.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
13
class
Action
14
{
15
// Constants for different actions
16
const
ABOUT
=
'about'
;
17
const
ADD_ALIAS
=
'addAlias'
;
18
const
ADD_VHOST
=
'addVhost'
;
19
const
CHANGE_BROWSER
=
'changeBrowser'
;
20
const
CHANGE_DB_ROOT_PWD
=
'changeDbRootPwd'
;
21
const
CHANGE_PORT
=
'changePort'
;
22
const
CHECK_PORT
=
'checkPort'
;
23
const
CHECK_VERSION
=
'checkVersion'
;
24
const
CLEAR_FOLDERS
=
'clearFolders'
;
25
const
DEBUG_APACHE
=
'debugApache'
;
26
const
DEBUG_MARIADB
=
'debugMariadb'
;
27
const
DEBUG_MYSQL
=
'debugMysql'
;
28
const
DEBUG_POSTGRESQL
=
'debugPostgresql'
;
29
const
EDIT_ALIAS
=
'editAlias'
;
30
const
EDIT_VHOST
=
'editVhost'
;
31
const
ENABLE
=
'enable'
;
32
const
EXEC
=
'exec'
;
33
const
MAKE_ROOT_CA
=
'makeRootCA'
;
34
const
GEN_SSL_CERTIFICATE
=
'genSslCertificate'
;
35
const
DEL_SSL_CERTIFICATE
=
'delSslCertificate'
;
36
const
LAUNCH_STARTUP
=
'launchStartup'
;
37
const
MANUAL_RESTART
=
'manualRestart'
;
38
const
LOADING
=
'loading'
;
39
const
QUIT
=
'quit'
;
40
const
REBUILD_INI
=
'rebuildIni'
;
41
const
REFRESH_REPOS
=
'refreshRepos'
;
42
const
REFRESH_REPOS_STARTUP
=
'refreshReposStartup'
;
43
const
RELOAD
=
'reload'
;
44
const
RESTART
=
'restart'
;
45
const
RESTART_ALL_SERVICES
=
'restartAllServices'
;
46
const
SERVICE
=
'service'
;
47
const
START_ALL_SERVICES
=
'startAllServices'
;
48
const
STARTUP
=
'startup'
;
49
const
STOP_ALL_SERVICES
=
'stopAllServices'
;
50
const
SWITCH_APACHE_MODULE
=
'switchApacheModule'
;
51
const
SWITCH_LANG
=
'switchLang'
;
52
const
SWITCH_LOGS_VERBOSE
=
'switchLogsVerbose'
;
53
const
SWITCH_PHP_EXTENSION
=
'switchPhpExtension'
;
54
const
SWITCH_PHP_PARAM
=
'switchPhpParam'
;
55
const
SWITCH_ONLINE
=
'switchOnline'
;
56
const
SWITCH_VERSION
=
'switchVersion'
;
57
58
const
EXT
=
'ext'
;
59
63
private
$current
;
64
69
public
function
__construct
()
70
{
71
// Initialization code can be added here if needed
72
}
73
83
public
function
process
()
84
{
85
if
($this->
exists
()) {
86
$action =
UtilInput::cleanArgv
(1);
87
$actionClass =
'Action'
. ucfirst($action);
88
89
$args = array();
90
foreach
($_SERVER[
'argv'
] as $key => $arg) {
91
if
($key > 1) {
92
$args[] = $action == self::EXT ? $arg : base64_decode($arg);
93
}
94
}
95
96
$this->current =
null
;
97
if
(class_exists($actionClass)) {
98
Log::debug
(
'Start '
. $actionClass);
99
$this->current =
new
$actionClass($args);
100
} elseif ($action == self::GEN_SSL_CERTIFICATE) {
101
global
$bearsamppRoot
, $bearsamppOpenSsl;
102
$bearsamppRoot
->loadOpenSsl();
103
$bearsamppOpenSsl->genSslCertificate();
104
} elseif ($action == self::MAKE_ROOT_CA) {
105
global
$bearsamppRoot
, $bearsamppOpenSsl;
106
$bearsamppRoot
->loadOpenSsl();
107
$bearsamppOpenSsl->makeRootCa();
108
} elseif ($action == self::DEL_SSL_CERTIFICATE) {
109
global
$bearsamppRoot
, $bearsamppOpenSsl;
110
$bearsamppRoot
->loadOpenSsl();
111
$bearsamppOpenSsl->delSslCertificate();
112
}
113
}
114
}
115
127
public
function
call
($actionName, $actionArgs =
null
)
128
{
129
$actionClass =
'Action'
. ucfirst($actionName);
130
if
(class_exists($actionClass)) {
131
Log::debug
(
'Start '
. $actionClass);
132
new
$actionClass($actionArgs);
133
}
134
}
135
144
public
function
exists
()
145
{
146
return
isset($_SERVER[
'argv'
])
147
&& isset($_SERVER[
'argv'
][1])
148
&& !empty($_SERVER[
'argv'
][1]);
149
}
150
}
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
Action
Definition
class.action.php:14
Action\ADD_ALIAS
const ADD_ALIAS
Definition
class.action.php:17
Action\__construct
__construct()
Definition
class.action.php:69
Action\DEBUG_APACHE
const DEBUG_APACHE
Definition
class.action.php:25
Action\QUIT
const QUIT
Definition
class.action.php:39
Action\SWITCH_VERSION
const SWITCH_VERSION
Definition
class.action.php:56
Action\EDIT_VHOST
const EDIT_VHOST
Definition
class.action.php:30
Action\$current
$current
Definition
class.action.php:63
Action\MANUAL_RESTART
const MANUAL_RESTART
Definition
class.action.php:37
Action\DEBUG_MARIADB
const DEBUG_MARIADB
Definition
class.action.php:26
Action\SWITCH_LOGS_VERBOSE
const SWITCH_LOGS_VERBOSE
Definition
class.action.php:52
Action\STOP_ALL_SERVICES
const STOP_ALL_SERVICES
Definition
class.action.php:49
Action\START_ALL_SERVICES
const START_ALL_SERVICES
Definition
class.action.php:47
Action\CHANGE_DB_ROOT_PWD
const CHANGE_DB_ROOT_PWD
Definition
class.action.php:20
Action\DEBUG_MYSQL
const DEBUG_MYSQL
Definition
class.action.php:27
Action\SERVICE
const SERVICE
Definition
class.action.php:46
Action\DEL_SSL_CERTIFICATE
const DEL_SSL_CERTIFICATE
Definition
class.action.php:35
Action\REBUILD_INI
const REBUILD_INI
Definition
class.action.php:40
Action\CHECK_VERSION
const CHECK_VERSION
Definition
class.action.php:23
Action\MAKE_ROOT_CA
const MAKE_ROOT_CA
Definition
class.action.php:33
Action\CHANGE_PORT
const CHANGE_PORT
Definition
class.action.php:21
Action\LOADING
const LOADING
Definition
class.action.php:38
Action\call
call($actionName, $actionArgs=null)
Definition
class.action.php:127
Action\LAUNCH_STARTUP
const LAUNCH_STARTUP
Definition
class.action.php:36
Action\RELOAD
const RELOAD
Definition
class.action.php:43
Action\process
process()
Definition
class.action.php:83
Action\RESTART_ALL_SERVICES
const RESTART_ALL_SERVICES
Definition
class.action.php:45
Action\ABOUT
const ABOUT
Definition
class.action.php:16
Action\EDIT_ALIAS
const EDIT_ALIAS
Definition
class.action.php:29
Action\SWITCH_PHP_EXTENSION
const SWITCH_PHP_EXTENSION
Definition
class.action.php:53
Action\EXEC
const EXEC
Definition
class.action.php:32
Action\STARTUP
const STARTUP
Definition
class.action.php:48
Action\ADD_VHOST
const ADD_VHOST
Definition
class.action.php:18
Action\RESTART
const RESTART
Definition
class.action.php:44
Action\REFRESH_REPOS
const REFRESH_REPOS
Definition
class.action.php:41
Action\REFRESH_REPOS_STARTUP
const REFRESH_REPOS_STARTUP
Definition
class.action.php:42
Action\DEBUG_POSTGRESQL
const DEBUG_POSTGRESQL
Definition
class.action.php:28
Action\SWITCH_PHP_PARAM
const SWITCH_PHP_PARAM
Definition
class.action.php:54
Action\exists
exists()
Definition
class.action.php:144
Action\GEN_SSL_CERTIFICATE
const GEN_SSL_CERTIFICATE
Definition
class.action.php:34
Action\CHECK_PORT
const CHECK_PORT
Definition
class.action.php:22
Action\CHANGE_BROWSER
const CHANGE_BROWSER
Definition
class.action.php:19
Action\CLEAR_FOLDERS
const CLEAR_FOLDERS
Definition
class.action.php:24
Action\EXT
const EXT
Definition
class.action.php:58
Action\SWITCH_ONLINE
const SWITCH_ONLINE
Definition
class.action.php:55
Action\SWITCH_LANG
const SWITCH_LANG
Definition
class.action.php:51
Action\SWITCH_APACHE_MODULE
const SWITCH_APACHE_MODULE
Definition
class.action.php:50
Action\ENABLE
const ENABLE
Definition
class.action.php:31
Log\debug
static debug($data, $file=null)
Definition
class.log.php:616
UtilInput\cleanArgv
static cleanArgv($name, $type='text')
Definition
class.util.input.php:34
sandbox
core
classes
actions
class.action.php
Generated by
1.17.0