mirror of
https://github.com/ZeJMaN/LBCAlerte_ynh.git
synced 2025-07-26 13:17:34 +02:00
Upgrade LBCAlerte to version 3.3
Add upgrade script
This commit is contained in:
@ -41,6 +41,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$_POST["options"]["password"], $_POST["options"]["dbname"]);
|
||||
if ($dbConnection->connect_error) {
|
||||
$errors["host"] = "Connexion impossible à la base de données.";
|
||||
} else {
|
||||
$dbConnection->set_charset("utf8");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,8 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="robots" content="none">
|
||||
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="static/styles.css?v=<?php echo APPLICATION_VERSION; ?>" />
|
||||
<link rel="stylesheet" href="static/styles.css?v=<?php echo STATIC_REV; ?>" />
|
||||
<link rel="stylesheet" href="static/font-awesome/css/font-awesome.min.css?v=<?php echo STATIC_REV; ?>" />
|
||||
</head>
|
||||
<body>
|
||||
<?php if ($userAuthed) : ?>
|
||||
|
9
sources/app/annonce/init.php
Normal file
9
sources/app/annonce/init.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
$storageType = $config->get("storage", "type", "files");
|
||||
if ($storageType == "db") {
|
||||
$storage = new \App\Storage\Db\Ad($dbConnection, $userAuthed);
|
||||
} else {
|
||||
$storage = new \App\Storage\File\Ad(DOCUMENT_ROOT."/var/configs/backup-ads-".$auth->getUsername().".csv");
|
||||
}
|
||||
|
||||
$adPhoto = new App\Storage\AdPhoto($userAuthed);
|
40
sources/app/annonce/scripts/backup.php
Normal file
40
sources/app/annonce/scripts/backup.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
$url = !empty($_GET["aurl"]) ? $_GET["aurl"] : null;
|
||||
|
||||
$logger = Logger::getLogger("main");
|
||||
|
||||
$content = $client->request($url);
|
||||
|
||||
try {
|
||||
$parser = \AdService\ParserFactory::factory($url);
|
||||
} catch (\AdService\Exception $e) {
|
||||
$logger->err($e->getMessage());
|
||||
}
|
||||
|
||||
$ad = $parser->processAd(
|
||||
$content,
|
||||
parse_url($url, PHP_URL_SCHEME)
|
||||
);
|
||||
|
||||
$ad_stored = $storage->fetchById($ad->getId());
|
||||
if ($ad_stored) {
|
||||
if ($_SERVER["REQUEST_METHOD"] != "POST") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Supprime les photos
|
||||
$adPhoto->delete($ad);
|
||||
}
|
||||
|
||||
|
||||
if (!$ad_stored) {
|
||||
$ad_stored = new \App\Ad\Ad();
|
||||
}
|
||||
|
||||
$ad_stored->setFromArray($ad->toArray());
|
||||
$storage->save($ad_stored);
|
||||
|
||||
$adPhoto->import($ad_stored);
|
||||
|
||||
header("LOCATION: ./?mod=annonce&a=view&id=".$ad->getId()); exit;
|
27
sources/app/annonce/scripts/form-comment.php
Normal file
27
sources/app/annonce/scripts/form-comment.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use AdService\SiteConfigFactory;
|
||||
|
||||
if (!isset($_GET["id"])) {
|
||||
header("LOCATION: ./?mod=annonce"); exit;
|
||||
}
|
||||
|
||||
$ad = $storage->fetchById($_GET["id"]);
|
||||
if (!$ad) {
|
||||
header("LOCATION: ./?mod=annonce"); exit;
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$comment = isset($_POST["comment"]) ? trim($_POST["comment"]) : "";
|
||||
$ad->setComment($comment);
|
||||
$storage->save($ad);
|
||||
|
||||
header("LOCATION: ./?mod=annonce&a=view&id=".$ad->getId()."&update=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$ad_config = SiteConfigFactory::factory($ad->getLink());
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
17
sources/app/annonce/scripts/form-delete.php
Normal file
17
sources/app/annonce/scripts/form-delete.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
if (!isset($_GET["id"])) {
|
||||
header("LOCATION: ./?mod=annonce"); exit;
|
||||
}
|
||||
$ad = $storage->fetchById($_GET["id"]);
|
||||
if (!$ad) {
|
||||
header("LOCATION: ./?mod=annonce"); exit;
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (isset($_POST["id"]) && $_POST["id"] == $_GET["id"]) {
|
||||
$storage->delete($ad);
|
||||
$adPhoto->delete($ad);
|
||||
}
|
||||
header("LOCATION: ./?mod=annonce"); exit;
|
||||
}
|
||||
|
||||
$referer = isset($_GET["r"]) ? $_GET["r"] : "";
|
46
sources/app/annonce/scripts/form.php
Normal file
46
sources/app/annonce/scripts/form.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
$ad = new App\Ad\Ad();
|
||||
|
||||
$link = "";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (empty($_POST["link"])) {
|
||||
$errors["link"] = "Ce champ est obligatoire.";
|
||||
} else {
|
||||
$link = $_POST["link"];
|
||||
try {
|
||||
$siteConfig = \AdService\SiteConfigFactory::factory($link);
|
||||
$parser = \AdService\ParserFactory::factory($link);
|
||||
} catch (\Exception $e) {
|
||||
$errors["link"] = "Cette adresse ne semble pas valide.";
|
||||
}
|
||||
}
|
||||
if (empty($errors)) {
|
||||
$ad = $parser->processAd(
|
||||
$client->request($link),
|
||||
parse_url($link, PHP_URL_SCHEME)
|
||||
);
|
||||
if (!$ad) {
|
||||
$errors["link"] = "Impossible de sauvegarder l'annonce (annonce hors ligne ou format des données invalides).";
|
||||
}
|
||||
}
|
||||
if (empty($errors) && !empty($ad)) {
|
||||
$ad = $parser->processAd(
|
||||
$client->request($link),
|
||||
parse_url($link, PHP_URL_SCHEME)
|
||||
);
|
||||
|
||||
$ad_stored = $storage->fetchById($ad->getId());
|
||||
if (!$ad_stored) {
|
||||
$ad_stored = new \App\Ad\Ad();
|
||||
}
|
||||
|
||||
$ad_stored->setFromArray($ad->toArray());
|
||||
$storage->save($ad_stored);
|
||||
|
||||
$adPhoto->import($ad_stored);
|
||||
|
||||
header("LOCATION: ./?mod=annonce");
|
||||
exit;
|
||||
}
|
||||
}
|
28
sources/app/annonce/scripts/index.php
Normal file
28
sources/app/annonce/scripts/index.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
if (isset($_GET["sort"])) {
|
||||
if (in_array($_GET["sort"], array("title", "price", "city", "category", "author", "date", "zip_code", "date_created"))) {
|
||||
if (!isset($_SESSION["backupad"]["sort"]) || $_SESSION["backupad"]["sort"] != $_GET["sort"]) {
|
||||
$_SESSION["backupad"]["sort"] = $_GET["sort"];
|
||||
$_SESSION["backupad"]["order"] = "asc";
|
||||
} elseif (!isset($_SESSION["backupad"]["order"]) || $_SESSION["backupad"]["order"] == "desc") {
|
||||
$_SESSION["backupad"]["order"] = "asc";
|
||||
} else {
|
||||
$_SESSION["backupad"]["order"] = "desc";
|
||||
}
|
||||
}
|
||||
header("LOCATION: ?mod=annonce"); exit;
|
||||
}
|
||||
|
||||
$sort = "date_created";
|
||||
$order = "desc";
|
||||
if (isset($_SESSION["backupad"]["sort"])) {
|
||||
$sort = $_SESSION["backupad"]["sort"];
|
||||
}
|
||||
if (isset($_SESSION["backupad"]["order"])) {
|
||||
$order = $_SESSION["backupad"]["order"];
|
||||
}
|
||||
|
||||
$ads = $storage->fetchAll($sort." ".$order);
|
||||
|
||||
|
18
sources/app/annonce/scripts/view.php
Normal file
18
sources/app/annonce/scripts/view.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use AdService\SiteConfigFactory;
|
||||
|
||||
if (!isset($_GET["id"])) {
|
||||
header("LOCATION: ./?mod=annonce"); exit;
|
||||
}
|
||||
|
||||
$ad = $storage->fetchById($_GET["id"]);
|
||||
if (!$ad) {
|
||||
header("LOCATION: ./?mod=annonce"); exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$ad_config = SiteConfigFactory::factory($ad->getLink());
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
20
sources/app/annonce/views/backup.phtml
Normal file
20
sources/app/annonce/views/backup.phtml
Normal file
@ -0,0 +1,20 @@
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<legend>Annonce déjà sauvegardée</legend>
|
||||
|
||||
<p>
|
||||
Vous avez déjà sauvegardé cette annonce.
|
||||
Souhaitez vous écraser la sauvegarde ?
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Titre : <?php echo htmlspecialchars($ad_stored->getTitle()); ?></li>
|
||||
<li>Url : <?php echo htmlspecialchars($ad_stored->getLink()); ?></li>
|
||||
</ul>
|
||||
<p>
|
||||
<input type="hidden" name="id" value="<?php echo $ad_stored->getId(); ?>" />
|
||||
<input type="submit" value="Oui" style="font-weight: bold;" />
|
||||
| <a href="?mod=annonce">Non</a>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
17
sources/app/annonce/views/form-comment.phtml
Normal file
17
sources/app/annonce/views/form-comment.phtml
Normal file
@ -0,0 +1,17 @@
|
||||
<h2>
|
||||
<?php echo htmlspecialchars($ad->getTitle()); ?>
|
||||
</h2>
|
||||
|
||||
<form action="" method="post">
|
||||
<p><label for="comment">Votre note :</label></p>
|
||||
<p>
|
||||
<textarea name="comment" cols="75" rows="5"><?php
|
||||
echo htmlspecialchars($ad->getComment()); ?></textarea>
|
||||
<br />
|
||||
<p>
|
||||
<input type="submit" value="Enregistrer" />
|
||||
| <a href="?mod=annonce&a=view&id=<?php
|
||||
echo $ad->getId(); ?>">annuler</a>
|
||||
</p>
|
||||
</p>
|
||||
</form>
|
15
sources/app/annonce/views/form-delete.phtml
Normal file
15
sources/app/annonce/views/form-delete.phtml
Normal file
@ -0,0 +1,15 @@
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<legend>Supprimer cette annonce ?</legend>
|
||||
<ul>
|
||||
<li>Titre : <?php echo htmlspecialchars($ad->getTitle()); ?></li>
|
||||
<li>Url : <?php echo htmlspecialchars($ad->getLink()); ?></li>
|
||||
</ul>
|
||||
<p>
|
||||
<input type="hidden" name="id" value="<?php echo $_GET["id"]; ?>" />
|
||||
<input type="submit" value="Oui" style="font-weight: bold;" />
|
||||
| <a href="?mod=annonce<?php
|
||||
echo $referer == "view" ? '&a=view&id='.$ad->getId() : ''; ?>">Non</a>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
28
sources/app/annonce/views/form.phtml
Normal file
28
sources/app/annonce/views/form.phtml
Normal file
@ -0,0 +1,28 @@
|
||||
<form action="" method="post">
|
||||
<h2>Sauvegarder une annonce</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
<label for="url">URL de l'annonce</label>
|
||||
</dt>
|
||||
<dd>
|
||||
<input type="text" id="link" name="link" value="<?php
|
||||
echo htmlspecialchars($link);
|
||||
?>" size="75" />
|
||||
<?php if (isset($errors["link"])) : ?>
|
||||
<p class="error"><?php echo $errors["link"]; ?></p>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
</dl>
|
||||
<p><input type="submit" value="Enregistrer" />
|
||||
| <a href="?mod=annonce">annuler</a></p>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
103
sources/app/annonce/views/index.phtml
Normal file
103
sources/app/annonce/views/index.phtml
Normal file
@ -0,0 +1,103 @@
|
||||
<p>
|
||||
<?php if (0 < $nbAds = count($ads)) : ?>
|
||||
<strong><?php echo $nbAds ?> <?php
|
||||
echo $nbAds > 1?"annonces sauvegardées":"annonce sauvegardée"; ?></strong> |
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&a=form" class="link-create-ad">Sauvegarder une annonce</a>
|
||||
</p>
|
||||
|
||||
<table style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 20px"></th>
|
||||
<th style="width: 20px"></th>
|
||||
<th>
|
||||
<?php if ($sort == "title") : ?>
|
||||
<img src="static/images/sort-<?php echo $order; ?>.png" alt="" />
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&sort=title">Titre</a>
|
||||
</th>
|
||||
<th style="width: 200px">
|
||||
<?php if ($sort == "author") : ?>
|
||||
<img src="static/images/sort-<?php echo $order; ?>.png" alt="" />
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&sort=author">Auteur</a>
|
||||
</th>
|
||||
<th style="width: 200px">
|
||||
<?php if ($sort == "date_created") : ?>
|
||||
<img src="static/images/sort-<?php echo $order; ?>.png" alt="" />
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&sort=date_created">Date de sauvegarde</a>
|
||||
</th>
|
||||
<th style="width: 200px">
|
||||
<?php if ($sort == "date") : ?>
|
||||
<img src="static/images/sort-<?php echo $order; ?>.png" alt="" />
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&sort=date">Date de publication</a>
|
||||
</th>
|
||||
<th style="width: 200px">
|
||||
<?php if ($sort == "category") : ?>
|
||||
<img src="static/images/sort-<?php echo $order; ?>.png" alt="" />
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&sort=category">Catégorie</a>
|
||||
</th>
|
||||
<th style="width: 100px">
|
||||
<?php if ($sort == "price") : ?>
|
||||
<img src="static/images/sort-<?php echo $order; ?>.png" alt="" />
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&sort=price">Prix</a>
|
||||
</th>
|
||||
<th style="width: 200px">
|
||||
<?php if ($sort == "zip_code") : ?>
|
||||
<img src="static/images/sort-<?php echo $order; ?>.png" alt="" />
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&sort=zip_code">Code postal</a>
|
||||
</th>
|
||||
<th style="width: 200px">
|
||||
<?php if ($sort == "city") : ?>
|
||||
<img src="static/images/sort-<?php echo $order; ?>.png" alt="" />
|
||||
<?php endif; ?>
|
||||
<a href="?mod=annonce&sort=city">Villes</a>
|
||||
</th>
|
||||
<th style="width: 20px"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (0 == $nbAds) : ?>
|
||||
<tr><td colspan="11">Aucune annonce sauvegardée</td></tr>
|
||||
<?php else: ?>
|
||||
<?php $i = 1; foreach ($ads AS $ad) : ?>
|
||||
<?php
|
||||
$date = implode("/", array_reverse(explode("-", $ad->getDate())));
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $i++; ?></td>
|
||||
<td>
|
||||
<?php if ($photos = $ad->getPhotos()) : ?>
|
||||
<img src="<?php echo $adPhoto->getPublicDestination($photos[0]["local"]); ?>" alt=""
|
||||
style="max-width: 100px; max-height: 100px;" />
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="title"><a href="?mod=annonce&a=view&id=<?php echo $ad->getId(); ?>"><?php
|
||||
echo $ad->getTitle()?htmlspecialchars($ad->getTitle()):"-"; ?></a></td>
|
||||
<td><?php echo htmlspecialchars($ad->getAuthor()); ?></td>
|
||||
<td><?php echo date("d/m/Y à H:i", strtotime($ad->getDateCreated())); ?></td>
|
||||
<td><?php echo htmlspecialchars($date); ?></td>
|
||||
<td><?php echo htmlspecialchars($ad->getCategory()); ?></td>
|
||||
<td style="text-align: right;">
|
||||
<?php if ($price = $ad->getPrice()) : ?>
|
||||
<?php echo number_format($price, 0, ",", " ")." ";
|
||||
echo htmlspecialchars($ad->getCurrency()); ?>
|
||||
<?php else: ?>
|
||||
-
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($ad->getZipCode()); ?></td>
|
||||
<td><?php echo htmlspecialchars($ad->getCity()); ?></td>
|
||||
<td><a href="?mod=annonce&a=form-delete&id=<?php echo $ad->getId(); ?>"
|
||||
title="Supprimer l'annonce"><span class="fa fa-times"></span></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
95
sources/app/annonce/views/view.phtml
Normal file
95
sources/app/annonce/views/view.phtml
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
$date = implode("/", array_reverse(explode("-", $ad->getDate())));
|
||||
?>
|
||||
<p>
|
||||
<a href="?mod=annonce">< retour à la liste des annonces sauvegardées</a> |
|
||||
<a href="?mod=annonce&a=form-delete&id=<?php echo $ad->getId(); ?>&r=view"
|
||||
title="Supprimer l'annonce"><span class="fa fa-times"></span> supprimer l'annonce</a>
|
||||
</p>
|
||||
|
||||
<h2>
|
||||
<?php echo htmlspecialchars($ad->getTitle()); ?>
|
||||
<a href="<?php echo $ad->getLink(); ?>"
|
||||
target="_blank"
|
||||
title="Ouvrir sur <?php echo $ad_config->getOption("site_name");
|
||||
?>"><span class="fa fa-external-link"></span></a>
|
||||
</h2>
|
||||
<div class="annonce">
|
||||
<div class="annonce-data">
|
||||
<ul>
|
||||
<li class="annonce-data-line">
|
||||
<span class="annonce-label">Auteur</span><span
|
||||
class="annonce-value"><?php echo $ad->getAuthor(); ?></span>
|
||||
</li>
|
||||
<?php if ($value = $ad->getPrice()) : ?>
|
||||
<li class="annonce-data-line">
|
||||
<span class="annonce-label">Prix</span><span
|
||||
class="annonce-value"><?php
|
||||
echo number_format($value, 0, ",", " ")." ";
|
||||
echo htmlspecialchars($ad->getCurrency());
|
||||
?></span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li class="annonce-data-line">
|
||||
<span class="annonce-label">Date</span><span
|
||||
class="annonce-value"><?php
|
||||
echo $date; ?></span>
|
||||
</li>
|
||||
<li class="annonce-data-line">
|
||||
<span class="annonce-label">Catégorie</span><span
|
||||
class="annonce-value"><?php
|
||||
echo htmlspecialchars($ad->getCategory()); ?></span>
|
||||
</li>
|
||||
<?php if ($value = $ad->getCity()) : ?>
|
||||
<li class="annonce-data-line">
|
||||
<span class="annonce-label">Ville</span><span
|
||||
class="annonce-value">
|
||||
<?php echo htmlspecialchars($ad->getZipCode()); ?>
|
||||
<?php echo htmlspecialchars($value); ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($ad->getProperties() AS $name => $value) : ?>
|
||||
<?php if ($value) : ?>
|
||||
<li class="annonce-data-line">
|
||||
<span class="annonce-label"><?php echo htmlspecialchars($name); ?></span><span
|
||||
class="annonce-value">
|
||||
<?php echo htmlspecialchars($value); ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<div class="annonce-description">
|
||||
<span class="annonce-label">Description</span>
|
||||
<p><?php
|
||||
echo nl2br(htmlspecialchars($ad->getDescription())); ?></p>
|
||||
</div>
|
||||
<div class="annonce-comment">
|
||||
<span class="annonce-label">Note</span>
|
||||
<div>
|
||||
<p><?php echo nl2br(htmlspecialchars($note = $ad->getComment())); ?></p>
|
||||
<p><a href="?mod=annonce&a=form-comment&id=<?php echo $ad->getId(); ?>"
|
||||
class="button">
|
||||
<?php if (!$note) : ?>
|
||||
Ajouter une note
|
||||
<?php else: ?>
|
||||
Modifier la note
|
||||
<?php endif; ?>
|
||||
</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $photos = $ad->getPhotos(); ?>
|
||||
<div class="annonce-photos">
|
||||
<?php foreach ($photos AS $photo) : ?>
|
||||
<div class="annonce-photo">
|
||||
<a href="<?php echo $adPhoto->getPublicDestination($photo["local"]);
|
||||
?>" target="_blank"><img
|
||||
src="<?php echo $adPhoto->getPublicDestination($photo["local"]); ?>"
|
||||
alt="" class="annonce-photo-img" /></a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
44
sources/app/api/annonce/create.php
Normal file
44
sources/app/api/annonce/create.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
$ad = new App\Ad\Ad();
|
||||
|
||||
$link = "";
|
||||
|
||||
if (empty($_POST["link"])) {
|
||||
return array(
|
||||
"data" => $_POST,
|
||||
"errors" => array(
|
||||
"link" => "Ce champ est obligatoire."
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$link = $_POST["link"];
|
||||
try {
|
||||
$siteConfig = \AdService\SiteConfigFactory::factory($link);
|
||||
$parser = \AdService\ParserFactory::factory($link);
|
||||
} catch (\Exception $e) {
|
||||
return array(
|
||||
"data" => $_POST,
|
||||
"errors" => array(
|
||||
"link" => "Cette adresse ne semble pas valide."
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$ad = $parser->processAd(
|
||||
$client->request($link),
|
||||
parse_url($link, PHP_URL_SCHEME)
|
||||
);
|
||||
|
||||
$ad_stored = $storage->fetchById($ad->getId());
|
||||
if (!$ad_stored) {
|
||||
$ad_stored = new \App\Ad\Ad();
|
||||
}
|
||||
|
||||
$ad_stored->setFromArray($ad->toArray());
|
||||
$storage->save($ad_stored);
|
||||
|
||||
$adPhoto = new App\Storage\AdPhoto($userAuthed);
|
||||
$adPhoto->import($ad_stored);
|
||||
|
||||
return $ad_stored->toArray();
|
16
sources/app/api/annonce/delete.php
Normal file
16
sources/app/api/annonce/delete.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
if (empty($_POST["id"])) {
|
||||
return array(
|
||||
"data" => $_POST,
|
||||
"errors" => array(
|
||||
"id" => "Un ID doit être fourni"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$ad = $storage->fetchById($_POST["id"]);
|
||||
if ($ad) {
|
||||
$storage->delete($ad);
|
||||
$adPhoto = new App\Storage\AdPhoto($userAuthed);
|
||||
$adPhoto->delete($ad);
|
||||
}
|
24
sources/app/api/annonce/index.php
Normal file
24
sources/app/api/annonce/index.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$order_by = null;
|
||||
$sort = isset($_GET["sort"]) ? $_GET["sort"] : "";
|
||||
$order = isset($_GET["order"]) ? $_GET["order"] : "asc";
|
||||
|
||||
if ($sort) {
|
||||
$order_by = $sort." ".$order;
|
||||
}
|
||||
|
||||
$ads = $storage->fetchAll($order_by);
|
||||
|
||||
$baseurl = $config->get("general", "baseurl", "");
|
||||
$adPhoto = new App\Storage\AdPhoto($userAuthed);
|
||||
$return = array();
|
||||
foreach ($ads AS $ad) {
|
||||
$params = $ad->toArray();
|
||||
foreach ($params["photos"] AS $i => $photo) {
|
||||
$params["photos"][$i]["local"] = $baseurl.$adPhoto->getPublicDestination($photo["local"]);
|
||||
}
|
||||
$return[$ad->getId()] = $params;
|
||||
}
|
||||
|
||||
return $return;
|
75
sources/app/data/notifications.php
Normal file
75
sources/app/data/notifications.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
$notifications_enabled = array();
|
||||
if ($userAuthed) {
|
||||
$notifications_enabled = $userAuthed->getNotificationsEnabled();
|
||||
$notifications_enabled["mail"] = array();
|
||||
}
|
||||
|
||||
$data_notifications = array(
|
||||
"mail" => array(
|
||||
"list_label" => "Envoyer par email",
|
||||
"form_label" => "par email",
|
||||
"form_name" => "send_mail",
|
||||
"enabled" => true,
|
||||
),
|
||||
"freemobile" => array(
|
||||
"label" => "SMS - Free Mobile",
|
||||
"link" => "https://mobile.free.fr/moncompte/",
|
||||
"list_label" => "SMS Free Mobile",
|
||||
"form_label" => "par SMS Free Mobile",
|
||||
"form_name" => "send_sms_free_mobile",
|
||||
"enabled" => isset($notifications_enabled["freeMobile"]),
|
||||
),
|
||||
"ovh" => array(
|
||||
"label" => "SMS - OVH Telecom",
|
||||
"cost" => "À partir de 0,07 € / SMS",
|
||||
"link" => "https://www.ovhtelecom.fr/sms/",
|
||||
"list_label" => "SMS OVH",
|
||||
"form_label" => "par SMS OVH",
|
||||
"form_name" => "send_sms_ovh",
|
||||
"enabled" => isset($notifications_enabled["ovh"]),
|
||||
),
|
||||
"pushbullet" => array(
|
||||
"label" => "Pushbullet",
|
||||
"link" => "https://www.pushbullet.com/",
|
||||
"list_label" => "Pushbullet",
|
||||
"form_label" => "par Pushbullet",
|
||||
"form_name" => "send_pushbullet",
|
||||
"enabled" => isset($notifications_enabled["pushbullet"]),
|
||||
),
|
||||
"notifymyandroid" => array(
|
||||
"label" => "NotifyMyAndroid",
|
||||
"cost" => "5 notifications / jour (illimité en premium)",
|
||||
"link" => "http://www.notifymyandroid.com/",
|
||||
"list_label" => "NotityMyAndroid",
|
||||
"form_label" => "par NotityMyAndroid",
|
||||
"form_name" => "send_notifymyandroid",
|
||||
"enabled" => isset($notifications_enabled["notifymyandroid"]),
|
||||
),
|
||||
"pushover" => array(
|
||||
"label" => "Pushover",
|
||||
"link" => "https://pushover.net/",
|
||||
"list_label" => "Pushover",
|
||||
"form_label" => "par Pushover",
|
||||
"form_name" => "send_pushover",
|
||||
"enabled" => isset($notifications_enabled["pushover"]),
|
||||
),
|
||||
"joaoappsjoin" => array(
|
||||
"label" => "Joaoapps / Join",
|
||||
"link" => "https://joaoapps.com/join/",
|
||||
"list_label" => "Joaoapps / Join",
|
||||
"form_label" => "par Joaoapps / Join",
|
||||
"form_name" => "send_joaoappsjoin",
|
||||
"enabled" => isset($notifications_enabled["joaoappsjoin"]),
|
||||
),
|
||||
"slack" => array(
|
||||
"label" => "Slack",
|
||||
"cost" => "Ofre gratuite et premium",
|
||||
"link" => "https://slack.com",
|
||||
"list_label" => "Slack",
|
||||
"form_label" => "par Slack",
|
||||
"form_name" => "send_slack",
|
||||
"enabled" => isset($notifications_enabled["slack"]),
|
||||
),
|
||||
);
|
@ -12,7 +12,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$auth->setUsername($username)
|
||||
->setPassword(sha1($password));
|
||||
if ($auth->authenticate()) {
|
||||
if ($module == "default" && $action == "login") {
|
||||
if (isset($_GET["a"]) && $_GET["a"] == "login") {
|
||||
$redirect = "./";
|
||||
} else {
|
||||
$redirect = $_SERVER["REQUEST_URI"];
|
||||
|
@ -5,7 +5,8 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="robots" content="none">
|
||||
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="static/styles.css?v=<?php echo APPLICATION_VERSION; ?>" />
|
||||
<link rel="stylesheet" href="static/styles.css?v=<?php echo STATIC_REV; ?>" />
|
||||
<link rel="stylesheet" href="static/font-awesome/css/font-awesome.min.css?v=<?php echo STATIC_REV; ?>" />
|
||||
</head>
|
||||
<body>
|
||||
<?php if ($userAuthed) : ?>
|
||||
@ -13,8 +14,9 @@
|
||||
<h1><a href="./">Système d'alerte Leboncoin</a></h1>
|
||||
<ul class="topmenu">
|
||||
<li<?php echo $module === "default"?' class="active"':''; ?>><a href="./?"><img src="static/images/home.png" alt="" /></a></li>
|
||||
<li<?php echo $module === "mail"?' class="active"':''; ?>><a href="?mod=mail">Mail / SMS</a></li>
|
||||
<li<?php echo $module === "rss"?' class="active"':''; ?>><a href="?mod=rss">RSS</a></li>
|
||||
<li<?php echo $module === "mail"?' class="active"':''; ?>><a href="?mod=mail">Mes alertes</a></li>
|
||||
<li<?php echo $module === "rss"?' class="active"':''; ?>><a href="?mod=rss">Flux RSS</a></li>
|
||||
<li<?php echo $module === "annonce"?' class="active"':''; ?>><a href="?mod=annonce">Mes annonces sauvegardées</a></li>
|
||||
<li<?php echo $module === "user"?' class="active"':''; ?>><a href="?mod=user&a=settings">Paramètres</a></li>
|
||||
<li><a href="https://alerte.ilatumi.org/forum">Forum</a></li>
|
||||
<li style="float: right;"><a href="?a=logout">Déconnexion <span>(<?php echo htmlspecialchars($userAuthed->getUsername()); ?>)</span></a></li>
|
||||
@ -35,4 +37,4 @@
|
||||
<?php endif; ?>
|
||||
<script type="text/javascript" src="static/scripts.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -4,6 +4,14 @@ $errors = array();
|
||||
$formErrors = array();
|
||||
$messages = array();
|
||||
|
||||
if (!function_exists("curl_init")) {
|
||||
$errors[] = "php-curl doit être installé pour continuer l'installation";
|
||||
}
|
||||
|
||||
if (!class_exists("mysqli")) {
|
||||
$warnings["mysqli"] = "mysqli doit être installé pour utiliser le stockage en base de données";
|
||||
}
|
||||
|
||||
if (!is_writable(DOCUMENT_ROOT."/var")) {
|
||||
$errors[] = "Il est nécessaire de pouvoir écrire dans le dossier 'var' (".DOCUMENT_ROOT."/var".").";
|
||||
}
|
||||
@ -46,8 +54,12 @@ if (!$errors && $_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (!is_dir(DOCUMENT_ROOT."/var/log")) {
|
||||
mkdir(DOCUMENT_ROOT."/var/log");
|
||||
}
|
||||
if (!is_dir(DOCUMENT_ROOT."/var/tmp")) {
|
||||
mkdir(DOCUMENT_ROOT."/var/tmp");
|
||||
}
|
||||
$config->set("general", "version", APPLICATION_VERSION);
|
||||
if (isset($dbConnection)) {
|
||||
$dbConnection->set_charset("utf8");
|
||||
$config->set("storage", "type", "db");
|
||||
$config->set("storage", "options", array(
|
||||
"host" => $_POST["db"]["host"],
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?php if (!empty($errors)) : ?>
|
||||
<ul class="error"><li><?php echo implode("</li><li>", $errors); ?></li></ul>
|
||||
<?php else: ?>
|
||||
|
||||
<?php if (!empty($warnings)) : ?>
|
||||
<ul class="warning"><li><?php echo implode("</li><li>", $warnings); ?></li></ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<legend>Nouvelle installation</legend>
|
||||
@ -35,13 +40,16 @@
|
||||
<dd>
|
||||
<label for="typefiles">
|
||||
<input type="radio" id="typefiles" name="type" value="files"<?php
|
||||
echo isset($_POST["type"]) && "files" == $_POST["type"] ? ' checked="checked"' : ""
|
||||
echo isset($warnings["mysqli"])
|
||||
|| isset($_POST["type"]) && "files" == $_POST["type"] ?
|
||||
' checked="checked"' : ""
|
||||
?> />
|
||||
fichiers
|
||||
</label>
|
||||
<label for="typedb" style="margin-left: 40px;">
|
||||
<input type="radio" id="typedb" name="type" value="db"<?php
|
||||
echo isset($_POST["type"]) && "db" == $_POST["type"] ? ' checked="checked"' : ""
|
||||
echo isset($_POST["type"]) && "db" == $_POST["type"] ? ' checked="checked"' : "";
|
||||
echo isset($warnings["mysqli"]) ? ' disabled="disabled"' : "";
|
||||
?> />
|
||||
base de données MySQL
|
||||
</label>
|
||||
@ -93,6 +101,18 @@
|
||||
<p>Vous pouvez vous connecter avec les identifiants suivants :<br />
|
||||
<strong>Utilisateur:</strong> admin<br />
|
||||
<strong>Mot de passe:</strong> spécifié lors de l'installation.</p>
|
||||
|
||||
<h3>Configuration d'une tâche automatique</h3>
|
||||
<p>
|
||||
L'installation de LBCAlerte est terminée mais il reste une étape
|
||||
indispensable. Afin de recevoir les nouvelles alertes, vous devez
|
||||
configurer une tâche automatique.
|
||||
<br />
|
||||
Vous trouverez plus d'informations sur la
|
||||
<a href="https://alerte.ilatumi.org/documentation/configuration-alerte-leboncoin-mail-sms"
|
||||
target="_blank">page dédiée de la documentation</a>.
|
||||
</p>
|
||||
|
||||
<p><a href="./">continuer ></a></p>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
|
@ -6,4 +6,6 @@ if ($action != "check") {
|
||||
} else {
|
||||
$storage = new \App\Storage\File\Alert(DOCUMENT_ROOT."/var/configs/".$auth->getUsername().".csv");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require DOCUMENT_ROOT."/app/data/notifications.php";
|
||||
|
@ -138,24 +138,22 @@ class Main
|
||||
|
||||
// configuration des notifications.
|
||||
$notifications = array();
|
||||
$notifications_params = $user->getOption("notification");
|
||||
if ($notifications_params && is_array($notifications_params)) {
|
||||
foreach ($notifications_params AS $notification_name => $options) {
|
||||
if (!is_array($options)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$notifications[$notification_name] = \Message\AdapterFactory::factory($notification_name, $options);
|
||||
$this->_logger->debug(
|
||||
"[Pid ".getmypid()."] USER : ".$user->getUsername().
|
||||
" -> Notification ".get_class($notifications[$notification_name])." activée"
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$this->_logger->warn(
|
||||
"[Pid ".getmypid()."] USER : ".$user->getUsername().
|
||||
" -> Notification ".$notification_name." invalide"
|
||||
);
|
||||
}
|
||||
$notifications_enabled = $user->getNotificationsEnabled();
|
||||
foreach ($notifications_enabled AS $notification_name => $options) {
|
||||
if (!is_array($options)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$notifications[$notification_name] = \Message\AdapterFactory::factory($notification_name, $options);
|
||||
$this->_logger->debug(
|
||||
"[Pid ".getmypid()."] USER : ".$user->getUsername().
|
||||
" -> Notification ".get_class($notifications[$notification_name])." activée"
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$this->_logger->warn(
|
||||
"[Pid ".getmypid()."] USER : ".$user->getUsername().
|
||||
" -> Notification ".$notification_name." invalide"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,6 +165,7 @@ class Main
|
||||
if (count($alerts) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($alerts AS $i => $alert) {
|
||||
$log_id = "[Pid ".getmypid()."] USER : ".$user->getUsername()." - ALERT ID : ".$alert->id." -> ";
|
||||
|
||||
@ -205,7 +204,7 @@ class Main
|
||||
try {
|
||||
$parser = \AdService\ParserFactory::factory($alert->url);
|
||||
} catch (\AdService\Exception $e) {
|
||||
$this->_logger->err($log_id." ".$e->getMessage());
|
||||
$this->_logger->warn($log_id." ".$e->getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -310,15 +309,12 @@ class Main
|
||||
$error = true;
|
||||
}
|
||||
if (!$error) {
|
||||
if ($alert->group_ads) {
|
||||
$newAdsCount = count($newAds);
|
||||
$subject = "Alerte ".$siteConfig->getOption("site_name")." : ".$alert->title;
|
||||
$message = '
|
||||
$message_header = '
|
||||
<h1 style="font-size: 16px;">Alerte : '.htmlspecialchars($alert->title, null, "UTF-8").'</h1>
|
||||
<p style="font-size: 14px; margin: 0;"><strong><a href="'.htmlspecialchars($alert->url, null, "UTF-8").'"
|
||||
style="text-decoration: none; color: #0B6CDA;">LIEN DE RECHERCHE</a>';
|
||||
if ($baseurl) {
|
||||
$message .= '
|
||||
$message_header .= '
|
||||
- <a href="'.$baseurl.'?mod=mail&a=form&id='. $alert->id .
|
||||
'" style="text-decoration: none; color: #E77600;">MODIFIER</a>
|
||||
- <a href="'.$baseurl.'?mod=mail&a=toggle_status&s=suspend&id='. $alert->id .
|
||||
@ -327,8 +323,13 @@ class Main
|
||||
'" style="text-decoration: none; color: #FF0000;">SUPPRIMER</a>
|
||||
';
|
||||
}
|
||||
$message .= '</strong></p>';
|
||||
$message .= '<hr />';
|
||||
$message_header .= '</strong></p>';
|
||||
$message_header .= '<hr />';
|
||||
|
||||
if ($alert->group_ads) {
|
||||
$newAdsCount = count($newAds);
|
||||
$subject = "Alerte ".$siteConfig->getOption("site_name")." : ".$alert->title;
|
||||
$message = $message_header;
|
||||
$message .= '<p style="font-size: 16px; margin: 10px 0;"><strong>'.
|
||||
$newAdsCount.' nouvelle'.($newAdsCount > 1?'s':'').
|
||||
' annonce'.($newAdsCount > 1?'s':'').
|
||||
@ -344,27 +345,12 @@ class Main
|
||||
} catch (phpmailerException $e) {
|
||||
$this->_logger->warn($log_id.$e->getMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
$newAds = array_reverse($newAds, true);
|
||||
foreach ($newAds AS $id => $ad) {
|
||||
$subject = ($alert->title?$alert->title." : ":"").$ads[$id]->getTitle();
|
||||
$message = '
|
||||
<h1 style="font-size: 16px;">Alerte : '.htmlspecialchars($alert->title, null, "UTF-8").'</h1>
|
||||
<p style="font-size: 14px; margin: 0;"><strong><a href="'.htmlspecialchars($alert->url, null, "UTF-8").'"
|
||||
style="text-decoration: none; color: #0B6CDA;">LIEN DE RECHERCHE</a>';
|
||||
if ($baseurl) {
|
||||
$message .= '
|
||||
- <a href="'.$baseurl.'?mod=mail&a=form&id='. $alert->id .
|
||||
'" style="text-decoration: none; color: #E77600;">MODIFIER</a>
|
||||
- <a href="'.$baseurl.'?mod=mail&a=toggle_status&s=suspend&id='. $alert->id .
|
||||
'" style="text-decoration: none; color: #999999;">ACTIVER / DÉSACTIVER</a>
|
||||
- <a href="'.$baseurl.'?mod=mail&a=form-delete&id='. $alert->id .
|
||||
'" style="text-decoration: none; color: #FF0000;">SUPPRIMER</a>
|
||||
';
|
||||
}
|
||||
$message .= '</strong></p>';
|
||||
$message .= '<hr /><br />';
|
||||
$message .= $ad;
|
||||
$message = $message_header.$ad;
|
||||
|
||||
$this->_mailer->Subject = $subject;
|
||||
$this->_mailer->Body = $message;
|
||||
@ -377,13 +363,9 @@ class Main
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($notifications && (
|
||||
$alert->send_sms_free_mobile
|
||||
|| $alert->send_sms_ovh
|
||||
|| $alert->send_pushbullet
|
||||
|| $alert->send_notifymyandroid
|
||||
|| $alert->send_pushover
|
||||
)) {
|
||||
|
||||
$params = array();
|
||||
if ($notifications) {
|
||||
if ($countAds < 5) { // limite à 5 SMS
|
||||
foreach ($newAds AS $id => $ad) {
|
||||
$ad = $ads[$id]; // récupère l'objet.
|
||||
@ -411,30 +393,6 @@ class Main
|
||||
"description" => "Nouvelle annonce".($alert->title ? " pour : ".$alert->title : ""),
|
||||
"url" => $url,
|
||||
);
|
||||
foreach ($notifications AS $key => $notifier) {
|
||||
switch ($key) {
|
||||
case "freeMobile":
|
||||
$key_test = "send_sms_free_mobile";
|
||||
break;
|
||||
case "ovh":
|
||||
$key_test = "send_sms_ovh";
|
||||
break;
|
||||
default:
|
||||
$key_test = "send_".$key;
|
||||
}
|
||||
if (isset($alert->$key_test) && $alert->$key_test) {
|
||||
try {
|
||||
$notifier->send($msg, $params);
|
||||
} catch (Exception $e) {
|
||||
$this->_logger->warn(
|
||||
$log_id."Erreur sur envoi via ".
|
||||
get_class($notifier).
|
||||
": (".$e->getCode().") ".
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // envoi un msg global
|
||||
@ -448,28 +406,31 @@ class Main
|
||||
($alert->title ? " pour : ".$alert->title : ""),
|
||||
"url" => $url,
|
||||
);
|
||||
foreach ($notifications AS $key => $notifier) {
|
||||
switch ($key) {
|
||||
case "freeMobile":
|
||||
$key_test = "send_sms_free_mobile";
|
||||
break;
|
||||
case "ovh":
|
||||
$key_test = "send_sms_ovh";
|
||||
break;
|
||||
default:
|
||||
$key_test = "send_".$key;
|
||||
}
|
||||
if (isset($alert->$key_test) && $alert->$key_test) {
|
||||
try {
|
||||
$notifier->send($msg, $params);
|
||||
} catch (Exception $e) {
|
||||
$this->_logger->warn(
|
||||
$log_id."Erreur sur envoi via ".
|
||||
get_class($notifier).
|
||||
": (".$e->getCode().") ".
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($params) {
|
||||
foreach ($notifications AS $key => $notifier) {
|
||||
switch ($key) {
|
||||
case "freeMobile":
|
||||
$key_test = "send_sms_free_mobile";
|
||||
break;
|
||||
case "ovh":
|
||||
$key_test = "send_sms_ovh";
|
||||
break;
|
||||
default:
|
||||
$key_test = "send_".$key;
|
||||
}
|
||||
if (isset($alert->$key_test) && $alert->$key_test) {
|
||||
try {
|
||||
$notifier->send($msg, $params);
|
||||
} catch (Exception $e) {
|
||||
$this->_logger->warn(
|
||||
$log_id."Erreur sur envoi via ".
|
||||
get_class($notifier).
|
||||
": (".$e->getCode().") ".
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -548,11 +509,7 @@ try {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$main->check();
|
||||
} catch (\Exception $e) {
|
||||
Logger::getLogger("main")->warn($e->getMessage());
|
||||
}
|
||||
$main->check();
|
||||
$main->shutdown();
|
||||
|
||||
|
||||
|
@ -4,9 +4,17 @@ if (isset($_GET["id"])) {
|
||||
}
|
||||
if (empty($alert)) {
|
||||
$alert = new App\Mail\Alert();
|
||||
if ($emails = $userAuthed->getOption("addresses_mails")) {
|
||||
$alert->email = $emails;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["preurl"])) {
|
||||
$alert->url = $_GET["preurl"];
|
||||
}
|
||||
|
||||
$categoryCollection = new \Lbc\CategoryCollection();
|
||||
$errors = array();
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
foreach ($_POST AS $name => $value) {
|
||||
@ -17,15 +25,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
}
|
||||
}
|
||||
$alert->fromArray($_POST);
|
||||
if (empty($alert->send_mail)
|
||||
&& empty($alert->send_sms_free_mobile)
|
||||
&& empty($alert->send_sms_ovh)
|
||||
&& empty($alert->send_pushbullet)
|
||||
&& empty($alert->send_notifymyandroid)
|
||||
&& empty($alert->send_pushover)
|
||||
) {
|
||||
$errors["send_type"] = "Vous devez sélectionner au moins un moyen de communication.";
|
||||
}
|
||||
|
||||
if (empty($alert->email)) {
|
||||
$errors["email"] = "Ce champ est obligatoire.";
|
||||
}
|
||||
|
@ -67,20 +67,3 @@ if (in_array("Sans groupe", $groups)) {
|
||||
unset($groups[array_search("Sans groupe", $groups)]);
|
||||
$groups[] = "Sans groupe";
|
||||
}
|
||||
|
||||
$notification["freeMobile"] = $userAuthed->hasSMSFreeMobile();
|
||||
$notification["ovh"] = $userAuthed->hasSMSOvh();
|
||||
$notification["pushbullet"] = $userAuthed->hasPushbullet();
|
||||
$notification["notifymyandroid"] = $userAuthed->hasNotifyMyAndroid();
|
||||
$notification["pushover"] = $userAuthed->hasPushover();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,25 @@
|
||||
<?php
|
||||
|
||||
if (isset($_GET["id"]) && $alert = $storage->fetchById($_GET["id"])) {
|
||||
$status = isset($_GET["s"])?$_GET["s"]:"";
|
||||
if (in_array($status, array("suspend", "send_mail", "send_sms_free_mobile",
|
||||
"send_sms_ovh", "send_pushbullet", "send_notifymyandroid",
|
||||
"send_pushover"))) {
|
||||
$status = isset($_GET["s"]) ? $_GET["s"] : "";
|
||||
$update = false;
|
||||
if ($status == "suspend") {
|
||||
$alert->$status = !$alert->$status;
|
||||
$update = true;
|
||||
} else {
|
||||
foreach ($data_notifications AS $name => $notification) {
|
||||
if ($status == $notification["form_name"]) {
|
||||
$alert->$status = !$alert->$status;
|
||||
$update = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
$storage->save($alert);
|
||||
}
|
||||
}
|
||||
header("LOCATION: ./?mod=mail"); exit;
|
||||
|
||||
header("LOCATION: ./?mod=mail");
|
||||
exit;
|
||||
|
@ -29,63 +29,24 @@ $alertCategories = $alert->getCategories();
|
||||
<p class="error"><?php echo $errors["title"]; ?></p>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<?php if ($userAuthed->hasSMSFreeMobile() || $userAuthed->hasSMSOvh() || $userAuthed->hasPushbullet()) : ?>
|
||||
<?php if ($userAuthed->hasNotification()) : ?>
|
||||
<dt>
|
||||
<label>Comment souhaitez-vous recevoir les alertes</label>
|
||||
</dt>
|
||||
<dd class="notification-list">
|
||||
<input type="hidden" name="send_mail" value="0" />
|
||||
<input type="hidden" name="send_sms_free_mobile" value="0" />
|
||||
<input type="hidden" name="send_sms_ovh" value="0" />
|
||||
<input type="hidden" name="send_pushbullet" value="0" />
|
||||
<input type="hidden" name="send_notifymyandroid" value="0" />
|
||||
<input type="hidden" name="send_pushover" value="0" />
|
||||
<label for="alert_mail">
|
||||
<input id="alert_mail" type="checkbox" name="send_mail" value="1"<?php
|
||||
echo $alert->send_mail?' checked="checked"':''
|
||||
?> />
|
||||
par email
|
||||
<?php foreach ($data_notifications AS $name => $notification) : ?>
|
||||
<?php if (!$notification["enabled"]) continue; ?>
|
||||
<input type="hidden" name="<?php echo $notification["form_name"]; ?>" value="0" />
|
||||
<label for="<?php echo $notification["form_name"]; ?>">
|
||||
<input id="<?php echo $notification["form_name"]; ?>"
|
||||
type="checkbox"
|
||||
name="<?php echo $notification["form_name"]; ?>"
|
||||
value="1"
|
||||
<?php echo $alert->{$notification["form_name"]} ? ' checked="checked"' : ''; ?>
|
||||
/>
|
||||
<?php echo $notification["form_label"]; ?>
|
||||
</label>
|
||||
<?php if ($userAuthed->hasSMSFreeMobile()) : ?>
|
||||
<label for="alert_sms_free">
|
||||
<input id="alert_sms_free" type="checkbox" name="send_sms_free_mobile" value="1"<?php
|
||||
echo $alert->send_sms_free_mobile?' checked="checked"':''
|
||||
?> />
|
||||
par SMS Free Mobile
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if ($userAuthed->hasSMSOvh()) : ?>
|
||||
<label for="alert_sms_ovh">
|
||||
<input id="alert_sms_ovh" type="checkbox" name="send_sms_ovh" value="1"<?php
|
||||
echo $alert->send_sms_ovh?' checked="checked"':''
|
||||
?> />
|
||||
par SMS OVH
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if ($userAuthed->hasPushbullet()) : ?>
|
||||
<label for="alert_pushbullet">
|
||||
<input id="alert_pushbullet" type="checkbox" name="send_pushbullet" value="1"<?php
|
||||
echo $alert->send_pushbullet?' checked="checked"':''
|
||||
?> />
|
||||
par Pushbullet
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if ($userAuthed->hasNotifyMyAndroid()) : ?>
|
||||
<label for="alert_notifymyandroid">
|
||||
<input id="alert_notifymyandroid" type="checkbox" name="send_notifymyandroid" value="1"<?php
|
||||
echo $alert->send_notifymyandroid?' checked="checked"':''
|
||||
?> />
|
||||
par NotityMyAndroid
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if ($userAuthed->hasPushover()) : ?>
|
||||
<label for="alert_pushover">
|
||||
<input id="alert_pushover" type="checkbox" name="send_pushover" value="1"<?php
|
||||
echo $alert->send_pushover?' checked="checked"':''
|
||||
?> />
|
||||
par Pushover
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if (isset($errors["send_type"])) : ?>
|
||||
<p class="error"><?php echo $errors["send_type"]; ?></p>
|
||||
<?php endif; ?>
|
||||
|
@ -30,29 +30,12 @@
|
||||
<?php if ($showCities) : ?>
|
||||
<th style="width: 200px">Villes</th>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["freeMobile"]
|
||||
|| $notification["ovh"]
|
||||
|| $notification["pushbullet"]
|
||||
|| $notification["notifymyandroid"]
|
||||
|| $notification["pushover"]
|
||||
) : ?>
|
||||
<th style="width: 140px">Envoyer par email</th>
|
||||
<?php if ($notification["freeMobile"]) : ?>
|
||||
<th style="width: 140px">SMS Free Mobile</th>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["ovh"]) : ?>
|
||||
<th style="width: 140px">SMS OVH</th>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["pushbullet"]) : ?>
|
||||
<th style="width: 140px">Pushbullet</th>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["notifymyandroid"]) : ?>
|
||||
<th style="width: 140px">NotityMyAndroid</th>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["pushover"]) : ?>
|
||||
<th style="width: 140px">Pushover</th>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($data_notifications AS $name => $notification) : ?>
|
||||
<?php if (!$notification["enabled"]) continue; ?>
|
||||
<th style="width: 140px"><?php echo $notification["list_label"]; ?></th>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<th style="width: 70px">Actif</th>
|
||||
<th style="width: 170px"> </th>
|
||||
</tr>
|
||||
@ -89,53 +72,17 @@
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["freeMobile"]
|
||||
|| $notification["ovh"]
|
||||
|| $notification["pushbullet"]
|
||||
|| $notification["notifymyandroid"]
|
||||
|| $notification["pushover"]
|
||||
) : ?>
|
||||
|
||||
<?php foreach ($data_notifications AS $name => $notification) : ?>
|
||||
<?php if (!$notification["enabled"]) continue; ?>
|
||||
<td>
|
||||
<a href="?mod=mail&a=toggle_status&s=send_mail&id=<?php echo $alert->id;
|
||||
?>"><img src="static/images/<?php
|
||||
echo !$alert->send_mail?"disable":"enable"; ?>.png" alt="" /></a>
|
||||
<a href="?mod=mail&a=toggle_status&s=<?php
|
||||
echo $notification["form_name"]; ?>&id=<?php
|
||||
echo $alert->id; ?>"><img src="static/images/<?php
|
||||
echo !$alert->{$notification["form_name"]} ? "disable" : "enable";
|
||||
?>.png" alt="" /></a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["freeMobile"]) : ?>
|
||||
<td>
|
||||
<a href="?mod=mail&a=toggle_status&s=send_sms_free_mobile&id=<?php echo $alert->id;
|
||||
?>"><img src="static/images/<?php
|
||||
echo !$alert->send_sms_free_mobile?"disable":"enable"; ?>.png" alt="" /></a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["ovh"]) : ?>
|
||||
<td>
|
||||
<a href="?mod=mail&a=toggle_status&s=send_sms_ovh&id=<?php echo $alert->id;
|
||||
?>"><img src="static/images/<?php
|
||||
echo !$alert->send_sms_ovh?"disable":"enable"; ?>.png" alt="" /></a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["pushbullet"]) : ?>
|
||||
<td>
|
||||
<a href="?mod=mail&a=toggle_status&s=send_pushbullet&id=<?php echo $alert->id;
|
||||
?>"><img src="static/images/<?php
|
||||
echo !$alert->send_pushbullet?"disable":"enable"; ?>.png" alt="" /></a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["notifymyandroid"]) : ?>
|
||||
<td>
|
||||
<a href="?mod=mail&a=toggle_status&s=send_notifymyandroid&id=<?php echo $alert->id;
|
||||
?>"><img src="static/images/<?php
|
||||
echo !$alert->send_notifymyandroid?"disable":"enable"; ?>.png" alt="" /></a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($notification["pushover"]) : ?>
|
||||
<td>
|
||||
<a href="?mod=mail&a=toggle_status&s=send_pushover&id=<?php echo $alert->id;
|
||||
?>"><img src="static/images/<?php
|
||||
echo !$alert->send_pushover?"disable":"enable"; ?>.png" alt="" /></a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<td>
|
||||
<a href="?mod=mail&a=toggle_status&s=suspend&id=<?php echo $alert->id;
|
||||
?>"><img src="static/images/<?php
|
||||
|
@ -2,6 +2,10 @@
|
||||
<div>
|
||||
<?php if ($ad->getDate()) : ?>
|
||||
<strong>Publié le <?php echo date("d/m/Y à H:i", $ad->getDate()); ?></strong>
|
||||
<?php if (!empty($baseurl) && isset($config) && $config->getOption("allow_backup")) : ?>
|
||||
- <a href="<?php echo $baseurl; ?>?mod=annonce&a=backup&aurl=<?php echo $ad->getLink(); ?>"
|
||||
target="_blank">SAUVEGARDER L'ANNONCE</a>
|
||||
<?php endif; ?>
|
||||
<br />
|
||||
<?php endif; ?>
|
||||
|
||||
@ -37,7 +41,7 @@
|
||||
<?php endif; ?>
|
||||
<?php if ($ad->getThumbnailLink()) : ?>
|
||||
<br /><img src="<?php echo str_replace('/thumbs/', '/images/', $ad->getThumbnailLink()); ?>" alt=""
|
||||
style="max-width: 100%; overflow:hidden;" />
|
||||
style="max-width: 100%; max-height: 600px; overflow:hidden;" />
|
||||
<?php else : ?>
|
||||
<br />Pas de photo disponible.
|
||||
<?php endif; ?>
|
||||
|
75
sources/app/models/Ad/Ad.php
Normal file
75
sources/app/models/Ad/Ad.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ad;
|
||||
|
||||
class Ad extends \AdService\Ad
|
||||
{
|
||||
protected $_aid;
|
||||
protected $_date_created;
|
||||
protected $_comment;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Ad
|
||||
*/
|
||||
public function setAid($id)
|
||||
{
|
||||
$this->_aid = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAid()
|
||||
{
|
||||
return $this->_aid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $date_created
|
||||
* @return Ad
|
||||
*/
|
||||
public function setDateCreated($date)
|
||||
{
|
||||
$this->_date_created = $date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
return $this->_date_created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $comment
|
||||
* @return Ad
|
||||
*/
|
||||
public function setComment($comment)
|
||||
{
|
||||
$this->_comment = $comment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComment()
|
||||
{
|
||||
return $this->_comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$data = parent::toArray();
|
||||
$data["date_created"] = (string) $this->_date_created;
|
||||
$data["comment"] = (string) $this->_comment;
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -27,6 +27,8 @@ class Alert
|
||||
public $send_pushbullet = 0;
|
||||
public $send_notifymyandroid = 0;
|
||||
public $send_pushover = 0;
|
||||
public $send_joaoappsjoin = 0;
|
||||
public $send_slack = 0;
|
||||
|
||||
public function fromArray(array $values)
|
||||
{
|
||||
@ -82,7 +84,9 @@ class Alert
|
||||
"send_sms_ovh" => $this->send_sms_ovh,
|
||||
"send_pushbullet" => $this->send_pushbullet,
|
||||
"send_notifymyandroid" => $this->send_notifymyandroid,
|
||||
"send_pushover" => $this->send_pushover
|
||||
"send_pushover" => $this->send_pushover,
|
||||
"send_joaoappsjoin" => $this->send_joaoappsjoin,
|
||||
"send_slack" => $this->send_slack,
|
||||
);
|
||||
}
|
||||
}
|
16
sources/app/models/Storage/Ad.php
Normal file
16
sources/app/models/Storage/Ad.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Storage;
|
||||
|
||||
use App\Ad\Ad as AdItem;
|
||||
|
||||
interface Ad
|
||||
{
|
||||
public function fetchAll();
|
||||
|
||||
public function fetchById($id);
|
||||
|
||||
public function save(AdItem $ad);
|
||||
|
||||
public function delete(AdItem $ad);
|
||||
}
|
57
sources/app/models/Storage/AdPhoto.php
Normal file
57
sources/app/models/Storage/AdPhoto.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Storage;
|
||||
|
||||
use App\Ad\Ad as AdItem;
|
||||
|
||||
class AdPhoto
|
||||
{
|
||||
protected $_user;
|
||||
|
||||
public function __construct(\App\User\User $user)
|
||||
{
|
||||
$this->_user = $user;
|
||||
}
|
||||
|
||||
public function getPublicDestination($filename = null)
|
||||
{
|
||||
$destination = "static/media/annonce/".$this->_user->getUsername();
|
||||
if ($filename) {
|
||||
$destination .= "/".$filename;
|
||||
}
|
||||
return $destination;
|
||||
}
|
||||
|
||||
public function getDestination()
|
||||
{
|
||||
return DOCUMENT_ROOT."/static/media/annonce/".$this->_user->getUsername();
|
||||
}
|
||||
|
||||
public function import(AdItem $ad, $override = false)
|
||||
{
|
||||
$destination = $this->getDestination();
|
||||
if (!is_dir($destination) && !mkdir($destination)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($ad->getPhotos() AS $photo) {
|
||||
$filename = $destination."/".$photo["local"];
|
||||
if (!is_file($filename) || $override) {
|
||||
copy($photo["remote"], $filename);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delete(AdItem $ad)
|
||||
{
|
||||
$destination = $this->getDestination();
|
||||
foreach ($ad->getPhotos() AS $photo) {
|
||||
$filename = $destination."/".$photo["local"];
|
||||
if (is_file($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
154
sources/app/models/Storage/Db/Ad.php
Normal file
154
sources/app/models/Storage/Db/Ad.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Storage\Db;
|
||||
|
||||
use App\Ad\Ad as AdItem;
|
||||
|
||||
class Ad implements \App\Storage\Ad
|
||||
{
|
||||
/**
|
||||
* @var \mysqli
|
||||
*/
|
||||
protected $_connection;
|
||||
|
||||
protected $_table = "LBC_BackupAd";
|
||||
|
||||
/**
|
||||
* @var \App\User\User
|
||||
*/
|
||||
protected $_user;
|
||||
|
||||
public function __construct(\mysqli $connection, \App\User\User $user)
|
||||
{
|
||||
$this->_connection = $connection;
|
||||
$this->_user = $user;
|
||||
}
|
||||
|
||||
public function fetchAll($order = null)
|
||||
{
|
||||
$ads = array();
|
||||
$query = "SELECT * FROM ".$this->_table
|
||||
." WHERE user_id = ".$this->_user->getId();
|
||||
if ($order) {
|
||||
if (is_string($order)) {
|
||||
$query .= " ORDER By ".$order;
|
||||
} elseif (is_array($order)) {
|
||||
$query .= implode(", ", $order);
|
||||
}
|
||||
}
|
||||
$adsDb = $this->_connection->query($query);
|
||||
while ($adDb = $adsDb->fetch_assoc()) {
|
||||
foreach (array("photos", "properties") AS $key) {
|
||||
$adDb[$key] = json_decode($adDb[$key], true);
|
||||
if (!$adDb[$key]) {
|
||||
$adDb[$key] = array();
|
||||
}
|
||||
}
|
||||
$ad = new AdItem();
|
||||
$ad->setFromArray($adDb);
|
||||
$ads[] = $ad;
|
||||
}
|
||||
return $ads;
|
||||
}
|
||||
|
||||
public function fetchById($id)
|
||||
{
|
||||
$ad = null;
|
||||
$adDb = $this->_connection->query(
|
||||
"SELECT * FROM ".$this->_table." WHERE user_id = ".$this->_user->getId()."
|
||||
AND id = '".$this->_connection->real_escape_string($id)."'")
|
||||
->fetch_assoc();
|
||||
if ($adDb) {
|
||||
foreach (array("photos", "properties") AS $key) {
|
||||
$adDb[$key] = json_decode($adDb[$key], true);
|
||||
if (!$adDb[$key]) {
|
||||
$adDb[$key] = array();
|
||||
}
|
||||
}
|
||||
$ad = new AdItem();
|
||||
$ad->setFromArray($adDb);
|
||||
}
|
||||
return $ad;
|
||||
}
|
||||
|
||||
public function save(AdItem $ad)
|
||||
{
|
||||
$options = $ad->toArray();
|
||||
$options["photos"] = json_encode($options["photos"]);
|
||||
$options["properties"] = json_encode($options["properties"]);
|
||||
|
||||
if (!$ad->getAid()) {
|
||||
$options["user_id"] = $this->_user->getId();
|
||||
unset($options["aid"]);
|
||||
if (empty($options["date_created"])) {
|
||||
$options["date_created"] = date("Y-m-d H:i:s");
|
||||
}
|
||||
$sqlOptions = array();
|
||||
foreach ($options AS $name => $value) {
|
||||
if ($value === null) {
|
||||
$value = "NULL";
|
||||
} elseif (is_bool($value)) {
|
||||
$value = (int) $value;
|
||||
} else {
|
||||
$value = "'".$this->_connection->real_escape_string($value)."'";
|
||||
}
|
||||
$sqlOptions[$name] = $value;
|
||||
}
|
||||
$this->_connection->query("INSERT INTO ".$this->_table.
|
||||
" (`".implode("`, `", array_keys($options)).
|
||||
"`) VALUES (".implode(", ", $sqlOptions).")");
|
||||
if ($this->_connection->error) {
|
||||
var_dump($this->_connection->error);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sqlOptions = array();
|
||||
unset($options["aid"]);
|
||||
foreach ($options AS $name => $value) {
|
||||
if ($value === null) {
|
||||
$value = "NULL";
|
||||
} elseif (is_bool($value)) {
|
||||
$value = (int) $value;
|
||||
} else {
|
||||
$value = "'".$this->_connection->real_escape_string($value)."'";
|
||||
}
|
||||
$sqlOptions[] = "`".$name."` = ".$value;
|
||||
}
|
||||
$this->_connection->query("UPDATE ".$this->_table." SET
|
||||
".implode(",", $sqlOptions).
|
||||
" WHERE `aid` = ".$ad->getAid());
|
||||
if ($this->_connection->error) {
|
||||
var_dump($this->_connection->error);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function delete(AdItem $ad)
|
||||
{
|
||||
$this->_connection->query("DELETE FROM ".$this->_table."
|
||||
WHERE `aid` = ".$ad->getAid());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \mysqli $dbConnection
|
||||
* @return \App\Storage\Db\Ad
|
||||
*/
|
||||
public function setDbConnection($dbConnection)
|
||||
{
|
||||
$this->_connection = $dbConnection;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \mysqli
|
||||
*/
|
||||
public function getDbConnection()
|
||||
{
|
||||
return $this->_connection;
|
||||
}
|
||||
}
|
@ -24,13 +24,9 @@ class User implements \App\Storage\User
|
||||
$user = new \App\User\User();
|
||||
$user->setId($userDb->id)
|
||||
->setPassword($userDb->password)
|
||||
->setUsername($userDb->username);
|
||||
if (!empty($userDb->options)) {
|
||||
$options = json_decode($userDb->options, true);
|
||||
if (is_array($options)) {
|
||||
$user->setOptions($options);
|
||||
}
|
||||
}
|
||||
->setUsername($userDb->username)
|
||||
->setApiKey($userDb->api_key);
|
||||
$this->_loadUserOptions($user, $userDb->options);
|
||||
$users[] = $user;
|
||||
}
|
||||
return $users;
|
||||
@ -47,29 +43,56 @@ class User implements \App\Storage\User
|
||||
$user = new \App\User\User();
|
||||
$user->setId($userDb->id)
|
||||
->setPassword($userDb->password)
|
||||
->setUsername($userDb->username);
|
||||
if (!empty($userDb->options)) {
|
||||
$options = json_decode($userDb->options, true);
|
||||
if (is_array($options)) {
|
||||
$user->setOptions($options);
|
||||
}
|
||||
}
|
||||
->setUsername($userDb->username)
|
||||
->setApiKey($userDb->api_key);
|
||||
$this->_loadUserOptions($user, $userDb->options);
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
protected function _loadUserOptions(\App\User\User $user, $options)
|
||||
{
|
||||
if (empty($options)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$options = json_decode($options, true);
|
||||
if (!is_array($options)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!empty($options["notification"]) && is_array($options["notification"])) {
|
||||
foreach ($options["notification"] AS $key => $params) {
|
||||
if ($params && !isset($params["active"])) {
|
||||
$options["notification"][$key]["active"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$user->setOptions($options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function save(\App\User\User $user)
|
||||
{
|
||||
if (!$api_key = $user->getApiKey()) {
|
||||
$api_key = "NULL";
|
||||
} else {
|
||||
$api_key = "'".$this->_connection->real_escape_string($api_key)."'";
|
||||
}
|
||||
if (!$this->fetchByUsername($user->getUsername())) {
|
||||
$this->_connection->query("INSERT INTO `".$this->_table.
|
||||
"` (`username`, `password`, `options`) VALUES (
|
||||
"` (`username`, `password`, `api_key`, `options`) VALUES (
|
||||
'".$this->_connection->real_escape_string($user->getUsername())."',
|
||||
'".$this->_connection->real_escape_string($user->getPassword())."',
|
||||
".$api_key.",
|
||||
'".$this->_connection->real_escape_string(json_encode($user->getOptions()))."'
|
||||
)");
|
||||
} else {
|
||||
$this->_connection->query("UPDATE `".$this->_table."` SET
|
||||
`password` = '".$this->_connection->real_escape_string($user->getPassword())."',
|
||||
`api_key` = ".$api_key.",
|
||||
`options` = '".$this->_connection->real_escape_string(json_encode($user->getOptions()))."'
|
||||
WHERE id = ".$user->getId());
|
||||
}
|
||||
|
205
sources/app/models/Storage/File/Ad.php
Normal file
205
sources/app/models/Storage/File/Ad.php
Normal file
@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace App\Storage\File;
|
||||
|
||||
use App\Ad\Ad as AdItem;
|
||||
|
||||
class Ad implements \App\Storage\Ad
|
||||
{
|
||||
protected $_filename;
|
||||
|
||||
public function __construct($filename)
|
||||
{
|
||||
$this->_filename = $filename;
|
||||
$this->_checkFile();
|
||||
}
|
||||
|
||||
public function fetchAll($order = null)
|
||||
{
|
||||
$ads = array();
|
||||
if (is_file($this->_filename)) {
|
||||
$fopen = fopen($this->_filename, "r");
|
||||
if ($header = fgetcsv($fopen, 0, ",", '"')) {
|
||||
$nb_columns = count($header);
|
||||
while (false !== $values = fgetcsv($fopen, 0, ",", '"')) {
|
||||
$ad = new AdItem();
|
||||
$options = array_combine(
|
||||
$header,
|
||||
array_slice($values, 0, count($header))
|
||||
);
|
||||
if (!empty($options["photos"])) {
|
||||
$options["photos"] = json_decode($options["photos"], true);
|
||||
}
|
||||
if (!empty($options["properties"])) {
|
||||
$options["properties"] = json_decode($options["properties"], true);
|
||||
}
|
||||
$ad->setFromArray($options);
|
||||
$ads[$ad->getId()] = $ad;
|
||||
}
|
||||
}
|
||||
fclose($fopen);
|
||||
}
|
||||
|
||||
if (null !== $order) {
|
||||
|
||||
if (is_array($order)) {
|
||||
$order = array_shift($order);
|
||||
}
|
||||
if (is_string($order) && preg_match("#(?<sort>.+)\s+(?<order>asc|desc)#i", $order, $m)) {
|
||||
$sort = $m["sort"];
|
||||
$order = strtolower($m["order"]);
|
||||
$method = "get".str_replace(" ", "", ucwords(str_replace("_", " ", $sort)));
|
||||
if (!method_exists(new \App\Ad\Ad(), $method)) {
|
||||
unset($sort, $order, $method);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($sort)) {
|
||||
setlocale(LC_CTYPE, "fr_FR.UTF-8");
|
||||
usort($ads, function ($ad1, $ad2) use ($sort, $method) {
|
||||
$param1 = mb_strtolower($ad1->$method());
|
||||
$param2 = mb_strtolower($ad2->$method());
|
||||
if ($sort == "title" && function_exists("iconv")) {
|
||||
$param1 = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $param1);
|
||||
$param2 = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $param2);
|
||||
}
|
||||
if ($param1 < $param2) {
|
||||
return -1;
|
||||
}
|
||||
if ($param1 > $param2) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
if ($order == "desc") {
|
||||
$ads = array_reverse($ads);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ads;
|
||||
}
|
||||
|
||||
public function fetchById($id)
|
||||
{
|
||||
$ad = null;
|
||||
if (is_file($this->_filename)) {
|
||||
$fopen = fopen($this->_filename, "r");
|
||||
if ($header = fgetcsv($fopen, 0, ",", '"')) {
|
||||
while (false !== $values = fgetcsv($fopen, 0, ",", '"')) {
|
||||
$options = array_combine(
|
||||
$header,
|
||||
array_slice($values, 0, count($header))
|
||||
);
|
||||
if ($options["id"] == $id) {
|
||||
$ad = new AdItem();
|
||||
if (!empty($options["photos"])) {
|
||||
$options["photos"] = json_decode($options["photos"], true);
|
||||
}
|
||||
if (!empty($options["properties"])) {
|
||||
$options["properties"] = json_decode($options["properties"], true);
|
||||
}
|
||||
$ad->setFromArray($options);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($fopen);
|
||||
}
|
||||
return $ad;
|
||||
}
|
||||
|
||||
public function save(AdItem $ad)
|
||||
{
|
||||
$ads = $this->fetchAll();
|
||||
|
||||
$fopen = fopen($this->_filename, "a");
|
||||
flock($fopen, LOCK_EX);
|
||||
$fpNewFile = fopen($this->_filename.".new", "w");
|
||||
flock($fpNewFile, LOCK_EX);
|
||||
|
||||
// Entête du fichier CSV
|
||||
$headers = array_keys($ad->toArray());
|
||||
fputcsv($fpNewFile, $headers, ",", '"');
|
||||
|
||||
$updated = false;
|
||||
foreach ($ads AS $a) {
|
||||
if ($a->getId() == $ad->getId()) {
|
||||
$a = $ad;
|
||||
$updated = true;
|
||||
}
|
||||
$data = $a->toArray();
|
||||
$data["photos"] = json_encode($data["photos"]);
|
||||
$data["properties"] = json_encode($data["properties"]);
|
||||
if (empty($data["date_created"])) {
|
||||
$data["date_created"] = date("Y-m-d H:i:s");
|
||||
}
|
||||
fputcsv($fpNewFile, $data, ",", '"');
|
||||
}
|
||||
if (!$updated) {
|
||||
$data = $ad->toArray();
|
||||
$data["photos"] = json_encode($data["photos"]);
|
||||
$data["properties"] = json_encode($data["properties"]);
|
||||
if (empty($data["date_created"])) {
|
||||
$data["date_created"] = date("Y-m-d H:i:s");
|
||||
}
|
||||
fputcsv($fpNewFile, $data, ",", '"');
|
||||
}
|
||||
|
||||
fclose($fpNewFile);
|
||||
fclose($fopen);
|
||||
file_put_contents($this->_filename, file_get_contents($this->_filename.".new"));
|
||||
unlink($this->_filename.".new");
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function delete(AdItem $ad)
|
||||
{
|
||||
$ads = $this->fetchAll();
|
||||
$fopen = fopen($this->_filename, "a");
|
||||
flock($fopen, LOCK_EX);
|
||||
$fpNewFile = fopen($this->_filename.".new", "w");
|
||||
flock($fpNewFile, LOCK_EX);
|
||||
|
||||
// Entête du fichier CSV
|
||||
$headers = array_keys($ad->toArray());
|
||||
fputcsv($fpNewFile, $headers, ",", '"');
|
||||
|
||||
unset($ads[$ad->getId()]);
|
||||
foreach ($ads AS $a) {
|
||||
$data = $a->toArray();
|
||||
$data["photos"] = json_encode($data["photos"]);
|
||||
$data["properties"] = json_encode($data["properties"]);
|
||||
fputcsv($fpNewFile, $data, ",", '"');
|
||||
}
|
||||
|
||||
fclose($fpNewFile);
|
||||
fclose($fopen);
|
||||
file_put_contents($this->_filename, file_get_contents($this->_filename.".new"));
|
||||
unlink($this->_filename.".new");
|
||||
|
||||
// Si aucune annonce trouvée, on supprime le fichier CSV
|
||||
$ads = $this->fetchAll();
|
||||
if (0 == count($ads) && is_file($this->_filename)) {
|
||||
unlink($this->_filename);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _checkFile()
|
||||
{
|
||||
if (empty($this->_filename)) {
|
||||
throw new \Exception("Un fichier doit être spécifié.");
|
||||
}
|
||||
$dir = dirname($this->_filename);
|
||||
if (!is_file($this->_filename)) {
|
||||
if (!is_writable($dir)) {
|
||||
throw new \Exception("Pas d'accès en écriture sur le répertoire '".$dir."'.");
|
||||
}
|
||||
} elseif (!is_writable($this->_filename)) {
|
||||
throw new \Exception("Pas d'accès en écriture sur le fichier '".$this->_filename."'.");
|
||||
}
|
||||
}
|
||||
}
|
@ -29,7 +29,9 @@ class Alert implements \App\Storage\Alert
|
||||
"send_sms_ovh",
|
||||
"send_pushbullet",
|
||||
"send_notifymyandroid",
|
||||
"send_pushover"
|
||||
"send_pushover",
|
||||
"send_joaoappsjoin",
|
||||
"send_slack",
|
||||
);
|
||||
|
||||
public function __construct($filename)
|
||||
|
@ -115,7 +115,18 @@ class User implements \App\Storage\User
|
||||
$filename = $dir.DS."user_".$user->getUsername().".json";
|
||||
if (is_file($filename)) {
|
||||
$data = json_decode(trim(file_get_contents($filename)), true);
|
||||
if (isset($data["api_key"])) {
|
||||
$user->setApiKey($data["api_key"]);
|
||||
unset($data["api_key"]);
|
||||
}
|
||||
if ($data && is_array($data)) {
|
||||
if (!empty($data["notification"]) && is_array($data["notification"])) {
|
||||
foreach ($data["notification"] AS $key => $params) {
|
||||
if ($params && !isset($params["active"])) {
|
||||
$data["notification"][$key]["active"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$user->setOptions($data);
|
||||
}
|
||||
}
|
||||
@ -129,7 +140,11 @@ class User implements \App\Storage\User
|
||||
mkdir($dir);
|
||||
}
|
||||
$filename = $dir.DS."user_".$user->getUsername().".json";
|
||||
file_put_contents($filename, json_encode($user->getOptions()));
|
||||
$data = $user->getOptions();
|
||||
if ($api_key = $user->getApiKey()) {
|
||||
$data["api_key"] = $api_key;
|
||||
}
|
||||
file_put_contents($filename, json_encode($data));
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ class User
|
||||
protected $_id;
|
||||
protected $_username;
|
||||
protected $_password;
|
||||
protected $_api_key;
|
||||
protected $_options = array();
|
||||
protected $_optionsLoaded = false;
|
||||
|
||||
@ -21,6 +22,9 @@ class User
|
||||
if (isset($options["password"])) {
|
||||
$this->setPassword($options["password"]);
|
||||
}
|
||||
if (isset($options["api_key"])) {
|
||||
$this->setApiKey($options["api_key"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,6 +66,24 @@ class User
|
||||
return $this->_username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return User
|
||||
*/
|
||||
public function setApiKey($key)
|
||||
{
|
||||
$this->_api_key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getApiKey()
|
||||
{
|
||||
return $this->_api_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
* @return User
|
||||
@ -81,48 +103,58 @@ class User
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne vrai si la notification SMS Free Mobile est activée.
|
||||
* Indique si au moins un service de notification est activé.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasSMSFreeMobile()
|
||||
public function hasNotification()
|
||||
{
|
||||
return false != $this->getOption("notification.freeMobile");
|
||||
$notifications = $this->getOption("notification");
|
||||
if (!$notifications || !is_array($notifications)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($notifications AS $name => $params) {
|
||||
if (is_array($params) && !empty($params["active"])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne vrai si la notification SMS OVH est activée.
|
||||
* @return boolean
|
||||
* Retourne les systèmes d'alerte activés.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function hasSMSOvh()
|
||||
public function getNotificationsEnabled()
|
||||
{
|
||||
return false != $this->getOption("notification.ovh");
|
||||
$notifications = $this->getOption("notification");
|
||||
if (!$notifications || !is_array($notifications)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$notifications_enabled = array();
|
||||
foreach ($notifications AS $name => $params) {
|
||||
if (is_array($params) && !empty($params["active"])) {
|
||||
$notifications_enabled[$name] = $params;
|
||||
}
|
||||
}
|
||||
|
||||
return $notifications_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne vrai si la notification Pushbullet est activée.
|
||||
* Indique si un système d'alerte est actif ou non.
|
||||
*
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasPushbullet()
|
||||
public function notificationEnabled($name)
|
||||
{
|
||||
return false != $this->getOption("notification.pushbullet");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne vrai si la notification NotifyMyAndroid est activée.
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasNotifyMyAndroid()
|
||||
{
|
||||
return false != $this->getOption("notification.notifymyandroid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne vrai si la notification Pushover est activée.
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasPushover()
|
||||
{
|
||||
return false != $this->getOption("notification.pushover");
|
||||
$params = $this->getOption("notification.".$name);
|
||||
return is_array($params) && !empty($params["active"]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,10 @@ $values = array(
|
||||
|
||||
$categoryCollection = new \Lbc\CategoryCollection();
|
||||
|
||||
if (isset($_GET["preurl"])) {
|
||||
$values["url"] = $_GET["preurl"];
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
foreach ($_POST AS $name => $value) {
|
||||
if (is_array($value)) {
|
||||
|
@ -5,7 +5,6 @@ if (!isset($_GET["url"])) {
|
||||
}
|
||||
|
||||
$disableLayout = true;
|
||||
$logFile = DOCUMENT_ROOT."/var/logs/rss.log";
|
||||
|
||||
use \FeedWriter\RSS2;
|
||||
|
||||
@ -35,7 +34,7 @@ $logger = Logger::getLogger("main");
|
||||
|
||||
$id = sha1($_SERVER["REQUEST_URI"]);
|
||||
$cache_filename = DOCUMENT_ROOT."/var/feeds/".$id.".xml";
|
||||
if (is_file($cache_filename)) {
|
||||
if ("development" != APPLICATION_ENV && is_file($cache_filename)) {
|
||||
readfile($cache_filename);
|
||||
return;
|
||||
}
|
||||
@ -49,6 +48,7 @@ $content = $client->request($_GET["url"]);
|
||||
|
||||
$filter = new \AdService\Filter($params);
|
||||
$siteConfig = \AdService\SiteConfigFactory::factory($_GET["url"]);
|
||||
$baseurl = $config->get("general", "baseurl", "");
|
||||
|
||||
$ads = $parser->process(
|
||||
$content,
|
||||
|
@ -3,6 +3,10 @@ ob_start();
|
||||
?>
|
||||
<?php if ($ad->getDate()) : ?>
|
||||
Publié le <strong><?php echo date("d/m/Y H:i", $ad->getDate()); ?></strong>
|
||||
<?php if (!empty($baseurl) && isset($siteConfig) && $siteConfig->getOption("allow_backup")) : ?>
|
||||
- <a href="<?php echo $baseurl; ?>?mod=annonce&a=backup&aurl=<?php echo $ad->getLink(); ?>"
|
||||
target="_blank">SAUVEGARDER L'ANNONCE</a>
|
||||
<?php endif; ?>
|
||||
<br />
|
||||
<br />
|
||||
<?php endif; ?>
|
||||
@ -37,7 +41,7 @@ Publié le <strong><?php echo date("d/m/Y H:i", $ad->getDate()); ?></strong>
|
||||
|
||||
<?php if ($ad->getThumbnailLink()) : ?>
|
||||
<br /><img src="<?php echo str_replace('/thumbs/', '/images/', $ad->getThumbnailLink()); ?>"
|
||||
alt="" style="max-width: 600px; float: left; display: block;" />
|
||||
alt="" style="max-width: 600px; max-height: 600px; float: left; display: block;" />
|
||||
<?php else : ?>
|
||||
<br />Pas de photo disponible.
|
||||
<?php endif; ?>
|
||||
|
33
sources/app/user/scripts/settings-disable-notification.php
Normal file
33
sources/app/user/scripts/settings-disable-notification.php
Normal 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;
|
66
sources/app/user/scripts/settings-freemobile.php
Normal file
66
sources/app/user/scripts/settings-freemobile.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
67
sources/app/user/scripts/settings-joaoappsjoin.php
Normal file
67
sources/app/user/scripts/settings-joaoappsjoin.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
67
sources/app/user/scripts/settings-notifymyandroid.php
Normal file
67
sources/app/user/scripts/settings-notifymyandroid.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
73
sources/app/user/scripts/settings-ovh.php
Normal file
73
sources/app/user/scripts/settings-ovh.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
65
sources/app/user/scripts/settings-pushbullet.php
Normal file
65
sources/app/user/scripts/settings-pushbullet.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
67
sources/app/user/scripts/settings-pushover.php
Normal file
67
sources/app/user/scripts/settings-pushover.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
65
sources/app/user/scripts/settings-slack.php
Normal file
65
sources/app/user/scripts/settings-slack.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"];
|
||||
|
50
sources/app/user/views/settings-freemobile.phtml
Normal file
50
sources/app/user/views/settings-freemobile.phtml
Normal 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:
|
||||
« La notification SMS est fonctionnelle ».<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>
|
50
sources/app/user/views/settings-joaoappsjoin.phtml
Normal file
50
sources/app/user/views/settings-joaoappsjoin.phtml
Normal 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:
|
||||
« La notification Joaoapps / Join est fonctionnelle ».<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>
|
39
sources/app/user/views/settings-notifymyandroid.phtml
Normal file
39
sources/app/user/views/settings-notifymyandroid.phtml
Normal 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:
|
||||
« La notification NotifyMyAndroid est fonctionnelle ».<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>
|
83
sources/app/user/views/settings-ovh.phtml
Normal file
83
sources/app/user/views/settings-ovh.phtml
Normal 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:
|
||||
« La notification SMS est fonctionnelle ».<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>
|
39
sources/app/user/views/settings-pushbullet.phtml
Normal file
39
sources/app/user/views/settings-pushbullet.phtml
Normal 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:
|
||||
« La notification Pushbullet est fonctionnelle ».<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>
|
50
sources/app/user/views/settings-pushover.phtml
Normal file
50
sources/app/user/views/settings-pushover.phtml
Normal 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:
|
||||
« La notification Pushover est fonctionnelle ».<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>
|
39
sources/app/user/views/settings-slack.phtml
Normal file
39
sources/app/user/views/settings-slack.phtml
Normal 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:
|
||||
« La notification Slack est fonctionnelle ».<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>
|
@ -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"> </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&a=settings-<?php echo $name; ?>">Configurer</a> |
|
||||
<a href="?mod=user&a=settings-disable-notification&s=<?php echo $name; ?>">Désactiver</a>
|
||||
<?php else: ?>
|
||||
<a href="?mod=user&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&a=settings">annuler les modifications</a></p>
|
||||
</form>
|
||||
<p><input type="submit" value="Enregistrer" /></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user