Upgrade LBCAlerte to version 3.3

Add upgrade script
This commit is contained in:
Jimmy Monin
2016-11-26 19:19:16 +01:00
parent a7c054b535
commit 58ffd500e6
89 changed files with 6436 additions and 758 deletions

View File

@ -0,0 +1,33 @@
<?php
if (empty($_GET["s"])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
switch ($_GET["s"]) {
case "sms-free-mobile":
$key = "freeMobile";
break;
case "sms-ovh":
$key = "ovh";
break;
default:
$key = $_GET["s"];
}
$notifications = $userAuthed->getOption("notification");
if (!isset($notifications[$key])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
$notifications[$key]["active"] = false;
$userAuthed->mergeOptions(array(
"notification" => $notifications
));
$userStorage->save($userAuthed);
header("LOCATION: ./?mod=user&a=settings");
exit;

View File

@ -0,0 +1,66 @@
<?php
$form_values = array(
"user" => "",
"key" => "",
);
$data_user = $userAuthed->getOption("notification.freeMobile");
if ($data_user && is_array($data_user)) {
$form_values = array_merge($form_values, $data_user);
}
$errors = array();
$errorsTest = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["cancel-config"])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
if (!empty($_POST["delete-config"])) {
$userAuthed->mergeOptions(array(
"notification" => array(
"freeMobile" => false,
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
$form_values = array_intersect_key($_POST, $form_values);
// Validation des champs
foreach ($form_values AS $name => $value) {
if (empty($value)) {
$errors[$name] = "Ce champ doit être renseigné.";
}
}
if (empty($errors)) {
if (!empty($_POST["test-config"])) {
$sms = \Message\AdapterFactory::factory("freeMobile", $form_values);
try {
$sms->send("La notification SMS est fonctionnelle.");
} catch (Exception $e) {
$errorsTest = "Erreur lors de l'envoi du SMS : (".$e->getCode().") ".$e->getMessage();
}
} else {
$userAuthed->mergeOptions(array(
"notification" => array(
"freeMobile" => array(
"user" => $form_values["user"],
"key" => $form_values["key"],
"active" => true,
),
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
}
}

View File

@ -0,0 +1,67 @@
<?php
$form_values = array(
"device_ids" => "group.all",
"token" => "",
);
$data_user = $userAuthed->getOption("notification.joaoappsjoin");
if ($data_user && is_array($data_user)) {
$form_values = array_merge($form_values, $data_user);
}
$errors = array();
$errorsTest = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["cancel-config"])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
if (!empty($_POST["delete-config"])) {
$userAuthed->mergeOptions(array(
"notification" => array(
"joaoappsjoin" => false,
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
$form_values = array_intersect_key($_POST, $form_values);
// Validation des champs
foreach ($form_values AS $name => $value) {
if (empty($value)) {
$errors[$name] = "Ce champ doit être renseigné.";
}
}
if (empty($errors)) {
if (!empty($_POST["test-config"])) {
$sender = \Message\AdapterFactory::factory("joaoappsjoin", $form_values);
try {
$sender->send("La notification Joaoapps / Join est fonctionnelle");
} catch (Exception $e) {
$errorsTest = "Erreur lors de l'envoi de la notification : (".$e->getCode().") ".$e->getMessage();
}
} else {
$userAuthed->mergeOptions(array(
"notification" => array(
"joaoappsjoin" => array(
"device_ids" => $form_values["device_ids"],
"token" => $form_values["token"],
"active" => true,
),
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
}
}

View File

@ -0,0 +1,67 @@
<?php
$form_values = array(
"token" => "",
);
$data_user = $userAuthed->getOption("notification.notifymyandroid");
if ($data_user && is_array($data_user)) {
$form_values = array_merge($form_values, $data_user);
}
$errors = array();
$errorsTest = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["cancel-config"])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
if (!empty($_POST["delete-config"])) {
$userAuthed->mergeOptions(array(
"notification" => array(
"notifymyandroid" => false,
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
$form_values = array_intersect_key($_POST, $form_values);
// Validation des champs
foreach ($form_values AS $name => $value) {
if (empty($value)) {
$errors[$name] = "Ce champ doit être renseigné.";
}
}
if (empty($errors)) {
if (!empty($_POST["test-config"])) {
$sender = \Message\AdapterFactory::factory("notifymyandroid", $form_values);
try {
$sender->send("La notification NotifyMyAndroid est fonctionnelle", array(
"title" => "Test alerte"
));
} catch (Exception $e) {
$errorsTest = "Erreur lors de l'envoi de la notification : (".$e->getCode().") ".$e->getMessage();
}
} else {
$userAuthed->mergeOptions(array(
"notification" => array(
"notifymyandroid" => array(
"token" => $form_values["token"],
"active" => true,
),
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
}
}

View File

@ -0,0 +1,73 @@
<?php
$form_values = array(
"account" => "",
"login" => "",
"password" => "",
"from" => "",
"to" => "",
);
$data_user = $userAuthed->getOption("notification.ovh");
if ($data_user && is_array($data_user)) {
$form_values = array_merge($form_values, $data_user);
}
$errors = array();
$errorsTest = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["cancel-config"])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
if (!empty($_POST["delete-config"])) {
$userAuthed->mergeOptions(array(
"notification" => array(
"ovh" => false,
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
$form_values = array_intersect_key($_POST, $form_values);
// Validation des champs
foreach ($form_values AS $name => $value) {
if (empty($value)) {
$errors[$name] = "Ce champ doit être renseigné.";
}
}
if (empty($errors)) {
if (!empty($_POST["test-config"])) {
$sender = \Message\AdapterFactory::factory("SmsOvh", $form_values);
try {
$sender->send("La notification SMS est fonctionnelle.");
} catch (Exception $e) {
$errorsTest = "Erreur lors de l'envoi du SMS : (".$e->getCode().") ".$e->getMessage();
}
} else {
$userAuthed->mergeOptions(array(
"notification" => array(
"ovh" => array(
"account" => $form_values["account"],
"login" => $form_values["login"],
"password" => $form_values["password"],
"from" => $form_values["from"],
"to" => $form_values["to"],
"active" => true,
),
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
}
}

View File

@ -0,0 +1,65 @@
<?php
$form_values = array(
"token" => "",
);
$data_user = $userAuthed->getOption("notification.pushbullet");
if ($data_user && is_array($data_user)) {
$form_values = array_merge($form_values, $data_user);
}
$errors = array();
$errorsTest = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["cancel-config"])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
if (!empty($_POST["delete-config"])) {
$userAuthed->mergeOptions(array(
"notification" => array(
"pushbullet" => false,
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
$form_values = array_intersect_key($_POST, $form_values);
// Validation des champs
foreach ($form_values AS $name => $value) {
if (empty($value)) {
$errors[$name] = "Ce champ doit être renseigné.";
}
}
if (empty($errors)) {
if (!empty($_POST["test-config"])) {
$sender = \Message\AdapterFactory::factory("pushbullet", $form_values);
try {
$sender->send("La notification Pushbullet est fonctionnelle");
} catch (Exception $e) {
$errorsTest = "Erreur lors de l'envoi de la notification : (".$e->getCode().") ".$e->getMessage();
}
} else {
$userAuthed->mergeOptions(array(
"notification" => array(
"pushbullet" => array(
"token" => $form_values["token"],
"active" => true,
),
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
}
}

View File

@ -0,0 +1,67 @@
<?php
$form_values = array(
"token" => "",
"user_key" => "",
);
$data_user = $userAuthed->getOption("notification.pushover");
if ($data_user && is_array($data_user)) {
$form_values = array_merge($form_values, $data_user);
}
$errors = array();
$errorsTest = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["cancel-config"])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
if (!empty($_POST["delete-config"])) {
$userAuthed->mergeOptions(array(
"notification" => array(
"pushover" => false,
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
$form_values = array_intersect_key($_POST, $form_values);
// Validation des champs
foreach ($form_values AS $name => $value) {
if (empty($value)) {
$errors[$name] = "Ce champ doit être renseigné.";
}
}
if (empty($errors)) {
if (!empty($_POST["test-config"])) {
$sender = \Message\AdapterFactory::factory("pushover", $form_values);
try {
$sender->send("La notification Pushover est fonctionnelle");
} catch (Exception $e) {
$errorsTest = "Erreur lors de l'envoi de la notification : (".$e->getCode().") ".$e->getMessage();
}
} else {
$userAuthed->mergeOptions(array(
"notification" => array(
"pushover" => array(
"token" => $form_values["token"],
"user_key" => $form_values["user_key"],
"active" => true,
),
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
}
}

View File

@ -0,0 +1,65 @@
<?php
$form_values = array(
"hookurl" => "",
);
$data_user = $userAuthed->getOption("notification.slack");
if ($data_user && is_array($data_user)) {
$form_values = array_merge($form_values, $data_user);
}
$errors = array();
$errorsTest = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["cancel-config"])) {
header("LOCATION: ./?mod=user&a=settings");
exit;
}
if (!empty($_POST["delete-config"])) {
$userAuthed->mergeOptions(array(
"notification" => array(
"slack" => false,
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
$form_values = array_intersect_key($_POST, $form_values);
// Validation des champs
foreach ($form_values AS $name => $value) {
if (empty($value)) {
$errors[$name] = "Ce champ doit être renseigné.";
}
}
if (empty($errors)) {
if (!empty($_POST["test-config"])) {
$sender = \Message\AdapterFactory::factory("slack", $form_values);
try {
$sender->send("La notification Slack est fonctionnelle");
} catch (Exception $e) {
$errorsTest = "Erreur lors de l'envoi de la notification : (".$e->getCode().") ".$e->getMessage();
}
} else {
$userAuthed->mergeOptions(array(
"notification" => array(
"slack" => array(
"hookurl" => trim($form_values["hookurl"]),
"active" => true,
),
),
));
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings");
exit;
}
}
}

View File

@ -1,122 +1,49 @@
<?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)
"unique_ads" => $userAuthed->getOption("unique_ads", false),
"api_key" => $userAuthed->getApiKey(),
"addresses_mails" => $userAuthed->getOption("addresses_mails"),
);
if (!is_array($params["notification"])) {
$params["notification"] = array();
}
$form_values["notification"] = array_replace_recursive(array(
"freeMobile" => array(
"user" => "",
"key" => "",
),
"notifymyandroid" => array(
"token" => "",
),
"pushbullet" => array(
"token" => "",
),
"ovh" => array(
"account" => "",
"login" => "",
"password" => "",
"from" => "",
"to" => "",
),
"pushover" => array(
"token" => "",
"user_key" => "",
),
), $params["notification"]);
$errors = array();
$errorsTest = array();
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") {
$params = array_merge($params, $_POST);
$form_values = array_intersect_key($_POST, $form_values);
// test config Free Mobile
foreach ($params["notification"] AS $section => $options) {
if (is_array($options)) {
$hasValue = false;
foreach ($options AS $name => $value) {
if (empty($value)) {
$errors["notification"][$section][$name] = "Ce champ doit être renseigné.";
} else {
$hasValue = true;
}
}
if (!$hasValue) {
unset($errors["notification"][$section]);
$params["notification"][$section] = false;
}
}
}
if (empty($errors["notification"])) {
unset($errors["notification"]);
}
if (empty($errors)) {
if (!empty($_POST["testFreeMobile"])) {
$sms = \Message\AdapterFactory::factory("freeMobile", $params["notification"]["freeMobile"]);
try {
$sms->send("La notification SMS est fonctionnelle.");
} catch (Exception $e) {
$errorsTest["freeMobile"] = "Erreur lors de l'envoi du SMS : (".$e->getCode().") ".$e->getMessage();
}
} elseif (!empty($_POST["testPushbullet"])) {
if (empty($_POST["notification"]["pushbullet"]["token"])) {
$errors["notification"]["pushbullet"]["token"] = "Veuillez renseigner la clé d'identification. ";
} else {
$sender = \Message\AdapterFactory::factory("pushbullet", $_POST["notification"]["pushbullet"]);
try {
$sender->send("La notification Pushbullet est fonctionnelle");
} catch (Exception $e) {
$errorsTest["pushbullet"] = "Erreur lors de l'envoi de la notification : (".$e->getCode().") ".$e->getMessage();
}
}
} elseif (!empty($_POST["testOvh"])) {
$sender = \Message\AdapterFactory::factory("SmsOvh", $params["notification"]["ovh"]);
try {
$sender->send("La notification SMS est fonctionnelle.");
} catch (Exception $e) {
$errorsTest["ovh"] = "Erreur lors de l'envoi du SMS : (".$e->getCode().") ".$e->getMessage();
}
} elseif (!empty($_POST["testNotifyMyAndroid"])) {
if (empty($_POST["notification"]["notifymyandroid"]["token"])) {
$errors["notification"]["notifymyandroid"]["token"] = "Veuillez renseigner la clé d'identification.";
} else {
$sender = \Message\AdapterFactory::factory("notifymyandroid", $_POST["notification"]["notifymyandroid"]);
try {
$sender->send("La notification NotifyMyAndroid est fonctionnelle", array(
"title" => "Test alerte"
));
} catch (Exception $e) {
$errorsTest["notifymyandroid"] = "Erreur lors de l'envoi de la notification : (".$e->getCode().") ".$e->getMessage();
}
}
} elseif (!empty($_POST["testPushover"])) {
if (empty($_POST["notification"]["pushover"]["token"])) {
$errors["notification"]["pushover"]["token"] = "Veuillez renseigner la clé application.";
} elseif (empty($_POST["notification"]["pushover"]["user_key"])) {
$errors["notification"]["pushover"]["user_key"] = "Veuillez renseigner la clé utilisateur.";
} else {
$sender = \Message\AdapterFactory::factory("pushover", $_POST["notification"]["pushover"]);
try {
$sender->send("La notification Pushover est fonctionnelle");
} catch (Exception $e) {
$errorsTest["pushover"] = "Erreur lors de l'envoi de la notification : (".$e->getCode().") ".$e->getMessage();
}
}
} else {
$userAuthed->mergeOptions($params);
$userStorage->save($userAuthed);
$_SESSION["userSettingsSaved"] = true;
header("LOCATION: ./?mod=user&a=settings"); exit;
}
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"];

View File

@ -0,0 +1,50 @@
<form action="" method="post" autocomplete="off">
<?php if (!empty($errorsTest)) : ?>
<p class="error big">
Le test d'envoi a échoué :<br />
<?php echo htmlspecialchars($errorsTest); ?>
</p>
<?php elseif (empty($errors) && !empty($_POST["test-config"])) : ?>
<p class="message-success">
Vous devriez recevoir un SMS contenant le message suivant:
«&nbsp;La notification SMS est fonctionnelle&nbsp;».<br />
<span style="text-decoration: underline;">Pensez à confirmer
la configuration en cliquant sur "Enregistrer".</span>
</p>
<?php endif;?>
<h2>Configuration SMS via Free Mobile</h2>
<dl>
<dt>
<label for="free_mobile_user">ID utilisateur</label>
</dt>
<dd>
<input type="text" id="free_mobile_user" name="user" value="<?php
echo htmlspecialchars($form_values["user"]);
?>" />
<?php if (isset($errors["user"])) : ?>
<p class="error"><?php echo $errors["user"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="free_mobile_key">Clé d'identification</label>
</dt>
<dd>
<input type="text" id="free_mobile_key" name="key" value="<?php
echo htmlspecialchars($form_values["key"]);
?>" />
<?php if (isset($errors["key"])) : ?>
<p class="error"><?php echo $errors["key"]; ?></p>
<?php endif; ?>
</dd>
</dl>
<p>
<input type="submit" name="test-config" value="Effectuer un test d'envoi" />
<input type="submit" value="Enregistrer" />
<?php if ($data_user) : ?>
<input type="submit" name="delete-config" value="Supprimer la configuration" />
<?php endif; ?>
<input type="submit" name="cancel-config" value="Annuler" />
</p>
</form>

View File

@ -0,0 +1,50 @@
<form action="" method="post" autocomplete="off">
<?php if (!empty($errorsTest)) : ?>
<p class="error big">
Le test d'envoi a échoué :<br />
<?php echo htmlspecialchars($errorsTest); ?>
</p>
<?php elseif (empty($errors) && !empty($_POST["test-config"])) : ?>
<p class="message-success">
Vous devriez recevoir une notification contenant le message suivant:
«&nbsp;La notification Joaoapps / Join est fonctionnelle&nbsp;».<br />
<span style="text-decoration: underline;">Pensez à confirmer
la configuration en cliquant sur "Enregistrer".</span>
</p>
<?php endif;?>
<h2>Configuration de Joaoapps / Join</h2>
<dl>
<dt>
<label for="token">API Key</label>
</dt>
<dd>
<input type="text" id="token" name="token" value="<?php
echo htmlspecialchars($form_values["token"]);
?>" />
<?php if (isset($errors["token"])) : ?>
<p class="error"><?php echo $errors["token"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="device_ids">Device IDs</label>
</dt>
<dd>
<input type="text" id="device_ids" name="device_ids" value="<?php
echo htmlspecialchars($form_values["device_ids"]);
?>" />
<?php if (isset($errors["device_ids"])) : ?>
<p class="error"><?php echo $errors["device_ids"]; ?></p>
<?php endif; ?>
</dd>
</dl>
<p>
<input type="submit" name="test-config" value="Effectuer un test d'envoi" />
<input type="submit" value="Enregistrer" />
<?php if ($data_user) : ?>
<input type="submit" name="delete-config" value="Supprimer la configuration" />
<?php endif; ?>
<input type="submit" name="cancel-config" value="Annuler" />
</p>
</form>

View File

@ -0,0 +1,39 @@
<form action="" method="post" autocomplete="off">
<?php if (!empty($errorsTest)) : ?>
<p class="error big">
Le test d'envoi a échoué :<br />
<?php echo htmlspecialchars($errorsTest); ?>
</p>
<?php elseif (empty($errors) && !empty($_POST["test-config"])) : ?>
<p class="message-success">
Vous devriez recevoir une notification contenant le message suivant:
«&nbsp;La notification NotifyMyAndroid est fonctionnelle&nbsp;».<br />
<span style="text-decoration: underline;">Pensez à confirmer
la configuration en cliquant sur "Enregistrer".</span>
</p>
<?php endif;?>
<h2>Configuration NotifyMyAndroid</h2>
<dl>
<dt>
<label for="token">Clé du service</label>
</dt>
<dd>
<input type="text" id="token" name="token" value="<?php
echo htmlspecialchars($form_values["token"]);
?>" />
<?php if (isset($errors["token"])) : ?>
<p class="error"><?php echo $errors["token"]; ?></p>
<?php endif; ?>
</dd>
</dl>
<p>
<input type="submit" name="test-config" value="Effectuer un test d'envoi" />
<input type="submit" value="Enregistrer" />
<?php if ($data_user) : ?>
<input type="submit" name="delete-config" value="Supprimer la configuration" />
<?php endif; ?>
<input type="submit" name="cancel-config" value="Annuler" />
</p>
</form>

View File

@ -0,0 +1,83 @@
<form action="" method="post" autocomplete="off">
<?php if (!empty($errorsTest)) : ?>
<p class="error big">
Le test d'envoi a échoué :<br />
<?php echo htmlspecialchars($errorsTest); ?>
</p>
<?php elseif (empty($errors) && !empty($_POST["test-config"])) : ?>
<p class="message-success">
Vous devriez recevoir un SMS contenant le message suivant:
«&nbsp;La notification SMS est fonctionnelle&nbsp;».<br />
<span style="text-decoration: underline;">Pensez à confirmer
la configuration en cliquant sur "Enregistrer".</span>
</p>
<?php endif;?>
<h2>Configuration SMS via OVH Telecom</h2>
<dl>
<dt>
<label for="account">Numéro de compte</label>
</dt>
<dd>
<input type="text" id="account" name="account" value="<?php
echo htmlspecialchars($form_values["account"]);
?>" placeholder="De la forme : sms-xxxxxxxx-x" />
<?php if (isset($errors["account"])) : ?>
<p class="error"><?php echo $errors["account"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="login">Utilisateur</label>
</dt>
<dd>
<input type="text" id="login" name="login" value="<?php
echo htmlspecialchars($form_values["login"]);
?>" />
<?php if (isset($errors["login"])) : ?>
<p class="error"><?php echo $errors["login"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="password">Mot de passe</label>
</dt>
<dd>
<input type="text" id="password" name="password" value="<?php
echo htmlspecialchars($form_values["password"]);
?>" />
<?php if (isset($errors["password"])) : ?>
<p class="error"><?php echo $errors["password"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="from">Expéditeur</label>
</dt>
<dd>
<input type="text" id="from" name="from" value="<?php
echo htmlspecialchars($form_values["from"]);
?>" />
<?php if (isset($errors["from"])) : ?>
<p class="error"><?php echo $errors["from"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="to">Destinataire</label>
</dt>
<dd>
<input type="text" id="to" name="to" value="<?php
echo htmlspecialchars($form_values["to"]);
?>" placeholder="Forme international (Ex: +33605040301)" />
<?php if (isset($errors["to"])) : ?>
<p class="error"><?php echo $errors["to"]; ?></p>
<?php endif; ?>
</dd>
</dl>
<p>
<input type="submit" name="test-config" value="Effectuer un test d'envoi" />
<input type="submit" value="Enregistrer" />
<?php if ($data_user) : ?>
<input type="submit" name="delete-config" value="Supprimer la configuration" />
<?php endif; ?>
<input type="submit" name="cancel-config" value="Annuler" />
</p>
</form>

View File

@ -0,0 +1,39 @@
<form action="" method="post" autocomplete="off">
<?php if (!empty($errorsTest)) : ?>
<p class="error big">
Le test d'envoi a échoué :<br />
<?php echo htmlspecialchars($errorsTest); ?>
</p>
<?php elseif (empty($errors) && !empty($_POST["test-config"])) : ?>
<p class="message-success">
Vous devriez recevoir une notification contenant le message suivant:
«&nbsp;La notification Pushbullet est fonctionnelle&nbsp;».<br />
<span style="text-decoration: underline;">Pensez à confirmer
la configuration en cliquant sur "Enregistrer".</span>
</p>
<?php endif;?>
<h2>Configuration de Pushbullet</h2>
<dl>
<dt>
<label for="token">Clé du service</label>
</dt>
<dd>
<input type="text" id="token" name="token" value="<?php
echo htmlspecialchars($form_values["token"]);
?>" />
<?php if (isset($errors["token"])) : ?>
<p class="error"><?php echo $errors["token"]; ?></p>
<?php endif; ?>
</dd>
</dl>
<p>
<input type="submit" name="test-config" value="Effectuer un test d'envoi" />
<input type="submit" value="Enregistrer" />
<?php if ($data_user) : ?>
<input type="submit" name="delete-config" value="Supprimer la configuration" />
<?php endif; ?>
<input type="submit" name="cancel-config" value="Annuler" />
</p>
</form>

View File

@ -0,0 +1,50 @@
<form action="" method="post" autocomplete="off">
<?php if (!empty($errorsTest)) : ?>
<p class="error big">
Le test d'envoi a échoué :<br />
<?php echo htmlspecialchars($errorsTest); ?>
</p>
<?php elseif (empty($errors) && !empty($_POST["test-config"])) : ?>
<p class="message-success">
Vous devriez recevoir une notification contenant le message suivant:
«&nbsp;La notification Pushover est fonctionnelle&nbsp;».<br />
<span style="text-decoration: underline;">Pensez à confirmer
la configuration en cliquant sur "Enregistrer".</span>
</p>
<?php endif;?>
<h2>Configuration de Pushover</h2>
<dl>
<dt>
<label for="token">Clé application</label>
</dt>
<dd>
<input type="text" id="token" name="token" value="<?php
echo htmlspecialchars($form_values["token"]);
?>" />
<?php if (isset($errors["token"])) : ?>
<p class="error"><?php echo $errors["token"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="user_key">Clé utilisateur</label>
</dt>
<dd>
<input type="text" id="user_key" name="user_key" value="<?php
echo htmlspecialchars($form_values["user_key"]);
?>" />
<?php if (isset($errors["user_key"])) : ?>
<p class="error"><?php echo $errors["user_key"]; ?></p>
<?php endif; ?>
</dd>
</dl>
<p>
<input type="submit" name="test-config" value="Effectuer un test d'envoi" />
<input type="submit" value="Enregistrer" />
<?php if ($data_user) : ?>
<input type="submit" name="delete-config" value="Supprimer la configuration" />
<?php endif; ?>
<input type="submit" name="cancel-config" value="Annuler" />
</p>
</form>

View File

@ -0,0 +1,39 @@
<form action="" method="post" autocomplete="off">
<?php if (!empty($errorsTest)) : ?>
<p class="error big">
Le test d'envoi a échoué :<br />
<?php echo htmlspecialchars($errorsTest); ?>
</p>
<?php elseif (empty($errors) && !empty($_POST["test-config"])) : ?>
<p class="message-success">
Vous devriez recevoir une notification contenant le message suivant:
«&nbsp;La notification Slack est fonctionnelle&nbsp;».<br />
<span style="text-decoration: underline;">Pensez à confirmer
la configuration en cliquant sur "Enregistrer".</span>
</p>
<?php endif;?>
<h2>Configuration de Slack</h2>
<dl>
<dt>
<label for="hookurl">URL</label>
</dt>
<dd>
<input type="text" id="hookurl" name="hookurl" value="<?php
echo htmlspecialchars($form_values["hookurl"]);
?>" placeholder="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX" />
<?php if (isset($errors["hookurl"])) : ?>
<p class="error"><?php echo $errors["hookurl"]; ?></p>
<?php endif; ?>
</dd>
</dl>
<p>
<input type="submit" name="test-config" value="Effectuer un test d'envoi" />
<input type="submit" value="Enregistrer" />
<?php if ($data_user) : ?>
<input type="submit" name="delete-config" value="Supprimer la configuration" />
<?php endif; ?>
<input type="submit" name="cancel-config" value="Annuler" />
</p>
</form>

View File

@ -1,250 +1,133 @@
<form action="" method="post" autocomplete="off">
<?php if (!empty($errors)) : ?>
<p class="error" style="font-size: 1.3em; background: #AB0000; color: #FFF; text-align: center; line-height: 200%;">
Il y a au moins une erreur présente dans le formulaire.</p>
<?php elseif (!empty($errorsTest)) : ?>
<p class="error" style="font-size: 1.3em; background: #AB0000; color: #FFF; text-align: center; line-height: 200%;">
Le test d'envoi a échoué. Voir ci-dessous pour le message d'erreur.</p>
<?php elseif ($userSettingsSaved) : ?>
<p style="font-size: 1.3em; background: #00AB00; color: #FFF; text-align: center; line-height: 200%;">
Les paramètres ont été enregistrés.</p>
<?php endif;?>
<h2>Options générales</h2>
<dl>
<dt style="margin-bottom: 10px;">
<input type="hidden" name="unique_ads" value="0" />
<label for="unique_ads">
<input type="checkbox" id="unique_ads" name="unique_ads" value="1"<?php
echo $params["unique_ads"] ?' checked="checked"':''
?> style="margin-left: 0;" />
Cochez la case pour ne pas recevoir les annonces remontées (évite les doublons).
</label>
</dt>
</dl>
<?php if ($userSettingsSaved) : ?>
<p style="font-size: 1.3em; background: #00AB00; color: #FFF; text-align: center; line-height: 200%;">
Les paramètres ont été enregistrés.</p>
<?php endif;?>
<div class="user-settings-container">
<h2 id="configFreeMobile" class="formbox">Configuration SMS via Free Mobile</h2>
<dl id="configFreeMobile-content" style="display: <?php echo !empty($form_values["notification"]["freeMobile"]["user"]) ? "block" : "none"; ?>;">
<dt>
<label for="free_mobile_user">ID utilisateur</label>
</dt>
<dd>
<input type="text" id="free_mobile_user" name="notification[freeMobile][user]" value="<?php
echo htmlspecialchars($form_values["notification"]["freeMobile"]["user"]);
?>" />
<?php if (isset($errors["notification"]["freeMobile"]["user"])) : ?>
<p class="error"><?php echo $errors["notification"]["freeMobile"]["user"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="free_mobile_key">Clé d'identification</label>
</dt>
<dd>
<input type="text" id="free_mobile_key" name="notification[freeMobile][key]" value="<?php
echo htmlspecialchars($form_values["notification"]["freeMobile"]["key"]);
?>" />
<?php if (isset($errors["notification"]["freeMobile"]["key"])) : ?>
<p class="error"><?php echo $errors["notification"]["freeMobile"]["key"]; ?></p>
<?php endif; ?>
</dd>
<dt style="border: none;">
<input type="submit" name="testFreeMobile" value="Effectuer un test d'envoi SMS" />
</dt>
<?php if (empty($errors) && !empty($_POST["testFreeMobile"])) : ?>
<dd>
<?php if (isset($errorsTest["freeMobile"])) : ?>
<p style="font-weight: bold; color: #AB0000;"><?php
echo htmlspecialchars($errorsTest["freeMobile"]);
?></p>
<?php else: ?>
<p style="font-weight: bold; color: #333399;">Vous devriez recevoir un SMS contenant le message suivant:
« La notification SMS est fonctionnelle ».</p>
<p style="font-weight: bold; color: #339933;">Pensez à confirmer la configuration en cliquant sur "Enregistrer".</p>
<?php endif; ?>
</dd>
<?php endif; ?>
</dl>
<div class="block user-settings-notification">
<h2 class="block-title">Configuration des systèmes d'alerte</h2>
<div class="block-content">
<table class="user-notifications">
<thead>
<tr class="user-notifications-header">
<th class="user-notifications-type">Service</th>
<th class="user-notifications-cost">Coût / Limitation</th>
<th class="user-notifications-active">Actif</th>
<th class="user-notifications-action">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach ($data_notifications AS $name => $notification) : ?>
<?php if (empty($notification["label"])) continue; ?>
<tr>
<td class="user-notifications-type">
<?php echo htmlspecialchars($notification["label"]); ?>
<?php if (!empty($notification["link"])) : ?>
<a class="user-notifications-link"
href="<?php echo $notification["link"]; ?>"
title="Plus d'informations sur <?php echo $notification["link"]; ?> (nouvelle fenêtre)"
target="_blank"><span class="fa fa-info-circle fa-fw"></span></a>
<?php endif; ?>
</td>
<td class="user-notifications-cost">
<?php if (empty($notification["cost"])) : ?>
Gratuit
<?php else: ?>
<?php echo htmlspecialchars($notification["cost"]); ?>
<?php endif; ?>
</td>
<td class="user-notifications-active">
<span class="fa fa-<?php
echo $notification["enabled"] ? "check active" : "minus";
?>"></span>
</td>
<td class="user-notifications-action">
<?php if ($notification["enabled"]) : ?>
<a href="?mod=user&amp;a=settings-<?php echo $name; ?>">Configurer</a> |
<a href="?mod=user&amp;a=settings-disable-notification&amp;s=<?php echo $name; ?>">Désactiver</a>
<?php else: ?>
<a href="?mod=user&amp;a=settings-<?php echo $name; ?>">Activer</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<h2 id="configPushbullet" class="formbox">Configuration alerte via Pushbullet</h2>
<dl id="configPushbullet-content" style="display: <?php echo !empty($form_values["notification"]["pushbullet"]["token"]) ? "block" : "none"; ?>;">
<dt>
<label for="pushbullet_token">Clé du service</label>
</dt>
<dd>
<input type="text" id="pushbullet_token" name="notification[pushbullet][token]" value="<?php
echo htmlspecialchars($form_values["notification"]["pushbullet"]["token"]);
?>" />
<?php if (isset($errors["notification"]["pushbullet"]["token"])) : ?>
<p class="error"><?php echo $errors["notification"]["pushbullet"]["token"]; ?></p>
<?php endif; ?>
</dd>
<dt style="border: none;">
<input type="submit" name="testPushbullet" value="Effectuer un test d'envoi de message" />
</dt>
<?php if (empty($errors) && !empty($_POST["testPushbullet"])) : ?>
<dd>
<?php if (isset($errorsTest["pushbullet"])) : ?>
<p style="font-weight: bold; color: #AB0000;"><?php
echo htmlspecialchars($errorsTest["pushbullet"]);
?></p>
<?php else: ?>
<p style="font-weight: bold; color: #333399;">Vous devriez recevoir une notification contenant le message suivant:
« La notification Pushbullet est fonctionnelle ».</p>
<p style="font-weight: bold; color: #339933;">Pensez à confirmer la configuration en cliquant sur "Enregistrer".</p>
<?php endif; ?>
</dd>
<?php endif; ?>
</dl>
<div class="block user-settings-mails">
<h2 class="block-title">Configuration mail</h2>
<div class="block-content">
<p>
Vous pouvez indiquer une ou plusieurs adresses mails. Ces
adresses seront utilisées lors de la création de vos alertes.
</p>
<form action="" method="post">
<dl>
<dd>
<input type="text"
id="addresses_mails"
name="addresses_mails"
value="<?php echo htmlspecialchars($form_values["addresses_mails"]); ?>"
/>
</dd>
</dl>
<p>
Pour utiliser plusieurs adresses, séparez-les par une
virgule.
</p>
<p><input type="submit" value="Enregistrer" /></p>
</form>
</div>
</div>
<h2 id="configOvh" class="formbox">Configuration SMS via OVH Telecom</h2>
<dl id="configOvh-content" style="display: <?php echo !empty($form_values["notification"]["ovh"]["account"]) ? "block" : "none"; ?>;">
<dt>
<label for="ovh_account">Numéro de compte</label>
</dt>
<dd>
<input type="text" id="ovh_account" name="notification[ovh][account]" value="<?php
echo htmlspecialchars($form_values["notification"]["ovh"]["account"]);
?>" placeholder="De la forme : sms-xxxxxxxx-x" />
<?php if (isset($errors["notification"]["ovh"]["account"])) : ?>
<p class="error"><?php echo $errors["notification"]["ovh"]["account"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="ovh_login">Utilisateur</label>
</dt>
<dd>
<input type="text" id="ovh_login" name="notification[ovh][login]" value="<?php
echo htmlspecialchars($form_values["notification"]["ovh"]["login"]);
?>" />
<?php if (isset($errors["notification"]["ovh"]["login"])) : ?>
<p class="error"><?php echo $errors["notification"]["ovh"]["login"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="ovh_password">Mot de passe</label>
</dt>
<dd>
<input type="text" id="ovh_password" name="notification[ovh][password]" value="<?php
echo htmlspecialchars($form_values["notification"]["ovh"]["password"]);
?>" />
<?php if (isset($errors["notification"]["ovh"]["password"])) : ?>
<p class="error"><?php echo $errors["notification"]["ovh"]["password"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="ovh_from">Expéditeur</label>
</dt>
<dd>
<input type="text" id="ovh_from" name="notification[ovh][from]" value="<?php
echo htmlspecialchars($form_values["notification"]["ovh"]["from"]);
?>" />
<?php if (isset($errors["notification"]["ovh"]["from"])) : ?>
<p class="error"><?php echo $errors["notification"]["ovh"]["from"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="ovh_to">Destinataire</label>
</dt>
<dd>
<input type="text" id="ovh_to" name="notification[ovh][to]" value="<?php
echo htmlspecialchars($form_values["notification"]["ovh"]["to"]);
?>" placeholder="Forme international (Ex: +33605040301)" />
<?php if (isset($errors["notification"]["ovh"]["to"])) : ?>
<p class="error"><?php echo $errors["notification"]["ovh"]["to"]; ?></p>
<?php endif; ?>
</dd>
<div class="block user-settings-apikey">
<h2 class="block-title">Accès API</h2>
<div class="block-content">
<p>
Cette clé vous permet d'interagir avec votre compte
LBCAlerte à partir d'autre application.
</p>
<form action="" method="post" autocomplete="off"
onsubmit="return window.confirm('Êtes-vous sur de vouloir réinitialiser la clé ?');">
<dl>
<dd>
<input type="text" id="api_key" value="<?php
echo htmlspecialchars($form_values["api_key"]);
?>" readonly="readonly" />
</dd>
</dl>
<dt style="border: none;">
<input type="submit" name="testOvh" value="Effectuer un test d'envoi SMS" />
</dt>
<?php if (empty($errors) && !empty($_POST["testOvh"])) : ?>
<dd>
<?php if (isset($errorsTest["ovh"])) : ?>
<p style="font-weight: bold; color: #AB0000;"><?php
echo htmlspecialchars($errorsTest["ovh"]);
?></p>
<?php else: ?>
<p style="font-weight: bold; color: #333399;">Vous devriez recevoir un SMS contenant le message suivant:
« La notification SMS est fonctionnelle ».</p>
<p style="font-weight: bold; color: #339933;">Pensez à confirmer la configuration en cliquant sur "Enregistrer".</p>
<?php endif; ?>
</dd>
<?php endif; ?>
</dl>
<p>
Si nécessaire, vous pouvez réinitialiser votre clé.
Il faudra configurer la nouvelle clé dans vos applications.
</p>
<p><input type="submit" name="regenerate-apikey"
value="Régénérer" /></p>
</form>
</div>
</div>
<h2 id="configNotifyMyAndroid" class="formbox">Configuration alerte via NotifyMyAndroid</h2>
<dl id="configNotifyMyAndroid-content" style="display: <?php echo !empty($form_values["notification"]["notifymyandroid"]["token"]) ? "block" : "none"; ?>;">
<dt>
<label for="notifymyandroid_token">Clé du service</label>
</dt>
<dd>
<input type="text" id="notifymyandroid_token" name="notification[notifymyandroid][token]" value="<?php
echo htmlspecialchars($form_values["notification"]["notifymyandroid"]["token"]);
?>" />
<?php if (isset($errors["notification"]["notifymyandroid"]["token"])) : ?>
<p class="error"><?php echo $errors["notification"]["notifymyandroid"]["token"]; ?></p>
<?php endif; ?>
</dd>
<dt style="border: none;">
<input type="submit" name="testNotifyMyAndroid" value="Effectuer un test d'envoi de message" />
</dt>
<?php if (empty($errors) && !empty($_POST["testNotifyMyAndroid"])) : ?>
<dd>
<?php if (isset($errorsTest["notifymyandroid"])) : ?>
<p style="font-weight: bold; color: #AB0000;"><?php
echo htmlspecialchars($errorsTest["notifymyandroid"]);
?></p>
<?php else: ?>
<p style="font-weight: bold; color: #333399;">Vous devriez recevoir une notification contenant le message suivant:
« La notification NotifyMyAndroid est fonctionnelle ».</p>
<p style="font-weight: bold; color: #339933;">Pensez à confirmer la configuration en cliquant sur "Enregistrer".</p>
<?php endif; ?>
</dd>
<?php endif; ?>
</dl>
<div class="block user-settings-general">
<h2 class="block-title">Options diverses</h2>
<div class="block-content">
<form action="" method="post" autocomplete="off">
<dl>
<dt style="margin-bottom: 10px;">
<input type="hidden" name="unique_ads" value="0" />
<label for="unique_ads">
<input type="checkbox" id="unique_ads" name="unique_ads" value="1"<?php
echo $params["unique_ads"] ?' checked="checked"':''
?> style="margin-left: 0;" />
Cochez la case pour ne pas recevoir les annonces remontées (évite les doublons).
</label>
</dt>
</dl>
<h2 id="configPushover" class="formbox">Configuration alerte via Pushover</h2>
<dl id="configPushover-content" style="display: <?php echo !empty($form_values["notification"]["pushover"]["token"]) ? "block" : "none"; ?>;">
<dt>
<label for="pushover_token">Clé application</label>
</dt>
<dd>
<input type="text" id="pushover_token" name="notification[pushover][token]" value="<?php
echo htmlspecialchars($form_values["notification"]["pushover"]["token"]);
?>" />
<?php if (isset($errors["notification"]["pushover"]["token"])) : ?>
<p class="error"><?php echo $errors["notification"]["pushover"]["token"]; ?></p>
<?php endif; ?>
</dd>
<dt>
<label for="pushover_token">Clé utilisateur</label>
</dt>
<dd>
<input type="text" id="pushover_token" name="notification[pushover][user_key]" value="<?php
echo htmlspecialchars($form_values["notification"]["pushover"]["user_key"]);
?>" />
<?php if (isset($errors["notification"]["pushover"]["user_key"])) : ?>
<p class="error"><?php echo $errors["notification"]["pushover"]["user_key"]; ?></p>
<?php endif; ?>
</dd>
<dt style="border: none;">
<input type="submit" name="testPushover" value="Effectuer un test d'envoi de message" />
</dt>
<?php if (empty($errors) && !empty($_POST["testPushover"])) : ?>
<dd>
<?php if (isset($errorsTest["pushover"])) : ?>
<p style="font-weight: bold; color: #AB0000;"><?php
echo htmlspecialchars($errorsTest["pushover"]);
?></p>
<?php else: ?>
<p style="font-weight: bold; color: #333399;">Vous devriez recevoir une notification contenant le message suivant:
« La notification Pushover est fonctionnelle ».</p>
<p style="font-weight: bold; color: #339933;">Pensez à confirmer la configuration en cliquant sur "Enregistrer".</p>
<?php endif; ?>
</dd>
<?php endif; ?>
</dl>
<p><input type="submit" value="Enregistrer" />
| <a href="?mod=user&amp;a=settings">annuler les modifications</a></p>
</form>
<p><input type="submit" value="Enregistrer" /></p>
</form>
</div>
</div>
</div>