예제 #1
0
<meta charset="utf-8">
<?php 
require_once "fortress/config-fortress.php";
/******** Do this in a project-wide config file ********/
// Start the session
session_start();
// Create a message translator
$translator = new Fortress\MessageTranslator();
// Set the translation paths
$translator->setTranslationTable("fortress/locale/es_ES.php");
$translator->setDefaultTable("fortress/locale/en_US.php");
// Set the message stream
if (!isset($_SESSION['Fortress']['alerts'])) {
    $_SESSION['Fortress']['alerts'] = new Fortress\MessageStream($translator);
}
$ms = $_SESSION['Fortress']['alerts'];
/*******************************************************/
// Test the error stream and reset
echo "<h2>Current message stream</h2>";
echo "<pre>";
print_r($ms->messages());
echo "</pre>";
$ms->resetMessageStream();
// Load the request schema
$schema = new Fortress\RequestSchema("fortress/schema/forms/register.json");
// POST request
$rf = new Fortress\HTTPRequestFortress($ms, $schema, $_GET);
// Remove csrf_token from the request data, if specified
$rf->removeFields(['csrf_token']);
// Sanitize, and print sanitized data for demo purposes
$rf->sanitize(true, "error");