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:
sabelo 2024-07-28 22:59:41 -03:00
parent 1f19120631
commit bfaad0d508
6 changed files with 535 additions and 1400 deletions

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -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');
$data = $db->getAll(); $db = new DB($dbSettings);
return $this->renderer->render($response, 'participants.html', ['registros' => $data]); $data = $db->getAll();
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,43 +63,43 @@ $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);
}); });
$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']))

View File

@ -7,15 +7,17 @@
<h1>Registration</h1> <h1>Registration</h1>
<form id="registerform" method="POST" action novalidate="novalidate"> <form id="registerform" method="POST" action novalidate="novalidate">
<!-- Nombre y Apellido --> <fieldset disabled="disabled">
<div class="row">
<!-- Nombre y Apellido -->
<div class="row">
<div class="form-group col-xs-12 col-sm-6"> <div class="form-group col-xs-12 col-sm-6">
<label class="control-label" for="nombre">First Name</label> <label class="control-label" for="nombre">First Name</label>
<div class="input-container"> <div class="input-container">
<input id="nombre" class="form-control" name="nombre" type="text"> <input id="nombre" class="form-control" name="nombre" type="text">
</div> </div>
</div> </div>
<div class="form-group col-xs-12 col-sm-6"> <div class="form-group col-xs-12 col-sm-6">
<label class="control-label" for="apellido">Last Name</label> <label class="control-label" for="apellido">Last Name</label>
<div class="input-container"> <div class="input-container">
@ -23,7 +25,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Título y Afiliación --> <!-- Título y Afiliación -->
<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">
@ -31,18 +33,18 @@
<div class="input-container"> <div class="input-container">
<input id="titulo" class="form-control" name="titulo" <input id="titulo" class="form-control" name="titulo"
placeholder="Professor, Post Doc, Grad Student(1st year, 2nd year, etc..)" type="text"> placeholder="Professor, Post Doc, Grad Student(1st year, 2nd year, etc..)" type="text">
</div>
</div> </div>
</div>
<div class="form-group col-xs-12 col-sm-6">
<div class="form-group col-xs-12 col-sm-6"> <label class="control-label " for="afiliacion">Affiliation</label>
<label class="control-label " for="afiliacion">Affiliation</label>
<div class="input-container"> <div class="input-container">
<input id="afiliacion" class="form-control" name="afiliacion" <input id="afiliacion" class="form-control" name="afiliacion"
placeholder="Which university or organization" type="text"> placeholder="Which university or organization" type="text">
</div> </div>
</div> </div>
</div> </div>
<!-- Ciudad y Pais --> <!-- Ciudad y Pais -->
<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">
@ -58,18 +60,18 @@
<select id="pais" name="pais"> <select id="pais" name="pais">
<option></optoon> <option></optoon>
</select> </select>
</div> </div>
</div> </div>
</div> </div>
<!-- Email --> <!-- Email -->
<div class="row"> <div class="row">
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label class="control-label" for="email">Email</label> <label class="control-label" for="email">Email</label>
<div class="input-container"> <div class="input-container">
<input id="email" class="form-control" name="email" <input id="email" class="form-control" name="email"
placeholder="mail@example.com" type="email"> placeholder="mail@example.com" type="email">
</div> </div>
</div> </div>
</div> </div>
@ -89,20 +91,20 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Financial Support --> <!-- Financial Support -->
<div class="row"> <div class="row">
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label class="control-label" for="sifinan"> <label class="control-label" for="sifinan">
Are you asking for support from the conference? Are you asking for support from the conference?
</label> </label>
<div class="radios input-container"> <div class="radios input-container">
<label class="radio-inline"><input id="sifinan" type="radio" name="financiacion" value="1">Yes</label> <label class="radio-inline"><input id="sifinan" type="radio" name="financiacion" value="1">Yes</label>
<label class="radio-inline"><input id="nofinan" type="radio" name="financiacion" value="0">No</label> <label class="radio-inline"><input id="nofinan" type="radio" name="financiacion" value="0">No</label>
</div> </div>
<div class="col-sm-8 alert alert-info" style="margin:10px 0px 5px 0px;"> <div class="col-sm-8 alert alert-info" style="margin:10px 0px 5px 0px;">
<em class="text-justify"> <em class="text-justify">
we have submitted funding requests and hope to cover the housing we have submitted funding requests and hope to cover the housing
for a shared room, but we cannot make a guarantee at this time for a shared room, but we cannot make a guarantee at this time
@ -110,35 +112,35 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Invitation and letter of --> <!-- Invitation and letter of -->
<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">
<!--requerido--> <!--requerido-->
<label class="control-label" for="invited"> <label class="control-label" for="invited">
Were you invited to participate in this conference? Were you invited to participate in this conference?
</label> </label>
<div class="input-container"> <div class="input-container">
<div class="radio"> <div class="radio">
<label><input id="invited" type="radio" name="invited" value="1">Yes, I was previously invited</label> <label><input id="invited" type="radio" name="invited" value="1">Yes, I was previously invited</label>
</div> </div>
<div class="radio"> <div class="radio">
<label><input id="noinvited" type="radio" name="invited" value="0">No, I am applying(Registration committee will notifiy you if accepted)</label> <label><input id="noinvited" type="radio" name="invited" value="0">No, I am applying(Registration committee will notifiy you if accepted)</label>
</div>
</div> </div>
</div> </div>
</div>
<div class="form-group col-xs-12 col-sm-6">
<div class="form-group col-xs-12 col-sm-6"> <label class="control-label" for="invited">
<label class="control-label" for="invited"> Do you need a letter of invitation?
Do you need a letter of invitation? </label>
</label> <div class="input-container">
<div class="input-container"> <label class="radio-inline"><input id="sifinan" type="radio" name="letterinvited" value="1">Yes</label>
<label class="radio-inline"><input id="sifinan" type="radio" name="letterinvited" value="1">Yes</label> <label class="radio-inline"><input id="nofinan" type="radio" name="letterinvited" value="0">No</label>
<label class="radio-inline"><input id="nofinan" type="radio" name="letterinvited" value="0">No</label> </div>
</div> </div>
</div>
</div> </div>
<!-- Rooming Preferences --> <!-- Rooming Preferences -->
<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">
@ -146,16 +148,16 @@
<div class="input-container"> <div class="input-container">
<select id="roomtype" name="roomtype"> <select id="roomtype" name="roomtype">
<option></optoon> <option></optoon>
</select> </select>
</div>
</div> </div>
</div>
<div class="form-group col-xs-12 col-sm-6"> <div class="form-group col-xs-12 col-sm-6">
<label class=" control-label" for="roomate">Name of preferred roommate (if any)</label> <label class=" control-label" for="roomate">Name of preferred roommate (if any)</label>
<div class="input-container"> <div class="input-container">
<input id="roomate" name="roomate" class="form-control" <input id="roomate" name="roomate" class="form-control"
type="text"> type="text">
</div> </div>
</div> </div>
</div> </div>
@ -163,34 +165,27 @@
<!--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>
<!-- Confirm Button --> <!-- Confirm Button -->
<div class="row"> <div class="row">
<div class="form-group col-xs-12 col-sm-8"> <div class="form-group col-xs-12 col-sm-8">
<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">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
@ -198,9 +193,9 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="alert"> <div class="alert">
</div> </div>
</div> </div>
<!--<div class="modal-footer"> <!--<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"> <button type="button" class="btn btn-default" data-dismiss="modal">