File manager - Edit - /home/webtrixia/.trash/test-cards.php
Back
<?php define('ROOT', __DIR__); require ROOT.'/config/config.php'; require ROOT.'/src/helpers/Core.php'; Auth::start(); $user = Auth::user(); // Simple test if ($_SERVER['REQUEST_METHOD'] === 'POST') { header('Content-Type: application/json'); echo json_encode([ 'ok' => true, 'post' => $_POST, 'user_role' => $user ? $user->role : 'not logged in', 'csrf_ok' => hash_equals((string)($_SESSION['csrf']??''), (string)($_POST['csrf']??'')) ]); exit; } ?> <!DOCTYPE html> <html> <head><meta charset="UTF-8"><title>Test Cards</title></head> <body> <h2>Test Card Generation</h2> <p>Logged in as: <?= $user ? htmlspecialchars($user->name).' ('.$user->role.')' : 'NOT LOGGED IN' ?></p> <form id="test-form"> <input type="hidden" name="csrf" value="<?= $_SESSION['csrf'] ?? 'NO CSRF' ?>"> <input type="text" name="location" value="TEST"> <input type="number" name="count" value="3"> <button type="button" id="test-btn">Test POST</button> </form> <div id="result" style="margin-top:20px;white-space:pre;background:#f0f0f0;padding:10px"></div> <script> document.getElementById('test-btn').addEventListener('click', async function() { const fd = new FormData(document.getElementById('test-form')); document.getElementById('result').textContent = 'Sending...'; try { const res = await fetch('/test-cards.php', {method:'POST', body:fd}); const text = await res.text(); document.getElementById('result').textContent = 'Status: ' + res.status + '\nResponse: ' + text; } catch(err) { document.getElementById('result').textContent = 'ERROR: ' + err.message; } }); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0 |
proxy
|
phpinfo
|
Settings