| Server IP : 103.243.232.44 / Your IP : 216.73.216.237 Web Server : LiteSpeed System : Linux server17213-10344.hostycare.online 5.14.0-687.38.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 12 17:19:12 EDT 2026 x86_64 User : iamakash ( 1400) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/iamakash/public_html/shaurya.meals28.com/ |
Upload File : |
<?php
require __DIR__ . '/includes/auth.php';
requireLogin();
/**
* One-time setup helper. DELETE THIS FILE after setup is complete.
*/
$checks = [];
$dbOk = false;
$tablesOk = false;
$configFile = __DIR__ . '/config/db.php';
// 1. Check PHP version
$checks['PHP Version'] = [
'value' => PHP_VERSION,
'ok' => version_compare(PHP_VERSION, '8.1.0', '>='),
'fix' => 'Need PHP 8.1+. Change PHP version in cPanel → Select PHP Version.',
];
// 2. Check required extensions
foreach (['pdo_mysql', 'zip', 'xml', 'gd', 'mbstring'] as $ext) {
$checks["Extension: $ext"] = [
'value' => extension_loaded($ext) ? 'loaded' : 'MISSING',
'ok' => extension_loaded($ext),
'fix' => "Enable in cPanel → Select PHP Version → Extensions → check $ext",
];
}
// 3. Check vendor directory
$checks['Composer vendor/'] = [
'value' => is_dir(__DIR__ . '/vendor') ? 'exists' : 'MISSING',
'ok' => is_dir(__DIR__ . '/vendor'),
'fix' => 'Upload the vendor/ folder from the deployment zip.',
];
// 4. Check uploads/ directory writable
$uploadsDir = __DIR__ . '/uploads';
if (!is_dir($uploadsDir)) { @mkdir($uploadsDir, 0775, true); }
$checks['uploads/ writable'] = [
'value' => is_writable($uploadsDir) ? 'writable' : 'NOT writable',
'ok' => is_writable($uploadsDir),
'fix' => 'In File Manager, right-click uploads/ → Permissions → set 775.',
];
// 5. Check PHP limits
foreach (['upload_max_filesize', 'post_max_size', 'memory_limit', 'max_execution_time'] as $key) {
$val = ini_get($key);
$checks["php.ini: $key"] = [
'value' => $val,
'ok' => true, // informational
'fix' => '',
];
}
// 6. Check DB connection
$dbError = '';
if (is_file($configFile)) {
$cfg = require $configFile;
try {
$dsn = sprintf('mysql:host=%s;port=%d;dbname=%s;charset=%s',
$cfg['host'], $cfg['port'], $cfg['database'], $cfg['charset']);
$pdo = new PDO($dsn, $cfg['username'], $cfg['password'], [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
$dbOk = true;
// Check tables exist
$tables = [];
foreach ($pdo->query("SHOW TABLES") as $r) { $tables[] = array_values($r)[0]; }
$needed = ['commodities', 'monthly_indices', 'uploads'];
$missing = array_diff($needed, $tables);
$tablesOk = empty($missing);
$checks['Database connection'] = [
'value' => 'connected to ' . $cfg['database'],
'ok' => true,
'fix' => '',
];
$checks['Tables'] = [
'value' => $tablesOk ? 'all 3 present (' . implode(', ', $needed) . ')' : 'MISSING: ' . implode(', ', $missing),
'ok' => $tablesOk,
'fix' => $tablesOk ? '' : 'Run sql/deploy.sql in phpMyAdmin.',
];
if ($tablesOk) {
$commCount = (int)$pdo->query('SELECT COUNT(*) FROM commodities')->fetchColumn();
$valCount = (int)$pdo->query('SELECT COUNT(*) FROM monthly_indices')->fetchColumn();
$checks['Data loaded'] = [
'value' => "$commCount commodities, $valCount index values",
'ok' => $commCount > 0,
'fix' => $commCount === 0 ? 'Go to Upload page and upload monthly_index_YYYYMM.xls' : '',
];
}
} catch (PDOException $e) {
$dbError = $e->getMessage();
$checks['Database connection'] = [
'value' => 'FAILED: ' . $dbError,
'ok' => false,
'fix' => 'Edit config/db.php with the correct database name, username, and password from cPanel.',
];
}
} else {
$checks['config/db.php'] = [
'value' => 'FILE MISSING',
'ok' => false,
'fix' => 'config/db.php not found. Re-upload from the deployment zip.',
];
}
$allOk = !array_filter($checks, fn($c) => !$c['ok']);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Shaurya Setup Check</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container py-4" style="max-width: 720px;">
<h2 class="mb-1">Shaurya — Setup Check</h2>
<p class="text-muted mb-4">Verifies your hosting environment is ready. <strong>Delete this file (setup.php) after setup is complete.</strong></p>
<?php if ($allOk): ?>
<div class="alert alert-success">
All checks passed. <a href="index.php" class="fw-bold">Go to Dashboard</a> — then <strong>delete setup.php</strong>.
</div>
<?php endif; ?>
<table class="table table-sm">
<thead><tr><th>Check</th><th>Status</th><th>Action needed</th></tr></thead>
<tbody>
<?php foreach ($checks as $name => $c): ?>
<tr>
<td><?= htmlspecialchars($name) ?></td>
<td>
<span class="badge bg-<?= $c['ok'] ? 'success' : 'danger' ?>"><?= $c['ok'] ? 'OK' : 'FAIL' ?></span>
<span class="small text-muted ms-1"><?= htmlspecialchars($c['value']) ?></span>
</td>
<td class="small"><?= htmlspecialchars($c['fix']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="card mt-4"><div class="card-body">
<h5>Quick setup steps</h5>
<ol>
<li>cPanel → <strong>MySQL Databases</strong> → create DB + user + grant all privileges</li>
<li>Edit <code>config/db.php</code> in File Manager → paste your DB name, user, password</li>
<li>cPanel → <strong>phpMyAdmin</strong> → select your DB → <strong>SQL tab</strong> → paste contents of <code>sql/deploy.sql</code> → click Go</li>
<li>Reload this page — all checks should turn green</li>
<li>Go to <a href="upload.php">Upload</a> and upload the monthly index file</li>
<li><strong>Delete this file (setup.php)</strong></li>
</ol>
</div></div>
</div>
</body>
</html>