This commit is contained in:
nox 2019-11-22 20:46:58 +01:00
commit e4e2ae854a
29 changed files with 109 additions and 110 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
config/config.php
config/conf.php
.idea
/public/uploads
/tmp

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# Plateforme événementielle de mise en relation des Ḡmarchés.
## Site en construction
### TODO: README

View File

@ -1,4 +0,0 @@
<?php
return [
'gmarche.prefix' => '/news'
];

53
config/apply.php Normal file
View File

@ -0,0 +1,53 @@
<?php
include 'config.php';
use App\Framework\Twig\UrlExtension;
use Framework\Middleware\CsrfMiddleware;
use Framework\Renderer\RendererInterface;
use Framework\Renderer\TwigRendererFactory;
use Framework\Router;
use Framework\Router\RouterFactory;
use Framework\Router\RouterTwigExtension;
use Framework\Session\PHPSession;
use Framework\Session\SessionInterface;
use Framework\Twig\{
CsrfExtension, FlashExtension, FormExtension, PagerFantaExtension, TextExtension, TimeExtension
};
return [
'env' => \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)
];

View File

@ -1,5 +0,0 @@
<?php
$host = '';
$username = '';
$password = '';
$database_name = '';

View File

@ -1,52 +1,7 @@
<?php
use App\Framework\Twig\UrlExtension;
use Framework\Middleware\CsrfMiddleware;
use Framework\Renderer\RendererInterface;
use Framework\Renderer\TwigRendererFactory;
use Framework\Router;
use Framework\Router\RouterFactory;
use Framework\Router\RouterTwigExtension;
use Framework\Session\PHPSession;
use Framework\Session\SessionInterface;
use Framework\Twig\{
CsrfExtension, FlashExtension, FormExtension, PagerFantaExtension, TextExtension, TimeExtension
};
return [
'env' => \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';

View File

@ -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( $chemin .'config/config.php'))
$app = (new \Framework\App( $chemin_new .'config/apply.php'))
->addModule(AdminModule::class)
->addModule(ContactModule::class)
->addModule(ProductModule::class)

View File

@ -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') {

View File

@ -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();

View File

@ -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();

View File

@ -1,10 +1,10 @@
<?php
include '../../config/conf.php';
include '../../config/config.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'];

View File

@ -1,10 +1,10 @@
<?php
include '../../config/conf.php';
include '../../config/config.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'];

View File

@ -1,10 +1,10 @@
<?php
include '../../config/conf.php';
include '../../config/config.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'];

View File

@ -1,6 +1,6 @@
<?php
ini_set('display_errors', 0);
include '../../config/conf.php';
include '../../config/config.php';
if(isset($_GET['vendeur']))
{
// Get public key from pseudo

View File

@ -1,10 +1,10 @@
<?php
include '../../config/conf.php';
include '../../config/config.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']) && isset($_POST['id']) != "") {
$product_id = $_POST['id'];

View File

@ -1,10 +1,10 @@
<?php
include '../../config/conf.php';
include '../../config/config.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'];

View File

@ -1,10 +1,10 @@
<?php
session_start();
ini_set('display_errors', 0);
include '../../config/conf.php';
include '../../config/config.php';
$antenne_slug = $_GET['antenne_slug'];
$nom_connecte = $_SESSION['user'];
$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 = '<table class="table table-bordered table-striped">

View File

@ -1,10 +1,10 @@
<?php
session_start();
ini_set('display_errors', 0);
include '../../config/conf.php';
include '../../config/config.php';
$antenne_slug = $_GET['antenne_slug'];
$nom_connecte = $_SESSION['user'];
$bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password);
$nom_connecte = $_SESSION['user'];
$bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password);
// Affichage des intitulés de colonnes
$data = '<table class="table table-bordered table-striped">

View File

@ -1,8 +1,8 @@
<?php
include '../../config/conf.php';
include '../../config/config.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))
{

View File

@ -1,8 +1,8 @@
<?php
include '../../config/conf.php';
include '../../config/config.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))
{

View File

@ -1,2 +0,0 @@
test
commit du fichier

View File

@ -14,7 +14,7 @@ class NotFoundMiddleware {
background:url(\'/images/bildreich_1275.jpg\') no-repeat;background-size: cover;">
<div class="container" style="padding: 2rem;margin: 5rem 2rem;width:15rem;height:14rem;background-color: #c9c9c9;">
<h4>Erreur 404</h4><br />Cette url n\'existe pas.<br /><br />
<a class="btn btn-primary btn-md" href="https://gmarche.monnaie-libre.fr/france" role="button">
<a class="btn btn-primary btn-md" href="/" role="button">
Retour à l\'accueil</a></div></div></html>');
}
}
}

View File

@ -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);
}
}
}

View File

@ -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');
}
}

View File

@ -5,5 +5,5 @@ use function \Di\object;
use function \Di\get;
/* Chemin */
return [
'gmarche.prefix' => '/france'
'gmarche.prefix' => '/'
];

View File

@ -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');
}

View File

@ -93,7 +93,7 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ gmarchePrefix }}">France</a></li>
<li class="breadcrumb-item"><a href="{{ gmarchePrefix }}/{{ region_slug }}">{{ region_name }}</a></li>
<li class="breadcrumb-item"><a href="{{ gmarchePrefix }}{{ region_slug }}">{{ region_name }}</a></li>
<li class="breadcrumb-item active">G-Marché de {{ antenne_name }}</li>
<div class="toggle_radio">
@ -102,7 +102,7 @@
<label for="first_toggle"><p>PRODUITS</p></label>
<label for="second_toggle">
<p>
<a style="color:black;" href="{{ gmarchePrefix }}/{{ region_slug }}/{{ antenne_slug }}/recherches">RECHERCHES</a>
<a style="color:black;" href="{{ gmarchePrefix }}{{ region_slug }}/{{ antenne_slug }}/recherches">RECHERCHES</a>
</p>
</label>
<div class="toggle_option_slider">

View File

@ -93,14 +93,14 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ gmarchePrefix }}">France</a></li>
<li class="breadcrumb-item"><a href="{{ gmarchePrefix }}/{{ region_slug }}">{{ region_name }}</a></li>
<li class="breadcrumb-item"><a href="{{ gmarchePrefix }}{{ region_slug }}">{{ region_name }}</a></li>
<li class="breadcrumb-item active">G-Marché de {{ antenne_name }}</li>
<div class="toggle_radio">
<input type="radio" class="toggle_option" id="first_toggle" name="toggle_option">
<input style="color:black;" type="radio" checked class="toggle_option" id="second_toggle" name="toggle_option">
<label for="first_toggle">
<a style="color:black;" href="{{ gmarchePrefix }}/{{ region_slug }}/{{ antenne_slug }}/produits">PRODUITS</a>
<a style="color:black;" href="{{ gmarchePrefix }}{{ region_slug }}/{{ antenne_slug }}/produits">PRODUITS</a>
</label>
<label for="second_toggle">
<p>RECHERCHES</p>

View File

@ -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
// ));
// }
}
}