First Commit

This commit is contained in:
marco
2026-09-04 14:54:13 -03:00
commit 9c54bd3ac7
4914 changed files with 789004 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
function startSessionIfNeeded() {
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
}
function generateCsrfToken() {
startSessionIfNeeded();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
return $_SESSION['csrf_token'];
}
function getCsrfToken() {
startSessionIfNeeded();
return $_SESSION['csrf_token'] ?? '';
}
function validateCsrfToken($token) {
startSessionIfNeeded();
return hash_equals($_SESSION['csrf_token'] ?? '', $token ?? '');
}