Bearsampp 2026.9.23
Loading...
Searching...
No Matches
ajax.summary.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2026 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
17
18// Initialize result array
19$result = array(
20 'binapache' => '',
21 'binmailpit' => '',
22 'binmariadb' => '',
23 'binmysql' => '',
24 'binpostgresql' => '',
25 'binmemcached' => '',
26 'binnodejs' => '',
27 'binphp' => '',
28 'binxlight' => '',
29);
30
31// Template for download link
33 'module/%s',
34 '#releases'
35 ) . '" target="_blank" title="' . $downloadTitle . '"><span class="float-end download-icon-wrapper"><i class="fa-solid fa-cloud-arrow-down"></i></span></a>';
36
37try {
43 $apachePort = $bearsamppBins->getApache()->getPort();
44 $apacheSslPort = $bearsamppBins->getApache()->getSslPort();
45 $apacheLabel = 'bg-secondary';
46 if ($bearsamppBins->getApache()->isEnable()) {
47 $apacheLabel = 'bg-danger';
48 if ($bearsamppBins->getApache()->checkPort($apachePort)) {
49 if ($bearsamppBins->getApache()->checkPort($apacheSslPort, true)) {
50 $apacheLabel = 'bg-success';
51 } else {
52 $apacheLabel = 'bg-warning';
53 }
54 }
55 }
56 $result['binapache'] = sprintf($dlMoreTpl, 'apache');
57 $result['binapache'] .= '<span class = " float-end badge ' . $apacheLabel . '">' . $bearsamppBins->getApache()->getVersion() . '</span>';
58} catch (Exception $e) {
59 Log::error('Error getting summary for Apache: ' . $e->getMessage());
60 $result['binapache'] = '<span class="float-end badge bg-danger">Error</span>';
61}
62
63try {
69 $mailpitPort = $bearsamppBins->getMailpit()->getSmtpPort();
70 $mailpitLabel = 'bg-secondary';
71 if ($bearsamppBins->getMailpit()->isEnable()) {
72 $mailpitLabel = 'bg-danger';
73 if ($bearsamppBins->getMailpit()->checkPort($mailpitPort)) {
74 $mailpitLabel = 'bg-success';
75 }
76 }
77 $result['binmailpit'] = sprintf($dlMoreTpl, 'mailpit');
78 $result['binmailpit'] .= '<span class = " float-end badge ' . $mailpitLabel . '">' . $bearsamppBins->getMailpit()->getVersion() . '</span>';
79} catch (Exception $e) {
80 Log::error('Error getting summary for Mailpit: ' . $e->getMessage());
81 $result['binmailpit'] = '<span class="float-end badge bg-danger">Error</span>';
82}
83
84try {
90 $xlightPort = $bearsamppBins->getXlight()->getPort();
91 $xlightLabel = 'bg-secondary';
92 if ($bearsamppBins->getXlight()->isEnable()) {
93 $xlightLabel = 'bg-danger';
94 if ($bearsamppBins->getXlight()->checkPort($xlightPort)) {
95 $xlightLabel = 'bg-success';
96 }
97 }
98 $result['binxlight'] = sprintf($dlMoreTpl, 'xlight');
99 $result['binxlight'] .= '<span class = " float-end badge ' . $xlightLabel . '">' . $bearsamppBins->getXlight()->getVersion() . '</span>';
100} catch (Exception $e) {
101 Log::error('Error getting summary for Xlight: ' . $e->getMessage());
102 $result['binxlight'] = '<span class="float-end badge bg-danger">Error</span>';
103}
104
105try {
111 $mariadbPort = $bearsamppBins->getMariadb()->getPort();
112 $mariadbLabel = 'bg-secondary';
113 if ($bearsamppBins->getMariadb()->isEnable()) {
114 $mariadbLabel = 'bg-danger';
115 if ($bearsamppBins->getMariadb()->checkPort($mariadbPort)) {
116 $mariadbLabel = 'bg-success';
117 }
118 }
119 $result['binmariadb'] = sprintf($dlMoreTpl, 'mariadb');
120 $result['binmariadb'] .= '<span class = " float-end badge ' . $mariadbLabel . '">' . $bearsamppBins->getMariadb()->getVersion() . '</span>';
121} catch (Exception $e) {
122 Log::error('Error getting summary for MariaDB: ' . $e->getMessage());
123 $result['binmariadb'] = '<span class="float-end badge bg-danger">Error</span>';
124}
125
126try {
132 $mysqlPort = $bearsamppBins->getMysql()->getPort();
133 $mysqlLabel = 'bg-secondary';
134 if ($bearsamppBins->getMysql()->isEnable()) {
135 $mysqlLabel = 'bg-danger';
136 if ($bearsamppBins->getMysql()->checkPort($mysqlPort)) {
137 $mysqlLabel = 'bg-success';
138 }
139 }
140 $result['binmysql'] = sprintf($dlMoreTpl, 'mysql');
141 $result['binmysql'] .= '<span class = " float-end badge ' . $mysqlLabel . '">' . $bearsamppBins->getMysql()->getVersion() . '</span>';
142} catch (Exception $e) {
143 Log::error('Error getting summary for MySQL: ' . $e->getMessage());
144 $result['binmysql'] = '<span class="float-end badge bg-danger">Error</span>';
145}
146
147try {
153 $postgresqlPort = $bearsamppBins->getPostgresql()->getPort();
154 $postgresqlLabel = 'bg-secondary';
155 if ($bearsamppBins->getPostgresql()->isEnable()) {
156 $postgresqlLabel = 'bg-danger';
157 if ($bearsamppBins->getPostgresql()->checkPort($postgresqlPort)) {
158 $postgresqlLabel = 'bg-success';
159 }
160 }
161 $result['binpostgresql'] = sprintf($dlMoreTpl, 'postgresql');
162 $result['binpostgresql'] .= '<span class = " float-end badge ' . $postgresqlLabel . '">' . $bearsamppBins->getPostgresql()->getVersion() . '</span>';
163} catch (Exception $e) {
164 Log::error('Error getting summary for PostgreSQL: ' . $e->getMessage());
165 $result['binpostgresql'] = '<span class="float-end badge bg-danger">Error</span>';
166}
167
168try {
174 $memcachedPort = $bearsamppBins->getMemcached()->getPort();
175 $memcachedLabel = 'bg-secondary';
176 if ($bearsamppBins->getMemcached()->isEnable()) {
177 $memcachedLabel = 'bg-danger';
178 if ($bearsamppBins->getMemcached()->checkPort($memcachedPort)) {
179 $memcachedLabel = 'bg-success';
180 }
181 }
182 $result['binmemcached'] = sprintf($dlMoreTpl, 'memcached');
183 $result['binmemcached'] .= '<span class = " float-end badge ' . $memcachedLabel . '">' . $bearsamppBins->getMemcached()->getVersion() . '</span>';
184} catch (Exception $e) {
185 Log::error('Error getting summary for Memcached: ' . $e->getMessage());
186 $result['binmemcached'] = '<span class="float-end badge bg-danger">Error</span>';
187}
188
189try {
195 $nodejsLabel = 'bg-secondary';
196 if ($bearsamppBins->getNodejs()->isEnable()) {
197 $nodejsLabel = 'bg-success';
198 }
199 $result['binnodejs'] = sprintf($dlMoreTpl, 'nodejs');
200 $result['binnodejs'] .= '<span class = " float-end badge ' . $nodejsLabel . '">' . $bearsamppBins->getNodejs()->getVersion() . '</span>';
201} catch (Exception $e) {
202 Log::error('Error getting summary for NodeJS: ' . $e->getMessage());
203 $result['binnodejs'] = '<span class="float-end badge bg-danger">Error</span>';
204}
205
206try {
212 $phpLabel = 'bg-secondary';
213 if ($bearsamppBins->getPhp()->isEnable()) {
214 $phpLabel = 'bg-success';
215 }
216 $result['binphp'] = sprintf($dlMoreTpl, 'php');
217 $result['binphp'] .= '<span class = " float-end badge ' . $phpLabel . '">' . $bearsamppBins->getPhp()->getVersion() . '</span>';
218} catch (Exception $e) {
219 Log::error('Error getting summary for PHP: ' . $e->getMessage());
220 $result['binphp'] = '<span class="float-end badge bg-danger">Error</span>';
221}
222
223// Output the result as JSON
224echo json_encode($result);
$result
global $bearsamppBins
$dlMoreTpl
$mariadbLabel
$memcachedLabel
$mysqlLabel
$mailpitLabel
$postgresqlLabel
$xlightLabel
$apacheLabel
global $downloadTitle
$apacheSslPort
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
static error($data, $file=null)