|
|
@ -53,7 +53,7 @@ if ($hasSupplier) { |
|
|
|
'start' => 'now 00:00:00', |
|
|
|
'frequency' => '1 day', |
|
|
|
'password' => '', |
|
|
|
|
|
|
|
'excludes' => [], |
|
|
|
], |
|
|
|
$config[$supplier] |
|
|
|
); |
|
|
@ -63,16 +63,16 @@ if ($hasSupplier) { |
|
|
|
if ($action === 'config') { |
|
|
|
if ($hasPassword) { |
|
|
|
if (!isset($_SERVER['PHP_AUTH_USER'])) { |
|
|
|
header(sprintf('WWW-Authenticate: Basic realm="mon-panier-bio config %s"', $supplier)); |
|
|
|
header(sprintf('WWW-Authenticate: Basic realm="Configuration de mon panier bio pour %s"', $supplier)); |
|
|
|
header('HTTP/1.0 401 Unauthorized'); |
|
|
|
printf('Cette config est protégée par mot de passe !'); |
|
|
|
printf('Cette configuration est protégée par mot de passe !'); |
|
|
|
exit; |
|
|
|
} elseif ( |
|
|
|
($_SERVER['PHP_AUTH_USER'] !== $supplier) |
|
|
|
or ($_SERVER['PHP_AUTH_PW'] !== $config[$supplier]['password']) |
|
|
|
) { |
|
|
|
header('HTTP/1.0 403 Forbidden'); |
|
|
|
printf('Cette config est protégée par mot de passe !'); |
|
|
|
printf('Cette configuration est protégée par mot de passe !'); |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
@ -86,20 +86,22 @@ if ($hasSupplier) { |
|
|
|
$config[$supplier]['start'] = 'now 00:00:00'; |
|
|
|
|
|
|
|
|
|
|
|
if (is_string($config[$supplier]['choices'])) |
|
|
|
$config[$supplier]['choices'] = explode(PHP_EOL, $config[$supplier]['choices']); |
|
|
|
foreach (['choices', 'excludes'] as $key) { |
|
|
|
if (is_string($config[$supplier][$key])) |
|
|
|
$config[$supplier][$key] = explode(PHP_EOL, $config[$supplier][$key]); |
|
|
|
|
|
|
|
if (!is_array($config[$supplier]['choices'])) |
|
|
|
$config[$supplier]['choices'] = []; |
|
|
|
if (!is_array($config[$supplier][$key])) |
|
|
|
$config[$supplier][$key] = []; |
|
|
|
|
|
|
|
$config[$supplier]['choices'] = array_filter( |
|
|
|
$config[$supplier]['choices'], |
|
|
|
function ($choice) { |
|
|
|
return is_string($choice) and !empty(trim($choice)); |
|
|
|
} |
|
|
|
); |
|
|
|
$config[$supplier][$key] = array_filter( |
|
|
|
$config[$supplier][$key], |
|
|
|
function ($choice) { |
|
|
|
return is_string($choice) and !empty(trim($choice)); |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
$config[$supplier]['choices'] = array_map('trim', $config[$supplier]['choices']); |
|
|
|
$config[$supplier][$key] = array_map('trim', $config[$supplier][$key]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$isConfig = false; |
|
|
@ -323,6 +325,14 @@ if (!$isConfig and $hasSupplier) { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="row mb-3"> |
|
|
|
<label for="excludes" class="col-sm-2 col-form-label">Exceptions</label> |
|
|
|
<div class="col-sm-10"> |
|
|
|
<textarea class="form-control" name="excludes" rows="5"><?php echo implode(PHP_EOL, $config[$supplier]['excludes']); ?></textarea>
|
|
|
|
<div class="form-text">Les dates à exclure. Une par ligne. Ou pas.</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="row mb-3"> |
|
|
|
<label for="password" class="col-sm-2 col-form-label">Mot de passe</label> |
|
|
|
<div class="col-sm-10"> |
|
|
|
<input class="form-control" type="text" name="password" value="<?php echo $config[$supplier]['password']; ?>" /> |
|
|
|