-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
186 lines (161 loc) · 5.57 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
// Function to detect the latest PHP version
function detectPhpVersion() {
$phpDirs = array_filter(glob('/etc/php-*'), 'is_dir');
$phpVersions = [];
foreach ($phpDirs as $dir) {
if (preg_match('/php-(\d+\.\d+)/', basename($dir), $matches)) {
$phpVersions[] = $matches[1];
}
}
if (!empty($phpVersions)) {
// Sort and return the latest version
usort($phpVersions, 'version_compare');
return end($phpVersions);
}
return null;
}
// Function to check the status of a service
function checkServiceStatus($service) {
$status = shell_exec("rcctl check $service 2>&1");
return nl2br(htmlspecialchars($status));
}
// Detect installed PHP version
$phpVersion = detectPhpVersion();
$phpDaemon = $phpVersion ? "php" . str_replace('.', '', $phpVersion) . "_fpm" : null;
$apacheStatus = checkServiceStatus('apache2');
$mysqlStatus = checkServiceStatus('mysqld');
$phpStatus = $phpDaemon ? checkServiceStatus($phpDaemon) : 'No PHP version detected';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Open-AMP Control Panel</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #333; /* Darker background color */
margin: 0;
padding: 0;
}
h1 {
text-align: center;
color: orange; /* Title color set to orange */
font-size: 2.5em; /* Increased title size */
margin-bottom: 20px; /* Added space below the title */
}
h2 {
text-align: center;
color: #fff; /* White text for h2 */
}
.container {
max-width: 900px;
margin: 0 auto;
padding: 20px;
}
.card {
background-color: #444; /* Changed card background color to match page background */
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
padding: 20px;
}
.output {
background-color: #444; /* Changed output background color */
border-left: 5px solid #007BFF;
padding: 10px;
margin-top: 15px;
border-radius: 5px;
color: #fff; /* Changed text color to white for better contrast */
white-space: pre-wrap;
}
ul {
list-style: none;
padding: 0;
}
ul li {
margin: 8px 0;
}
a {
text-decoration: none;
color: #007BFF;
transition: color 0.3s;
}
a:hover {
color: #0056b3;
}
.ascii {
font-family: monospace; /* Use monospace font for ASCII */
text-align: center; /* Center the ASCII art */
white-space: pre; /* Preserve whitespace for ASCII art */
margin: 20px auto; /* Center and adjust margin for spacing */
position: relative; /* Enable offsetting */
left: -7%; /* Offset to center the ASCII */
font-size: 1.2em; /* Slightly increase size of ASCII art */
}
.yellow {
color: orange; /* Color for c1 */
}
.white {
color: white; /* Color for c2 */
}
</style>
</head>
<body>
<div class="container">
<h1>Open-AMP Control Panel</h1>
<div class="ascii">
<span class="yellow"> _____ </span><br>
<span class="yellow"> \\- -/</span><br>
<span class="yellow">\\_/ \\</span><br>
<span class="yellow"> | <span class="white">O O</span> |</span><br>
<span class="yellow"> |_ < ) 3 )</span><br>
<span class="yellow"> / \\ /</span><br>
<span class="yellow"> /-_____-\\</span>
</div>
<!-- Service Status Card -->
<div class="card">
<h2>Service Status</h2>
<div class="output">
<strong>Apache Status:</strong><br>
<?php echo $apacheStatus; ?>
</div>
<div class="output">
<strong>MySQL Status:</strong><br>
<?php echo $mysqlStatus; ?>
</div>
<div class="output">
<strong>PHP-FPM Status:</strong><br>
<?php echo $phpStatus; ?>
</div>
</div>
<!-- phpMyAdmin Access Card -->
<div class="card">
<h2>Access phpMyAdmin</h2>
<a href="http://localhost/phpMyAdmin" class="link-button">Click here to access phpMyAdmin</a>
</div>
<!-- Virtual Hosts Card -->
<div class="card">
<h2>Virtual Hosts (Projects)</h2>
<ul>
<?php
// Define the directory where projects are stored
$project_dir = '/var/www/htdocs';
// Scan the directory and list the folders (projects)
$projects = array_filter(glob($project_dir . '/*'), 'is_dir');
if (!empty($projects)) {
foreach ($projects as $project) {
$project_name = basename($project);
echo "<li><a href=\"/$project_name\">$project_name</a></li>";
}
} else {
echo "<li>No projects found in /var/www/htdocs</li>";
}
?>
</ul>
</div>
</div>
</body>
</html>