Bearsampp 2025.8.29
Loading...
Searching...
No Matches
ajax.summary.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
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
32$dlMoreTpl = '<a href="' . Util::getWebsiteUrl( 'module/%s', '#releases' ) . '" target="_blank" title="' . $downloadTitle . '"><span class="float-end" style="margin-left:.5rem;"><i class="fa-solid fa-cloud-arrow-down"></i></span></a>';
33
34try {
40 $apachePort = $bearsamppBins->getApache()->getPort();
41 $apacheSslPort = $bearsamppBins->getApache()->getSslPort();
42 $apacheLabel = 'bg-secondary';
43 if ( $bearsamppBins->getApache()->isEnable() ) {
44 $apacheLabel = 'bg-danger';
45 if ( $bearsamppBins->getApache()->checkPort( $apachePort ) ) {
46 if ( $bearsamppBins->getApache()->checkPort( $apacheSslPort, true ) ) {
47 $apacheLabel = 'bg-success';
48 }
49 else {
50 $apacheLabel = 'bg-warning';
51 }
52 }
53 }
54 $result['binapache'] = sprintf( $dlMoreTpl, 'apache' );
55 $result['binapache'] .= '<span class = " float-end badge ' . $apacheLabel . '">' . $bearsamppBins->getApache()->getVersion() . '</span>';
56}
57catch ( Exception $e ) {
58 $result['binapache'] = 'An error occurred getting the summary of Apache. ' . $e->getMessage();
59}
60
61try {
67 $mailpitPort = $bearsamppBins->getMailpit()->getSmtpPort();
68 $mailpitLabel = 'bg-secondary';
69 if ( $bearsamppBins->getMailpit()->isEnable() ) {
70 $mailpitLabel = 'bg-danger';
71 if ( $bearsamppBins->getMailpit()->checkPort( $mailpitPort ) ) {
72 $mailpitLabel = 'bg-success';
73 }
74 }
75 $result['binmailpit'] = sprintf( $dlMoreTpl, 'mailpit' );
76 $result['binmailpit'] .= '<span class = " float-end badge ' . $mailpitLabel . '">' . $bearsamppBins->getMailpit()->getVersion() . '</span>';
77}
78catch ( Exception $e ) {
79 $result['binmailpit'] = 'An error occurred getting the summary of Mailpit. ' . $e->getMessage();
80}
81
82try {
88 $xlightPort = $bearsamppBins->getXlight()->getPort();
89 $xlightLabel = 'bg-secondary';
90 if ( $bearsamppBins->getXlight()->isEnable() ) {
91 $xlightLabel = 'bg-danger';
92 if ( $bearsamppBins->getXlight()->checkPort( $xlightPort ) ) {
93 $xlightLabel = 'bg-success';
94 }
95 }
96 $result['binxlight'] = sprintf( $dlMoreTpl, 'xlight' );
97 $result['binxlight'] .= '<span class = " float-end badge ' . $xlightLabel . '">' . $bearsamppBins->getXlight()->getVersion() . '</span>';
98}
99catch ( Exception $e ) {
100 $result['binxlight'] = 'An error occurred getting the summary of Xlight. ' . $e->getMessage();
101}
102
103try {
109 $mariadbPort = $bearsamppBins->getMariadb()->getPort();
110 $mariadbLabel = 'bg-secondary';
111 if ( $bearsamppBins->getMariadb()->isEnable() ) {
112 $mariadbLabel = 'bg-danger';
113 if ( $bearsamppBins->getMariadb()->checkPort( $mariadbPort ) ) {
114 $mariadbLabel = 'bg-success';
115 }
116 }
117 $result['binmariadb'] = sprintf( $dlMoreTpl, 'mariadb' );
118 $result['binmariadb'] .= '<span class = " float-end badge ' . $mariadbLabel . '">' . $bearsamppBins->getMariadb()->getVersion() . '</span>';
119}
120catch ( Exception $e ) {
121 $result['binmariadb'] = 'An error occurred getting the summary of MariaDB. ' . $e->getMessage();
122}
123
124try {
130 $mysqlPort = $bearsamppBins->getMysql()->getPort();
131 $mysqlLabel = 'bg-secondary';
132 if ( $bearsamppBins->getMysql()->isEnable() ) {
133 $mysqlLabel = 'bg-danger';
134 if ( $bearsamppBins->getMysql()->checkPort( $mysqlPort ) ) {
135 $mysqlLabel = 'bg-success';
136 }
137 }
138 $result['binmysql'] = sprintf( $dlMoreTpl, 'mysql' );
139 $result['binmysql'] .= '<span class = " float-end badge ' . $mysqlLabel . '">' . $bearsamppBins->getMysql()->getVersion() . '</span>';
140}
141catch ( Exception $e ) {
142 $result['binmysql'] = 'An error occurred getting the summary of MySql. ' . $e->getMessage();
143}
144
145try {
151 $postgresqlPort = $bearsamppBins->getPostgresql()->getPort();
152 $postgresqlLabel = 'bg-secondary';
153 if ( $bearsamppBins->getPostgresql()->isEnable() ) {
154 $postgresqlLabel = 'bg-danger';
155 if ( $bearsamppBins->getPostgresql()->checkPort( $postgresqlPort ) ) {
156 $postgresqlLabel = 'bg-success';
157 }
158 }
159 $result['binpostgresql'] = sprintf( $dlMoreTpl, 'postgresql' );
160 $result['binpostgresql'] .= '<span class = " float-end badge ' . $postgresqlLabel . '">' . $bearsamppBins->getPostgresql()->getVersion() . '</span>';
161}
162catch ( Exception $e ) {
163 $result['binpostgresql'] = 'An error occurred getting the summary of Postgresql. ' . $e->getMessage();
164}
165
166try {
172 $memcachedPort = $bearsamppBins->getMemcached()->getPort();
173 $memcachedLabel = 'bg-secondary';
174 if ( $bearsamppBins->getMemcached()->isEnable() ) {
175 $memcachedLabel = 'bg-danger';
176 if ( $bearsamppBins->getMemcached()->checkPort( $memcachedPort ) ) {
177 $memcachedLabel = 'bg-success';
178 }
179 }
180 $result['binmemcached'] = sprintf( $dlMoreTpl, 'memcached' );
181 $result['binmemcached'] .= '<span class = " float-end badge ' . $memcachedLabel . '">' . $bearsamppBins->getMemcached()->getVersion() . '</span>';
182}
183catch ( Exception $e ) {
184 $result['binmemcached'] = 'An error occurred getting the summary of Memchached. ' . $e->getMessage();
185}
186
187try {
193 $nodejsLabel = 'bg-secondary';
194 if ( $bearsamppBins->getNodejs()->isEnable() ) {
195 $nodejsLabel = 'bg-success';
196 }
197 $result['binnodejs'] = sprintf( $dlMoreTpl, 'nodejs' );
198 $result['binnodejs'] .= '<span class = " float-end badge ' . $nodejsLabel . '">' . $bearsamppBins->getNodejs()->getVersion() . '</span>';
199}
200catch ( Exception $e ) {
201 $result['binnodejs'] = 'An error occurred getting the summary of NodeJS. ' . $e->getMessage();
202}
203
204try {
210 $phpLabel = 'bg-secondary';
211 if ( $bearsamppBins->getPhp()->isEnable() ) {
212 $phpLabel = 'bg-success';
213 }
214 $result['binphp'] = sprintf( $dlMoreTpl, 'php' );
215 $result['binphp'] .= '<span class = " float-end badge ' . $phpLabel . '">' . $bearsamppBins->getPhp()->getVersion() . '</span>';
216}
217catch ( Exception $e ) {
218 $result['binphp'] = 'An error occurred getting the summary of PHP. ' . $e->getMessage();
219}
220
221// Output the result as JSON
222echo json_encode( $result );
$result
global $bearsamppBins
$dlMoreTpl
$mariadbLabel
$memcachedLabel
$mysqlLabel
$mailpitLabel
$postgresqlLabel
$xlightLabel
$apacheLabel
global $downloadTitle
$apacheSslPort
static getWebsiteUrl($path='', $fragment='', $utmSource=true)