2024.8.23
Loading...
Searching...
No Matches
class.action.switchOnline.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
10
/**
11
* Class ActionSwitchOnline
12
* Handles the switching of the application between online and offline modes.
13
*/
14
class
ActionSwitchOnline
15
{
16
/**
17
* ActionSwitchOnline constructor.
18
* Initializes the online/offline switch based on the provided arguments.
19
*
20
* @param array $args Arguments to determine the online/offline state.
21
*/
22
public
function
__construct
($args)
23
{
24
global
$bearsamppConfig
;
25
26
if
(isset($args[0]) && $args[0] ==
Config::ENABLED
|| $args[0] ==
Config::DISABLED
) {
27
Util::startLoading
();
28
$putOnline = $args[0] ==
Config::ENABLED
;
29
30
$this->
switchApache
($putOnline);
31
$this->
switchAlias
($putOnline);
32
$this->
switchVhosts
($putOnline);
33
$this->
switchFilezilla
($putOnline);
34
$bearsamppConfig
->replace(
Config::CFG_ONLINE
, $args[0]);
35
}
36
}
37
38
/**
39
* Switches the Apache configuration based on the online/offline state.
40
*
41
* @param bool $putOnline True to put online, false to put offline.
42
*/
43
private
function
switchApache
($putOnline)
44
{
45
global
$bearsamppBins
;
46
$bearsamppBins
->getApache()->refreshConf($putOnline);
47
}
48
49
/**
50
* Switches the Apache aliases based on the online/offline state.
51
*
52
* @param bool $putOnline True to put online, false to put offline.
53
*/
54
private
function
switchAlias
($putOnline)
55
{
56
global
$bearsamppBins
;
57
$bearsamppBins
->getApache()->refreshAlias($putOnline);
58
}
59
60
/**
61
* Switches the Apache virtual hosts based on the online/offline state.
62
*
63
* @param bool $putOnline True to put online, false to put offline.
64
*/
65
private
function
switchVhosts
($putOnline)
66
{
67
global
$bearsamppBins
;
68
$bearsamppBins
->getApache()->refreshVhosts($putOnline);
69
}
70
71
/**
72
* Switches the Filezilla configuration based on the online/offline state.
73
*
74
* @param bool $putOnline True to put online, false to put offline.
75
*/
76
private
function
switchFilezilla
($putOnline)
77
{
78
global
$bearsamppBins
;
79
80
if
($putOnline) {
81
$bearsamppBins
->getFilezilla()->setConf(array(
82
BinFilezilla::CFG_IP_FILTER_ALLOWED
=>
'*'
,
83
BinFilezilla::CFG_IP_FILTER_DISALLOWED
=>
''
,
84
));
85
}
else
{
86
$bearsamppBins
->getFilezilla()->setConf(array(
87
BinFilezilla::CFG_IP_FILTER_ALLOWED
=>
'127.0.0.1 ::1'
,
88
BinFilezilla::CFG_IP_FILTER_DISALLOWED
=>
'*'
,
89
));
90
}
91
}
92
}
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
ActionSwitchOnline
Definition
class.action.switchOnline.php:15
ActionSwitchOnline\__construct
__construct($args)
Definition
class.action.switchOnline.php:22
ActionSwitchOnline\switchApache
switchApache($putOnline)
Definition
class.action.switchOnline.php:43
ActionSwitchOnline\switchAlias
switchAlias($putOnline)
Definition
class.action.switchOnline.php:54
ActionSwitchOnline\switchVhosts
switchVhosts($putOnline)
Definition
class.action.switchOnline.php:65
ActionSwitchOnline\switchFilezilla
switchFilezilla($putOnline)
Definition
class.action.switchOnline.php:76
BinFilezilla\CFG_IP_FILTER_ALLOWED
const CFG_IP_FILTER_ALLOWED
Definition
class.bin.filezilla.php:32
BinFilezilla\CFG_IP_FILTER_DISALLOWED
const CFG_IP_FILTER_DISALLOWED
Definition
class.bin.filezilla.php:33
Config\DISABLED
const DISABLED
Definition
class.config.php:33
Config\CFG_ONLINE
const CFG_ONLINE
Definition
class.config.php:29
Config\ENABLED
const ENABLED
Definition
class.config.php:32
Util\startLoading
static startLoading()
Definition
class.util.php:947
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:26
Bearsampp-development
sandbox
core
classes
actions
class.action.switchOnline.php
Generated by
1.11.0