From 24d3336d007c3e6daf5b8c2dd04c29507174f88b Mon Sep 17 00:00:00 2001 From: poka Date: Wed, 20 Nov 2019 21:59:17 +0100 Subject: [PATCH 1/9] Change config var names, fusion config, remove prefix in url routing --- .gitignore | 1 - config.php | 4 ---- config/conf-sample.php | 9 +++++---- config/{config-sample.php => config.php} | 9 +++++---- public/ajax/addRecord.php | 2 +- public/ajax/addRecord2.php | 2 +- public/ajax/connexion.php | 2 +- public/ajax/deleteProduits.php | 2 +- public/ajax/deleteRecherches.php | 2 +- public/ajax/readProduitsDetails.php | 2 +- public/ajax/readRecherchesDetails.php | 2 +- public/ajax/readRecords.php | 2 +- public/ajax/readRecords2.php | 2 +- public/ajax/updateProduitsDetails.php | 2 +- public/ajax/updateRecherchesDetails.php | 2 +- src/Framework/Middleware/TrailingSlashMiddleware.php | 4 ++-- src/Gmarche/config.php | 2 +- 17 files changed, 24 insertions(+), 27 deletions(-) delete mode 100644 config.php rename config/{config-sample.php => config.php} (91%) diff --git a/.gitignore b/.gitignore index 422241c..e77ceac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -config/config.php config/conf.php .idea /public/uploads 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/conf-sample.php b/config/conf-sample.php index d322285..be493eb 100644 --- a/config/conf-sample.php +++ b/config/conf-sample.php @@ -1,5 +1,6 @@ \DI\env('ENV', 'production'), - 'database.host' => '', - 'database.username' => '', - 'database.password' => '', - 'database.name' => '', + '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), diff --git a/public/ajax/addRecord.php b/public/ajax/addRecord.php index 34883c8..35a7060 100644 --- a/public/ajax/addRecord.php +++ b/public/ajax/addRecord.php @@ -4,7 +4,7 @@ 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); + $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/ajax/addRecord2.php index a4a107d..0513b8d 100644 --- a/public/ajax/addRecord2.php +++ b/public/ajax/addRecord2.php @@ -4,7 +4,7 @@ { // Connexion à la base de données include '../../config/conf.php'; - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + $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/ajax/connexion.php index 075bfc7..3595c80 100644 --- a/public/ajax/connexion.php +++ b/public/ajax/connexion.php @@ -4,7 +4,7 @@ include '../../config/conf.php'; try { - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); if (isset($_POST['nom_connecte']) && isset($_POST['mdp']) != "") { $params["username"] = $_POST['nom_connecte']; diff --git a/public/ajax/deleteProduits.php b/public/ajax/deleteProduits.php index 444e62e..80faed5 100644 --- a/public/ajax/deleteProduits.php +++ b/public/ajax/deleteProduits.php @@ -4,7 +4,7 @@ include '../../config/conf.php'; if($_POST['id'] !== null) { // Connexion à la base de données - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); $params['product_id'] = $_POST['id']; $filename = $_POST['nom_image']; diff --git a/public/ajax/deleteRecherches.php b/public/ajax/deleteRecherches.php index 521e9ff..35dd406 100644 --- a/public/ajax/deleteRecherches.php +++ b/public/ajax/deleteRecherches.php @@ -4,7 +4,7 @@ include '../../config/conf.php'; if($_POST['id_r'] !== null) { // Connexion à la base de données - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); $params['souhait_id'] = $_POST['id_r']; $filename = $_POST['nom_image']; diff --git a/public/ajax/readProduitsDetails.php b/public/ajax/readProduitsDetails.php index 76d3b59..c616086 100644 --- a/public/ajax/readProduitsDetails.php +++ b/public/ajax/readProduitsDetails.php @@ -4,7 +4,7 @@ try { - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); if (isset($_POST['id']) && isset($_POST['id']) != "") { $product_id = $_POST['id']; diff --git a/public/ajax/readRecherchesDetails.php b/public/ajax/readRecherchesDetails.php index e5358cf..1f3d931 100644 --- a/public/ajax/readRecherchesDetails.php +++ b/public/ajax/readRecherchesDetails.php @@ -4,7 +4,7 @@ include '../../config/conf.php'; try { - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); if (isset($_POST['id_r']) && isset($_POST['id_r']) != "") { $souhait_id = $_POST['id_r']; diff --git a/public/ajax/readRecords.php b/public/ajax/readRecords.php index 8077419..36b524f 100644 --- a/public/ajax/readRecords.php +++ b/public/ajax/readRecords.php @@ -3,7 +3,7 @@ include '../../config/conf.php'; $antenne_slug = $_GET['antenne_slug']; $nom_connecte = $_GET['nom_connecte']; - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); // Affichage des intitulés de colonnes $data = ' diff --git a/public/ajax/readRecords2.php b/public/ajax/readRecords2.php index e810520..3ea2bda 100644 --- a/public/ajax/readRecords2.php +++ b/public/ajax/readRecords2.php @@ -3,7 +3,7 @@ include '../../config/conf.php'; $antenne_slug = $_GET['antenne_slug']; $nom_connecte = $_GET['nom_connecte']; - $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); // Affichage des intitulés de colonnes $data = '
diff --git a/public/ajax/updateProduitsDetails.php b/public/ajax/updateProduitsDetails.php index cfdd1f4..bf9d4cb 100644 --- a/public/ajax/updateProduitsDetails.php +++ b/public/ajax/updateProduitsDetails.php @@ -2,7 +2,7 @@ include '../../config/conf.php'; -$bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); +$bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); if(isset($_POST)) { diff --git a/public/ajax/updateRecherchesDetails.php b/public/ajax/updateRecherchesDetails.php index bfabd95..c4d4a35 100644 --- a/public/ajax/updateRecherchesDetails.php +++ b/public/ajax/updateRecherchesDetails.php @@ -2,7 +2,7 @@ include '../../config/conf.php'; -$bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); +$bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); if(isset($_POST)) { diff --git a/src/Framework/Middleware/TrailingSlashMiddleware.php b/src/Framework/Middleware/TrailingSlashMiddleware.php index 262a188..4c0917d 100644 --- a/src/Framework/Middleware/TrailingSlashMiddleware.php +++ b/src/Framework/Middleware/TrailingSlashMiddleware.php @@ -8,7 +8,7 @@ class TrailingSlashMiddleware { public function __invoke(ServerRequestInterface $request, callable $next) { $uri = $request->getUri()->getPath(); - if (!empty($uri) && $uri[-1] === "/") { + if (!empty($uri) && $uri[-1] === "/" && $uri !== "/") { return (new \GuzzleHttp\Psr7\Response()) ->withStatus(301) ->withHeader('Location', substr($uri, 0, -1)); @@ -16,4 +16,4 @@ class TrailingSlashMiddleware { return $next($request); } -} \ No newline at end of file +} diff --git a/src/Gmarche/config.php b/src/Gmarche/config.php index 20f652a..561c078 100644 --- a/src/Gmarche/config.php +++ b/src/Gmarche/config.php @@ -5,5 +5,5 @@ use function \Di\object; use function \Di\get; /* Chemin */ return [ - 'gmarche.prefix' => '/france' + 'gmarche.prefix' => '/' ]; From 6cdfb46025577f4ca099ff01c55231894c483d04 Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 21 Nov 2019 12:57:32 +0100 Subject: [PATCH 2/9] Improve configs files --- .gitignore | 2 +- config/{config.php => apply.php} | 4 ++-- config/{conf-sample.php => config-sample.php} | 1 + public/ajax/addRecord.php | 2 +- public/ajax/addRecord2.php | 2 +- public/ajax/connexion.php | 2 +- public/ajax/deleteProduits.php | 2 +- public/ajax/deleteRecherches.php | 2 +- public/ajax/getG1PubKey.php | 2 +- public/ajax/readProduitsDetails.php | 2 +- public/ajax/readRecherchesDetails.php | 2 +- public/ajax/readRecords.php | 2 +- public/ajax/readRecords2.php | 2 +- public/ajax/updateProduitsDetails.php | 2 +- public/ajax/updateRecherchesDetails.php | 2 +- public/index.php | 4 ++-- 16 files changed, 18 insertions(+), 17 deletions(-) rename config/{config.php => apply.php} (96%) rename config/{conf-sample.php => config-sample.php} (87%) diff --git a/.gitignore b/.gitignore index e77ceac..7a4fc65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -config/conf.php +config/config.php .idea /public/uploads /tmp diff --git a/config/config.php b/config/apply.php similarity index 96% rename from config/config.php rename to config/apply.php index 77e89ad..80827d1 100644 --- a/config/config.php +++ b/config/apply.php @@ -1,5 +1,5 @@ 'admin@gmarche-testmail.com', - 'mail.from' => 'no-reply@admin.fr', + 'mail.from' => '$mail_from', Swift_Mailer::class => \DI\factory(\Framework\SwiftMailerFactory::class) ]; diff --git a/config/conf-sample.php b/config/config-sample.php similarity index 87% rename from config/conf-sample.php rename to config/config-sample.php index be493eb..be398a3 100644 --- a/config/conf-sample.php +++ b/config/config-sample.php @@ -3,4 +3,5 @@ $db_username = ''; $db_password = ''; $db_name = ''; + $mail_from = ''; $g1_node = 'https://duniter-g1.p2p.legal'; diff --git a/public/ajax/addRecord.php b/public/ajax/addRecord.php index 35a7060..6c81824 100644 --- a/public/ajax/addRecord.php +++ b/public/ajax/addRecord.php @@ -3,7 +3,7 @@ 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'; + 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 diff --git a/public/ajax/addRecord2.php b/public/ajax/addRecord2.php index 0513b8d..1101410 100644 --- a/public/ajax/addRecord2.php +++ b/public/ajax/addRecord2.php @@ -3,7 +3,7 @@ if(isset($_POST['produit']) && isset($_POST['acheteur']) && isset($_POST['quantite']) ) { // Connexion à la base de données - include '../../config/conf.php'; + 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 diff --git a/public/ajax/connexion.php b/public/ajax/connexion.php index 3595c80..951db35 100644 --- a/public/ajax/connexion.php +++ b/public/ajax/connexion.php @@ -1,6 +1,6 @@ addModule(AdminModule::class) ->addModule(ContactModule::class) ->addModule(ProductModule::class) From bf21fcf39628f3d5ec9317232778f81f20eb03f7 Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 21 Nov 2019 13:00:35 +0100 Subject: [PATCH 3/9] Improve README.md --- README.md | 4 ++++ readme.md | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 README.md delete mode 100644 readme.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..7fd8f62 --- /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/readme.md b/readme.md deleted file mode 100644 index 03b8dd8..0000000 --- a/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -test -commit du fichier \ No newline at end of file From 8eeafbe1fb8a7e668dd843abc721acb529e77b4b Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 21 Nov 2019 13:02:18 +0100 Subject: [PATCH 4/9] typo readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fd8f62..3d8a652 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Plateforme évènementielle de mise en relation des Ḡmarchés. +# Plateforme événementielle de mise en relation des Ḡmarchés. ## Site en construction ### TODO: README From 7e3d9537c7bde3ef37328daf5d41eb45ca174d34 Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 21 Nov 2019 13:40:50 +0100 Subject: [PATCH 5/9] Comment check if (->matches()) line 94 in vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php --- .../fast-route/src/DataGenerator/RegexBasedAbstract.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php b/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php index 6457290..b3e42ed 100644 --- a/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php +++ b/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php @@ -91,12 +91,12 @@ abstract class RegexBasedAbstract implements DataGenerator if (isset($this->methodToRegexToRoutesMap[$httpMethod])) { foreach ($this->methodToRegexToRoutesMap[$httpMethod] as $route) { - if ($route->matches($routeStr)) { - throw new BadRouteException(sprintf( - 'Static route "%s" is shadowed by previously defined variable route "%s" for method "%s"', - $routeStr, $route->regex, $httpMethod - )); - } + // if ($route->matches($routeStr)) { + // throw new BadRouteException(sprintf( + // 'Static route "%s" is shadowed by previously defined variable route "%s" for method "%s"', + // $routeStr, $route->regex, $httpMethod + // )); + // } } } From 6296f10b3f16b29ebf6f1b052a3613d9232dc46f Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 21 Nov 2019 13:42:06 +0100 Subject: [PATCH 6/9] Fix home button with standard location --- src/Framework/Middleware/NotFoundMiddleware.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Framework/Middleware/NotFoundMiddleware.php b/src/Framework/Middleware/NotFoundMiddleware.php index 125d19b..f34b422 100644 --- a/src/Framework/Middleware/NotFoundMiddleware.php +++ b/src/Framework/Middleware/NotFoundMiddleware.php @@ -14,7 +14,7 @@ class NotFoundMiddleware { background:url(\'/images/bildreich_1275.jpg\') no-repeat;background-size: cover;">

Erreur 404


Cette url n\'existe pas.

- + Retour à l\'accueil
'); } -} \ No newline at end of file +} From f37184721490312596f447c45d650cc6d8bd5d27 Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 21 Nov 2019 13:43:48 +0100 Subject: [PATCH 7/9] Fix regions link in home page by removing / in src/Gmarche/GmarcheModule.php line 24 --- src/Gmarche/GmarcheModule.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Gmarche/GmarcheModule.php b/src/Gmarche/GmarcheModule.php index ad076b9..3adde69 100644 --- a/src/Gmarche/GmarcheModule.php +++ b/src/Gmarche/GmarcheModule.php @@ -20,7 +20,7 @@ class GmarcheModule extends Module $gmarchePrefix = $container->get('gmarche.prefix'); $container->get(RendererInterface::class)->addPath('gmarche', __DIR__ . '/views'); $router = $container->get(Router::class); - $router->get( "$gmarchePrefix", RegionIndexAction::class, 'gmarche.index'); - $router->get("$gmarchePrefix/{slug:[a-z\-0-9]+}", AntenneShowAction::class, 'gmarche.antenne'); + $router->get("$gmarchePrefix", RegionIndexAction::class, 'gmarche.index'); + $router->get("$gmarchePrefix{slug:[a-z\-0-9]+}", AntenneShowAction::class, 'gmarche.antenne'); } } From b42726ff2d73b6f38a921e4a5967bf7f2d4c95ad Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 21 Nov 2019 14:16:02 +0100 Subject: [PATCH 8/9] Fix produits and recherches routes --- src/Product/ProductModule.php | 4 ++-- src/Product/views/admin/products/index.twig | 4 ++-- src/Product/views/admin/recherches/index.twig | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Product/ProductModule.php b/src/Product/ProductModule.php index 010edab..93b5275 100644 --- a/src/Product/ProductModule.php +++ b/src/Product/ProductModule.php @@ -20,8 +20,8 @@ class ProductModule extends Module $container->get(RendererInterface::class)->addPath('product', __DIR__ . '/views'); $router = $container->get(Router::class); - $router->get("$gmarchePrefix/{region:[a-z\-0-9]+}/{slug:[a-z\-0-9]+}/produits", ProductIndexAction::class, 'product.ville'); - $router->get("$gmarchePrefix/{region:[a-z\-0-9]+}/{slug:[a-z\-0-9]+}/recherches", RechIndexAction::class, 'product.recherches'); + $router->get("$gmarchePrefix{region:[a-z\-0-9]+}/{slug:[a-z\-0-9]+}/produits", ProductIndexAction::class, 'product.ville'); + $router->get("$gmarchePrefix{region:[a-z\-0-9]+}/{slug:[a-z\-0-9]+}/recherches", RechIndexAction::class, 'product.recherches'); // $router->crud("$gmarchePrefix/{region:[a-z\-]+}/{slug:[a-z\-0-9]+}/{antenne:[0-9]{1,}}",[LoggedInMiddleware::class, ProductCrudAction::class],'product.admin'); } diff --git a/src/Product/views/admin/products/index.twig b/src/Product/views/admin/products/index.twig index fb258fc..cf4e4d9 100644 --- a/src/Product/views/admin/products/index.twig +++ b/src/Product/views/admin/products/index.twig @@ -93,7 +93,7 @@