2024.8.23
Loading...
Searching...
No Matches
class.action.debugApache.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 ActionDebugApache
12 *
13 * This class handles the debugging of Apache configurations and settings.
14 * It retrieves various Apache debug information based on the provided arguments
15 * and displays the information in a message box or editor.
16 */
18{
19 /**
20 * Constructor for ActionDebugApache.
21 *
22 * @param array $args An array of arguments specifying the type of Apache debug information to retrieve.
23 */
24 public function __construct($args)
25 {
26 global $bearsamppLang, $bearsamppBins, $bearsamppTools, $bearsamppWinbinder;
27
28 if (isset($args[0]) && !empty($args[0])) {
29 $editor = false;
30 $msgBoxError = false;
31 $caption = $bearsamppLang->getValue(Lang::DEBUG) . ' ' . $bearsamppLang->getValue(Lang::APACHE) . ' - ';
32
33 // Determine the type of debug information requested and set the caption accordingly
34 if ($args[0] == BinApache::CMD_VERSION_NUMBER) {
36 } elseif ($args[0] == BinApache::CMD_COMPILE_SETTINGS) {
38 } elseif ($args[0] == BinApache::CMD_COMPILED_MODULES) {
40 } elseif ($args[0] == BinApache::CMD_CONFIG_DIRECTIVES) {
41 $editor = true;
43 } elseif ($args[0] == BinApache::CMD_VHOSTS_SETTINGS) {
44 $editor = true;
46 } elseif ($args[0] == BinApache::CMD_LOADED_MODULES) {
47 $editor = true;
49 } elseif ($args[0] == BinApache::CMD_SYNTAX_CHECK) {
51 }
52 $caption .= ' (' . $args[0] . ')';
53
54 // Retrieve the debug output from Apache
55 $debugOutput = $bearsamppBins->getApache()->getCmdLineOutput($args[0]);
56
57 // Handle syntax check specifically
58 if ($args[0] == BinApache::CMD_SYNTAX_CHECK) {
59 $msgBoxError = !$debugOutput['syntaxOk'];
60 $debugOutput['content'] = $debugOutput['syntaxOk'] ? 'Syntax OK !' : $debugOutput['content'];
61 }
62
63 // Display the debug output in an editor or message box
64 if ($editor) {
65 Util::openFileContent($caption, $debugOutput['content']);
66 } else {
67 if ($msgBoxError) {
68 $bearsamppWinbinder->messageBoxError(
69 $debugOutput['content'],
70 $caption
71 );
72 } else {
73 $bearsamppWinbinder->messageBoxInfo(
74 $debugOutput['content'],
75 $caption
76 );
77 }
78 }
79 }
80 }
81}
global $bearsamppBins
global $bearsamppLang
const CMD_LOADED_MODULES
const CMD_VERSION_NUMBER
const CMD_VHOSTS_SETTINGS
const CMD_CONFIG_DIRECTIVES
const CMD_COMPILE_SETTINGS
const CMD_SYNTAX_CHECK
const CMD_COMPILED_MODULES
const DEBUG_APACHE_CONFIG_DIRECTIVES
const DEBUG_APACHE_COMPILE_SETTINGS
const DEBUG_APACHE_COMPILED_MODULES
const DEBUG_APACHE_VHOSTS_SETTINGS
const DEBUG_APACHE_SYNTAX_CHECK
const DEBUG
const DEBUG_APACHE_VERSION_NUMBER
const DEBUG_APACHE_LOADED_MODULES
const APACHE
static openFileContent($caption, $content)