From 58ffd500e6ee85018e23567f666a1b1b09a2a52d Mon Sep 17 00:00:00 2001
From: Jimmy Monin
Date: Sat, 26 Nov 2016 19:19:16 +0100
Subject: [PATCH] Upgrade LBCAlerte to version 3.3 Add upgrade script
---
README.md | 2 +-
scripts/install | 3 +-
scripts/upgrade | 45 +
sources/CHANGELOG.txt | 18 +
sources/api.php | 60 +
sources/app/admin/scripts/storage.php | 2 +
sources/app/admin/views/layout.phtml | 3 +-
sources/app/annonce/init.php | 9 +
sources/app/annonce/scripts/backup.php | 40 +
sources/app/annonce/scripts/form-comment.php | 27 +
sources/app/annonce/scripts/form-delete.php | 17 +
sources/app/annonce/scripts/form.php | 46 +
sources/app/annonce/scripts/index.php | 28 +
sources/app/annonce/scripts/view.php | 18 +
sources/app/annonce/views/backup.phtml | 20 +
sources/app/annonce/views/form-comment.phtml | 17 +
sources/app/annonce/views/form-delete.phtml | 15 +
sources/app/annonce/views/form.phtml | 28 +
sources/app/annonce/views/index.phtml | 103 +
sources/app/annonce/views/view.phtml | 95 +
sources/app/api/annonce/create.php | 44 +
sources/app/api/annonce/delete.php | 16 +
sources/app/api/annonce/index.php | 24 +
sources/app/data/notifications.php | 75 +
sources/app/default/scripts/login.php | 2 +-
sources/app/default/views/layout.phtml | 10 +-
sources/app/install/scripts/index.php | 12 +
sources/app/install/views/index.phtml | 24 +-
sources/app/mail/init.php | 4 +-
sources/app/mail/scripts/check.php | 159 +-
sources/app/mail/scripts/form.php | 18 +-
sources/app/mail/scripts/index.php | 17 -
sources/app/mail/scripts/toggle_status.php | 23 +-
sources/app/mail/views/form.phtml | 65 +-
sources/app/mail/views/index.phtml | 83 +-
sources/app/mail/views/mail-ad.phtml | 6 +-
sources/app/models/Ad/Ad.php | 75 +
sources/app/models/Mail/Alert.php | 6 +-
sources/app/models/Storage/Ad.php | 16 +
sources/app/models/Storage/AdPhoto.php | 57 +
sources/app/models/Storage/Db/Ad.php | 154 ++
sources/app/models/Storage/Db/User.php | 53 +-
sources/app/models/Storage/File/Ad.php | 205 ++
sources/app/models/Storage/File/Alert.php | 4 +-
sources/app/models/Storage/File/User.php | 17 +-
sources/app/models/User/User.php | 88 +-
sources/app/rss/scripts/index.php | 4 +
sources/app/rss/scripts/refresh.php | 4 +-
sources/app/rss/views/rss-ad.phtml | 6 +-
.../scripts/settings-disable-notification.php | 33 +
.../app/user/scripts/settings-freemobile.php | 66 +
.../user/scripts/settings-joaoappsjoin.php | 67 +
.../user/scripts/settings-notifymyandroid.php | 67 +
sources/app/user/scripts/settings-ovh.php | 73 +
.../app/user/scripts/settings-pushbullet.php | 65 +
.../app/user/scripts/settings-pushover.php | 67 +
sources/app/user/scripts/settings-slack.php | 65 +
sources/app/user/scripts/settings.php | 145 +-
.../app/user/views/settings-freemobile.phtml | 50 +
.../user/views/settings-joaoappsjoin.phtml | 50 +
.../user/views/settings-notifymyandroid.phtml | 39 +
sources/app/user/views/settings-ovh.phtml | 83 +
.../app/user/views/settings-pushbullet.phtml | 39 +
.../app/user/views/settings-pushover.phtml | 50 +
sources/app/user/views/settings-slack.phtml | 39 +
sources/app/user/views/settings.phtml | 369 +--
sources/bootstrap.php | 105 +-
sources/lib/AdService/Ad.php | 139 +-
.../lib/AdService/Parser/AbstractParser.php | 11 +
sources/lib/AdService/Parser/Lbc.php | 169 +-
.../SiteConfig/AbstractSiteConfig.php | 6 +
sources/lib/AdService/SiteConfig/Lbc.php | 1 +
sources/lib/Auth/ApiKey.php | 31 +
sources/lib/Http/Client/Curl.php | 6 +
sources/lib/Message/Adapter/Joaoappsjoin.php | 73 +
sources/lib/Message/Adapter/Slack.php | 67 +
sources/lib/Message/AdapterFactory.php | 4 +
sources/others/install/schema.php | 32 +
sources/others/update/3.3.php | 81 +
.../static/font-awesome/css/font-awesome.css | 2199 +++++++++++++++++
.../font-awesome/css/font-awesome.min.css | 4 +
.../static/font-awesome/fonts/FontAwesome.otf | Bin 0 -> 124988 bytes
.../fonts/fontawesome-webfont.eot | Bin 0 -> 76518 bytes
.../fonts/fontawesome-webfont.svg | 685 +++++
.../fonts/fontawesome-webfont.ttf | Bin 0 -> 152796 bytes
.../fonts/fontawesome-webfont.woff | Bin 0 -> 90412 bytes
.../fonts/fontawesome-webfont.woff2 | Bin 0 -> 71896 bytes
sources/static/styles.css | 345 ++-
sources/version.php | 2 +-
89 files changed, 6436 insertions(+), 758 deletions(-)
create mode 100644 scripts/upgrade
create mode 100644 sources/api.php
create mode 100644 sources/app/annonce/init.php
create mode 100644 sources/app/annonce/scripts/backup.php
create mode 100644 sources/app/annonce/scripts/form-comment.php
create mode 100644 sources/app/annonce/scripts/form-delete.php
create mode 100644 sources/app/annonce/scripts/form.php
create mode 100644 sources/app/annonce/scripts/index.php
create mode 100644 sources/app/annonce/scripts/view.php
create mode 100644 sources/app/annonce/views/backup.phtml
create mode 100644 sources/app/annonce/views/form-comment.phtml
create mode 100644 sources/app/annonce/views/form-delete.phtml
create mode 100644 sources/app/annonce/views/form.phtml
create mode 100644 sources/app/annonce/views/index.phtml
create mode 100644 sources/app/annonce/views/view.phtml
create mode 100644 sources/app/api/annonce/create.php
create mode 100644 sources/app/api/annonce/delete.php
create mode 100644 sources/app/api/annonce/index.php
create mode 100644 sources/app/data/notifications.php
create mode 100644 sources/app/models/Ad/Ad.php
create mode 100644 sources/app/models/Storage/Ad.php
create mode 100644 sources/app/models/Storage/AdPhoto.php
create mode 100644 sources/app/models/Storage/Db/Ad.php
create mode 100644 sources/app/models/Storage/File/Ad.php
create mode 100644 sources/app/user/scripts/settings-disable-notification.php
create mode 100644 sources/app/user/scripts/settings-freemobile.php
create mode 100644 sources/app/user/scripts/settings-joaoappsjoin.php
create mode 100644 sources/app/user/scripts/settings-notifymyandroid.php
create mode 100644 sources/app/user/scripts/settings-ovh.php
create mode 100644 sources/app/user/scripts/settings-pushbullet.php
create mode 100644 sources/app/user/scripts/settings-pushover.php
create mode 100644 sources/app/user/scripts/settings-slack.php
create mode 100644 sources/app/user/views/settings-freemobile.phtml
create mode 100644 sources/app/user/views/settings-joaoappsjoin.phtml
create mode 100644 sources/app/user/views/settings-notifymyandroid.phtml
create mode 100644 sources/app/user/views/settings-ovh.phtml
create mode 100644 sources/app/user/views/settings-pushbullet.phtml
create mode 100644 sources/app/user/views/settings-pushover.phtml
create mode 100644 sources/app/user/views/settings-slack.phtml
create mode 100644 sources/lib/Auth/ApiKey.php
create mode 100644 sources/lib/Message/Adapter/Joaoappsjoin.php
create mode 100644 sources/lib/Message/Adapter/Slack.php
create mode 100644 sources/others/update/3.3.php
create mode 100644 sources/static/font-awesome/css/font-awesome.css
create mode 100644 sources/static/font-awesome/css/font-awesome.min.css
create mode 100644 sources/static/font-awesome/fonts/FontAwesome.otf
create mode 100644 sources/static/font-awesome/fonts/fontawesome-webfont.eot
create mode 100644 sources/static/font-awesome/fonts/fontawesome-webfont.svg
create mode 100644 sources/static/font-awesome/fonts/fontawesome-webfont.ttf
create mode 100644 sources/static/font-awesome/fonts/fontawesome-webfont.woff
create mode 100644 sources/static/font-awesome/fonts/fontawesome-webfont.woff2
diff --git a/README.md b/README.md
index 9aa72ae..6517833 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ LBCAlerte for YunoHost
Logiciel pour être alerté de nouvelles annonces par mail, flux RSS et SMS sur Leboncoin et d'autres sites d'annonces.
-**Version incluse:** 3.2
+**Version incluse:** 3.3
## Limitations
diff --git a/scripts/install b/scripts/install
index 73dc086..721c919 100644
--- a/scripts/install
+++ b/scripts/install
@@ -27,8 +27,7 @@ sudo mkdir -p $src_path/var
sudo cp -a ../sources/. $src_path
# Set permissions to app files
-sudo chown -R root: $src_path
-sudo chown -R www-data: $src_path/var
+sudo chown -R www-data: $src_path
# Generate MySQL password and create database
dbuser=$app
diff --git a/scripts/upgrade b/scripts/upgrade
new file mode 100644
index 0000000..c5b621d
--- /dev/null
+++ b/scripts/upgrade
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# Exit on command errors and treat unset variables as an error
+set -eu
+
+# See comments in install script
+app=$YNH_APP_INSTANCE_NAME
+
+# Source YunoHost helpers
+source /usr/share/yunohost/helpers
+
+# Retrieve app settings
+domain=$(ynh_app_setting_get "$app" domain)
+path=$(ynh_app_setting_get "$app" path)
+admin=$(ynh_app_setting_get "$app" admin)
+is_public=$(ynh_app_setting_get "$app" is_public)
+language=$(ynh_app_setting_get "$app" language)
+
+# Remove trailing "/" for next commands
+path=${path%/}
+
+# Copy source files
+src_path=/var/www/$app
+sudo mkdir -p $src_path
+sudo cp -a ../sources/. $src_path
+
+# Set permissions to app files
+# you may need to make some file and/or directory writeable by www-data (nginx user)
+sudo chown -R www-data: $src_path
+
+# Modify Nginx configuration file and copy it to Nginx conf directory
+nginx_conf=../conf/nginx.conf
+sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
+sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
+
+sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
+
+# If app is public, add url to SSOWat conf as skipped_uris
+if [[ $is_public -eq 1 ]]; then
+ # See install script
+ ynh_app_setting_set "$app" unprotected_uris "/"
+fi
+
+# Reload nginx service
+sudo service nginx reload
diff --git a/sources/CHANGELOG.txt b/sources/CHANGELOG.txt
index 434ecd1..7e85789 100644
--- a/sources/CHANGELOG.txt
+++ b/sources/CHANGELOG.txt
@@ -1,4 +1,22 @@
+## Version 3.3
+
+ * ajout: possibilité de sauvegarder les annonces Leboncoin.
+ * ajout: possiblité d'ajouter une note aux annonces sauvegardées.
+ * ajout: possiblité de pré-remplir les champs de création d'alerte et flux RSS.
+ * ajout: test de la disponibilité de mysqli et php-curl à l'installation.
+ * ajout: un début d'API est mis en place.
+ * ajout: notification vers Joaoapps / Join.
+ * ajout: notifications vers Slack.
+ * ajout: possibilité d'enregistrer une ou plusieurs adresses mails par défaut.
+ * amélioration: les erreurs sont mieux gérées.
+ * amélioration: la page des paramètres utilisateur est refondu.
+ * amélioration: optimisation de la gestion des systèmes d'alerte.
+ * correction: encodage des caractères en base de données invalide.
+ * correction: encodage des caractères du contenu Leboncoin invalide.
+ * correction: factorisation du code de la tâche cron.
+ * correction: la réinitialisation des alertes ne fonctionne pas sur une nouvelle installation.
+
## Version 3.2
* correction: si CURLOPT_FOLLOWLOCATION désactivé, suivre manuellement les redirections.
diff --git a/sources/api.php b/sources/api.php
new file mode 100644
index 0000000..35d1a65
--- /dev/null
+++ b/sources/api.php
@@ -0,0 +1,60 @@
+get("storage", "type", "files");
+if ($storageType == "db") {
+ $userStorage = new \App\Storage\Db\User($dbConnection);
+} else {
+ $userStorage = new \App\Storage\File\User(DOCUMENT_ROOT."/var/users.db");
+}
+
+
+// Identification par clé API
+$auth = new Auth\ApiKey($userStorage);
+if (!$userAuthed = $auth->authenticate()) {
+ header("HTTP/1.0 401 Unauthorized");
+ exit;
+}
+
+// Si une action de modification de données est demandée, il faut que ce soit
+// en POST.
+if (in_array($action, array("create", "modify", "delete"))
+ && $_SERVER["REQUEST_METHOD"] != "POST") {
+ header("HTTP/1.0 400 Bad Request");
+ exit;
+}
+
+$init = DOCUMENT_ROOT."/app/".$module."/init.php";
+$script = DOCUMENT_ROOT."/app/api/".$module."/".$action.".php";
+
+if (!is_file($script)) {
+ header("HTTP/1.0 400 Bad Request");
+ exit;
+}
+
+if (is_file($init)) {
+ require $init;
+}
+$data = require $script;
+
+if (empty($data)) {
+ $data = array();
+}
+echo json_encode($data);
diff --git a/sources/app/admin/scripts/storage.php b/sources/app/admin/scripts/storage.php
index 7b25d09..9360a66 100644
--- a/sources/app/admin/scripts/storage.php
+++ b/sources/app/admin/scripts/storage.php
@@ -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");
}
}
}
diff --git a/sources/app/admin/views/layout.phtml b/sources/app/admin/views/layout.phtml
index 45e39cd..459fd9c 100644
--- a/sources/app/admin/views/layout.phtml
+++ b/sources/app/admin/views/layout.phtml
@@ -5,7 +5,8 @@
-
+
+
diff --git a/sources/app/annonce/init.php b/sources/app/annonce/init.php
new file mode 100644
index 0000000..a5dd526
--- /dev/null
+++ b/sources/app/annonce/init.php
@@ -0,0 +1,9 @@
+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);
diff --git a/sources/app/annonce/scripts/backup.php b/sources/app/annonce/scripts/backup.php
new file mode 100644
index 0000000..98e0b1c
--- /dev/null
+++ b/sources/app/annonce/scripts/backup.php
@@ -0,0 +1,40 @@
+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;
\ No newline at end of file
diff --git a/sources/app/annonce/scripts/form-comment.php b/sources/app/annonce/scripts/form-comment.php
new file mode 100644
index 0000000..c90e9fe
--- /dev/null
+++ b/sources/app/annonce/scripts/form-comment.php
@@ -0,0 +1,27 @@
+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) {
+
+}
\ No newline at end of file
diff --git a/sources/app/annonce/scripts/form-delete.php b/sources/app/annonce/scripts/form-delete.php
new file mode 100644
index 0000000..c9676a0
--- /dev/null
+++ b/sources/app/annonce/scripts/form-delete.php
@@ -0,0 +1,17 @@
+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"] : "";
\ No newline at end of file
diff --git a/sources/app/annonce/scripts/form.php b/sources/app/annonce/scripts/form.php
new file mode 100644
index 0000000..58e0aea
--- /dev/null
+++ b/sources/app/annonce/scripts/form.php
@@ -0,0 +1,46 @@
+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;
+ }
+}
\ No newline at end of file
diff --git a/sources/app/annonce/scripts/index.php b/sources/app/annonce/scripts/index.php
new file mode 100644
index 0000000..cffb677
--- /dev/null
+++ b/sources/app/annonce/scripts/index.php
@@ -0,0 +1,28 @@
+fetchAll($sort." ".$order);
+
+
diff --git a/sources/app/annonce/scripts/view.php b/sources/app/annonce/scripts/view.php
new file mode 100644
index 0000000..a858bf5
--- /dev/null
+++ b/sources/app/annonce/scripts/view.php
@@ -0,0 +1,18 @@
+fetchById($_GET["id"]);
+if (!$ad) {
+ header("LOCATION: ./?mod=annonce"); exit;
+}
+
+try {
+ $ad_config = SiteConfigFactory::factory($ad->getLink());
+} catch (Exception $e) {
+
+}
\ No newline at end of file
diff --git a/sources/app/annonce/views/backup.phtml b/sources/app/annonce/views/backup.phtml
new file mode 100644
index 0000000..ee46816
--- /dev/null
+++ b/sources/app/annonce/views/backup.phtml
@@ -0,0 +1,20 @@
+
diff --git a/sources/app/annonce/views/form-comment.phtml b/sources/app/annonce/views/form-comment.phtml
new file mode 100644
index 0000000..3592cc5
--- /dev/null
+++ b/sources/app/annonce/views/form-comment.phtml
@@ -0,0 +1,17 @@
+
+ getTitle()); ?>
+
+
+
+
\ No newline at end of file
diff --git a/sources/app/annonce/views/form-delete.phtml b/sources/app/annonce/views/form-delete.phtml
new file mode 100644
index 0000000..fa4fb82
--- /dev/null
+++ b/sources/app/annonce/views/form-delete.phtml
@@ -0,0 +1,15 @@
+
diff --git a/sources/app/annonce/views/form.phtml b/sources/app/annonce/views/form.phtml
new file mode 100644
index 0000000..ef6a605
--- /dev/null
+++ b/sources/app/annonce/views/form.phtml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sources/app/annonce/views/index.phtml b/sources/app/annonce/views/index.phtml
new file mode 100644
index 0000000..014582e
--- /dev/null
+++ b/sources/app/annonce/views/index.phtml
@@ -0,0 +1,103 @@
+
+
+ 1?"annonces sauvegardées":"annonce sauvegardée"; ?> |
+
+ Sauvegarder une annonce
+
+
+
diff --git a/sources/app/annonce/views/view.phtml b/sources/app/annonce/views/view.phtml
new file mode 100644
index 0000000..f24f285
--- /dev/null
+++ b/sources/app/annonce/views/view.phtml
@@ -0,0 +1,95 @@
+getDate())));
+?>
+
+ < retour à la liste des annonces sauvegardées |
+ supprimer l'annonce
+
+
+
+ getTitle()); ?>
+ ">
+
+
+
+
+ -
+ AuteurgetAuthor(); ?>
+
+ getPrice()) : ?>
+ -
+ PrixgetCurrency());
+ ?>
+
+
+ -
+ Date
+
+ -
+ CatégoriegetCategory()); ?>
+
+ getCity()) : ?>
+ -
+ Ville
+ getZipCode()); ?>
+
+
+
+
+
+ getProperties() AS $name => $value) : ?>
+
+ -
+
+
+
+
+
+
+
+
+
Description
+
getDescription())); ?>
+
+
+
+ getPhotos(); ?>
+
+
diff --git a/sources/app/api/annonce/create.php b/sources/app/api/annonce/create.php
new file mode 100644
index 0000000..d1a5bb4
--- /dev/null
+++ b/sources/app/api/annonce/create.php
@@ -0,0 +1,44 @@
+ $_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();
\ No newline at end of file
diff --git a/sources/app/api/annonce/delete.php b/sources/app/api/annonce/delete.php
new file mode 100644
index 0000000..0e97cc6
--- /dev/null
+++ b/sources/app/api/annonce/delete.php
@@ -0,0 +1,16 @@
+ $_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);
+}
diff --git a/sources/app/api/annonce/index.php b/sources/app/api/annonce/index.php
new file mode 100644
index 0000000..2575eec
--- /dev/null
+++ b/sources/app/api/annonce/index.php
@@ -0,0 +1,24 @@
+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;
\ No newline at end of file
diff --git a/sources/app/data/notifications.php b/sources/app/data/notifications.php
new file mode 100644
index 0000000..1faa32d
--- /dev/null
+++ b/sources/app/data/notifications.php
@@ -0,0 +1,75 @@
+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"]),
+ ),
+);
diff --git a/sources/app/default/scripts/login.php b/sources/app/default/scripts/login.php
index 93be68d..2421ca3 100644
--- a/sources/app/default/scripts/login.php
+++ b/sources/app/default/scripts/login.php
@@ -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"];
diff --git a/sources/app/default/views/layout.phtml b/sources/app/default/views/layout.phtml
index 9b55c1f..089b421 100644
--- a/sources/app/default/views/layout.phtml
+++ b/sources/app/default/views/layout.phtml
@@ -5,7 +5,8 @@
-
+
+
@@ -13,8 +14,9 @@
getComment())); ?>
++ + Ajouter une note + + Modifier la note + +
+