File manager - Edit - /home/verseaumee/chatblueversion/includes/bootstrap.php
Back
<?php declare(strict_types=1); session_start(); define('ROOT',dirname(__DIR__)); $file=ROOT.'/config.php'; if(!file_exists($file)){if(!str_contains($_SERVER['REQUEST_URI']??'','/install/')){header('Location: install/');exit;}return;} $config=require $file; try{$pdo=new PDO("mysql:host={$config['db']['host']};port={$config['db']['port']};dbname={$config['db']['name']};charset=utf8mb4",$config['db']['user'],$config['db']['pass'],[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_ASSOC]);}catch(Throwable $e){http_response_code(500);exit('Database connection failed.');} function current_user():?array{return $_SESSION['user']??null;} function require_login():void{if(!current_user()){header('Location: /login.php');exit;}} function require_admin():void{require_login();if((current_user()['role']??'')!=='admin'){http_response_code(403);exit('Forbidden');}} function json_out(array $v,int $s=200):never{http_response_code($s);header('Content-Type: application/json');echo json_encode($v);exit;} function csrf_token():string{if(empty($_SESSION['csrf']))$_SESSION['csrf']=bin2hex(random_bytes(24));return $_SESSION['csrf'];} function check_csrf():void{if(!hash_equals($_SESSION['csrf']??'',$_POST['csrf']??'')){http_response_code(419);exit('Session expired. Please go back and try again.');}}
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings