Browse Source

ajoute les exceptions dans la configuration

master
vince vince 2 years ago
parent
commit
7d2700bcf2
1 changed files with 25 additions and 15 deletions
  1. +25
    -15
      index.php

+ 25
- 15
index.php View File

@ -53,7 +53,7 @@ if ($hasSupplier) {
'start' => 'now 00:00:00', 'start' => 'now 00:00:00',
'frequency' => '1 day', 'frequency' => '1 day',
'password' => '', 'password' => '',
'excludes' => [],
], ],
$config[$supplier] $config[$supplier]
); );
@ -63,16 +63,16 @@ if ($hasSupplier) {
if ($action === 'config') { if ($action === 'config') {
if ($hasPassword) { if ($hasPassword) {
if (!isset($_SERVER['PHP_AUTH_USER'])) { 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'); 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; exit;
} elseif ( } elseif (
($_SERVER['PHP_AUTH_USER'] !== $supplier) ($_SERVER['PHP_AUTH_USER'] !== $supplier)
or ($_SERVER['PHP_AUTH_PW'] !== $config[$supplier]['password']) or ($_SERVER['PHP_AUTH_PW'] !== $config[$supplier]['password'])
) { ) {
header('HTTP/1.0 403 Forbidden'); 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; exit;
} }
} }
@ -86,20 +86,22 @@ if ($hasSupplier) {
$config[$supplier]['start'] = 'now 00:00:00'; $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; $isConfig = false;
@ -323,6 +325,14 @@ if (!$isConfig and $hasSupplier) {
</div> </div>
</div> </div>
<div class="row mb-3"> <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> <label for="password" class="col-sm-2 col-form-label">Mot de passe</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input class="form-control" type="text" name="password" value="<?php echo $config[$supplier]['password']; ?>" /> <input class="form-control" type="text" name="password" value="<?php echo $config[$supplier]['password']; ?>" />


Loading…
Cancel
Save