Add load and local save of the cloud

This commit is contained in:
Gregory Trolliet 2020-11-25 22:13:59 +01:00
parent 98b3498de2
commit fea36cb867
3 changed files with 118 additions and 37 deletions

View file

@ -7,24 +7,28 @@ if (empty($_POST)) {
}
include 'templates/header.php';
$id = null;
$cpt = 0;
$already_used = array();
foreach ($_POST as $name => $value) {
$cpt;
if ($name == 'fid') {
$id = $value;
continue;
}
if (isset($id) && !in_array($value, $already_used)) {
$already_used[] = $value;
$value = trim(strtolower($value));
$db->addWord($id, $value);
}
if ($cpt > 9) {
break;
if (!isset($_POST['fid'])) {
echo sprintf('<h3>%s</h3>', L::save_missingId);
} elseif (!$db->loadCloud($_POST['fid'])) {
echo sprintf('<h3>%s</h3>', L::save_cloudNotFound($_POST['fid']));
} else {
$cpt = 0;
$already_used = array();
foreach ($_POST as $name => $value) {
if ($name == 'fid') {
continue;
}
$cpt++;
if (!in_array($value, $already_used)) {
$already_used[] = $value;
$value = trim(strtolower($value));
$db->addWord($value);
}
if ($cpt > 9) {
break;
}
}
echo sprintf('<h3>%s</h3>', L::save_success);
}
echo sprintf('<h3>%s</h3>', L::save_success);
include 'templates/footer.php';