2024.8.23
Loading...
Searching...
No Matches
ajax.filezilla.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 * This script retrieves information about the status of the FileZilla service and its versions.
12 * It checks if the FileZilla service is enabled, verifies the ports it is running on, and lists available versions.
13 * The output is encoded in JSON format and includes 'checkport' and 'versions' keys with corresponding information.
14 */
15
16// Declare global variables to access various parts of the application such as language settings and core functionalities.
18
19// Initialize the result array with keys 'checkport' and 'versions'.
20$result = array(
21 'checkport' => '',
22 'versions' => '',
23);
24
25// Retrieve the port and SSL port for the FileZilla service.
26$port = $bearsamppBins->getFilezilla()->getPort();
27$sslPort = $bearsamppBins->getFilezilla()->getSslPort();
28
29// Retrieve localized strings for service status messages.
33
34/**
35 * Check if the FileZilla service is enabled.
36 * If enabled, check the status of the ports and update the 'checkport' key in the result array accordingly.
37 * If not enabled, set the 'checkport' key to indicate that the service is disabled.
38 */
39if ($bearsamppBins->getFilezilla()->isEnable()) {
40 if ($bearsamppBins->getFilezilla()->checkPort($sslPort, true)) {
41 $result['checkport'] .= '<span class="float-end m-1 badge text-bg-success">' . sprintf($textServiceStarted, $sslPort) . ' (SSL)</span>';
42 } else {
43 $result['checkport'] .= '<span class="float-end m-1 badge text-bg-danger">' . $textServiceStopped . ' (SSL)</span>';
44 }
45 if ($bearsamppBins->getFilezilla()->checkPort($port)) {
46 $result['checkport'] .= '<span class="float-end m-1 badge text-bg-success">' . sprintf($textServiceStarted, $port) . '</span>';
47 } else {
48 $result['checkport'] .= '<span class="float-end m-1 badge text-bg-danger">' . $textServiceStopped . '</span>';
49 }
50} else {
51 $result['checkport'] = '<span class="float-end m-1 badge text-bg-secondary">' . $textDisabled . '</span>';
52}
53
54/**
55 * Retrieve the list of available versions for the FileZilla service.
56 * Update the 'versions' key in the result array with the version information.
57 * Highlight the current version with a primary badge and other versions with a secondary badge.
58 */
59foreach ($bearsamppBins->getFilezilla()->getVersionList() as $version) {
60 if ($version != $bearsamppBins->getFilezilla()->getVersion()) {
61 $result['versions'] .= '<span class="m-1 badge text-bg-secondary">' . $version . '</span>';
62 } else {
63 $result['versions'] .= '<span class="m-1 badge text-bg-primary">' . $bearsamppBins->getFilezilla()->getVersion() . '</span>';
64 }
65}
66
67// Encode the result array in JSON format and output it.
68echo json_encode($result);
$textServiceStopped
$textDisabled
global $bearsamppBins
global $bearsamppLang
$textServiceStarted
const HOMEPAGE_SERVICE_STOPPED
const HOMEPAGE_SERVICE_STARTED
const DISABLED