2024.8.23
Loading...
Searching...
No Matches
class.action.checkPort.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 * Class ActionCheckPort
12 *
13 * This class is responsible for checking the port status of various services (Apache, MySQL, MariaDB, PostgreSQL, Filezilla, Mailhog, Mailpit, Memcached, Xlight)
14 * based on the provided arguments.
15 */
17{
18 /**
19 * Constructor for ActionCheckPort.
20 *
21 * @param array $args An array of arguments where:
22 * - $args[0] is the name of the service (e.g., Apache, MySQL).
23 * - $args[1] is the port number to check.
24 * - $args[2] (optional) indicates if SSL should be used.
25 *
26 * @global object $bearsamppBins Global object containing instances of various services.
27 */
28 public function __construct($args)
29 {
30 global $bearsamppBins;
31
32 // Check if the required arguments are provided and not empty
33 if ( isset( $args[0] ) && !empty( $args[0] ) && isset( $args[1] ) && !empty( $args[1] ) ) {
34 // Determine if SSL is to be used
35 $ssl = isset( $args[2] ) && !empty( $args[2] );
36
37 // Check the port for the specified service
38 if ( $args[0] == $bearsamppBins->getApache()->getName() ) {
39 $bearsamppBins->getApache()->checkPort( $args[1], $ssl, true );
40 }
41 elseif ( $args[0] == $bearsamppBins->getMysql()->getName() ) {
42 $bearsamppBins->getMysql()->checkPort( $args[1], true );
43 }
44 elseif ( $args[0] == $bearsamppBins->getMariadb()->getName() ) {
45 $bearsamppBins->getMariadb()->checkPort( $args[1], true );
46 }
47 elseif ( $args[0] == $bearsamppBins->getPostgresql()->getName() ) {
48 $bearsamppBins->getPostgresql()->checkPort( $args[1], true );
49 }
50 elseif ( $args[0] == $bearsamppBins->getFilezilla()->getName() ) {
51 $bearsamppBins->getFilezilla()->checkPort( $args[1], $ssl, true );
52 }
53 elseif ( $args[0] == $bearsamppBins->getMailhog()->getName() ) {
54 $bearsamppBins->getMailhog()->checkPort( $args[1], true );
55 }
56 elseif ( $args[0] == $bearsamppBins->getMailpit()->getName() ) {
57 $bearsamppBins->getMailpit()->checkPort( $args[1], true );
58 }
59 elseif ( $args[0] == $bearsamppBins->getMemcached()->getName() ) {
60 $bearsamppBins->getMemcached()->checkPort( $args[1], true );
61 }
62 elseif ( $args[0] == $bearsamppBins->getXlight()->getName() ) {
63 $bearsamppBins->getXlight()->checkPort( $args[1], true );
64 }
65 }
66 }
67}
global $bearsamppBins