Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
ajax.apache.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
14
15
// Declare global variables
16
global
$bearsamppRoot
,
$bearsamppBins
,
$bearsamppLang
;
17
18
// Initialize result array
19
$result
= array(
20
'checkport'
=>
''
,
21
'versions'
=>
''
,
22
'modulescount'
=>
''
,
23
'aliasescount'
=>
''
,
24
'vhostscount'
=>
''
,
25
'moduleslist'
=>
''
,
26
'aliaseslist'
=>
''
,
27
'wwwdirectory'
=>
''
,
28
'vhostslist'
=>
''
,
29
);
30
34
$port
=
$bearsamppBins
->getApache()->getPort();
35
$sslPort
=
$bearsamppBins
->getApache()->getSslPort();
36
37
$textServiceStarted
=
$bearsamppLang
->getValue(
Lang::HOMEPAGE_SERVICE_STARTED
);
38
$textServiceStopped
=
$bearsamppLang
->getValue(
Lang::HOMEPAGE_SERVICE_STOPPED
);
39
$textDisabled
=
$bearsamppLang
->getValue(
Lang::DISABLED
);
40
41
if
(
$bearsamppBins
->getApache()->isEnable()) {
42
if
(
$bearsamppBins
->getApache()->checkPort(
$sslPort
,
true
)) {
43
$result
[
'checkport'
] .=
'<span class="m-1 float-end badge text-bg-success">'
. sprintf(
$textServiceStarted
,
$sslPort
) .
' (SSL)</span>'
;
44
}
else
{
45
$result
[
'checkport'
] .=
'<span class="m-1 float-end badge text-bg-danger">'
.
$textServiceStopped
.
' (SSL)</span>'
;
46
}
47
if
(
$bearsamppBins
->getApache()->checkPort(
$port
)) {
48
$result
[
'checkport'
] .=
'<span class="m-1 float-end badge text-bg-success">'
. sprintf(
$textServiceStarted
,
$port
) .
'</span>'
;
49
}
else
{
50
$result
[
'checkport'
] .=
'<span class="m-1 float-end badge text-bg-danger">'
.
$textServiceStopped
.
'</span>'
;
51
}
52
}
else
{
53
$result
[
'checkport'
] =
'<span class="m-1 float-end badge text-bg-secondary">'
.
$textDisabled
.
'</span>'
;
54
}
55
59
foreach
(
$bearsamppBins
->getApache()->getVersionList() as $version) {
60
$versionBadge =
'<span class="m-1 badge text-bg-%s">%s</span>'
;
61
$isCurrent = $version ===
$bearsamppBins
->getApache()->getVersion();
62
63
$result
[
'versions'
] .= sprintf(
64
$versionBadge,
65
$isCurrent ?
'primary'
:
'secondary'
,
66
$version
67
);
68
}
69
73
$modules
= count(
$bearsamppBins
->getApache()->getModules());
74
$modulesLoaded
= count(
$bearsamppBins
->getApache()->getModulesLoaded());
75
$result
[
'modulescount'
] .=
'<span class="m-1 float-end badge text-bg-primary">'
.
$modulesLoaded
.
' / '
.
$modules
.
'</span>'
;
76
80
$result
[
'aliasescount'
] .=
'<span class="m-1 float-end badge text-bg-primary">'
. count(
$bearsamppBins
->getApache()->getAlias()) .
'</span>'
;
81
85
$result
[
'vhostscount'
] .=
'<span class="m-1 float-end badge text-bg-primary">'
. count(
$bearsamppBins
->getApache()->getVhosts()) .
'</span>'
;
86
90
foreach
(
$bearsamppBins
->getApache()->getModulesFromConf() as $moduleName => $moduleStatus) {
91
if
($moduleStatus ==
ActionSwitchApacheModule::SWITCH_ON
) {
92
$result
[
'moduleslist'
] .=
'<span class="p-1 col col-xs-12"><i class="fa-regular fa-circle-check"></i> <strong>'
. $moduleName .
'</strong></span>'
;
93
}
else
{
94
$result
[
'moduleslist'
] .=
'<span class="p-1 col col-xs-12"><i class="fa-regular fa-circle"></i> '
. $moduleName .
'</span>'
;
95
}
96
}
97
101
foreach
(
$bearsamppBins
->getApache()->getAlias() as $alias) {
102
$result
[
'aliaseslist'
] .=
'<div class="float-start p-1"><a class="btn btn-outline-dark" target="_blank" href="'
.
Path::getLocalUrl
($alias) .
'"><i class="fa-solid fa-link"></i> '
. $alias .
'</a></div>'
;
103
}
104
108
foreach
(
$bearsamppBins
->getApache()->getWwwDirectories() as $wwwDirectory) {
109
$result
[
'wwwdirectory'
] .=
'<div class="float-start p-1"><a class="btn btn-outline-dark" target="_blank" href="'
.
Path::getLocalUrl
($wwwDirectory) .
'"><i class="fa-solid fa-link"></i> '
. $wwwDirectory .
'</a></div>'
;
110
}
111
115
foreach
(
$bearsamppBins
->getApache()->getVhostsUrl() as $vhost => $enabled) {
116
if
($enabled) {
117
$result
[
'vhostslist'
] .=
'<div class="float-start p-1"><a class="btn btn-outline-dark" target="_blank" href="//'
. $vhost .
'"><i class="fa-regular fa-circle-check"></i> '
. $vhost .
'</a></div>'
;
118
}
else
{
119
$result
[
'vhostslist'
] .=
'<div class="float-start p-1"><a class="btn btn-outline-dark" target="_blank" href="//'
. $vhost .
'"><i class="fa-regular fa-circle"></i> '
. $vhost .
'</a></div>'
;
120
}
121
}
122
126
echo json_encode(
$result
);
$result
$result
Definition
ajax.apache.php:19
$modules
foreach($bearsamppBins->getApache() ->getVersionList() as $version) $modules
Definition
ajax.apache.php:73
$textServiceStopped
$textServiceStopped
Definition
ajax.apache.php:38
$textDisabled
$textDisabled
Definition
ajax.apache.php:39
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
$port
$port
Definition
ajax.apache.php:34
$textServiceStarted
$textServiceStarted
Definition
ajax.apache.php:37
$modulesLoaded
$modulesLoaded
Definition
ajax.apache.php:74
$sslPort
$sslPort
Definition
ajax.apache.php:35
ActionSwitchApacheModule\SWITCH_ON
const SWITCH_ON
Definition
class.action.switchApacheModule.php:17
Lang\DISABLED
const DISABLED
Definition
class.lang.php:36
Lang\HOMEPAGE_SERVICE_STOPPED
const HOMEPAGE_SERVICE_STOPPED
Definition
class.lang.php:379
Lang\HOMEPAGE_SERVICE_STARTED
const HOMEPAGE_SERVICE_STARTED
Definition
class.lang.php:378
Path\getLocalUrl
static getLocalUrl($request=null)
Definition
class.path.php:407
sandbox
core
resources
homepage
ajax
ajax.apache.php
Generated by
1.17.0