-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem-check.php
More file actions
204 lines (190 loc) · 10.7 KB
/
system-check.php
File metadata and controls
204 lines (190 loc) · 10.7 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>System Check - Fastway Couriers</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
</head>
<body class="bg-light">
<div class="container my-5">
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="card shadow">
<div class="card-header bg-primary text-white">
<h1 class="h3 mb-0">
<i class="bi bi-gear-fill me-2"></i>System Check
</h1>
</div>
<div class="card-body">
<p class="text-muted">This page checks if your system meets all requirements for the Fastway Couriers application.</p>
<?php
$checks = [];
$allPassed = true;
// PHP Version Check
$phpVersion = phpversion();
$phpOk = version_compare($phpVersion, '7.4.0', '>=');
$checks[] = [
'name' => 'PHP Version',
'status' => $phpOk,
'message' => "Version {$phpVersion}" . ($phpOk ? ' (OK)' : ' (Requires 7.4+)'),
'required' => true
];
if (!$phpOk) $allPassed = false;
// cURL Extension
$curlOk = extension_loaded('curl');
$checks[] = [
'name' => 'cURL Extension',
'status' => $curlOk,
'message' => $curlOk ? 'Installed' : 'Not installed (Required for API calls)',
'required' => true
];
if (!$curlOk) $allPassed = false;
// JSON Extension
$jsonOk = extension_loaded('json');
$checks[] = [
'name' => 'JSON Extension',
'status' => $jsonOk,
'message' => $jsonOk ? 'Installed' : 'Not installed',
'required' => true
];
if (!$jsonOk) $allPassed = false;
// File Permissions
$logsDir = __DIR__ . '/logs';
$logsDirOk = is_writable(dirname($logsDir)) || (is_dir($logsDir) && is_writable($logsDir));
$checks[] = [
'name' => 'Logs Directory',
'status' => $logsDirOk,
'message' => $logsDirOk ? 'Writable' : 'Not writable (Check permissions)',
'required' => false
];
// API Config File
$configOk = file_exists(__DIR__ . '/api/config.php');
$checks[] = [
'name' => 'API Configuration',
'status' => $configOk,
'message' => $configOk ? 'Found' : 'Missing api/config.php',
'required' => true
];
if (!$configOk) $allPassed = false;
// Check internet connectivity
$internetOk = @fsockopen("www.google.com", 80, $errno, $errstr, 5);
if ($internetOk) fclose($internetOk);
$checks[] = [
'name' => 'Internet Connection',
'status' => (bool)$internetOk,
'message' => $internetOk ? 'Connected' : 'No connection detected',
'required' => true
];
if (!$internetOk) $allPassed = false;
// Memory Limit
$memoryLimit = ini_get('memory_limit');
$memoryOk = true; // Usually not critical
$checks[] = [
'name' => 'PHP Memory Limit',
'status' => $memoryOk,
'message' => $memoryLimit,
'required' => false
];
// Display results
?>
<div class="mt-4">
<h5 class="fw-bold mb-3">Requirements Check</h5>
<div class="list-group">
<?php foreach ($checks as $check): ?>
<div class="list-group-item">
<div class="d-flex justify-content-between align-items-center">
<div>
<strong><?php echo htmlspecialchars($check['name']); ?></strong>
<?php if ($check['required']): ?>
<span class="badge bg-warning text-dark ms-2">Required</span>
<?php endif; ?>
<p class="mb-0 mt-1 text-muted small">
<?php echo htmlspecialchars($check['message']); ?>
</p>
</div>
<div>
<?php if ($check['status']): ?>
<i class="bi bi-check-circle-fill text-success fs-3"></i>
<?php else: ?>
<i class="bi bi-x-circle-fill text-danger fs-3"></i>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php if ($allPassed): ?>
<div class="alert alert-success mt-4">
<i class="bi bi-check-circle-fill me-2"></i>
<strong>All requirements met!</strong> Your system is ready to run the Fastway Couriers application.
</div>
<div class="mt-3">
<a href="index.php" class="btn btn-success btn-lg">
<i class="bi bi-arrow-right me-2"></i>Go to Application
</a>
</div>
<?php else: ?>
<div class="alert alert-danger mt-4">
<i class="bi bi-exclamation-triangle-fill me-2"></i>
<strong>Some requirements are not met.</strong> Please resolve the issues above before proceeding.
</div>
<div class="mt-3">
<h6 class="fw-bold">Quick Fixes:</h6>
<ul class="small">
<?php if (!$curlOk): ?>
<li><strong>Install cURL:</strong>
<code>sudo apt-get install php-curl</code> (Ubuntu/Debian) or
<code>sudo yum install php-curl</code> (CentOS/RHEL)
</li>
<?php endif; ?>
<?php if (!$logsDirOk): ?>
<li><strong>Fix logs directory:</strong>
<code>mkdir -p logs && chmod 755 logs</code>
</li>
<?php endif; ?>
<?php if (!$configOk): ?>
<li><strong>Missing config file:</strong> Ensure all files are uploaded correctly</li>
<?php endif; ?>
</ul>
<button onclick="location.reload()" class="btn btn-primary">
<i class="bi bi-arrow-clockwise me-2"></i>Re-check
</button>
</div>
<?php endif; ?>
<div class="mt-4 pt-3 border-top">
<h6 class="fw-bold">System Information</h6>
<table class="table table-sm">
<tbody>
<tr>
<td><strong>PHP Version:</strong></td>
<td><?php echo phpversion(); ?></td>
</tr>
<tr>
<td><strong>Server Software:</strong></td>
<td><?php echo $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown'; ?></td>
</tr>
<tr>
<td><strong>Document Root:</strong></td>
<td><small><?php echo $_SERVER['DOCUMENT_ROOT'] ?? 'Unknown'; ?></small></td>
</tr>
<tr>
<td><strong>Current Time:</strong></td>
<td><?php echo date('Y-m-d H:i:s'); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="text-center mt-3">
<a href="README.md" class="text-muted small">View Documentation</a>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>