diff --git a/.gitignore b/.gitignore index 422241c..4df4448 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ config/config.php -config/conf.php .idea /public/uploads /tmp vendor composer.json composer.lock +/src/Framework/SwiftMailerFactory.php \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3d8a652 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Plateforme événementielle de mise en relation des Ḡmarchés. + +## Site en construction +### TODO: README diff --git a/config.php b/config.php deleted file mode 100644 index 212f5fc..0000000 --- a/config.php +++ /dev/null @@ -1,4 +0,0 @@ - '/news' -]; \ No newline at end of file diff --git a/config/apply.php b/config/apply.php new file mode 100644 index 0000000..80827d1 --- /dev/null +++ b/config/apply.php @@ -0,0 +1,53 @@ + \DI\env('ENV', 'production'), + 'database.host' => "$db_server", + 'database.username' => "$db_username", + 'database.password' => "$db_password", + 'database.name' => "$db_name", + 'views.path' => dirname(__DIR__) . '/views', + 'twig.extensions' => [ + \DI\get(RouterTwigExtension::class), + \DI\get(PagerFantaExtension::class), + \DI\get(TextExtension::class), + \DI\get(TimeExtension::class), + \DI\get(FlashExtension::class), + \DI\get(FormExtension::class), + \DI\get(CsrfExtension::class), + \DI\get(UrlExtension::class) + ], + SessionInterface::class => \DI\object(PHPSession::class), + CsrfMiddleware::class => \DI\object()->constructor(\DI\get(SessionInterface::class)), + Router::class => \DI\factory(RouterFactory::class), + RendererInterface::class => \DI\factory(TwigRendererFactory::class), + \PDO::class => function (\Psr\Container\ContainerInterface $c) { + return new PDO( + 'mysql:host='. $c->get('database.host') . ';dbname=' . $c->get('database.name'), + $c->get('database.username'), + $c->get('database.password'), + [ + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION + ] + ); + }, + // MAILER + 'mail.to' => 'admin@gmarche-testmail.com', + 'mail.from' => '$mail_from', + Swift_Mailer::class => \DI\factory(\Framework\SwiftMailerFactory::class) +]; diff --git a/config/conf-sample.php b/config/conf-sample.php deleted file mode 100644 index d322285..0000000 --- a/config/conf-sample.php +++ /dev/null @@ -1,5 +0,0 @@ - \DI\env('ENV', 'production'), - 'database.host' => '', - 'database.username' => '', - 'database.password' => '', - 'database.name' => '', - 'views.path' => dirname(__DIR__) . '/views', - 'twig.extensions' => [ - \DI\get(RouterTwigExtension::class), - \DI\get(PagerFantaExtension::class), - \DI\get(TextExtension::class), - \DI\get(TimeExtension::class), - \DI\get(FlashExtension::class), - \DI\get(FormExtension::class), - \DI\get(CsrfExtension::class), - \DI\get(UrlExtension::class) - ], - SessionInterface::class => \DI\object(PHPSession::class), - CsrfMiddleware::class => \DI\object()->constructor(\DI\get(SessionInterface::class)), - Router::class => \DI\factory(RouterFactory::class), - RendererInterface::class => \DI\factory(TwigRendererFactory::class), - \PDO::class => function (\Psr\Container\ContainerInterface $c) { - return new PDO( - 'mysql:host='. $c->get('database.host') . ';dbname=' . $c->get('database.name'), - $c->get('database.username'), - $c->get('database.password'), - [ - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION - ] - ); - }, - // MAILER - 'mail.to' => 'admin@gmarche-testmail.com', - 'mail.from' => 'no-reply@admin.fr', - Swift_Mailer::class => \DI\factory(\Framework\SwiftMailerFactory::class) -]; + $db_server = ''; + $db_username = ''; + $db_password = ''; + $db_name = ''; + $mail_from = ''; + $g1_node = 'https://duniter-g1.p2p.legal'; diff --git a/public/index.php b/public/index.php index 933cb55..8c8159b 100644 --- a/public/index.php +++ b/public/index.php @@ -24,8 +24,7 @@ require 'vendor/autoload.php'; $chemin = $_SERVER['DOCUMENT_ROOT']; $chemin_new = substr($chemin,0,-6); -$app = (new \Framework\App( $chemin_new .'/config/config.php')) -//$app = (new \Framework\App( '../config/config.php')) +$app = (new \Framework\App( $chemin_new .'config/apply.php')) ->addModule(AdminModule::class) ->addModule(ContactModule::class) ->addModule(ProductModule::class) diff --git a/public/js/connex.js b/public/js/connex.js index 85fca62..bd7bc43 100644 --- a/public/js/connex.js +++ b/public/js/connex.js @@ -1,6 +1,5 @@ -function connexion(nom_connecte, mdp) { - - $.post("/ajax/connexion.php", { +function connexion(nom_connecte, mdp, chemin) { + $.post('/models/connexion.php', { nom_connecte: nom_connecte, mdp: mdp }, function (data, status) { diff --git a/public/js/script.js b/public/js/script.js index fe77086..1f18d02 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -9,7 +9,7 @@ function addRecord(antenne_slug, antenne_id, nom_connecte, id_user) { var quantite = $("#quantite").val(); var prix = $("#prix").val(); // Add record - $.post("/ajax/addRecord.php", { + $.post("/models/addRecord.php", { produit: produit, image: nom_image, vendeur: vendeur, @@ -46,7 +46,7 @@ function addRecord2(antenne_slug, antenne_id, nom_connecte, id_user) { var quantite = $("#quantite").val(); var prix = $("#prix").val(); // Add record - $.post("/ajax/addRecord2.php", { + $.post("/models/addRecord2.php", { produit: produit, image: nom_image, acheteur: acheteur, @@ -75,7 +75,7 @@ function addRecord2(antenne_slug, antenne_id, nom_connecte, id_user) { // READ records function readRecords(antenne_slug, nom_connecte) { - $.get("/ajax/readRecords.php", { + $.get("/models/readRecords.php", { antenne_slug: antenne_slug, nom_connecte: nom_connecte }, function (data, status) { @@ -84,7 +84,7 @@ function readRecords(antenne_slug, nom_connecte) { } // READ records2 function readRecords2(antenne_slug, nom_connecte) { - $.get("/ajax/readRecords2.php", { + $.get("/models/readRecords2.php", { antenne_slug: antenne_slug, nom_connecte: nom_connecte }, function (data, status) { @@ -96,7 +96,7 @@ function DeleteProduits(id, antenne_slug, nom_image) { $("#hidden_antenne_slug").val(antenne_slug); var conf = confirm("Etes-vous sûr(e) de vouloir supprimer ce bien ou service ?"); if (conf == true) { - $.post("/ajax/deleteProduits.php", { + $.post("/models/deleteProduits.php", { id: id, antenne_slug: antenne_slug, nom_image: nom_image @@ -114,7 +114,7 @@ function DeleteRecherches(id, antenne_slug, nom_image) { $("#hidden_antenne_slug_r").val(antenne_slug); var conf = confirm("Etes-vous sûr(e) de vouloir supprimer ce bien ou service ?"); if (conf == true) { - $.post("/ajax/deleteRecherches.php", { + $.post("/models/deleteRecherches.php", { id_r: id, antenne_slug: antenne_slug, nom_image: nom_image @@ -132,7 +132,7 @@ function GetProduitsDetails(id, antenne_slug, nom_image) { $("#hidden_user_id").val(id); $("#hidden_antenne_slug").val(antenne_slug); $("#hidden_image_name").val(nom_image); - $.post("/ajax/readProduitsDetails.php", { + $.post("/models/readProduitsDetails.php", { id: id }, function (data, status) { @@ -153,7 +153,7 @@ function GetRecherchesDetails(id, antenne_slug, nom_image) { $("#hidden_user_id_r").val(id); $("#hidden_antenne_slug_r").val(antenne_slug); $("#hidden_image_name_r").val(nom_image); - $.post("/ajax/readRecherchesDetails.php", { + $.post("/models/readRecherchesDetails.php", { id_r: id }, function (data, status) { @@ -180,7 +180,7 @@ function UpdateProduitsDetails(nom_connecte) { // Champs cachés var id = $("#hidden_user_id").val(); var antenne_slug = $("#hidden_antenne_slug").val(); - $.post("/ajax/updateProduitsDetails.php", { + $.post("/models/updateProduitsDetails.php", { id: id, produit: produit, image: nom_image, @@ -208,7 +208,7 @@ function UpdateRecherchesDetails(nom_connecte) { var id = $("#hidden_user_id_r").val(); var antenne_slug = $("#hidden_antenne_slug_r").val(); // Update the details by requesting to the server using ajax - $.post("/ajax/updateRecherchesDetails.php", { + $.post("/models/updateRecherchesDetails.php", { id: id, produit: produit, image: nom_image, @@ -229,8 +229,8 @@ function UpdateRecherchesDetails(nom_connecte) { $(document).ready(function () { // On récupère le nom de l'antenne dans l'url pour afficher les biens/services de celle-ci var url = document.location.href; - var antenne_slug = url.split('/')[5]; - var affichage_slug = url.split('/')[6]; + var antenne_slug = url.split('/')[4]; + var affichage_slug = url.split('/')[5]; var nom_connecte = $("#nom_connecte").text(); if (affichage_slug == 'produits') { @@ -252,7 +252,7 @@ $(document).ready(function () { // requête AJAX pour copier la photo et l'afficher $.ajax({ - url: '/ajax/upload.php', + url: '/models/upload.php', type: 'post', data: fd_add, contentType: false, @@ -283,7 +283,7 @@ $(document).ready(function () { fd.append('source',source); // requête AJAX pour copier la photo et l'afficher $.ajax({ - url: '/ajax/upload.php', + url: '/models/upload.php', type: 'post', data: fd, contentType: false, diff --git a/public/ajax/addRecord.php b/public/models/addRecord.php similarity index 89% rename from public/ajax/addRecord.php rename to public/models/addRecord.php index 34883c8..6c81824 100644 --- a/public/ajax/addRecord.php +++ b/public/models/addRecord.php @@ -3,8 +3,8 @@ ini_set('display_errors', 0); if ($_POST['produit']!== '' && $_POST['vendeur']!== null && $_POST['quantite']>0 && $_POST['prix']>=0) { // Connexion à la base de données - include '../../config/conf.php'; - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + include '../../config/config.php'; + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); // Récupération des informations du formulaire $params = array(); diff --git a/public/ajax/addRecord2.php b/public/models/addRecord2.php similarity index 87% rename from public/ajax/addRecord2.php rename to public/models/addRecord2.php index a4a107d..1101410 100644 --- a/public/ajax/addRecord2.php +++ b/public/models/addRecord2.php @@ -3,8 +3,8 @@ if(isset($_POST['produit']) && isset($_POST['acheteur']) && isset($_POST['quantite']) ) { // Connexion à la base de données - include '../../config/conf.php'; - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + include '../../config/config.php'; + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); // Récupération des informations du formulaire $params = array(); diff --git a/public/ajax/connexion.php b/public/models/connexion.php similarity index 87% rename from public/ajax/connexion.php rename to public/models/connexion.php index 075bfc7..951db35 100644 --- a/public/ajax/connexion.php +++ b/public/models/connexion.php @@ -1,10 +1,10 @@ @@ -67,7 +68,7 @@ $data .= ''.$cle_pub_format.''; $data .= ''.$row['quantite'].''; $data .= ''.$prix.''; - if ($row['username'] == $_GET['nom_connecte'] ) { + if ($row['username'] == $nom_connecte ) { $data .= ''; $data .= ' + onclick="connexion(document.getElementById('pseudo').value,document.getElementById('mdp').value)">Valider