final rework just for deploy the fucking event in a nice an up to date version of php, participants database is missing
This commit is contained in:
parent
1f19120631
commit
bfaad0d508
@ -1,7 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "slim/slim-skeleton",
|
"name": "slim/slim-skeleton",
|
||||||
"description": "Groups Geometry and Dynamics, ICM2018 Satellite, Web Project",
|
"description": "Groups Geometry and Dynamics, ICM2018 Satellite, Web Project",
|
||||||
"keywords": ["ICM2018", "GGDWorkshop", "Montevideo","Math","Groups","Geometry"],
|
"keywords": [
|
||||||
|
"ICM2018",
|
||||||
|
"GGDWorkshop",
|
||||||
|
"Montevideo",
|
||||||
|
"Math",
|
||||||
|
"Groups",
|
||||||
|
"Geometry"
|
||||||
|
],
|
||||||
"homepage": "https://ggdworkshop.cmat.edu.uy",
|
"homepage": "https://ggdworkshop.cmat.edu.uy",
|
||||||
"license": "GPLv2",
|
"license": "GPLv2",
|
||||||
"authors": [
|
"authors": [
|
||||||
@ -17,22 +24,14 @@
|
|||||||
"monolog/monolog": "^1.17",
|
"monolog/monolog": "^1.17",
|
||||||
"slim/twig-view": "^3.4",
|
"slim/twig-view": "^3.4",
|
||||||
"google/recaptcha": "^1.1",
|
"google/recaptcha": "^1.1",
|
||||||
"slim/flash": "^0.4.0"
|
"slim/flash": "^0.4.0",
|
||||||
},
|
"slim/psr7": "^1.7",
|
||||||
"require-dev": {
|
"php-di/php-di": "^7.0"
|
||||||
"phpunit/phpunit": ">=4.8 < 6.0"
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"Tests\\": "tests/"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"process-timeout": 0
|
"process-timeout": 0
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "php -S localhost:8080 -t public index.php",
|
"start": "php -S localhost:8080 -t public index.php"
|
||||||
"test": "phpunit"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1622
composer.lock
generated
1622
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,30 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
// DIC configuration
|
// DIC configuration
|
||||||
|
use DI\Container;
|
||||||
|
use Slim\Flash\Messages;
|
||||||
|
|
||||||
$container = $app->getContainer();
|
$container = new Container();
|
||||||
|
// $container = $app->getContainer();
|
||||||
|
$container->set('settings', function(){
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
|
||||||
$container['flash'] = function($c){
|
$container->set('flash', function($c){
|
||||||
return new \Slim\Flash\Messages();
|
$storage = [];
|
||||||
};
|
return new Messages($storage);
|
||||||
|
});
|
||||||
|
|
||||||
$container['renderer'] = function ($c) {
|
// $container['renderer'] = function ($c) {
|
||||||
$settings = $c->get('settings')['renderer'];
|
// $settings = $c->get('settings')['renderer'];
|
||||||
|
|
||||||
$view = new Slim\Views\Twig($settings['template_path'],[
|
// $view = new Slim\Views\Twig($settings['template_path'],[
|
||||||
'cache' => $settings['cache_path'],
|
// 'cache' => $settings['cache_path'],
|
||||||
|
|
||||||
]);
|
// ]);
|
||||||
|
|
||||||
$view->addExtension(new Knlv\Slim\Views\TwigMessages(
|
// $view->addExtension(new Knlv\Slim\Views\TwigMessages(
|
||||||
new Slim\Flash\Messages()
|
// new Slim\Flash\Messages()
|
||||||
));
|
// ));
|
||||||
return $view;
|
// return $view;
|
||||||
};
|
// };
|
||||||
|
|
||||||
$container['db'] = function ($c) {
|
$container->set('db', function ($c) {
|
||||||
$db = $c->get('settings')['db'];
|
$dbconf = ['path' => __DIR__."/../db/ggdworkshop.db"];
|
||||||
try{
|
try{
|
||||||
$pdo = new PDO('sqlite:'.$db['path']);
|
$pdo = new PDO('sqlite:'.$dbconf['path']);
|
||||||
$pdo->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION );
|
$pdo->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION );
|
||||||
$pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
|
$pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
@ -33,12 +40,12 @@ $container['db'] = function ($c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $pdo;
|
return $pdo;
|
||||||
};
|
});
|
||||||
// monolog
|
// monolog
|
||||||
$container['logger'] = function ($c) {
|
// $container['logger'] = function ($c) {
|
||||||
$settings = $c->get('settings')['logger'];
|
// $settings = $c->get('settings')['logger'];
|
||||||
$logger = new Monolog\Logger($settings['name']);
|
// $logger = new Monolog\Logger($settings['name']);
|
||||||
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
|
// $logger->pushProcessor(new Monolog\Processor\UidProcessor());
|
||||||
$logger->pushHandler(new Monolog\Handler\StreamHandler($settings['path'], $settings['level']));
|
// $logger->pushHandler(new Monolog\Handler\StreamHandler($settings['path'], $settings['level']));
|
||||||
return $logger;
|
// return $logger;
|
||||||
};
|
// };
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
// Application middleware
|
use Slim\Views\Twig;
|
||||||
|
use Slim\Views\TwigMiddleware;
|
||||||
|
|
||||||
// e.g: $app->add(new \Slim\Csrf\Guard);
|
// Create Twig
|
||||||
|
$twig = Twig::create(__DIR__ . '/../templates', ['cache' => false]);
|
||||||
|
|
||||||
|
// Add Twig-View Middleware
|
||||||
|
$app->add(TwigMiddleware::create($app, $twig));
|
103
src/routes.php
103
src/routes.php
@ -1,47 +1,54 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
use Slim\Http\Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Views\Twig;
|
||||||
|
use Slim\Flash\Message;
|
||||||
// Routes
|
// Routes
|
||||||
|
|
||||||
$app->get('/', function (Request $request, Response $response, array $args) {
|
$app->get('/', function (Request $request, Response $response, array $args) {
|
||||||
$this->logger->info("GDDWorkshop '/' route");
|
// $this->logger->info("GDDWorkshop '/' route");
|
||||||
return $this->renderer->render($response, 'index.html', $args);
|
$view = Twig::fromRequest($request);
|
||||||
|
return $view->render($response, 'index.html', $args);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->get('/registration', function (Request $request, Response $response, array $args) {
|
$app->get('/registration', function (Request $request, Response $response, array $args) {
|
||||||
$this->logger->info("GDDWorkshop '/registrtion' route");
|
// $this->logger->info("GDDWorkshop '/registrtion' route");
|
||||||
return $this->renderer->render($response, 'registration.html', $args);
|
$view = Twig::fromRequest($request);
|
||||||
|
return $view->render($response, 'registration.html', $args);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$app->get('/participants', function (Request $request, Response $response, array $args) {
|
$app->get('/participants', function (Request $request, Response $response, array $args) {
|
||||||
$this->logger->info("GDDWorkshop '/participants' route");
|
$view = Twig::fromRequest($request);
|
||||||
$db = new DB($this->db);
|
$dbSettings = $this->get('db');
|
||||||
|
$db = new DB($dbSettings);
|
||||||
$data = $db->getAll();
|
$data = $db->getAll();
|
||||||
return $this->renderer->render($response, 'participants.html', ['registros' => $data]);
|
return $view->render($response, 'participants.html', ['registros' => $data]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$app->get('/committess', function (Request $request, Response $response, array $args) {
|
$app->get('/committess', function (Request $request, Response $response, array $args) {
|
||||||
$this->logger->info("GDDWorkshop '/committess' route");
|
// $this->logger->info("GDDWorkshop '/committess' route");
|
||||||
return $this->renderer->render($response, 'committess.html', $args);
|
$view = Twig::fromRequest($request);
|
||||||
|
return $view->render($response, 'committess.html', $args);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->get('/practicalinfo', function (Request $request, Response $response, array $args) {
|
$app->get('/practicalinfo', function (Request $request, Response $response, array $args) {
|
||||||
$this->logger->info("GDDWorkshop '/practicalinfo' route");
|
// $this->logger->info("GDDWorkshop '/practicalinfo' route");
|
||||||
return $this->renderer->render($response, 'practicalinfo.html', $args);
|
$view = Twig::fromRequest($request);
|
||||||
|
return $view->render($response, 'practicalinfo.html', $args);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->get('/invitedspeakers', function (Request $request, Response $response, array $args) {
|
$app->get('/invitedspeakers', function (Request $request, Response $response, array $args) {
|
||||||
$this->logger->info("GDDWorkshop '/invitedspeakers' route");
|
// $this->logger->info("GDDWorkshop '/invitedspeakers' route");
|
||||||
return $this->renderer->render($response, 'invitedspeakers.html', $args);
|
$view = Twig::fromRequest($request);
|
||||||
|
return $view->render($response, 'invitedspeakers.html', $args);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->get('/program', function (Request $request, Response $response, array $args) {
|
$app->get('/program', function (Request $request, Response $response, array $args) {
|
||||||
$this->logger->info("GDDWorkshop '/program' route");
|
// $this->logger->info("GDDWorkshop '/program' route");
|
||||||
return $this->renderer->render($response, 'program.html', $args);
|
$view = Twig::fromRequest($request);
|
||||||
|
return $view->render($response, 'program.html', $args);
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
$mw = function ($request, $response, $next) {
|
$mw = function ($request, $response, $next) {
|
||||||
@ -56,7 +63,7 @@ $mw = function ($request, $response, $next) {
|
|||||||
$app->group('/api', function($app){
|
$app->group('/api', function($app){
|
||||||
|
|
||||||
$app->get("/test", function(Request $request, Response $response, array $args) {
|
$app->get("/test", function(Request $request, Response $response, array $args) {
|
||||||
$this->logger->info("GDDWorkshop '/api/test' route");
|
// $this->logger->info("GDDWorkshop '/api/test' route");
|
||||||
return var_dump($request);
|
return var_dump($request);
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -64,35 +71,35 @@ $app->group('/api', function($app){
|
|||||||
$app->post('/register', function (Request $request, Response $response, array $args) {
|
$app->post('/register', function (Request $request, Response $response, array $args) {
|
||||||
$db = new DB($this->db);
|
$db = new DB($this->db);
|
||||||
$data = $request->getParsedBody();
|
$data = $request->getParsedBody();
|
||||||
$messages = $this->flash;
|
$messages = $this->get('flash');
|
||||||
if(!isset($data['nombre'])||empty($data['nombre']))
|
// if(!isset($data['nombre'])||empty($data['nombre']))
|
||||||
$messages->addMessageNow("submit-register-err", "First name could not be empty");
|
// $messages->addMessageNow("submit-register-err", "First name could not be empty");
|
||||||
if(!isset($data['apellido'])||empty($data['apellido']))
|
// if(!isset($data['apellido'])||empty($data['apellido']))
|
||||||
$messages->addMessageNow("submit-register-err", "Last name could not be empty");
|
// $messages->addMessageNow("submit-register-err", "Last name could not be empty");
|
||||||
if(!isset($data['email'])||empty($data['email']))
|
// if(!isset($data['email'])||empty($data['email']))
|
||||||
$messages->addMessageNow("submit-register-err", "E-mail could not be empty");
|
// $messages->addMessageNow("submit-register-err", "E-mail could not be empty");
|
||||||
if(!isset($data['financiacion'])||!is_numeric($data['financiacion']))
|
// if(!isset($data['financiacion'])||!is_numeric($data['financiacion']))
|
||||||
$messages->addMessageNow("submit-register-err", "Question about financial support must have a selected answer");
|
// $messages->addMessageNow("submit-register-err", "Question about financial support must have a selected answer");
|
||||||
if(!isset($data['invited'])||!is_numeric($data['invited']))
|
// if(!isset($data['invited'])||!is_numeric($data['invited']))
|
||||||
$messages->addMessageNow("submit-register-err", "Question about 'invited to participate in this conference' must have a selected answer");
|
// $messages->addMessageNow("submit-register-err", "Question about 'invited to participate in this conference' must have a selected answer");
|
||||||
if(!isset($data['letterinvited'])||!is_numeric($data['letterinvited']))
|
// if(!isset($data['letterinvited'])||!is_numeric($data['letterinvited']))
|
||||||
$messages->addMessageNow("submit-register-err", "Question about needing a letter of invitation must have a selected answer");
|
// $messages->addMessageNow("submit-register-err", "Question about needing a letter of invitation must have a selected answer");
|
||||||
|
|
||||||
//ReCaptcha Validation
|
// //ReCaptcha Validation
|
||||||
if(!isset($data['g-recaptcha-response'])||empty($data['g-recaptcha-response'])){
|
// if(!isset($data['g-recaptcha-response'])||empty($data['g-recaptcha-response'])){
|
||||||
$messages->addMessageNow("submit-register-err", "Please validate captcha!");
|
// $messages->addMessageNow("submit-register-err", "Please validate captcha!");
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
$recaptcha = new ReCaptcha\ReCaptcha($this->settings['recaptcha']['secret-test']);
|
// $recaptcha = new ReCaptcha\ReCaptcha($this->settings['recaptcha']['secret-test']);
|
||||||
//get remote ip from request header TODO
|
// //get remote ip from request header TODO
|
||||||
$resp = $recaptcha->verify($data['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
|
// $resp = $recaptcha->verify($data['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
|
||||||
if(!$resp->isSuccess()){
|
// if(!$resp->isSuccess()){
|
||||||
$messages->addMessageNow("submit-register-err", "ReCaptcha validation error " . implode($resp->getErrorCodes()));
|
// $messages->addMessageNow("submit-register-err", "ReCaptcha validation error " . implode($resp->getErrorCodes()));
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
unset($data['g-recaptcha-response']);
|
// unset($data['g-recaptcha-response']);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if($db->findByMail($data['email']))
|
if($db->findByMail($data['email']))
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
<h1>Registration</h1>
|
<h1>Registration</h1>
|
||||||
|
|
||||||
<form id="registerform" method="POST" action novalidate="novalidate">
|
<form id="registerform" method="POST" action novalidate="novalidate">
|
||||||
|
<fieldset disabled="disabled">
|
||||||
|
|
||||||
<!-- Nombre y Apellido -->
|
<!-- Nombre y Apellido -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-xs-12 col-sm-6">
|
<div class="form-group col-xs-12 col-sm-6">
|
||||||
@ -163,7 +165,7 @@
|
|||||||
<!--Captcha -->
|
<!--Captcha -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-xs-12">
|
<div class="form-group col-xs-12">
|
||||||
<div id="testing" class="input-container g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"></div>
|
<!-- <div id="testing" class="input-container g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"></div> -->
|
||||||
<!--<div class="input-container g-recaptcha" data-sitekey="6LesRDsUAAAAAJvyoODvjiza9u75qEGJmbKHEV6s"></div>-->
|
<!--<div class="input-container g-recaptcha" data-sitekey="6LesRDsUAAAAAJvyoODvjiza9u75qEGJmbKHEV6s"></div>-->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -174,20 +176,13 @@
|
|||||||
<button type="submit" class="btn-lg btn btn-primary">Register</button>
|
<button type="submit" class="btn-lg btn btn-primary">Register</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<div id="statusmsg" class="alert alert-error">
|
<div id="statusmsg" class="alert alert-error">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!--{% if flash("submit-register-err") %}
|
|
||||||
<div id="statusmsg" class="alert alert-error">
|
|
||||||
<strong>Error!</strong>
|
|
||||||
{% for msg in flash("submit-register-err") %}
|
|
||||||
<kbd>{{ msg }}.</kdb>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endif %}-->
|
|
||||||
<div id="msgModal" class="modal fade" role="dialog">
|
<div id="msgModal" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user