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",
"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",
"license": "GPLv2",
"authors": [
@ -17,22 +24,14 @@
"monolog/monolog": "^1.17",
"slim/twig-view": "^3.4",
"google/recaptcha": "^1.1",
"slim/flash": "^0.4.0"
},
"require-dev": {
"phpunit/phpunit": ">=4.8 < 6.0"
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
"slim/flash": "^0.4.0",
"slim/psr7": "^1.7",
"php-di/php-di": "^7.0"
},
"config": {
"process-timeout" : 0
"process-timeout": 0
},
"scripts": {
"start": "php -S localhost:8080 -t public index.php",
"test": "phpunit"
"start": "php -S localhost:8080 -t public index.php"
}
}

1622
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,37 @@
<?php
// 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){
return new \Slim\Flash\Messages();
};
$container->set('flash', function($c){
$storage = [];
return new Messages($storage);
});
$container['renderer'] = function ($c) {
$settings = $c->get('settings')['renderer'];
// $container['renderer'] = function ($c) {
// $settings = $c->get('settings')['renderer'];
$view = new Slim\Views\Twig($settings['template_path'],[
'cache' => $settings['cache_path'],
// $view = new Slim\Views\Twig($settings['template_path'],[
// 'cache' => $settings['cache_path'],
]);
// ]);
$view->addExtension(new Knlv\Slim\Views\TwigMessages(
new Slim\Flash\Messages()
));
return $view;
};
// $view->addExtension(new Knlv\Slim\Views\TwigMessages(
// new Slim\Flash\Messages()
// ));
// return $view;
// };
$container['db'] = function ($c) {
$db = $c->get('settings')['db'];
$container->set('db', function ($c) {
$dbconf = ['path' => __DIR__."/../db/ggdworkshop.db"];
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_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
}
@ -33,12 +40,12 @@ $container['db'] = function ($c) {
}
return $pdo;
};
});
// monolog
$container['logger'] = function ($c) {
$settings = $c->get('settings')['logger'];
$logger = new Monolog\Logger($settings['name']);
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
$logger->pushHandler(new Monolog\Handler\StreamHandler($settings['path'], $settings['level']));
return $logger;
};
// $container['logger'] = function ($c) {
// $settings = $c->get('settings')['logger'];
// $logger = new Monolog\Logger($settings['name']);
// $logger->pushProcessor(new Monolog\Processor\UidProcessor());
// $logger->pushHandler(new Monolog\Handler\StreamHandler($settings['path'], $settings['level']));
// return $logger;
// };

View File

@ -1,4 +1,9 @@
<?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
use Slim\Http\Request;
use Slim\Http\Response;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
use Slim\Flash\Message;
// Routes
$app->get('/', function (Request $request, Response $response, array $args) {
$this->logger->info("GDDWorkshop '/' route");
return $this->renderer->render($response, 'index.html', $args);
// $this->logger->info("GDDWorkshop '/' route");
$view = Twig::fromRequest($request);
return $view->render($response, 'index.html', $args);
});
$app->get('/registration', function (Request $request, Response $response, array $args) {
$this->logger->info("GDDWorkshop '/registrtion' route");
return $this->renderer->render($response, 'registration.html', $args);
// $this->logger->info("GDDWorkshop '/registrtion' route");
$view = Twig::fromRequest($request);
return $view->render($response, 'registration.html', $args);
});
$app->get('/participants', function (Request $request, Response $response, array $args) {
$this->logger->info("GDDWorkshop '/participants' route");
$db = new DB($this->db);
$data = $db->getAll();
return $this->renderer->render($response, 'participants.html', ['registros' => $data]);
$view = Twig::fromRequest($request);
$dbSettings = $this->get('db');
$db = new DB($dbSettings);
$data = $db->getAll();
return $view->render($response, 'participants.html', ['registros' => $data]);
});
$app->get('/committess', function (Request $request, Response $response, array $args) {
$this->logger->info("GDDWorkshop '/committess' route");
return $this->renderer->render($response, 'committess.html', $args);
// $this->logger->info("GDDWorkshop '/committess' route");
$view = Twig::fromRequest($request);
return $view->render($response, 'committess.html', $args);
});
$app->get('/practicalinfo', function (Request $request, Response $response, array $args) {
$this->logger->info("GDDWorkshop '/practicalinfo' route");
return $this->renderer->render($response, 'practicalinfo.html', $args);
// $this->logger->info("GDDWorkshop '/practicalinfo' route");
$view = Twig::fromRequest($request);
return $view->render($response, 'practicalinfo.html', $args);
});
$app->get('/invitedspeakers', function (Request $request, Response $response, array $args) {
$this->logger->info("GDDWorkshop '/invitedspeakers' route");
return $this->renderer->render($response, 'invitedspeakers.html', $args);
// $this->logger->info("GDDWorkshop '/invitedspeakers' route");
$view = Twig::fromRequest($request);
return $view->render($response, 'invitedspeakers.html', $args);
});
$app->get('/program', function (Request $request, Response $response, array $args) {
$this->logger->info("GDDWorkshop '/program' route");
return $this->renderer->render($response, 'program.html', $args);
// $this->logger->info("GDDWorkshop '/program' route");
$view = Twig::fromRequest($request);
return $view->render($response, 'program.html', $args);
});
/*
$mw = function ($request, $response, $next) {
@ -56,43 +63,43 @@ $mw = function ($request, $response, $next) {
$app->group('/api', function($app){
$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);
});
$app->post('/register', function (Request $request, Response $response, array $args) {
$db = new DB($this->db);
$db = new DB($this->db);
$data = $request->getParsedBody();
$messages = $this->flash;
if(!isset($data['nombre'])||empty($data['nombre']))
$messages->addMessageNow("submit-register-err", "First name could not be empty");
if(!isset($data['apellido'])||empty($data['apellido']))
$messages->addMessageNow("submit-register-err", "Last name could not be empty");
if(!isset($data['email'])||empty($data['email']))
$messages->addMessageNow("submit-register-err", "E-mail could not be empty");
if(!isset($data['financiacion'])||!is_numeric($data['financiacion']))
$messages->addMessageNow("submit-register-err", "Question about financial support must have a selected answer");
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");
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 = $this->get('flash');
// if(!isset($data['nombre'])||empty($data['nombre']))
// $messages->addMessageNow("submit-register-err", "First name could not be empty");
// if(!isset($data['apellido'])||empty($data['apellido']))
// $messages->addMessageNow("submit-register-err", "Last name could not be empty");
// if(!isset($data['email'])||empty($data['email']))
// $messages->addMessageNow("submit-register-err", "E-mail could not be empty");
// if(!isset($data['financiacion'])||!is_numeric($data['financiacion']))
// $messages->addMessageNow("submit-register-err", "Question about financial support must have a selected answer");
// 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");
// 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");
//ReCaptcha Validation
if(!isset($data['g-recaptcha-response'])||empty($data['g-recaptcha-response'])){
$messages->addMessageNow("submit-register-err", "Please validate captcha!");
}
else {
$recaptcha = new ReCaptcha\ReCaptcha($this->settings['recaptcha']['secret-test']);
//get remote ip from request header TODO
$resp = $recaptcha->verify($data['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if(!$resp->isSuccess()){
$messages->addMessageNow("submit-register-err", "ReCaptcha validation error " . implode($resp->getErrorCodes()));
}
else {
unset($data['g-recaptcha-response']);
}
}
// //ReCaptcha Validation
// if(!isset($data['g-recaptcha-response'])||empty($data['g-recaptcha-response'])){
// $messages->addMessageNow("submit-register-err", "Please validate captcha!");
// }
// else {
// $recaptcha = new ReCaptcha\ReCaptcha($this->settings['recaptcha']['secret-test']);
// //get remote ip from request header TODO
// $resp = $recaptcha->verify($data['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
// if(!$resp->isSuccess()){
// $messages->addMessageNow("submit-register-err", "ReCaptcha validation error " . implode($resp->getErrorCodes()));
// }
// else {
// unset($data['g-recaptcha-response']);
// }
// }
try{
if($db->findByMail($data['email']))

View File

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