Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.217.35 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaumee/chatblueversion/includes/ |
Upload File : |
<?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.');}}