Initial clean version
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
spl_autoload_register(function(string $class): void {
|
||||
if(str_starts_with($class,'Firebase\\JWT\\')){$path=__DIR__.'/vendor/firebase/php-jwt/src/'.substr($class,13).'.php';if(is_file($path))require $path;}
|
||||
|
||||
if (str_starts_with($class, 'App\\')) {
|
||||
$path=__DIR__.'/src/'.str_replace('\\','/',substr($class,4)).'.php';
|
||||
if (is_file($path)) require $path;
|
||||
}
|
||||
});
|
||||
function e(mixed $v): string { return htmlspecialchars((string)$v, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); }
|
||||
function go(string $url): never { header('Location: '.$url, true, 303); exit; }
|
||||
function csrf(): string { return '<input type="hidden" name="csrf" value="'.e($_SESSION['csrf']).'">'; }
|
||||
function field(string $name,string $label,mixed $value='',string $type='text',bool $required=false): string {
|
||||
return '<label>'.e($label).'<input name="'.e($name).'" type="'.e($type).'" value="'.e($value).'" '.($required?'required':'').'></label>';
|
||||
}
|
||||
function selectField(string $name,string $label,array $options,mixed $value=''): string {
|
||||
$html='<label>'.e($label).'<select name="'.e($name).'">';
|
||||
foreach($options as $k=>$v) $html.='<option value="'.e($k).'" '.((string)$k===(string)$value?'selected':'').'>'.e($v).'</option>';
|
||||
return $html.'</select></label>';
|
||||
}
|
||||
function options(array $rows,string $label='name'): array { return array_column($rows,$label,'id'); }
|
||||
function badge(string $status): string {
|
||||
$labels=['available'=>'Disponible','blocked'=>'Suspendu','review'=>'Contrôle nécessaire'];
|
||||
return '<span class="badge '.e($status).'">'.e($labels[$status]??$status).'</span>';
|
||||
}
|
||||
Reference in New Issue
Block a user