-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_status.php
More file actions
305 lines (275 loc) · 12.9 KB
/
system_status.php
File metadata and controls
305 lines (275 loc) · 12.9 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<?php
require_once 'includes/config.php';
$page_title = "System Status Check";
$tests = [];
// Database Connection Test
try {
$stmt = $pdo->query("SELECT 1");
$tests['database'] = ['status' => 'success', 'message' => 'Database connection successful'];
} catch (Exception $e) {
$tests['database'] = ['status' => 'error', 'message' => 'Database connection failed: ' . $e->getMessage()];
}
// Tables Check
$required_tables = ['events', 'donations', 'products', 'orders', 'order_items', 'event_registrations'];
$existing_tables = [];
try {
$stmt = $pdo->query("SHOW TABLES");
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
foreach ($required_tables as $table) {
if (in_array($table, $tables)) {
$existing_tables[$table] = 'exists';
} else {
$existing_tables[$table] = 'missing';
}
}
$tests['tables'] = ['status' => 'success', 'data' => $existing_tables];
} catch (Exception $e) {
$tests['tables'] = ['status' => 'error', 'message' => $e->getMessage()];
}
// Sample Data Check
try {
$stmt = $pdo->query("SELECT COUNT(*) as count FROM events");
$event_count = $stmt->fetch()['count'];
$stmt = $pdo->query("SELECT COUNT(*) as count FROM products");
$product_count = $stmt->fetch()['count'];
$tests['sample_data'] = [
'status' => 'success',
'events' => $event_count,
'products' => $product_count
];
} catch (Exception $e) {
$tests['sample_data'] = ['status' => 'error', 'message' => $e->getMessage()];
}
// File Structure Check
$required_files = [
'charity/index.php',
'charity/donate.php',
'charity/process_donate.php',
'shop/index.php',
'shop/checkout.php',
'shop/process_order.php',
'assets/css/main.css',
'includes/config.php'
];
$file_status = [];
foreach ($required_files as $file) {
$file_status[$file] = file_exists($file) ? 'exists' : 'missing';
}
$tests['files'] = ['status' => 'success', 'data' => $file_status];
// Payment Configuration Check
$momo_config = [
'endpoint' => 'https://test-payment.momo.vn/v2/gateway/api/create',
'partner_code' => 'MOMOBKUN20180529',
'access_key' => 'klm05TvNBzhg7h7j'
];
$vnpay_config = [
'vnp_TmnCode' => 'VNPAYTEST',
'vnp_HashSecret' => 'RAOEXHYVSDDIIENYWSLDIIZTANXUXZFJ'
];
$tests['payment_config'] = [
'status' => 'success',
'momo' => $momo_config,
'vnpay' => $vnpay_config
];
// MoMo API Test (simple connectivity)
function testMoMoAPI() {
$endpoint = "https://test-payment.momo.vn/v2/gateway/api/create";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_NOBODY, true);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [
'reachable' => $result !== false,
'http_code' => $httpCode
];
}
$tests['momo_connectivity'] = [
'status' => 'info',
'data' => testMoMoAPI()
];
include 'includes/header.php';
?>
<div class="container my-5">
<div class="row">
<div class="col-12">
<div class="card shadow-lg border-0">
<div class="card-header bg-gradient-primary text-white">
<h2 class="mb-0"><i class="fas fa-cogs me-2"></i>System Status Check</h2>
<p class="mb-0 opacity-75">Comprehensive system health and configuration check</p>
</div>
<div class="card-body p-4">
<!-- Database Test -->
<div class="status-section mb-4">
<h4 class="mb-3">
<i class="fas fa-database me-2"></i>Database Connection
<?php if ($tests['database']['status'] == 'success'): ?>
<span class="badge bg-success">OK</span>
<?php else: ?>
<span class="badge bg-danger">ERROR</span>
<?php endif; ?>
</h4>
<div class="alert alert-<?= $tests['database']['status'] == 'success' ? 'success' : 'danger' ?>">
<?= $tests['database']['message'] ?>
</div>
</div>
<!-- Tables Check -->
<div class="status-section mb-4">
<h4 class="mb-3">
<i class="fas fa-table me-2"></i>Database Tables
<?php if ($tests['tables']['status'] == 'success'): ?>
<span class="badge bg-success">OK</span>
<?php else: ?>
<span class="badge bg-danger">ERROR</span>
<?php endif; ?>
</h4>
<?php if ($tests['tables']['status'] == 'success'): ?>
<div class="row">
<?php foreach ($tests['tables']['data'] as $table => $status): ?>
<div class="col-md-4 mb-2">
<div class="d-flex align-items-center">
<i class="fas fa-<?= $status == 'exists' ? 'check text-success' : 'times text-danger' ?> me-2"></i>
<span><?= $table ?></span>
</div>
</div>
<?php endforeach; ?>
</div>
<?php else: ?>
<div class="alert alert-danger"><?= $tests['tables']['message'] ?></div>
<?php endif; ?>
</div>
<!-- Sample Data -->
<div class="status-section mb-4">
<h4 class="mb-3">
<i class="fas fa-chart-bar me-2"></i>Sample Data
<span class="badge bg-info">INFO</span>
</h4>
<?php if ($tests['sample_data']['status'] == 'success'): ?>
<div class="row">
<div class="col-md-6">
<div class="stats-mini">
<i class="fas fa-calendar-alt text-primary"></i>
<span><strong><?= $tests['sample_data']['events'] ?></strong> Events</span>
</div>
</div>
<div class="col-md-6">
<div class="stats-mini">
<i class="fas fa-box text-success"></i>
<span><strong><?= $tests['sample_data']['products'] ?></strong> Products</span>
</div>
</div>
</div>
<?php else: ?>
<div class="alert alert-warning"><?= $tests['sample_data']['message'] ?></div>
<?php endif; ?>
</div>
<!-- File Structure -->
<div class="status-section mb-4">
<h4 class="mb-3">
<i class="fas fa-folder me-2"></i>File Structure
<span class="badge bg-success">OK</span>
</h4>
<div class="row">
<?php foreach ($tests['files']['data'] as $file => $status): ?>
<div class="col-md-6 mb-2">
<div class="d-flex align-items-center">
<i class="fas fa-<?= $status == 'exists' ? 'check text-success' : 'times text-danger' ?> me-2"></i>
<span class="text-muted"><?= $file ?></span>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<!-- Payment Configuration -->
<div class="status-section mb-4">
<h4 class="mb-3">
<i class="fas fa-credit-card me-2"></i>Payment Configuration
<span class="badge bg-info">CONFIGURED</span>
</h4>
<div class="row">
<div class="col-md-6">
<h6><i class="fab fa-cc-visa me-2"></i>MoMo Configuration</h6>
<ul class="list-unstyled">
<li><i class="fas fa-check text-success me-2"></i>Endpoint: Configured</li>
<li><i class="fas fa-check text-success me-2"></i>Partner Code: <?= $tests['payment_config']['momo']['partner_code'] ?></li>
<li><i class="fas fa-check text-success me-2"></i>Access Key: Configured</li>
<li><i class="fas fa-info text-info me-2"></i>Request Type: captureWallet (QR Code)</li>
</ul>
</div>
<div class="col-md-6">
<h6><i class="fab fa-cc-visa me-2"></i>VNPay Configuration</h6>
<ul class="list-unstyled">
<li><i class="fas fa-check text-success me-2"></i>TMN Code: <?= $tests['payment_config']['vnpay']['vnp_TmnCode'] ?></li>
<li><i class="fas fa-check text-success me-2"></i>Hash Secret: Configured</li>
</ul>
</div>
</div>
</div>
<!-- MoMo Connectivity -->
<div class="status-section mb-4">
<h4 class="mb-3">
<i class="fas fa-wifi me-2"></i>MoMo API Connectivity
<?php if ($tests['momo_connectivity']['data']['reachable']): ?>
<span class="badge bg-success">REACHABLE</span>
<?php else: ?>
<span class="badge bg-warning">UNREACHABLE</span>
<?php endif; ?>
</h4>
<div class="alert alert-<?= $tests['momo_connectivity']['data']['reachable'] ? 'success' : 'warning' ?>">
MoMo API Endpoint: <?= $tests['momo_connectivity']['data']['reachable'] ? 'Reachable' : 'Not Reachable' ?>
(HTTP Code: <?= $tests['momo_connectivity']['data']['http_code'] ?>)
</div>
</div>
<!-- Action Links -->
<div class="status-section">
<h4 class="mb-3"><i class="fas fa-tools me-2"></i>Quick Actions</h4>
<div class="row">
<div class="col-md-3 mb-2">
<a href="charity/test_momo_simple.php" class="btn btn-outline-primary w-100" target="_blank">
<i class="fas fa-mobile-alt me-2"></i>Test MoMo QR
</a>
</div>
<div class="col-md-3 mb-2">
<a href="charity/debug_momo.php" class="btn btn-outline-info w-100" target="_blank">
<i class="fas fa-bug me-2"></i>MoMo Debug
</a>
</div>
<div class="col-md-3 mb-2">
<a href="shop/test_system.php" class="btn btn-outline-success w-100" target="_blank">
<i class="fas fa-shopping-cart me-2"></i>Test Shop
</a>
</div>
<div class="col-md-3 mb-2">
<a href="index.php" class="btn btn-primary w-100">
<i class="fas fa-home me-2"></i>Main Site
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
.status-section {
border-left: 4px solid #e9ecef;
padding-left: 20px;
margin-left: 10px;
}
.stats-mini {
display: flex;
align-items: center;
gap: 10px;
padding: 10px;
background: #f8f9fa;
border-radius: 8px;
}
.stats-mini i {
font-size: 1.5rem;
}
</style>
<?php include 'includes/footer.php'; ?>