Spaces:
Running
Running
Download config.php from danielmkinga92/usis: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/danielmkinga92/usis/resolve/main/config.php
- Command line
-
hf download hf://spaces/danielmkinga92/usis/config.php
-
curl -L -o config.php https://huggingface.co/spaces/danielmkinga92/usis/resolve/main/config.php
1.52 kB
| ```php | |
| // Database configuration | |
| define('DB_HOST', 'localhost'); | |
| define('DB_NAME', 'uatc_usis'); | |
| define('DB_USER', 'root'); | |
| define('DB_PASS', ''); | |
| // Session configuration | |
| ini_set('session.cookie_httponly', 1); | |
| ini_set('session.use_strict_mode', 1); | |
| // Error reporting | |
| error_reporting(E_ALL); | |
| ini_set('display_errors', 0); // Set to 1 for development, 0 for production | |
| // Timezone | |
| date_default_timezone_set('UTC'); | |
| // Establish database connection | |
| function getDBConnection() { | |
| try { | |
| $pdo = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASS); | |
| $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
| $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); | |
| $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); | |
| return $pdo; | |
| } catch (PDOException $e) { | |
| error_log("Database connection failed: " . $e->getMessage()); | |
| die("Database connection error. Please try again later."); | |
| } | |
| } | |
| // Security functions | |
| function sanitizeInput($data) { | |
| return htmlspecialchars(strip_tags(trim($data)), ENT_QUOTES, 'UTF-8'); | |
| } | |
| function isLoggedIn() { | |
| return isset($_SESSION['user_id']) && isset($_SESSION['role']); | |
| } | |
| function requireLogin() { | |
| if (!isLoggedIn()) { | |
| header('Location: login.html'); | |
| exit(); | |
| } | |
| } | |
| function requireRole($requiredRole) { | |
| requireLogin(); | |
| if ($_SESSION['role'] !== $requiredRole) { | |
| header('Location: unauthorized.html'); | |
| exit(); | |
| } | |
| } | |
| ``` |