░▒▓████████████████████████████████▓▒░ ░▒▓█ ▓▒░ ░▒▓█ ~ S W A M P ~ ▓▒░ ░▒▓█ ▓▒░ ░▒▓████████████████████████████████▓▒░
lon105.truehost.cloud
LOCATION:
/home/ilrtztmy/versatilesecuritylimited.com/api
☗ ROOT
↻ REFRESH
✎ CARVE FLESH
EDITING: config.php
<?php // Database configuration define('DB_HOST', 'localhost'); define('DB_NAME', 'ilrtztmy_vsl'); define('DB_USER', 'ilrtztmy_vsl'); define('DB_PASS', 'E.htmsS!_6jw[&T6'); // JWT Secret Key (Change this in production) define('JWT_SECRET', '865551f03e857d936825e511393b26a079579f7c1069d26ad3ffdbcd2811c787'); /** * Database connection using PDO */ function getDbConnection() { try { $dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4"; $options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; return new PDO($dsn, DB_USER, DB_PASS, $options); } catch (PDOException $e) { http_response_code(500); echo json_encode(['success' => false, 'message' => 'Database connection failed: ' . $e->getMessage()]); exit; } } /** * Simple JWT-like token generation (for demonstration purposes) * In a real production environment, use a robust JWT library like firebase/php-jwt */ function generateToken($userId) { $header = json_encode(['typ' => 'JWT', 'alg' => 'HS256']); $payload = json_encode([ 'user_id' => $userId, 'exp' => time() + (60 * 60 * 24) // 24 hours expiration ]); $base64UrlHeader = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($header)); $base64UrlPayload = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($payload)); $signature = hash_hmac('sha256', $base64UrlHeader . "." . $base64UrlPayload, JWT_SECRET, true); $base64UrlSignature = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($signature)); return $base64UrlHeader . "." . $base64UrlPayload . "." . $base64UrlSignature; } /** * Simple JWT-like token validation */ function validateToken($token) { $parts = explode('.', $token); if (count($parts) !== 3) return false; list($header, $payload, $signature) = $parts; $validSignature = hash_hmac('sha256', $header . "." . $payload, JWT_SECRET, true); $base64UrlValidSignature = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($validSignature)); if ($signature !== $base64UrlValidSignature) return false; $decodedPayload = json_decode(base64_decode(str_replace(['-', '_'], ['+', '/'], $payload)), true); if (!$decodedPayload || (isset($decodedPayload['exp']) && $decodedPayload['exp'] < time())) { return false; } return $decodedPayload; } /** * Helper to get Bearer token from Authorization header */ function getBearerToken() { $headers = getallheaders(); if (isset($headers['Authorization'])) { if (preg_match('/Bearer\s(\S+)/', $headers['Authorization'], $matches)) { return $matches[1]; } } return null; } /** * Middleware to ensure user is authenticated */ function authenticate() { $token = getBearerToken(); if (!$token) { http_response_code(401); echo json_encode(['success' => false, 'message' => 'Unauthorized: No token provided']); exit; } $decoded = validateToken($token); if (!$decoded) { http_response_code(401); echo json_encode(['success' => false, 'message' => 'Unauthorized: Invalid or expired token']); exit; } return $decoded; } /** * Helper to handle JSON input */ function getJsonInput() { return json_decode(file_get_contents('php://input'), true); } /** * Helper to send JSON response */ function sendJsonResponse($data, $statusCode = 200) { header('Content-Type: application/json'); http_response_code($statusCode); echo json_encode($data); exit; } ?>
CANCEL
Name
Type
Size
Modified
Actions
↩ ..
DIR
—
—
📁 admin/
DIR
—
2020-10-15 14:24
📄 careers.php
PHP
1.7 KB
2026-05-16 13:26
EDIT
📄 config.php
PHP
3.7 KB
2026-05-16 11:45
EDIT
📄 contact.php
PHP
1.7 KB
2026-05-16 13:27
EDIT
📄 packages-inquiry.php
PHP
1.8 KB
2026-05-16 13:26
EDIT