/
pageServerStatus.php
212 lines (186 loc) · 5.38 KB
/
pageServerStatus.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php
$appgini_version = '6.0.1145';
$generated_ts = '10/7/2021 9:20:39 PM';
$currDir = dirname(__FILE__);
require("{$currDir}/incCommon.php");
$GLOBALS['page_title'] = $Translation['server status'];
include("{$currDir}/incHeader.php");
// get phpinfo() and remove HTML wrapping
ob_start();
phpinfo();
$phpinfo_raw = ob_get_clean();
preg_match('/<table.*<\/table>/s', $phpinfo_raw, $phpinfo);
// AppGini version and gen date/time
$admin_config = config('adminConfig');
$gen_info = str_replace(
array(
'<VERSION>',
'<DATETIME>'
),
array(
"<span class=\"label label-info\">{$appgini_version}</span>",
$generated_ts
),
$Translation['generated by']
);
$eo = ['silentErrors' => true];
// uploads storage
$num_uploads = $uploads_size = 0;
// if uploads folder path is absolute, don't prepend app path
if(getUploadDir('')[0] == '/')
$uploads_path = getUploadDir('');
else
$uploads_path = dirname(__FILE__) . '/../' . getUploadDir('');
$uploads_path = rtrim($uploads_path, '\\/') . '/';
$uf = dir(rtrim($uploads_path));
while(false !== ($entry = $uf->read())) {
// entries to skip
if(in_array($entry, array(
'.',
'..',
'blank.gif',
'blank_dv.gif',
'blank_tv.gif',
'index.html'
))) continue;
if(@is_dir($uploads_path . $entry)) continue;
$num_uploads++;
$uploads_size += @filesize($uploads_path . $entry);
}
$uf->close();
// DB storage
$db_name = makeSafe(config('dbDatabase'));
$db_storage = [];
$total_storage = 0;
$res = sql(
"SELECT
table_name, ROUND((data_length + index_length) / 1024 , 1)
FROM information_schema.tables
WHERE table_schema='{$db_name}' AND table_type='BASE TABLE'
ORDER BY 2 DESC",
$eo
);
while($row = db_fetch_row($res)) {
$db_storage[$row[0]] = $row[1];
$total_storage += $row[1];
}
// MySQL status
$db_status = [];
$res = sql("show status", $eo);
while($row = db_fetch_array($res)) {
$db_status[$row[0]] = $row[1];
}
?>
<div class="page-header"><h1><?php echo $Translation['server status']; ?></h1></div>
<h4><?php echo $gen_info; ?></h4>
<hr>
<div class="row">
<div class="col-lg-4">
<h3><?php echo $Translation['uploads info']; ?></h3>
<span class="label label-info big-number">
<?php echo $num_uploads; ?>
<?php echo $Translation['files']; ?>
</span>
<span class="label label-info big-number"><?php echo number_format($uploads_size / 1024 / 1024, 2); ?> MB</span>
<h3><?php echo $Translation['db storage']; ?></h3>
<div class="db-status scrollable">
<table class="table table-striped table-hover table-bordered">
<thead>
<tr>
<th><?php echo $Translation['column table name']; ?></th>
<th class="text-center"><?php echo $Translation['column size kb']; ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($db_storage as $table => $storage) { ?>
<tr>
<th><?php echo $table; ?></th>
<td class="text-right"><?php echo number_format($storage); ?></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th><?php echo $Translation['total']; ?></th>
<th class="text-right"><?php echo number_format($total_storage); ?></th>
</tr>
</tfoot>
</table>
</div>
<hr>
</div>
<div class="col-lg-4">
<h3><?php echo $Translation['db status']; ?></h3>
<div class="db-status scrollable">
<table class="table table-striped table-hover table-bordered">
<?php foreach($db_status as $var => $val) { ?>
<tr>
<th><?php echo $var; ?></th>
<td><?php echo $val; ?></td>
</tr>
<?php } ?>
</table>
</div>
<hr>
</div>
<div class="col-lg-4" id="phpinfo">
<h3><?php echo $Translation['php info']; ?></h3>
<div class="db-status scrollable">
<?php echo $phpinfo[0]; ?>
</div>
</div>
</div>
<style>
#phpinfo table {
width: 100%;
}
#phpinfo td {
border: solid 1px #888;
padding: 3px 10px;
color: #000;
}
#phpinfo table tr:nth-child(even) {
background-color: #ddd;
}
#phpinfo table tr:nth-child(odd) {
background-color: #fff;
}
.db-status.scrollable {
max-height: 60vh;
overflow-y: auto;
}
.big-number {
font-size: 5rem;
line-height: 10rem;
margin: 0 1rem;
}
.cursor-pointer {
cursor: pointer;
}
</style>
<script>
$j(function() {
// apply a zoom-in button to each grid cell
$j('<i class="glyphicon glyphicon-zoom-in resizer text-primary hspacer-sm cursor-pointer"></i>').prependTo('.col-lg-4 > h3:first-child');
// and for every zoom-in button, add a class 'zoomable-cell' to its grid cell
$j('.resizer').parents('.col-lg-4').addClass('zoomable-cell');
// on clicking a zoom button, maximize/restore its parent grid cell
$j('.row').on('click', '.resizer', function() {
var toggler = $j(this),
cell = toggler.parents('.zoomable-cell'),
maximized = cell.hasClass('col-lg-12');
toggler.toggleClass('glyphicon-zoom-in glyphicon-zoom-out');
cell.toggleClass('col-lg-12 col-lg-4');
cell.children('.db-status').toggleClass('scrollable')
if(maximized) {
// restore default size
cell.parents('.row').children('.col-lg-4').removeClass('hidden');
} else {
// otherwise, maximize
cell.parents('.row').children('.col-lg-4').addClass('hidden');
}
})
})
</script>
<?php
include("{$currDir}/incFooter.php");