parent
04cbe54dd1
commit
220c0ece82
18 changed files with 95 additions and 22 deletions
|
|
@ -491,9 +491,9 @@ trait AnimalRecordActions
|
|||
$felv = array_key_exists('felv', $_POST) ? (isset($_POST['felv']) ? 1 : 0) : null;
|
||||
|
||||
// Validations minimales
|
||||
if ($name === '') {
|
||||
if ($name === '' || mb_strlen($name) > 150) {
|
||||
http_response_code(400);
|
||||
echo h(t('error.name_required'));
|
||||
echo h($name === '' ? t('error.name_required') : t('animal.name_too_long'));
|
||||
return;
|
||||
}
|
||||
if ($breed === '' && SpeciesService::isCat($species)) {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,10 @@ final class AuthController
|
|||
$error = t('install.association_required');
|
||||
} elseif ($email !== '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$error = t('settings.invalid_email');
|
||||
} elseif (!Ids::validRna((string) ($_POST['association_rna'] ?? ''))) {
|
||||
$error = t('settings.invalid_rna');
|
||||
} elseif (!Ids::validSiret((string) ($_POST['association_siret'] ?? ''))) {
|
||||
$error = t('settings.invalid_siret');
|
||||
} elseif (!preg_match('/^[a-zA-Z0-9._-]{3,40}$/', $username)) {
|
||||
$error = t('auth.invalid_username');
|
||||
} elseif ($display === '') {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ final class SettingsController
|
|||
echo h(t('settings.invalid_email'));
|
||||
return;
|
||||
}
|
||||
if (!Ids::validRna($values['association_rna'])) {
|
||||
header('Location: /settings/general?error=' . rawurlencode(t('settings.invalid_rna')));
|
||||
exit();
|
||||
}
|
||||
if (!Ids::validSiret($values['association_siret'])) {
|
||||
header('Location: /settings/general?error=' . rawurlencode(t('settings.invalid_siret')));
|
||||
exit();
|
||||
}
|
||||
$values['quarantine_days'] = (string) max(1, min(90, (int) ($_POST['quarantine_days'] ?? 15)));
|
||||
$values['backup_retention'] = (string) max(1, min(50, (int) ($_POST['backup_retention'] ?? 10)));
|
||||
$values['app_language'] = isset(I18n::LOCALES[(string) ($_POST['app_language'] ?? 'fr')])
|
||||
|
|
@ -230,6 +238,7 @@ final class SettingsController
|
|||
$color = (string) ($row['color'] ?? '#6c757d');
|
||||
if (
|
||||
$name === '' ||
|
||||
mb_strlen($name) > 100 ||
|
||||
!in_array($type, ['collective', 'boxes'], true) ||
|
||||
!in_array($status, ['refuge', 'soin', 'quarantaine'], true) ||
|
||||
!preg_match('/^#[0-9a-fA-F]{6}$/', $color)
|
||||
|
|
@ -253,6 +262,9 @@ final class SettingsController
|
|||
$new = (array) ($_POST['new_room'] ?? []);
|
||||
$newName = trim((string) ($new['name'] ?? ''));
|
||||
if ($newName !== '') {
|
||||
if (mb_strlen($newName) > 100) {
|
||||
throw new RuntimeException(t('rooms.name_too_long'));
|
||||
}
|
||||
$code = ShelterRoomService::normalizeCode((string) ($new['code'] ?? $newName));
|
||||
if (strlen($code) < 2) {
|
||||
throw new RuntimeException(t('rooms.invalid'));
|
||||
|
|
@ -297,6 +309,9 @@ final class SettingsController
|
|||
$known = $existing->fetchAll(PDO::FETCH_ASSOC);
|
||||
$kept = [];
|
||||
foreach ($names as $index => $name) {
|
||||
if (mb_strlen($name) > 100) {
|
||||
throw new RuntimeException(t('rooms.box_name_too_long'));
|
||||
}
|
||||
$position = ($index + 1) * 10;
|
||||
if (isset($known[$index])) {
|
||||
$id = (int) $known[$index]['id'];
|
||||
|
|
|
|||
Loading…
Reference in a new issue