2024.8.23
Loading...
Searching...
No Matches
ajax.xlight.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 */
10
11/**
12 * This script retrieves information about the Xlight service status and versions.
13 * It checks the SMTP port status and retrieves the list of available versions.
14 * The results are returned as a JSON-encoded array.
15 */
16
17// Initialize result array
18$result = array(
19 'checkport' => '',
20 'versions' => '',
21);
22
23// Check SMTP port
24$port = $bearsamppBins->getXlight()->getPort();
25
29
30/**
31 * Check if the Xlight service is running on the specified port.
32 * If the port is open, indicate that the service is started.
33 * If the port is closed, indicate that the service is stopped.
34 * If the service is disabled, indicate that it is disabled.
35 */
36if ($bearsamppBins->getXlight()->checkPort($port)) {
37 if ($bearsamppBins->getXlight()->checkPort($port)) {
38 $result['checkport'] .= '<span class="float-end badge text-bg-success">' . sprintf($textServiceStarted, $port) . '</span>';
39 } else {
40 $result['checkport'] .= '<span class="float-end badge text-bg-danger">' . $textServiceStopped . '</span>';
41 }
42} else {
43 $result['checkport'] = '<span class="float-end badge text-bg-secondary">' . $textDisabled . '</span>';
44}
45
46/**
47 * Retrieve the list of available Xlight versions.
48 * Highlight the current version with a primary badge.
49 * Other versions are displayed with a secondary badge.
50 */
51foreach ($bearsamppBins->getXlight()->getVersionList() as $version) {
52 if ($version != $bearsamppBins->getXlight()->getVersion()) {
53 $result['versions'] .= '<span class="m-1 badge text-bg-secondary">' . $version . '</span>';
54 } else {
55 $result['versions'] .= '<span class="m-1 badge text-bg-primary">' . $bearsamppBins->getXlight()->getVersion() . '</span>';
56 }
57}
58
59// Output the result as a JSON-encoded array
60echo json_encode($result);
$result
$textServiceStopped
$textDisabled
global $bearsamppBins
global $bearsamppLang
$port
$textServiceStarted
const HOMEPAGE_SERVICE_STOPPED
const HOMEPAGE_SERVICE_STARTED
const DISABLED