Jimmy Monin 58ffd500e6 Upgrade LBCAlerte to version 3.3
Add upgrade script
2016-11-26 19:25:53 +01:00

51 lines
1.4 KiB
PHP

<?php
if (!$userAuthed->getApiKey()) {
$userAuthed->setApiKey(
sha1(
str_repeat(
uniqid($_SERVER["HTTP_HOST"], true),
rand(10, 100)
)
)
);
$userStorage->save($userAuthed);
}
$params = array(
"notification" => $userAuthed->getOption("notification"),
"unique_ads" => $userAuthed->getOption("unique_ads", false),
"api_key" => $userAuthed->getApiKey(),
"addresses_mails" => $userAuthed->getOption("addresses_mails"),
);
require DOCUMENT_ROOT."/app/data/notifications.php";
$form_values = array(
"api_key" => $params["api_key"],
"unique_ads" => $params["unique_ads"],
"addresses_mails" => $params["addresses_mails"],
);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$form_values = array_intersect_key($_POST, $form_values);
if (!empty($_POST["regenerate-apikey"])) {
$userAuthed->setApiKey(
sha1(
str_repeat(
uniqid($_SERVER["HTTP_HOST"], true),
rand(10, 100)
)
)
);
}
$userAuthed->mergeOptions($form_values);
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings"); exit;
}
$userSettingsSaved = isset($_SESSION["userSettingsSaved"]) && true === $_SESSION["userSettingsSaved"];
unset($_SESSION["userSettingsSaved"]);