You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1001 B
35 lines
1001 B
<?php
|
|
namespace config;
|
|
|
|
class Validation
|
|
{
|
|
public static function val_action($action)
|
|
{
|
|
if (!isset($action)) {
|
|
throw new \Exception('pas d\'action');
|
|
//on pourrait aussi utiliser
|
|
//$action = $_GET['action'] ?? 'no';
|
|
// This is equivalent to:
|
|
//$action = if (isset($_GET['action'])) $action=$_GET['action'] else $action='no';
|
|
}
|
|
}
|
|
|
|
public static function val_form(string &$nom, string &$age, &$dVueEreur)
|
|
{
|
|
if (!isset($nom) || $nom == '') {
|
|
$dVueEreur[] = 'pas de nom';
|
|
$nom = '';
|
|
}
|
|
|
|
if ( strlen(htmlspecialchars($nom, ENT_QUOTES)) != strlen($nom) ) {
|
|
$dVueEreur[] = "testative d'injection de code (attaque sécurité)";
|
|
$nom = '';
|
|
}
|
|
|
|
if (!isset($age) || $age == '' || !filter_var($age, FILTER_VALIDATE_INT)) {
|
|
$dVueEreur[] = "pas d'age ";
|
|
$age = 0;
|
|
}
|
|
}
|
|
}
|