mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2024-12-04 18:46:52 +00:00
Copie du site du TFJM² à adapter aux Correspondances
This commit is contained in:
commit
fa5202fe4f
7
.htaccess
Normal file
7
.htaccess
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ErrorDocument 403 /tfjm/server_files/403.php
|
||||||
|
ErrorDocument 404 /tfjm/server_files/404.php
|
||||||
|
|
||||||
|
Options +FollowSymlinks
|
||||||
|
Options -Indexes
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteRule ^(.*)$ dispatcher.php?path=$1 [QSA,L]
|
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
# Default ignored files
|
||||||
|
/workspace.xml
|
8
.idea/Correspondances.iml
Normal file
8
.idea/Correspondances.iml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
15
.idea/deployment.xml
Normal file
15
.idea/deployment.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PublishConfigData" autoUpload="Always" serverName="inscription.correspondances-maths.fr" autoUploadExternalChanges="true">
|
||||||
|
<serverData>
|
||||||
|
<paths name="inscription.correspondances-maths.fr">
|
||||||
|
<serverdata>
|
||||||
|
<mappings>
|
||||||
|
<mapping deploy="/var/inscription-correspondances" local="$PROJECT_DIR$" web="/" />
|
||||||
|
</mappings>
|
||||||
|
</serverdata>
|
||||||
|
</paths>
|
||||||
|
</serverData>
|
||||||
|
<option name="myAutoUpload" value="ALWAYS" />
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptSettings">
|
||||||
|
<option name="languageLevel" value="ES6" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Correspondances.iml" filepath="$PROJECT_DIR$/.idea/Correspondances.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
15
.idea/webServers.xml
Normal file
15
.idea/webServers.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="WebServers">
|
||||||
|
<option name="servers">
|
||||||
|
<webServer id="404dd6ef-117b-4764-9a64-906a422d3780" name="inscription.correspondances-maths.fr" url="https://inscription.correspondances-maths.fr">
|
||||||
|
<fileTransfer host="tfjm.org" port="22" accessType="SFTP" authAgent="true">
|
||||||
|
<advancedOptions>
|
||||||
|
<advancedOptions dataProtectionLevel="Private" passiveMode="true" shareSSLContext="true" />
|
||||||
|
</advancedOptions>
|
||||||
|
<option name="port" value="22" />
|
||||||
|
</fileTransfer>
|
||||||
|
</webServer>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
37
Dockerfile
Normal file
37
Dockerfile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
FROM php:7.3-apache as plateforme-builder
|
||||||
|
|
||||||
|
# Enabling apache rewrite mod
|
||||||
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
|
RUN apt clean && apt update && apt upgrade -y
|
||||||
|
|
||||||
|
# Install MySQL drivers
|
||||||
|
RUN docker-php-ext-install pdo_mysql \
|
||||||
|
&& docker-php-ext-enable pdo_mysql
|
||||||
|
|
||||||
|
# Install zip utilities
|
||||||
|
RUN apt install -y libzip-dev zip \
|
||||||
|
&& docker-php-ext-configure zip --with-libzip \
|
||||||
|
&& docker-php-ext-install zip \
|
||||||
|
&& docker-php-ext-enable zip
|
||||||
|
|
||||||
|
# Setup locales
|
||||||
|
RUN apt install locales locales-all -y && locale-gen fr_FR.UTF-8
|
||||||
|
ENV LANG fr_FR.UTF-8
|
||||||
|
ENV LANGUAGE fr_FR:fr
|
||||||
|
ENV LC_ALL fr_FR.UTF-8
|
||||||
|
|
||||||
|
# Setup timezone
|
||||||
|
RUN echo Europe/Paris > /etc/timezone \
|
||||||
|
&& ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime \
|
||||||
|
&& dpkg-reconfigure -f noninteractive tzdata
|
||||||
|
|
||||||
|
# Setup mailing
|
||||||
|
RUN apt install -yq msmtp ca-certificates
|
||||||
|
COPY setup/msmtprc /etc/msmtprc
|
||||||
|
RUN echo "sendmail_path=msmtp -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini
|
||||||
|
|
||||||
|
# Setting environment
|
||||||
|
ENV TFJM_LOCAL_PATH /var/www/html
|
||||||
|
ENV TFJM_MAIL_DOMAIN tfjm.org
|
||||||
|
ENV TFJM_URL_BASE https://inscription.correspondances-maths.fr
|
BIN
assets/favicon.ico
Normal file
BIN
assets/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
114
assets/logo.svg
Normal file
114
assets/logo.svg
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
viewBox="209.843 -2.284 30.311995 9.7779996"
|
||||||
|
version="1.1"
|
||||||
|
id="svg27"
|
||||||
|
sodipodi:docname="logo.svg"
|
||||||
|
width="30.311995"
|
||||||
|
height="9.7779999"
|
||||||
|
style="fill:black"
|
||||||
|
inkscape:version="0.92.2 2405546, 2018-03-11">
|
||||||
|
<metadata
|
||||||
|
id="metadata31">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1055"
|
||||||
|
id="namedview29"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="41.779237"
|
||||||
|
inkscape:cx="15.215997"
|
||||||
|
inkscape:cy="4.3644999"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="25"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="svg27" />
|
||||||
|
<defs
|
||||||
|
id="defs15">
|
||||||
|
<path
|
||||||
|
id="b"
|
||||||
|
d="m 2.58,-3.347 c 0.409,0 1.405,0.02 1.485,1.135 0.01,0.12 0.02,0.25 0.18,0.25 0.168,0 0.168,-0.14 0.168,-0.32 v -2.7 c 0,-0.159 0,-0.318 -0.169,-0.318 -0.13,0 -0.17,0.1 -0.18,0.21 -0.059,1.155 -0.756,1.354 -1.484,1.384 v -2.102 c 0,-0.668 0.19,-0.668 0.429,-0.668 h 0.468 c 1.275,0 1.923,0.688 1.983,1.375 0.01,0.08 0.02,0.23 0.179,0.23 0.17,0 0.17,-0.16 0.17,-0.33 v -1.295 c 0,-0.308 -0.02,-0.328 -0.33,-0.328 h -5 c -0.18,0 -0.34,0 -0.34,0.179 0,0.17 0.19,0.17 0.27,0.17 0.567,0 0.607,0.079 0.607,0.567 v 4.991 c 0,0.469 -0.03,0.568 -0.558,0.568 -0.15,0 -0.319,0 -0.319,0.17 C 0.14,0 0.3,0 0.48,0 h 2.878 c 0.18,0 0.33,0 0.33,-0.18 0,-0.169 -0.17,-0.169 -0.3,-0.169 -0.767,0 -0.807,-0.07 -0.807,-0.597 v -2.401 z m 2.88,-3.129 v 0.469 A 2.557,2.557 0 0 0 4.922,-6.476 Z M 4.065,-3.158 A 1.51,1.51 0 0 0 3.537,-3.547 c 0.189,-0.09 0.388,-0.249 0.528,-0.418 z m -2.7,-2.77 c 0,-0.12 0,-0.368 -0.08,-0.548 h 1.056 c -0.11,0.23 -0.11,0.558 -0.11,0.648 v 4.901 c 0,0.15 0,0.389 0.1,0.578 H 1.285 c 0.08,-0.179 0.08,-0.428 0.08,-0.548 v -5.03 z"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
id="c"
|
||||||
|
d="m 1.564,-6.824 c -0.18,0 -0.339,0 -0.339,0.179 0,0.17 0.18,0.17 0.29,0.17 0.687,0 0.727,0.069 0.727,0.577 v 5.59 c 0,0.169 0,0.358 -0.17,0.527 -0.08,0.07 -0.239,0.18 -0.478,0.18 -0.07,0 -0.369,0 -0.369,-0.11 0,-0.08 0.04,-0.12 0.09,-0.17 A 0.704,0.704 0 0 0 0.777,-1.057 0.704,0.704 0 0 0 0.06,-0.359 c 0,0.629 0.637,1.106 1.604,1.106 1.106,0 2.042,-0.387 2.192,-1.614 0.01,-0.09 0.01,-0.647 0.01,-0.966 v -4.184 c 0,-0.449 0.139,-0.449 0.707,-0.459 0.09,0 0.17,-0.08 0.17,-0.17 0,-0.178 -0.15,-0.178 -0.33,-0.178 z M 0.867,0.239 C 0.767,0.19 0.408,0.02 0.408,-0.349 c 0,-0.259 0.22,-0.358 0.37,-0.358 0.168,0 0.368,0.12 0.368,0.348 0,0.15 -0.08,0.24 -0.12,0.27 -0.04,0.04 -0.13,0.139 -0.16,0.328 z M 2.59,-5.918 c 0,-0.11 0,-0.378 -0.09,-0.558 h 1.097 c -0.08,0.18 -0.08,0.369 -0.08,0.708 v 4.015 c 0,0.298 0,0.797 -0.01,0.896 C 3.427,-0.349 3.198,0.11 2.44,0.31 2.59,0.08 2.59,-0.109 2.59,-0.288 v -5.629 z"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
id="d"
|
||||||
|
d="M 4.643,-2.092 2.74,-6.625 c -0.08,-0.2 -0.09,-0.2 -0.359,-0.2 H 0.528 c -0.18,0 -0.329,0 -0.329,0.18 0,0.17 0.18,0.17 0.23,0.17 0.119,0 0.388,0.02 0.607,0.099 v 5.32 c 0,0.21 0,0.648 -0.677,0.707 -0.19,0.02 -0.19,0.16 -0.19,0.17 C 0.17,0 0.33,0 0.51,0 h 1.543 c 0.18,0 0.33,0 0.33,-0.18 0,-0.089 -0.08,-0.159 -0.16,-0.169 -0.767,-0.06 -0.767,-0.478 -0.767,-0.707 v -4.961 l 0.01,-0.01 2.429,5.817 c 0.08,0.18 0.15,0.209 0.21,0.209 0.12,0 0.149,-0.08 0.199,-0.2 l 2.44,-5.827 0.01,0.01 v 4.961 c 0,0.21 0,0.648 -0.677,0.707 -0.19,0.02 -0.19,0.16 -0.19,0.17 0,0.179 0.16,0.179 0.34,0.179 h 2.66 c 0.179,0 0.328,0 0.328,-0.18 C 9.215,-0.27 9.135,-0.34 9.056,-0.35 8.289,-0.41 8.289,-0.828 8.289,-1.057 v -4.712 c 0,-0.21 0,-0.648 0.677,-0.708 0.1,-0.01 0.19,-0.06 0.19,-0.17 0,-0.178 -0.15,-0.178 -0.33,-0.178 H 6.905 c -0.259,0 -0.279,0 -0.369,0.209 z m -0.3,0.18 c 0.08,0.169 0.09,0.178 0.21,0.218 L 4.115,-0.638 H 4.095 L 1.823,-6.058 C 1.773,-6.187 1.693,-6.356 1.554,-6.476 h 0.867 l 1.923,4.563 z M 1.336,-0.35 h -0.17 c 0.02,-0.03 0.04,-0.06 0.06,-0.08 0.01,-0.01 0.01,-0.02 0.02,-0.03 z M 7.104,-6.477 H 8.16 c -0.219,0.25 -0.219,0.508 -0.219,0.688 v 4.752 c 0,0.18 0,0.438 0.23,0.687 H 6.883 c 0.22,-0.249 0.22,-0.508 0.22,-0.687 v -5.44 z"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
id="a"
|
||||||
|
d="m 4.135,-6.466 c 1.305,0.07 1.793,0.917 1.833,1.385 0.01,0.15 0.02,0.299 0.179,0.299 0.18,0 0.18,-0.17 0.18,-0.359 v -1.325 c 0,-0.348 -0.04,-0.358 -0.34,-0.358 H 0.658 c -0.308,0 -0.328,0.02 -0.328,0.318 V -5.1 c 0,0.16 0,0.319 0.17,0.319 0.17,0 0.178,-0.18 0.178,-0.2 0.04,-0.826 0.788,-1.424 1.834,-1.484 v 5.54 c 0,0.498 -0.04,0.577 -0.668,0.577 -0.12,0 -0.299,0 -0.299,0.17 0,0.179 0.16,0.179 0.339,0.179 h 2.89 C 4.95,0 5.1,0 5.1,-0.18 c 0,-0.169 -0.17,-0.169 -0.28,-0.169 -0.647,0 -0.686,-0.07 -0.686,-0.578 v -5.539 z m -3.458,-0.01 h 0.598 c -0.249,0.15 -0.458,0.349 -0.598,0.518 z m 5.3,0 v 0.528 A 2.606,2.606 0 0 0 5.37,-6.476 H 5.978 Z M 2.77,-0.349 c 0.09,-0.179 0.09,-0.428 0.09,-0.558 v -5.569 h 0.926 v 5.57 c 0,0.129 0,0.378 0.09,0.557 H 2.77 Z"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
id="e"
|
||||||
|
d="M 3.522,-1.27 H 3.285 c -0.021,0.154 -0.091,0.566 -0.182,0.635 -0.055,0.042 -0.592,0.042 -0.69,0.042 H 1.13 c 0.732,-0.648 0.976,-0.844 1.395,-1.171 0.516,-0.412 0.997,-0.844 0.997,-1.507 0,-0.844 -0.74,-1.36 -1.632,-1.36 -0.865,0 -1.45,0.607 -1.45,1.249 0,0.355 0.3,0.39 0.369,0.39 0.167,0 0.37,-0.118 0.37,-0.37 0,-0.125 -0.05,-0.369 -0.412,-0.369 0.216,-0.495 0.69,-0.649 1.018,-0.649 0.698,0 1.06,0.544 1.06,1.11 0,0.606 -0.432,1.087 -0.655,1.338 l -1.68,1.66 C 0.44,-0.209 0.44,-0.195 0.44,0 h 2.873 z"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</defs>
|
||||||
|
<use
|
||||||
|
x="209.843"
|
||||||
|
y="6.6110001"
|
||||||
|
xlink:href="#a"
|
||||||
|
id="use17"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
transform="translate(-0.33000232,0.13600003)" />
|
||||||
|
<use
|
||||||
|
x="216.485"
|
||||||
|
y="6.6110001"
|
||||||
|
xlink:href="#b"
|
||||||
|
id="use19"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
transform="translate(-0.33000232,0.13600003)" />
|
||||||
|
<use
|
||||||
|
x="222.573"
|
||||||
|
y="6.6110001"
|
||||||
|
xlink:href="#c"
|
||||||
|
id="use21"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
transform="translate(-0.33000232,0.13600003)" />
|
||||||
|
<use
|
||||||
|
x="227.554"
|
||||||
|
y="6.6110001"
|
||||||
|
xlink:href="#d"
|
||||||
|
id="use23"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
transform="translate(-0.33000232,0.13600003)" />
|
||||||
|
<use
|
||||||
|
x="236.963"
|
||||||
|
y="2.211"
|
||||||
|
xlink:href="#e"
|
||||||
|
id="use25"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
transform="translate(-0.33000232,0.13600003)" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 7.1 KiB |
80
assets/style.css
Normal file
80
assets/style.css
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
body {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu {
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 220px;
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
flex-grow: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu a {
|
||||||
|
display: block;
|
||||||
|
color: #000;
|
||||||
|
padding: 10px 20px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu a.active {
|
||||||
|
background-color: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu a:hover:not(.active) {
|
||||||
|
background-color: #555;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu-logo img {
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
margin: 40px auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-container {
|
||||||
|
margin: 0;
|
||||||
|
flex-grow: 1;
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-content {
|
||||||
|
padding-top: 100px;
|
||||||
|
padding-bottom: 100px;
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 1000px;
|
||||||
|
text-align: justify;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 700px) {
|
||||||
|
body {
|
||||||
|
flex-direction: column;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
#menu {
|
||||||
|
height: auto;
|
||||||
|
width: 100%;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
#menu-logo img {
|
||||||
|
height: 70px;
|
||||||
|
padding-left: 7px;
|
||||||
|
}
|
||||||
|
#menu a {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
#main-content {
|
||||||
|
padding: 100px 16px;
|
||||||
|
}
|
||||||
|
}
|
76
dispatcher.php
Normal file
76
dispatcher.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "server_files/config.php";
|
||||||
|
|
||||||
|
require_once "server_files/classes/Document.php";
|
||||||
|
require_once "server_files/classes/Role.php";
|
||||||
|
require_once "server_files/classes/SchoolClass.php";
|
||||||
|
require_once "server_files/classes/Team.php";
|
||||||
|
require_once "server_files/classes/Tournament.php";
|
||||||
|
require_once "server_files/classes/User.php";
|
||||||
|
require_once "server_files/classes/ValidationStatus.php";
|
||||||
|
require_once "server_files/services/mail.php";
|
||||||
|
require_once "server_files/utils.php";
|
||||||
|
require_once "server_files/model.php";
|
||||||
|
|
||||||
|
loadUserValues();
|
||||||
|
|
||||||
|
if (!isset($_GET["path"]))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$path = $_GET["path"];
|
||||||
|
|
||||||
|
$ROUTES = [];
|
||||||
|
|
||||||
|
# URL paths
|
||||||
|
|
||||||
|
$ROUTES["^(|accueil|index|accueil\.php|accueil\.html|accueil\.py|index\.php|index\.html|index\.py)$"] = ["server_files/controllers/index.php"];
|
||||||
|
$ROUTES["^ajouter_equipe$"] = ["server_files/controllers/ajouter_equipe.php"];
|
||||||
|
$ROUTES["^ajouter_organisateur$"] = ["server_files/controllers/ajouter_organisateur.php"];
|
||||||
|
$ROUTES["^ajouter_tournoi$"] = ["server_files/controllers/ajouter_tournoi.php"];
|
||||||
|
$ROUTES["^confirmer_mail/([a-z0-9]*)/?$"] = ["server_files/controllers/confirmer_mail.php", "token"];
|
||||||
|
$ROUTES["^connexion/(confirmation-mail)/?$"] = ["server_files/controllers/connexion.php", "confirmation-mail"];
|
||||||
|
$ROUTES["^connexion/(mdp_oublie)/?$"] = ["server_files/controllers/connexion.php", "mdp_oublie"];
|
||||||
|
$ROUTES["^connexion/(reinitialiser_mdp)/(.*)/?$"] = ["server_files/controllers/connexion.php", "reset_password", "token"];
|
||||||
|
$ROUTES["^connexion/?$"] = ["server_files/controllers/connexion.php"];
|
||||||
|
$ROUTES["^deconnexion/?$"] = ["server_files/controllers/deconnexion.php"];
|
||||||
|
$ROUTES["^equipe/([A-Z]{3})/?$"] = ["server_files/controllers/equipe.php", "trigram"];
|
||||||
|
$ROUTES["^file/([a-z0-9]{64})/?$"] = ["server_files/controllers/view_file.php", "file_id"];
|
||||||
|
$ROUTES["^informations/([0-9]*)/.*?$"] = ["server_files/controllers/informations.php", "id"];
|
||||||
|
$ROUTES["^inscription/?$"] = ["server_files/controllers/inscription.php"];
|
||||||
|
$ROUTES["^mon_compte/?$"] = ["server_files/controllers/mon_compte.php"];
|
||||||
|
$ROUTES["^mon_equipe/(modifier)/?$"] = ["server_files/controllers/mon_equipe.php", "modifier"];
|
||||||
|
$ROUTES["^mon_equipe/?$"] = ["server_files/controllers/mon_equipe.php"];
|
||||||
|
$ROUTES["^rejoindre_equipe/?$"] = ["server_files/controllers/rejoindre_equipe.php"];
|
||||||
|
$ROUTES["^solutions/?$"] = ["server_files/controllers/solutions.php"];
|
||||||
|
$ROUTES["^solutions_orga/?$"] = ["server_files/controllers/solutions_orga.php"];
|
||||||
|
$ROUTES["^syntheses/?$"] = ["server_files/controllers/syntheses.php"];
|
||||||
|
$ROUTES["^syntheses_orga/?$"] = ["server_files/controllers/syntheses_orga.php"];
|
||||||
|
$ROUTES["^tournoi/(.*)/(modifier)/?$"] = ["server_files/controllers/tournoi.php", "name", "modifier"];
|
||||||
|
$ROUTES["^tournoi/(.*)/?$"] = ["server_files/controllers/tournoi.php", "name"];
|
||||||
|
$ROUTES["^tournois/?$"] = ["server_files/controllers/tournois.php"];
|
||||||
|
|
||||||
|
# Assets files
|
||||||
|
|
||||||
|
$ROUTES["^favicon\.ico$"] = ["assets/favicon.ico", "image/x-icon"];
|
||||||
|
$ROUTES["^logo\.svg$"] = ["assets/logo.svg", "image/svg+xml"];
|
||||||
|
$ROUTES["^style\.css$"] = ["assets/style.css", "text/css"];
|
||||||
|
|
||||||
|
foreach ($ROUTES as $route => $file) {
|
||||||
|
if (preg_match('#' . $route . '#', $path, $matches)) {
|
||||||
|
for ($i = 1; $i < sizeof($file); ++$i)
|
||||||
|
$_GET[$file[$i]] = $matches[$i];
|
||||||
|
|
||||||
|
if (!preg_match("#php$#", $file[0])) {
|
||||||
|
header("Content-Type: " . $file[1]);
|
||||||
|
readfile($file[0]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
require $file[0];
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/404.php";
|
12
index.html
Normal file
12
index.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||||
|
<title>Erreur</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
Le mode <i>Rewrite</i> n'est pas activé.
|
||||||
|
</body>
|
||||||
|
</html>
|
12
server_files/403.php
Normal file
12
server_files/403.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "config.php";
|
||||||
|
require_once "views/header.php";
|
||||||
|
|
||||||
|
http_response_code(403);
|
||||||
|
|
||||||
|
echo "<h1>Vous n'êtes pas autorisé à accéder à cette page.</h1>";
|
||||||
|
|
||||||
|
require_once "views/footer.php";
|
||||||
|
|
||||||
|
exit();
|
12
server_files/404.php
Normal file
12
server_files/404.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "config.php";
|
||||||
|
require_once "views/header.php";
|
||||||
|
|
||||||
|
http_response_code(404);
|
||||||
|
|
||||||
|
echo "<h1>Cette page n'existe pas.</h1>";
|
||||||
|
|
||||||
|
require_once "views/footer.php";
|
||||||
|
|
||||||
|
exit();
|
318
server_files/classes/Document.php
Normal file
318
server_files/classes/Document.php
Normal file
@ -0,0 +1,318 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Document
|
||||||
|
{
|
||||||
|
private $file_id;
|
||||||
|
private $user_id;
|
||||||
|
private $team_id;
|
||||||
|
private $tournament_id;
|
||||||
|
private $type;
|
||||||
|
private $uploaded_at;
|
||||||
|
private $version;
|
||||||
|
|
||||||
|
private function __construct() {}
|
||||||
|
|
||||||
|
public static function fromId($id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `documents` WHERE `file_id` = ?;");
|
||||||
|
$req->execute([htmlspecialchars($id)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return self::fromData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromData($data)
|
||||||
|
{
|
||||||
|
$doc = new Document();
|
||||||
|
$doc->fill($data);
|
||||||
|
return $doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fill($data)
|
||||||
|
{
|
||||||
|
$this->file_id = $data["file_id"];
|
||||||
|
$this->user_id = $data["user"];
|
||||||
|
$this->team_id = $data["team"];
|
||||||
|
$this->tournament_id = $data["tournament"];
|
||||||
|
$this->type = DocumentType::fromName($data["type"]);
|
||||||
|
$this->uploaded_at = $data["uploaded_at"];
|
||||||
|
$this->version = isset($data["version"]) ? $data["version"] : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileId()
|
||||||
|
{
|
||||||
|
return $this->file_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserId()
|
||||||
|
{
|
||||||
|
return $this->user_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTeamId()
|
||||||
|
{
|
||||||
|
return $this->team_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTournamentId()
|
||||||
|
{
|
||||||
|
return $this->tournament_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUploadedAt()
|
||||||
|
{
|
||||||
|
return $this->uploaded_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVersion()
|
||||||
|
{
|
||||||
|
return $this->version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Solution
|
||||||
|
{
|
||||||
|
private $file_id;
|
||||||
|
private $team_id;
|
||||||
|
private $tournament_id;
|
||||||
|
private $problem;
|
||||||
|
private $uploaded_at;
|
||||||
|
private $version;
|
||||||
|
|
||||||
|
private function __construct() {}
|
||||||
|
|
||||||
|
public static function fromId($id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `solutions` WHERE `file_id` = ?;");
|
||||||
|
$req->execute([htmlspecialchars($id)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return self::fromData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromData($data)
|
||||||
|
{
|
||||||
|
$sol = new Solution();
|
||||||
|
$sol->fill($data);
|
||||||
|
return $sol;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fill($data)
|
||||||
|
{
|
||||||
|
$this->file_id = $data["file_id"];
|
||||||
|
$this->team_id = $data["team"];
|
||||||
|
$this->tournament_id = $data["tournament"];
|
||||||
|
$this->problem = $data["problem"];
|
||||||
|
$this->uploaded_at = $data["uploaded_at"];
|
||||||
|
$this->version = isset($data["version"]) ? $data["version"] : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileId()
|
||||||
|
{
|
||||||
|
return $this->file_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTeamId()
|
||||||
|
{
|
||||||
|
return $this->team_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTournamentId()
|
||||||
|
{
|
||||||
|
return $this->tournament_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProblem()
|
||||||
|
{
|
||||||
|
return $this->problem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUploadedAt()
|
||||||
|
{
|
||||||
|
return $this->uploaded_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVersion()
|
||||||
|
{
|
||||||
|
return $this->version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Synthesis
|
||||||
|
{
|
||||||
|
private $file_id;
|
||||||
|
private $team_id;
|
||||||
|
private $tournament_id;
|
||||||
|
private $dest;
|
||||||
|
private $uploaded_at;
|
||||||
|
private $version;
|
||||||
|
|
||||||
|
private function __construct() {}
|
||||||
|
|
||||||
|
public static function fromId($id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `syntheses` WHERE `file_id` = ?;");
|
||||||
|
$req->execute([htmlspecialchars($id)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return self::fromData($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromData($data)
|
||||||
|
{
|
||||||
|
$synthese = new Synthesis();
|
||||||
|
$synthese->fill($data);
|
||||||
|
return $synthese;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fill($data)
|
||||||
|
{
|
||||||
|
$this->file_id = $data["file_id"];
|
||||||
|
$this->team_id = $data["team"];
|
||||||
|
$this->tournament_id = $data["tournament"];
|
||||||
|
$this->dest = DestType::fromName($data["dest"]);
|
||||||
|
$this->uploaded_at = $data["uploaded_at"];
|
||||||
|
$this->version = isset($data["version"]) ? $data["version"] : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileId()
|
||||||
|
{
|
||||||
|
return $this->file_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTeamId()
|
||||||
|
{
|
||||||
|
return $this->team_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTournamentId()
|
||||||
|
{
|
||||||
|
return $this->tournament_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDest()
|
||||||
|
{
|
||||||
|
return $this->dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUploadedAt()
|
||||||
|
{
|
||||||
|
return $this->uploaded_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVersion()
|
||||||
|
{
|
||||||
|
return $this->version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DestType
|
||||||
|
{
|
||||||
|
const DEFENSEUR = 0;
|
||||||
|
const OPPOSANT = 1;
|
||||||
|
const RAPPORTEUR = 2;
|
||||||
|
|
||||||
|
public static function getTranslatedName($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::OPPOSANT:
|
||||||
|
return "Opposant";
|
||||||
|
case self::RAPPORTEUR:
|
||||||
|
return "Rapporteur";
|
||||||
|
default:
|
||||||
|
return "Défenseur";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::OPPOSANT:
|
||||||
|
return "OPPOSANT";
|
||||||
|
case self::RAPPORTEUR:
|
||||||
|
return "RAPPORTEUR";
|
||||||
|
default:
|
||||||
|
return "DEFENSEUR";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromName($name) {
|
||||||
|
switch ($name) {
|
||||||
|
case "OPPOSANT":
|
||||||
|
return self::OPPOSANT;
|
||||||
|
case "RAPPORTEUR":
|
||||||
|
return self::RAPPORTEUR;
|
||||||
|
default:
|
||||||
|
return self::DEFENSEUR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DocumentType
|
||||||
|
{
|
||||||
|
const PARENTAL_CONSENT = 0;
|
||||||
|
const PHOTO_CONSENT = 1;
|
||||||
|
const SANITARY_PLUG = 2;
|
||||||
|
const SOLUTION = 3;
|
||||||
|
const SYNTHESIS = 4;
|
||||||
|
|
||||||
|
public static function getTranslatedName($type) {
|
||||||
|
switch ($type) {
|
||||||
|
case self::PARENTAL_CONSENT:
|
||||||
|
return "Autorisation parentale";
|
||||||
|
case self::PHOTO_CONSENT:
|
||||||
|
return "Autorisation de droit à l'image";
|
||||||
|
case self::SANITARY_PLUG:
|
||||||
|
return "Fiche sanitaire";
|
||||||
|
case self::SOLUTION:
|
||||||
|
return "Solution";
|
||||||
|
default:
|
||||||
|
return "Note de synthèse";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName($type) {
|
||||||
|
switch ($type) {
|
||||||
|
case self::PARENTAL_CONSENT:
|
||||||
|
return "PARENTAL_CONSENT";
|
||||||
|
case self::PHOTO_CONSENT:
|
||||||
|
return "PHOTO_CONSENT";
|
||||||
|
case self::SANITARY_PLUG:
|
||||||
|
return "SANITARY_PLUG";
|
||||||
|
case self::SOLUTION:
|
||||||
|
return "SOLUTION";
|
||||||
|
default:
|
||||||
|
return "SYNTHESIS";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromName($name) {
|
||||||
|
switch ($name) {
|
||||||
|
case "PARENTAL_CONSENT":
|
||||||
|
return self::PARENTAL_CONSENT;
|
||||||
|
case "PHOTO_CONSENT":
|
||||||
|
return self::PHOTO_CONSENT;
|
||||||
|
case "SANITARY_PLUG":
|
||||||
|
return self::SANITARY_PLUG;
|
||||||
|
case "SOLUTION":
|
||||||
|
return self::SOLUTION;
|
||||||
|
default:
|
||||||
|
return self::SYNTHESIS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
server_files/classes/Role.php
Normal file
48
server_files/classes/Role.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Role
|
||||||
|
{
|
||||||
|
const PARTICIPANT = 0;
|
||||||
|
const ENCADRANT = 1;
|
||||||
|
const ORGANIZER = 2;
|
||||||
|
const ADMIN = 3;
|
||||||
|
|
||||||
|
public static function getTranslatedName($role) {
|
||||||
|
switch ($role) {
|
||||||
|
case self::ENCADRANT:
|
||||||
|
return "Encadrant";
|
||||||
|
case self::ORGANIZER:
|
||||||
|
return "Organisateur";
|
||||||
|
case self::ADMIN:
|
||||||
|
return "Administrateur";
|
||||||
|
default:
|
||||||
|
return "Participant";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName($role) {
|
||||||
|
switch ($role) {
|
||||||
|
case self::ENCADRANT:
|
||||||
|
return "ENCADRANT";
|
||||||
|
case self::ORGANIZER:
|
||||||
|
return "ORGANIZER";
|
||||||
|
case self::ADMIN:
|
||||||
|
return "ADMIN";
|
||||||
|
default:
|
||||||
|
return "PARTICIPANT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromName($name) {
|
||||||
|
switch ($name) {
|
||||||
|
case "ENCADRANT":
|
||||||
|
return self::ENCADRANT;
|
||||||
|
case "ORGANIZER":
|
||||||
|
return self::ORGANIZER;
|
||||||
|
case "ADMIN":
|
||||||
|
return self::ADMIN;
|
||||||
|
default:
|
||||||
|
return self::PARTICIPANT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
server_files/classes/SchoolClass.php
Normal file
41
server_files/classes/SchoolClass.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class SchoolClass
|
||||||
|
{
|
||||||
|
const SECONDE = 0;
|
||||||
|
const PREMIERE = 1;
|
||||||
|
const TERMINALE = 2;
|
||||||
|
|
||||||
|
public static function getTranslatedName($class) {
|
||||||
|
switch ($class) {
|
||||||
|
case self::SECONDE:
|
||||||
|
return "Seconde ou inférieur";
|
||||||
|
case self::PREMIERE:
|
||||||
|
return "Première";
|
||||||
|
default:
|
||||||
|
return "Terminale";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName($class) {
|
||||||
|
switch ($class) {
|
||||||
|
case self::SECONDE:
|
||||||
|
return "SECONDE";
|
||||||
|
case self::PREMIERE:
|
||||||
|
return "PREMIERE";
|
||||||
|
default:
|
||||||
|
return "TERMINALE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromName($name) {
|
||||||
|
switch ($name) {
|
||||||
|
case "SECONDE":
|
||||||
|
return self::SECONDE;
|
||||||
|
case "PREMIERE":
|
||||||
|
return self::PREMIERE;
|
||||||
|
default:
|
||||||
|
return self::TERMINALE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
185
server_files/classes/Team.php
Normal file
185
server_files/classes/Team.php
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Team
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $name;
|
||||||
|
private $trigram;
|
||||||
|
private $tournament;
|
||||||
|
private $encadrants;
|
||||||
|
private $participants;
|
||||||
|
private $inscription_date;
|
||||||
|
private $validation_status;
|
||||||
|
private $final_selection;
|
||||||
|
private $access_code;
|
||||||
|
private $year;
|
||||||
|
|
||||||
|
private function __construct() {}
|
||||||
|
|
||||||
|
public static function fromId($id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `teams` WHERE `id` = ?;");
|
||||||
|
$req->execute([htmlspecialchars($id)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$team = new Team();
|
||||||
|
$team->fill($data);
|
||||||
|
return $team;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromTrigram($trigram)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `teams` WHERE `trigram` = ? AND `year` = $YEAR;");
|
||||||
|
$req->execute([htmlspecialchars($trigram)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$team = new Team();
|
||||||
|
$team->fill($data);
|
||||||
|
return $team;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromAccessCode($access_code)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `teams` WHERE `access_code` = ? AND `year` = $YEAR;");
|
||||||
|
$req->execute([htmlspecialchars($access_code)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$team = new Team();
|
||||||
|
$team->fill($data);
|
||||||
|
return $team;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fill($data)
|
||||||
|
{
|
||||||
|
$this->id = $data["id"];
|
||||||
|
$this->name = $data["name"];
|
||||||
|
$this->trigram = $data["trigram"];
|
||||||
|
$this->tournament = $data["tournament"];
|
||||||
|
$this->encadrants = [$data["encadrant_1"], $data["encadrant_2"]];
|
||||||
|
$this->participants = [$data["participant_1"], $data["participant_2"], $data["participant_3"], $data["participant_4"], $data["participant_5"], $data["participant_6"]];
|
||||||
|
$this->inscription_date = $data["inscription_date"];
|
||||||
|
$this->validation_status = ValidationStatus::fromName($data["validation_status"]);
|
||||||
|
$this->final_selection = $data["final_selection"] == true;
|
||||||
|
$this->access_code = $data["access_code"];
|
||||||
|
$this->year = $data["year"];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->name = $name;
|
||||||
|
$DB->prepare("UPDATE `teams` SET `name` = ? WHERE `id` = ?;")->execute([$name, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTrigram()
|
||||||
|
{
|
||||||
|
return $this->trigram;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTrigram($trigram)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->trigram = $trigram;
|
||||||
|
$DB->prepare("UPDATE `teams` SET `trigram` = ? WHERE `id` = ?;")->execute([$trigram, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTournamentId()
|
||||||
|
{
|
||||||
|
return $this->tournament;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTournamentId($tournament)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->tournament = $tournament;
|
||||||
|
$DB->prepare("UPDATE `teams` SET `tournament` = ? WHERE `id` = ?;")->execute([$tournament, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEncadrants()
|
||||||
|
{
|
||||||
|
return $this->encadrants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEncadrant($i, $encadrant)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->encadrants[$i - 1] = $encadrant;
|
||||||
|
/** @noinspection SqlResolve */
|
||||||
|
$DB->prepare("UPDATE `teams` SET `encadrant_$i` = ? WHERE `id` = ?;")->execute([$encadrant, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getParticipants()
|
||||||
|
{
|
||||||
|
return $this->participants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setParticipant($i, $participant)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->participants[$i - 1] = $participant;
|
||||||
|
/** @noinspection SqlResolve */
|
||||||
|
$DB->prepare("UPDATE `teams` SET `participant_$i` = ? WHERE `id` = ?;")->execute([$participant, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInscriptionDate()
|
||||||
|
{
|
||||||
|
return $this->inscription_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValidationStatus()
|
||||||
|
{
|
||||||
|
return $this->validation_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValidationStatus($status)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->validation_status = $status;
|
||||||
|
/** @noinspection PhpUndefinedMethodInspection */
|
||||||
|
$DB->prepare("UPDATE `teams` SET `validation_status` = ? WHERE `id` = ?;")->execute([ValidationStatus::getName($status), $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSelectedForFinal()
|
||||||
|
{
|
||||||
|
return $this->final_selection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectForFinal($selected)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->final_selection = $selected;
|
||||||
|
$DB->prepare("UPDATE `teams` SET `final_selection` = ? WHERE `id` = ?;")->execute([$selected, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAccessCode()
|
||||||
|
{
|
||||||
|
return $this->access_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getYear()
|
||||||
|
{
|
||||||
|
return $this->year;
|
||||||
|
}
|
||||||
|
}
|
357
server_files/classes/Tournament.php
Normal file
357
server_files/classes/Tournament.php
Normal file
@ -0,0 +1,357 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/** @noinspection SqlAggregates */
|
||||||
|
class Tournament
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $name;
|
||||||
|
private $size;
|
||||||
|
private $place;
|
||||||
|
private $price;
|
||||||
|
private $description;
|
||||||
|
private $date_start, $date_end;
|
||||||
|
private $date_inscription;
|
||||||
|
private $date_solutions;
|
||||||
|
private $date_syntheses;
|
||||||
|
private $final;
|
||||||
|
private $organizers = [];
|
||||||
|
private $year;
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromId($id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `tournaments` WHERE `id` = ?;");
|
||||||
|
$req->execute([htmlspecialchars($id)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$tournament = new Tournament();
|
||||||
|
$tournament->fill($data);
|
||||||
|
return $tournament;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromName($name)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `tournaments` WHERE `name` = ? AND `year` = $YEAR;");
|
||||||
|
$req->execute([htmlspecialchars($name)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$tournament = new Tournament();
|
||||||
|
$tournament->fill($data);
|
||||||
|
return $tournament;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFinalTournament()
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
$req = $DB->query("SELECT * FROM `tournaments` WHERE `final` AND `year` = $YEAR;");
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$tournament = new Tournament();
|
||||||
|
$tournament->fill($data);
|
||||||
|
return $tournament;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAllTournaments($include_final = true, $only_future = false)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
$sql = "SELECT * FROM `tournaments` WHERE ";
|
||||||
|
if (!$include_final)
|
||||||
|
$sql .= "`final` = 0 AND ";
|
||||||
|
if ($only_future)
|
||||||
|
$sql .= "`date_start` > CURRENT_DATE AND ";
|
||||||
|
$sql .= "`year` = $YEAR ORDER BY `date_start`, `name`;";
|
||||||
|
$req = $DB->query($sql);
|
||||||
|
|
||||||
|
$tournaments = [];
|
||||||
|
|
||||||
|
while (($data = $req->fetch()) !== false) {
|
||||||
|
$tournament = new Tournament();
|
||||||
|
$tournament->fill($data);
|
||||||
|
$tournaments[] = $tournament;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tournaments;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fill($data)
|
||||||
|
{
|
||||||
|
$this->id = $data["id"];
|
||||||
|
$this->name = $data["name"];
|
||||||
|
$this->size = $data["size"];
|
||||||
|
$this->place = $data["place"];
|
||||||
|
$this->price = $data["price"];
|
||||||
|
$this->description = $data["description"];
|
||||||
|
$this->date_start = $data["date_start"];
|
||||||
|
$this->date_end = $data["date_end"];
|
||||||
|
$this->date_inscription = $data["date_inscription"];
|
||||||
|
$this->date_solutions = $data["date_solutions"];
|
||||||
|
$this->date_syntheses = $data["date_syntheses"];
|
||||||
|
$this->final = $data["final"] == true;
|
||||||
|
$this->year = $data["year"];
|
||||||
|
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->prepare("SELECT `organizer` FROM `organizers` WHERE `tournament` = ?;");
|
||||||
|
$req->execute([$this->id]);
|
||||||
|
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
$this->organizers[] = User::fromId($data["organizer"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->name = $name;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `name` = ? WHERE `id` = ?;")->execute([$name, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSize()
|
||||||
|
{
|
||||||
|
return $this->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSize($size)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->size = $size;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `size` = ? WHERE `id` = ?;")->execute([$size, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPlace()
|
||||||
|
{
|
||||||
|
return $this->place;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlace($place)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->place = $place;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `place` = ? WHERE `id` = ?;")->execute([$place, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrice()
|
||||||
|
{
|
||||||
|
return $this->price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrice($price)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->price = $price;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `price` = ? WHERE `id` = ?;")->execute([$price, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDescription($desc)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->description = $desc;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `description` = ? WHERE `id` = ?;")->execute([$desc, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStartDate()
|
||||||
|
{
|
||||||
|
return $this->date_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStartDate($date)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->date_start = $date;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `date_start` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEndDate()
|
||||||
|
{
|
||||||
|
return $this->date_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEndDate($date)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->date_end = $date;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `date_end` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInscriptionDate()
|
||||||
|
{
|
||||||
|
return $this->date_inscription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setInscriptionDate($date)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->date_inscription = $date;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `date_inscription` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSolutionsDate()
|
||||||
|
{
|
||||||
|
return $this->date_solutions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSolutionsDate($date)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->date_solutions = $date;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `date_solutions` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSynthesesDate()
|
||||||
|
{
|
||||||
|
return $this->date_syntheses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSynthesesDate($date)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->date_syntheses = $date;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `date_syntheses` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isFinal()
|
||||||
|
{
|
||||||
|
return $this->final;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFinal($final)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->final = $final;
|
||||||
|
$DB->prepare("UPDATE `tournaments` SET `final` = ? WHERE `id` = ?;")->execute([$final, $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllTeams()
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
if ($this->final)
|
||||||
|
$req = $DB->query("SELECT `id` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
|
||||||
|
else
|
||||||
|
$req = $DB->query("SELECT `id` FROM `teams` WHERE `tournament` = $this->id AND `year` = $YEAR;");
|
||||||
|
|
||||||
|
$teams = [];
|
||||||
|
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
$teams[] = Team::fromId($data["id"]);
|
||||||
|
|
||||||
|
return $teams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrganizers()
|
||||||
|
{
|
||||||
|
return $this->organizers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function organize($user_id)
|
||||||
|
{
|
||||||
|
foreach ($this->organizers as $organizer) {
|
||||||
|
if ($organizer->getId() == $user_id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addOrganizer(User $user)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$this->organizers[] = $user;
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
|
||||||
|
$req->execute([$user->getId(), $this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearOrganizers()
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$this->organizers = [];
|
||||||
|
|
||||||
|
$req = $DB->prepare("DELETE FROM `organizers` WHERE `tournament` = ?;");
|
||||||
|
$req->execute([$this->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getYear()
|
||||||
|
{
|
||||||
|
return $this->year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllDocuments($team_id = -1)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
||||||
|
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `team`, `type`, `user`) `t2` "
|
||||||
|
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||||
|
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`type`;");
|
||||||
|
|
||||||
|
$docs = [];
|
||||||
|
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
$docs[] = Document::fromData($data);
|
||||||
|
|
||||||
|
return $docs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllSolutions($team_id = -1)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$req = $DB->query("SELECT * FROM `solutions` AS `t1` "
|
||||||
|
. "INNER JOIN (SELECT `team`, `problem`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `solutions` GROUP BY `tournament`, `team`, `problem`) `t2` "
|
||||||
|
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`problem` = `t2`.`problem` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||||
|
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`problem`;");
|
||||||
|
|
||||||
|
$sols = [];
|
||||||
|
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
$sols[] = Solution::fromData($data);
|
||||||
|
|
||||||
|
return $sols;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllSyntheses($team_id = -1)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$req = $DB->query("SELECT * FROM `syntheses` AS `t1` "
|
||||||
|
. "INNER JOIN (SELECT `team`, `dest`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `syntheses` GROUP BY `tournament`, `team`, `dest`) `t2` "
|
||||||
|
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`dest` = `t2`.`dest` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||||
|
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $this->id " . ($team_id == -1 ? "" : "AND `t1`.`team` = $team_id") . " ORDER BY `t1`.`team`, `t1`.`dest`;");
|
||||||
|
|
||||||
|
$syntheses = [];
|
||||||
|
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
$syntheses[] = Synthesis::fromData($data);
|
||||||
|
|
||||||
|
return $syntheses;
|
||||||
|
}
|
||||||
|
}
|
391
server_files/classes/User.php
Normal file
391
server_files/classes/User.php
Normal file
@ -0,0 +1,391 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class User
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
public $email;
|
||||||
|
private $pwd_hash;
|
||||||
|
public $surname;
|
||||||
|
public $first_name;
|
||||||
|
public $birth_date;
|
||||||
|
public $gender;
|
||||||
|
public $address;
|
||||||
|
public $postal_code;
|
||||||
|
public $city;
|
||||||
|
public $country;
|
||||||
|
public $phone_number;
|
||||||
|
public $school;
|
||||||
|
public $class;
|
||||||
|
public $responsible_name;
|
||||||
|
public $responsible_phone;
|
||||||
|
public $responsible_email;
|
||||||
|
public $description;
|
||||||
|
private $role;
|
||||||
|
private $team_id;
|
||||||
|
private $year;
|
||||||
|
private $confirm_email;
|
||||||
|
private $forgotten_password;
|
||||||
|
private $inscription_date;
|
||||||
|
|
||||||
|
private function __construct() {}
|
||||||
|
|
||||||
|
public static function fromId($id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `users` WHERE `id` = ?;");
|
||||||
|
$req->execute([htmlspecialchars($id)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$user = new User();
|
||||||
|
$user->fill($data);
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromEmail($email)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
$req = $DB->prepare("SELECT * FROM `users` WHERE `email` = ? AND `year` = $YEAR;");
|
||||||
|
$req->execute([htmlspecialchars($email)]);
|
||||||
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$user = new User();
|
||||||
|
$user->fill($data);
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fill($data)
|
||||||
|
{
|
||||||
|
$this->id = $data["id"];
|
||||||
|
$this->email = $data["email"];
|
||||||
|
$this->pwd_hash = $data["pwd_hash"];
|
||||||
|
$this->surname = $data["surname"];
|
||||||
|
$this->first_name = $data["first_name"];
|
||||||
|
$this->birth_date = $data["birth_date"];
|
||||||
|
$this->gender = $data["gender"];
|
||||||
|
$this->address = $data["address"];
|
||||||
|
$this->postal_code = $data["postal_code"];
|
||||||
|
$this->city = $data["city"];
|
||||||
|
$this->country = $data["country"];
|
||||||
|
$this->phone_number = $data["phone_number"];
|
||||||
|
$this->school = $data["school"];
|
||||||
|
$this->class = SchoolClass::fromName($data["class"]);
|
||||||
|
$this->responsible_name = $data["responsible_name"];
|
||||||
|
$this->responsible_phone = $data["responsible_phone"];
|
||||||
|
$this->responsible_email = $data["responsible_email"];
|
||||||
|
$this->description = $data["description"];
|
||||||
|
$this->role = Role::fromName($data["role"]);
|
||||||
|
$this->team_id = $data["team_id"];
|
||||||
|
$this->year = $data["year"];
|
||||||
|
$this->confirm_email = $data["confirm_email"];
|
||||||
|
$this->forgotten_password = $data["forgotten_password"];
|
||||||
|
$this->inscription_date = $data["inscription_date"];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail()
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmail($email)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->email = $email;
|
||||||
|
$DB->prepare("UPDATE `users` SET `email` = ? WHERE `id` = ?;")->execute([$email, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkPassword($password)
|
||||||
|
{
|
||||||
|
return password_verify($password, $this->pwd_hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPassword($password)
|
||||||
|
{
|
||||||
|
$this->setPasswordHash(password_hash($password, PASSWORD_BCRYPT));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setPasswordHash($password_hash)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->pwd_hash = $password_hash;
|
||||||
|
$DB->prepare("UPDATE `users` SET `pwd_hash` = ? WHERE `id` = ?;")->execute([$password_hash, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSurname()
|
||||||
|
{
|
||||||
|
return $this->surname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSurname($surname)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->surname = $surname;
|
||||||
|
$DB->prepare("UPDATE `users` SET `surname` = ? WHERE `id` = ?;")->execute([$surname, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFirstName()
|
||||||
|
{
|
||||||
|
return $this->first_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFirstName($first_name)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->first_name = $first_name;
|
||||||
|
$DB->prepare("UPDATE `users` SET `first_name` = ? WHERE `id` = ?;")->execute([$first_name, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBirthDate()
|
||||||
|
{
|
||||||
|
return $this->birth_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBirthDate($birth_date)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->birth_date = $birth_date;
|
||||||
|
$DB->prepare("UPDATE `users` SET `birth_date` = ? WHERE `id` = ?;")->execute([$birth_date, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGender()
|
||||||
|
{
|
||||||
|
return $this->gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGender($gender)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->gender = $gender;
|
||||||
|
$DB->prepare("UPDATE `users` SET `gender` = ? WHERE `id` = ?;")->execute([$gender, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAddress()
|
||||||
|
{
|
||||||
|
return $this->address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAddress($address)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->address = $address;
|
||||||
|
$DB->prepare("UPDATE `users` SET `address` = ? WHERE `id` = ?;")->execute([$address, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPostalCode()
|
||||||
|
{
|
||||||
|
return $this->postal_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPostalCode($postal_code)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->postal_code = $postal_code;
|
||||||
|
$DB->prepare("UPDATE `users` SET `postal_code` = ? WHERE `id` = ?;")->execute([$postal_code, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCity()
|
||||||
|
{
|
||||||
|
return $this->city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCity($city)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->city = $city;
|
||||||
|
$DB->prepare("UPDATE `users` SET `city` = ? WHERE `id` = ?;")->execute([$city, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCountry()
|
||||||
|
{
|
||||||
|
return $this->country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCountry($country)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->country = $country;
|
||||||
|
$DB->prepare("UPDATE `users` SET `country` = ? WHERE `id` = ?;")->execute([$country, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPhoneNumber()
|
||||||
|
{
|
||||||
|
return $this->phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPhoneNumber($phone_number)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->phone_number = $phone_number;
|
||||||
|
$DB->prepare("UPDATE `users` SET `phone_number` = ? WHERE `id` = ?;")->execute([$phone_number, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSchool()
|
||||||
|
{
|
||||||
|
return $this->school;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSchool($school)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->school = $school;
|
||||||
|
$DB->prepare("UPDATE `users` SET `school` = ? WHERE `id` = ?;")->execute([SchoolClass::getName($school), $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClass()
|
||||||
|
{
|
||||||
|
return $this->class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setClass($class)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->class = $class;
|
||||||
|
$DB->prepare("UPDATE `users` SET `class` = ? WHERE `id` = ?;")->execute([SchoolClass::getName($class), $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResponsibleName()
|
||||||
|
{
|
||||||
|
return $this->responsible_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setResponsibleName($responsible_name)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->responsible_name = $responsible_name;
|
||||||
|
$DB->prepare("UPDATE `users` SET `responsible_name` = ? WHERE `id` = ?;")->execute([$responsible_name, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResponsiblePhone()
|
||||||
|
{
|
||||||
|
return $this->responsible_phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setResponsiblePhone($responsible_phone)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->responsible_phone = $responsible_phone;
|
||||||
|
$DB->prepare("UPDATE `users` SET `responsible_phone` = ? WHERE `id` = ?;")->execute([$responsible_phone, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResponsibleEmail()
|
||||||
|
{
|
||||||
|
return $this->responsible_email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setResponsibleEmail($responsible_email)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->responsible_email = $responsible_email;
|
||||||
|
$DB->prepare("UPDATE `users` SET `responsible_email` = ? WHERE `id` = ?;")->execute([$responsible_email, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDescription($desc)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->description = $desc;
|
||||||
|
$DB->prepare("UPDATE `users` SET `description` = ? WHERE `id` = ?;")->execute([$desc, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRole()
|
||||||
|
{
|
||||||
|
return $this->role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRole($role)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->role = $role;
|
||||||
|
/** @noinspection PhpUndefinedMethodInspection */
|
||||||
|
$DB->prepare("UPDATE `users` SET `role` = ? WHERE `id` = ?;")->execute([Role::getName($role), $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTeamId()
|
||||||
|
{
|
||||||
|
return $this->team_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTeamId($team_id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->team_id = $team_id;
|
||||||
|
$DB->prepare("UPDATE `users` SET `team_id` = ? WHERE `id` = ?;")->execute([$team_id, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getYear()
|
||||||
|
{
|
||||||
|
return $this->year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getConfirmEmailToken()
|
||||||
|
{
|
||||||
|
return $this->confirm_email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setConfirmEmailToken($token)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->confirm_email = $token;
|
||||||
|
$DB->prepare("UPDATE `users` SET `confirm_email` = ? WHERE `id` = ?;")->execute([$token, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getForgottenPasswordToken()
|
||||||
|
{
|
||||||
|
return $this->forgotten_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setForgottenPasswordToken($token)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$this->forgotten_password = $token;
|
||||||
|
$DB->prepare("UPDATE `users` SET `forgotten_password` = ? WHERE `id` = ?;")->execute([$token, $this->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInscriptionDate()
|
||||||
|
{
|
||||||
|
return $this->inscription_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllDocuments($tournament_id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->query("SELECT * FROM `documents` AS `t1` "
|
||||||
|
. "INNER JOIN (SELECT `user`, `type`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `documents` GROUP BY `tournament`, `type`, `user`) `t2` "
|
||||||
|
. "ON `t1`.`user` = `t2`.`user` AND `t1`.`type` = `t2`.`type` AND `t1`.`tournament` = `t2`.`tournament` "
|
||||||
|
. "WHERE `t1`.`uploaded_at` = `t2`.`last_upload` AND `t1`.`tournament` = $tournament_id AND `t1`.`user` = $this->id ORDER BY `t1`.`type`;");
|
||||||
|
|
||||||
|
$docs = [];
|
||||||
|
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
$docs[] = Document::fromData($data);
|
||||||
|
|
||||||
|
return $docs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrganizedTournaments()
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$req = $DB->query("SELECT `tournament` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $this->id ORDER BY `date_start`, `name`;");
|
||||||
|
|
||||||
|
$tournaments = [];
|
||||||
|
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
$tournaments[] = Tournament::fromId($data["tournament"]);
|
||||||
|
|
||||||
|
return $tournaments;
|
||||||
|
}
|
||||||
|
}
|
41
server_files/classes/ValidationStatus.php
Normal file
41
server_files/classes/ValidationStatus.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ValidationStatus
|
||||||
|
{
|
||||||
|
const NOT_READY = 0;
|
||||||
|
const WAITING = 1;
|
||||||
|
const VALIDATED = 2;
|
||||||
|
|
||||||
|
public static function getTranslatedName($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::WAITING:
|
||||||
|
return "En attente de validation";
|
||||||
|
case self::VALIDATED:
|
||||||
|
return "Inscription validée";
|
||||||
|
default:
|
||||||
|
return "Inscription non terminée";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName($status) {
|
||||||
|
switch ($status) {
|
||||||
|
case self::WAITING:
|
||||||
|
return "WAITING";
|
||||||
|
case self::VALIDATED:
|
||||||
|
return "VALIDATED";
|
||||||
|
default:
|
||||||
|
return "NOT_READY";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromName($name) {
|
||||||
|
switch ($name) {
|
||||||
|
case "WAITING":
|
||||||
|
return self::WAITING;
|
||||||
|
case "VALIDATED":
|
||||||
|
return self::VALIDATED;
|
||||||
|
default:
|
||||||
|
return self::NOT_READY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
server_files/config.php
Normal file
28
server_files/config.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Config options
|
||||||
|
*/
|
||||||
|
|
||||||
|
$YEAR = $_ENV["TFJM_YEAR"];
|
||||||
|
$URL_BASE = $_ENV["TFJM_URL_BASE"];
|
||||||
|
$LOCAL_PATH = $_ENV["TFJM_LOCAL_PATH"];
|
||||||
|
$MAIL_DOMAIN = $_ENV["TFJM_MAIL_DOMAIN"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DB infos
|
||||||
|
*/
|
||||||
|
|
||||||
|
$DB_HOST = $_ENV["TFJM_DB_HOST"];
|
||||||
|
$DB_NAME = $_ENV["TFJM_DB_NAME"];
|
||||||
|
$DB_USER = $_ENV["TFJM_DB_USER"];
|
||||||
|
$DB_PASSWORD = $_ENV["TFJM_DB_PASSWORD"];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$DB = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME;charset=utf8", "$DB_USER", "$DB_PASSWORD", array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
||||||
|
}
|
||||||
|
catch (Exception $ex) {
|
||||||
|
die("Erreur lors de la connexion à la base de données : " . $ex->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
setlocale(LC_ALL, "fr_FR.utf8");
|
63
server_files/controllers/ajouter_equipe.php
Normal file
63
server_files/controllers/ajouter_equipe.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["role"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';");
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["submitted"])) {
|
||||||
|
$new_team = new NewTeam($_POST);
|
||||||
|
try {
|
||||||
|
$new_team->makeVerifications();
|
||||||
|
$new_team->register();
|
||||||
|
}
|
||||||
|
catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NewTeam {
|
||||||
|
public $name;
|
||||||
|
public $trigram;
|
||||||
|
public $tournament_id;
|
||||||
|
public $tournament;
|
||||||
|
public $access_code;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications() {
|
||||||
|
ensure($_SESSION["team"] == null, "Vous êtes déjà dans une équipe.");
|
||||||
|
ensure($this->name != null && $this->name != "", "Vous devez spécifier un nom d'équipe.");
|
||||||
|
ensure(preg_match("#^[A-Z]{3}$#", $this->trigram), "Le trigramme entré n'est pas valide.");
|
||||||
|
ensure(!teamExists($this->name), "Une équipe existe déjà avec ce nom.");
|
||||||
|
ensure(!trigramExists($this->trigram), "Une équipe a déjà choisi ce trigramme.");
|
||||||
|
$this->tournament = Tournament::fromId($this->tournament_id);
|
||||||
|
ensure($this->tournament != null, "Le tournoi spécifié n'existe pas.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register() {
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$this->access_code = genRandomPhrase(6);
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `teams` (`name`, `trigram`, `tournament`, `encadrant_1`, `participant_1`, `validation_status`, `access_code`, `year`)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
|
$req->execute([$this->name, $this->trigram, $this->tournament_id, $_SESSION["role"] == Role::ENCADRANT ? $_SESSION["user_id"] : NULL,
|
||||||
|
$_SESSION["role"] == Role::PARTICIPANT ? $_SESSION["user_id"] : NULL, ValidationStatus::NOT_READY, $this->access_code, $YEAR]);
|
||||||
|
|
||||||
|
$_SESSION["team"] = Team::fromTrigram($this->trigram);
|
||||||
|
$_SESSION["user"]->setTeamId($_SESSION["team"]->getId());
|
||||||
|
|
||||||
|
Mailer::sendAddTeamMail($_SESSION["user"], $_SESSION["team"], $this->tournament);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/ajouter_equipe.php";
|
57
server_files/controllers/ajouter_organisateur.php
Normal file
57
server_files/controllers/ajouter_organisateur.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["submitted"])) {
|
||||||
|
$orga = new NewOrganizer($_POST);
|
||||||
|
try {
|
||||||
|
$orga->makeVerifications();
|
||||||
|
$orga->register();
|
||||||
|
}
|
||||||
|
catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NewOrganizer {
|
||||||
|
public $surname;
|
||||||
|
public $first_name;
|
||||||
|
public $email;
|
||||||
|
public $admin;
|
||||||
|
public $password;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
ensure($this->surname != null && $this->surname != "", "Le nom est invalide.");
|
||||||
|
ensure($this->first_name != null && $this->first_name != "", "Le prénom est invalide.");
|
||||||
|
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse e-mail est invalide.");
|
||||||
|
$this->email = strtolower($this->email);
|
||||||
|
ensure(!userExists($this->email), "Cette adresse e-mail est déjà utilisée.");
|
||||||
|
$this->admin = $this->admin == "on" ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register() {
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$this->password = genRandomPhrase(16, true);
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `surname`, `first_name`, `role`, `year`)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?);");
|
||||||
|
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->surname, $this->first_name, $this->admin ? "ADMIN" : "ORGANIZER", $YEAR]);
|
||||||
|
|
||||||
|
Mailer::sendAddOrganizerMail($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/ajouter_organisateur.php";
|
104
server_files/controllers/ajouter_tournoi.php
Normal file
104
server_files/controllers/ajouter_tournoi.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["submitted"])) {
|
||||||
|
$tournament = new NewTournament($_POST);
|
||||||
|
try {
|
||||||
|
$tournament->makeVerifications();
|
||||||
|
$tournament->register();
|
||||||
|
}
|
||||||
|
catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NewTournament {
|
||||||
|
public $name;
|
||||||
|
public $organizers;
|
||||||
|
public $size;
|
||||||
|
public $place;
|
||||||
|
public $price;
|
||||||
|
public $date_start;
|
||||||
|
public $date_end;
|
||||||
|
public $date_inscription;
|
||||||
|
public $time_inscription;
|
||||||
|
public $date_solutions;
|
||||||
|
public $time_solutions;
|
||||||
|
public $date_syntheses;
|
||||||
|
public $time_syntheses;
|
||||||
|
public $description;
|
||||||
|
public $final;
|
||||||
|
public $tournament;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = ($key == "organizers" ? $value : htmlspecialchars($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $FINAL;
|
||||||
|
|
||||||
|
ensure($this->name != null && $this->name != "", "Le nom est invalide.");
|
||||||
|
ensure(!tournamentExists($this->name), "Un tournoi existe déjà avec ce nom.");
|
||||||
|
ensure(sizeof($this->organizers) > 0, "Aucun organisateur n'a été choisi.");
|
||||||
|
|
||||||
|
$orgas = [];
|
||||||
|
foreach ($this->organizers as $orga_id) {
|
||||||
|
$orga = User::fromId($orga_id);
|
||||||
|
ensure($orga != null, "Un organisateur spécifié n'existe pas.");
|
||||||
|
ensure($orga->getRole() == Role::ORGANIZER || $orga->getRole() == Role::ADMIN, "Une personne indiquée ne peut pas organiser de tournoi.");
|
||||||
|
$orgas[] = $orga;
|
||||||
|
}
|
||||||
|
$this->organizers = $orgas;
|
||||||
|
|
||||||
|
ensure(preg_match("#[0-9]*#", $this->size), "Le nombre d'équipes indiqué n'est pas un nombre valide.");
|
||||||
|
$this->size = intval($this->size);
|
||||||
|
ensure($this->size >= 3 && $this->size <= 15, "Un tournoi doit avoir au moins 3 et au plus 15 équipes.");
|
||||||
|
|
||||||
|
ensure(preg_match("#[0-9]*#", $this->price), "Le tarif pour les participants n'est pas un entier valide.");
|
||||||
|
$this->price = intval($this->price);
|
||||||
|
ensure($this->price >= 0, "Le TFJM² ne va pas payer les élèves pour venir.");
|
||||||
|
ensure($this->price <= 50, "Soyons raisonnable sur le prix.");
|
||||||
|
|
||||||
|
ensure(dateWellFormed($this->date_start), "La date de début n'est pas valide.");
|
||||||
|
ensure(dateWellFormed($this->date_end), "La date de fin n'est pas valide.");
|
||||||
|
ensure(dateWellFormed($this->date_inscription . " " . $this->time_inscription), "La date de clôture des inscriptions n'est pas valide.");
|
||||||
|
ensure(dateWellFormed($this->date_solutions . " " . $this->time_solutions), "La date limite de remise des solutions n'est pas valide.");
|
||||||
|
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse n'est pas valide.");
|
||||||
|
|
||||||
|
$this->final = $this->final ? 1 : 0;
|
||||||
|
|
||||||
|
ensure(!$this->final || $FINAL == NULL, "Une finale nationale est déjà enregistrée.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `tournaments` (`name`, `size`, `place`, `price`, `description`,
|
||||||
|
`date_start`, `date_end`, `date_inscription`, `date_solutions`, `date_syntheses`, `final`, `year`)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
|
$req->execute([$this->name, $this->size, $this->place, $this->price, $this->description, $this->date_start, $this->date_end,
|
||||||
|
"$this->date_inscription $this->time_inscription", "$this->date_solutions $this->time_solutions", "$this->date_syntheses $this->time_syntheses", $this->final ? 1 : 0, $YEAR]);
|
||||||
|
|
||||||
|
$this->tournament = Tournament::fromName($this->name);
|
||||||
|
|
||||||
|
/** @var User $organizer */
|
||||||
|
foreach ($this->organizers as $organizer) {
|
||||||
|
$this->tournament->addOrganizer($organizer);
|
||||||
|
Mailer::sendAddOrganizerForTournamentMail($organizer, $this->tournament);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/ajouter_tournoi.php";
|
19
server_files/controllers/confirmer_mail.php
Normal file
19
server_files/controllers/confirmer_mail.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$token = $_GET["token"];
|
||||||
|
|
||||||
|
if (isset($token)) {
|
||||||
|
$result = $DB->query("SELECT `email` FROM `users` WHERE `confirm_email` = '$token' AND `year` = '$YEAR';");
|
||||||
|
if (($data = $result->fetch()) === FALSE)
|
||||||
|
$error_message = "Le jeton est invalide. Votre compte est peut-être déjà validé ?";
|
||||||
|
else {
|
||||||
|
$DB->exec("UPDATE `users` SET `confirm_email` = NULL WHERE `confirm_email` = '$token';");
|
||||||
|
$error_message = "Votre adresse mail a été validée ! Vous pouvez désormais vous connecter.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$error_message = "Il n'y a pas de compte à valider !";
|
||||||
|
}
|
||||||
|
require_once "server_files/views/header.php";
|
||||||
|
echo "<h2>$error_message</h2>";
|
||||||
|
require_once "server_files/views/footer.php";
|
170
server_files/controllers/connexion.php
Normal file
170
server_files/controllers/connexion.php
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["submitted"]) && !isset($_SESSION["user_id"])) {
|
||||||
|
$logging_in_user = new LoggingInUser($_POST);
|
||||||
|
try {
|
||||||
|
$logging_in_user->makeVerifications();
|
||||||
|
$logging_in_user->login();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["forgotten_password"]) && !isset($_SESSION["user_id"])) {
|
||||||
|
$recuperate_account = new RecuperateAccount($_POST);
|
||||||
|
try {
|
||||||
|
$recuperate_account->makeVerifications();
|
||||||
|
$recuperate_account->recuperateAccount();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["reset_password"]) && isset($_GET["token"]) && !isset($_SESSION["user_id"])) {
|
||||||
|
$reset_password = new ResetPassword($_GET, $_POST);
|
||||||
|
try {
|
||||||
|
$reset_password->makeVerifications();
|
||||||
|
if (isset($_POST["password"]))
|
||||||
|
$reset_password->resetPassword();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["confirmation-mail"]) && !isset($_SESSION["user_id"]))
|
||||||
|
sendConfirmEmail();
|
||||||
|
|
||||||
|
class LoggingInUser
|
||||||
|
{
|
||||||
|
public $email;
|
||||||
|
/** @var User $user */
|
||||||
|
public $user;
|
||||||
|
private $password;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $URL_BASE;
|
||||||
|
|
||||||
|
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse email est invalide.");
|
||||||
|
$this->user = User::fromEmail($this->email);
|
||||||
|
ensure($this->user != null, "Le compte n'existe pas.");
|
||||||
|
ensure($this->user->checkPassword($this->password), "Le mot de passe est incorrect.");
|
||||||
|
if ($this->user->getConfirmEmailToken() != null) {
|
||||||
|
$_SESSION["confirm_email"] = $this->email;
|
||||||
|
throw new AssertionError("L'adresse mail n'a pas été validée. Veuillez vérifier votre boîte mail (surtout vos spams). "
|
||||||
|
. "<a href=\"$URL_BASE/connexion/confirmation-mail\">Cliquez ici pour renvoyer le mail de confirmation</a>.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login()
|
||||||
|
{
|
||||||
|
$_SESSION["user_id"] = $this->user->getId();
|
||||||
|
loadUserValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RecuperateAccount
|
||||||
|
{
|
||||||
|
public $email;
|
||||||
|
/** @var User $user */
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse email est invalide.");
|
||||||
|
$this->user = User::fromEmail($this->email);
|
||||||
|
ensure($this->user != null, "Le compte n'existe pas.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function recuperateAccount()
|
||||||
|
{
|
||||||
|
$token = genRandomPhrase(64);
|
||||||
|
$this->user->setForgottenPasswordToken($token);
|
||||||
|
Mailer::sendForgottenPasswordProcedureMail($this->user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ResetPassword
|
||||||
|
{
|
||||||
|
public $token;
|
||||||
|
/** @var User $user */
|
||||||
|
public $user;
|
||||||
|
private $password;
|
||||||
|
private $confirm_password;
|
||||||
|
|
||||||
|
public function __construct($data, $data2)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
foreach ($data2 as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
$data = $DB->query("SELECT `id` FROM `users` WHERE `forgotten_password` = '" . $this->token . "';")->fetch();
|
||||||
|
ensure($data !== false, "Il n'y a pas de compte à récupérer avec ce jeton.");
|
||||||
|
$this->user = User::fromId($data["id"]);
|
||||||
|
|
||||||
|
if ($this->password == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ensure($this->password == $this->confirm_password, "Les deux mots de passe sont différents.");
|
||||||
|
ensure(strlen($this->password) >= 8, "Le mot de passe doit comporter au moins 8 caractères.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetPassword()
|
||||||
|
{
|
||||||
|
$this->user->setForgottenPasswordToken(null);
|
||||||
|
$this->user->setPassword($this->password);
|
||||||
|
|
||||||
|
Mailer::sendChangePasswordMail($this->user);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendConfirmEmail()
|
||||||
|
{
|
||||||
|
global $URL_BASE;
|
||||||
|
|
||||||
|
$email = htmlspecialchars($_SESSION["confirm_email"]);
|
||||||
|
|
||||||
|
if (!isset($email)) {
|
||||||
|
header("Location: $URL_BASE/connexion");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = User::fromEmail($email);
|
||||||
|
|
||||||
|
if ($user === null) {
|
||||||
|
unset($_SESSION["confirm_email"]);
|
||||||
|
header("Location: $URL_BASE/connexion");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
Mailer::sendConfirmEmail($user);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/connexion.php";
|
8
server_files/controllers/deconnexion.php
Normal file
8
server_files/controllers/deconnexion.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
unset($_SESSION["user_id"]);
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
require_once "server_files/views/header.php";
|
||||||
|
echo "<h2>Déconnexion réussie !</h2>";
|
||||||
|
require_once "server_files/views/footer.php";
|
57
server_files/controllers/equipe.php
Normal file
57
server_files/controllers/equipe.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN)
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$trigram = htmlspecialchars($_GET["trigram"]);
|
||||||
|
|
||||||
|
$team = Team::fromTrigram($trigram);
|
||||||
|
$tournament = Tournament::fromId($team->getTournamentId());
|
||||||
|
|
||||||
|
if ($team === null)
|
||||||
|
require_once "server_files/404.php";
|
||||||
|
|
||||||
|
if (isset($_POST["validate"])) {
|
||||||
|
$team->setValidationStatus(ValidationStatus::VALIDATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["select"])) {
|
||||||
|
$team->selectForFinal(true);
|
||||||
|
$team->setValidationStatus(ValidationStatus::NOT_READY);
|
||||||
|
$sols = $tournament->getAllSolutions($team->getId());
|
||||||
|
/** @var Solution $sol */
|
||||||
|
foreach ($sols as $sol) {
|
||||||
|
$old_id = $sol->getFileId();
|
||||||
|
do
|
||||||
|
$id = genRandomPhrase(64);
|
||||||
|
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||||
|
|
||||||
|
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
|
||||||
|
$req->execute([$id, $team->getId(), $FINAL->getId(), $sol->getFileId()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["download_zip"])) {
|
||||||
|
$final = isset($_POST["final"]);
|
||||||
|
$tournament_dest = $final ? $FINAL : $tournament;
|
||||||
|
|
||||||
|
$file_name = getZipFile(DocumentType::PARENTAL_CONSENT, $tournament_dest->getId(), $team->getId());
|
||||||
|
|
||||||
|
header("Content-Type: application/zip");
|
||||||
|
header("Content-Disposition: attachment; filename=\"Documents de l'équipe " . $team->getTrigram() . ".zip\"");
|
||||||
|
header("Content-Length: " . strval(filesize($file_name)));
|
||||||
|
|
||||||
|
readfile($file_name);
|
||||||
|
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$documents = $tournament->getAllDocuments($team->getId());
|
||||||
|
$documents_final = null;
|
||||||
|
|
||||||
|
if ($team->isSelectedForFinal())
|
||||||
|
$documents_final = $FINAL->getAllDocuments($team->getId());
|
||||||
|
|
||||||
|
require_once "server_files/views/equipe.php";
|
3
server_files/controllers/index.php
Normal file
3
server_files/controllers/index.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "server_files/views/index.php";
|
26
server_files/controllers/informations.php
Normal file
26
server_files/controllers/informations.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["role"]))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$id = $_GET["id"];
|
||||||
|
$user = User::fromId($id);
|
||||||
|
|
||||||
|
if ($_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN) {
|
||||||
|
if ($user->getId() != $_SESSION["user_id"] && ($user->getTeamId() == null || $user->getTeamId() != $_SESSION["user"]->getTeamId()))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user === null)
|
||||||
|
require_once "server_files/404.php";
|
||||||
|
|
||||||
|
$team = Team::fromId($user->getTeamId());
|
||||||
|
$tournaments = $user->getOrganizedTournaments();
|
||||||
|
|
||||||
|
if ($team != null) {
|
||||||
|
$documents = $user->getAllDocuments($team->getTournamentId());
|
||||||
|
if ($team->isSelectedForFinal())
|
||||||
|
$documents_final = $user->getAllDocuments($FINAL->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/informations.php";
|
93
server_files/controllers/inscription.php
Normal file
93
server_files/controllers/inscription.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["submitted"])) {
|
||||||
|
$user = new NewUser($_POST);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$user->makeVerifications();
|
||||||
|
$user->register();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NewUser
|
||||||
|
{
|
||||||
|
public $email;
|
||||||
|
public $first_name;
|
||||||
|
public $surname;
|
||||||
|
public $birth_date;
|
||||||
|
public $gender;
|
||||||
|
public $address = "";
|
||||||
|
public $postal_code;
|
||||||
|
public $city = "";
|
||||||
|
public $country;
|
||||||
|
public $phone_number;
|
||||||
|
public $role;
|
||||||
|
public $school;
|
||||||
|
public $class;
|
||||||
|
public $responsible_name;
|
||||||
|
public $responsible_phone;
|
||||||
|
public $responsible_email;
|
||||||
|
public $description;
|
||||||
|
public $confirm_email_token;
|
||||||
|
private $password;
|
||||||
|
private $confirm_password;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse e-mail entrée est invalide.");
|
||||||
|
$this->email = strtolower($this->email);
|
||||||
|
ensure(!userExists($this->email), "Un compte existe déjà avec cette adresse e-mail.");
|
||||||
|
ensure(strlen($this->password) >= 8, "Le mot de passe doit comporter au moins 8 caractères.");
|
||||||
|
ensure($this->password == $this->confirm_password, "Les deux mots de passe sont différents.");
|
||||||
|
ensure($this->surname != "", "Le nom de famille est obligatoire.");
|
||||||
|
ensure($this->first_name != "", "Le prénom est obligatoire.");
|
||||||
|
ensure(dateWellFormed($this->birth_date), "La date de naissance est invalide.");
|
||||||
|
ensure($this->birth_date < $YEAR . "-01-01", "Vous devez être né.");
|
||||||
|
ensure($this->gender == "M" || $this->gender == "F", "Le sexe indiqué est invalide.");
|
||||||
|
ensure(preg_match("#^[0-9]{4}[0-9]?$#", $this->postal_code) && intval($this->postal_code) >= 01000 && intval($this->postal_code) <= 95999, "Le code postal est invalide.");
|
||||||
|
if ($this->country == "")
|
||||||
|
$this->country = "France";
|
||||||
|
ensure(strlen($this->phone_number) >= 10, "Le numéro de téléphone est invalide.");
|
||||||
|
$this->role = Role::fromName(strtoupper($this->role));
|
||||||
|
|
||||||
|
if ($this->role == Role::PARTICIPANT) {
|
||||||
|
$this->class = SchoolClass::fromName(strtoupper($this->class));
|
||||||
|
if ($this->birth_date > strval($YEAR - 18) . "04-01") {
|
||||||
|
ensure($this->responsible_name != "", "Veuillez spécifier un responsable légal.");
|
||||||
|
ensure(strlen($this->responsible_phone) >= 10, "Veuillez rentrer le numéro de téléphone de votre responsable légal.");
|
||||||
|
ensure(filter_var($this->responsible_email, FILTER_VALIDATE_EMAIL), "Veuillez spécifier un responsable légal.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->confirm_email_token = genRandomPhrase(64);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `birth_date`, `gender`,
|
||||||
|
`address`, `postal_code`, `city`, `country`, `phone_number`, `school`, `class`, `role`, `description`, `year`)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
|
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token, $this->surname, $this->first_name, $this->birth_date, $this->gender, $this->address,
|
||||||
|
$this->postal_code, $this->city, $this->country, $this->phone_number, $this->school, SchoolClass::getName($this->class), Role::getName($this->role), $this->description, $YEAR]);
|
||||||
|
|
||||||
|
Mailer::sendRegisterMail($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/inscription.php";
|
152
server_files/controllers/mon_compte.php
Normal file
152
server_files/controllers/mon_compte.php
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["user_id"]))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
/** @var User $user */
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["submitted"])) {
|
||||||
|
$my_account = new MyAccount($_POST);
|
||||||
|
try {
|
||||||
|
$my_account->makeVerifications();
|
||||||
|
$my_account->updateAccount();
|
||||||
|
}
|
||||||
|
catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["submitted_password"])) {
|
||||||
|
$new_password = new NewPassword($_POST);
|
||||||
|
try {
|
||||||
|
$new_password->makeVerifications();
|
||||||
|
$new_password->updatePassword();
|
||||||
|
}
|
||||||
|
catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyAccount
|
||||||
|
{
|
||||||
|
public $email;
|
||||||
|
public $surname;
|
||||||
|
public $first_name;
|
||||||
|
public $birth_date;
|
||||||
|
public $gender;
|
||||||
|
public $address;
|
||||||
|
public $postal_code;
|
||||||
|
public $city;
|
||||||
|
public $country;
|
||||||
|
public $phone_number;
|
||||||
|
public $school;
|
||||||
|
public $class;
|
||||||
|
public $responsible_name;
|
||||||
|
public $responsible_phone;
|
||||||
|
public $responsible_email;
|
||||||
|
public $description;
|
||||||
|
private $user;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
|
||||||
|
$this->user = $_SESSION["user"];
|
||||||
|
|
||||||
|
$keys = ["email", "surname", "first_name", "birth_date", "gender", "address", "postal_code", "city", "country", "phone_number",
|
||||||
|
"school", "class", "responsible_name", "responsible_phone", "responsible_email", "description"];
|
||||||
|
|
||||||
|
if ($this->user->getRole() == Role::PARTICIPANT)
|
||||||
|
$this->class = SchoolClass::fromName($this->class);
|
||||||
|
|
||||||
|
foreach ($keys as $key)
|
||||||
|
$this->$key = $this->$key != null && $this->$key != "" ? $this->$key : $this->user->$key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse e-mail entrée est invalide.");
|
||||||
|
$this->email = strtolower($this->email);
|
||||||
|
ensure($this->email == $this->user->getEmail() || !userExists($this->email), "Un compte existe déjà avec cette adresse e-mail.");
|
||||||
|
ensure(dateWellFormed($this->birth_date), "La date de naissance est invalide.");
|
||||||
|
ensure($this->birth_date < $YEAR . "-01-01", "Vous devez être né.");
|
||||||
|
ensure($this->gender == "M" || $this->gender == "F", "Le sexe indiqué est invalide.");
|
||||||
|
ensure(preg_match("#^[0-9]{4}[0-9]?$#", $this->postal_code) && intval($this->postal_code) >= 01000 && intval($this->postal_code) <= 95999, "Le code postal est invalide.");
|
||||||
|
ensure(strlen($this->phone_number) >= 10, "Le numéro de téléphone est invalide.");
|
||||||
|
|
||||||
|
if ($this->user->getRole() == Role::PARTICIPANT) {
|
||||||
|
if ($this->birth_date > strval($YEAR - 18) . "04-01") {
|
||||||
|
ensure($this->responsible_name != "", "Veuillez spécifier un responsable légal.");
|
||||||
|
ensure(strlen($this->responsible_phone) >= 10, "Veuillez rentrer le numéro de téléphone de votre responsable légal.");
|
||||||
|
ensure(filter_var($this->responsible_email, FILTER_VALIDATE_EMAIL), "Veuillez spécifier un responsable légal.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateAccount()
|
||||||
|
{
|
||||||
|
$this->user->setSurname($this->surname);
|
||||||
|
$this->user->setFirstName($this->first_name);
|
||||||
|
$this->user->setBirthDate($this->birth_date);
|
||||||
|
$this->user->setGender($this->gender);
|
||||||
|
$this->user->setAddress($this->address);
|
||||||
|
$this->user->setPostalCode($this->postal_code);
|
||||||
|
$this->user->setCity($this->city);
|
||||||
|
$this->user->setCountry($this->country);
|
||||||
|
$this->user->setPhoneNumber($this->phone_number);
|
||||||
|
$this->user->setSchool($this->school);
|
||||||
|
$this->user->setClass($this->class);
|
||||||
|
$this->user->setResponsibleName($this->responsible_name);
|
||||||
|
$this->user->setResponsiblePhone($this->responsible_phone);
|
||||||
|
$this->user->setResponsibleEmail($this->responsible_email);
|
||||||
|
$this->user->setDescription($this->description);
|
||||||
|
|
||||||
|
if ($this->email != $this->user->getEmail()) {
|
||||||
|
$this->user->setEmail($this->email);
|
||||||
|
$this->user->setConfirmEmailToken(genRandomPhrase(64));
|
||||||
|
|
||||||
|
Mailer::sendChangeEmailAddressMail($this->user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NewPassword
|
||||||
|
{
|
||||||
|
private $user;
|
||||||
|
private $old_password;
|
||||||
|
private $new_password;
|
||||||
|
private $confirm_password;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
|
||||||
|
$this->user = $_SESSION["user"];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
ensure($this->user->checkPassword($this->old_password), "L'ancien mot de passe est incorrect.");
|
||||||
|
ensure(strlen($this->new_password) >= 8, "Le mot de passe doit comporter au moins 8 caractères.");
|
||||||
|
ensure($this->new_password == $this->confirm_password, "Les deux mots de passe sont différents.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatePassword()
|
||||||
|
{
|
||||||
|
$this->user->setPassword($this->new_password);
|
||||||
|
|
||||||
|
Mailer::sendChangePasswordMail($this->user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/mon_compte.php";
|
141
server_files/controllers/mon_equipe.php
Normal file
141
server_files/controllers/mon_equipe.php
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (isset($_POST["leave_team"])) {
|
||||||
|
quitTeam();
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$tournaments = Tournament::getAllTournaments(false, true);
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["send_document"])) {
|
||||||
|
$send_document = new SendDocument();
|
||||||
|
try {
|
||||||
|
$send_document->makeVerifications();
|
||||||
|
$send_document->sendDocument();
|
||||||
|
}
|
||||||
|
catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["team_edit"])) {
|
||||||
|
$my_team = new MyTeam($_POST);
|
||||||
|
try {
|
||||||
|
$my_team->makeVerifications();
|
||||||
|
$my_team->updateTeam();
|
||||||
|
}
|
||||||
|
catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST["request_validation"])) {
|
||||||
|
if (!canValidate($team, $tournament))
|
||||||
|
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
|
||||||
|
else
|
||||||
|
$_SESSION["team"]->setValidationStatus(ValidationStatus::WAITING);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"] !== null) {
|
||||||
|
/**
|
||||||
|
* @var User $user
|
||||||
|
* @var Team $team
|
||||||
|
*/
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
$team = $_SESSION["team"];
|
||||||
|
|
||||||
|
$tournament = Tournament::fromId($team->getTournamentId());
|
||||||
|
$documents = $user->getAllDocuments($team->getTournamentId());
|
||||||
|
if ($team->isSelectedForFinal())
|
||||||
|
$documents_final = $user->getAllDocuments($FINAL->getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
class SendDocument
|
||||||
|
{
|
||||||
|
private $file;
|
||||||
|
private $type;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->file = $_FILES["document"];
|
||||||
|
$this->type = strtoupper(htmlspecialchars($_POST["type"]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH;
|
||||||
|
|
||||||
|
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
|
||||||
|
ensure(!$this->file["error"], "Une erreur est survenue.");
|
||||||
|
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
|
||||||
|
ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenue dans l'envoi du fichier. Veuillez contacter l'administrateur du serveur.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendDocument()
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH, $DB, $FINAL;
|
||||||
|
|
||||||
|
do
|
||||||
|
$id = genRandomPhrase(64);
|
||||||
|
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||||
|
|
||||||
|
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||||
|
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `tournament`, `type`)
|
||||||
|
VALUES (?, ?, ?, ?, ?);");
|
||||||
|
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team"]->getId(), $_SESSION["team"]->isSelectedForFinal() ? $FINAL->getId() : $_SESSION["team"]->getTournamentId(), $this->type]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyTeam
|
||||||
|
{
|
||||||
|
public $name;
|
||||||
|
public $trigram;
|
||||||
|
public $tournament_id;
|
||||||
|
private $team;
|
||||||
|
private $tournament;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = htmlspecialchars($value);
|
||||||
|
|
||||||
|
$this->trigram = strtoupper($this->trigram);
|
||||||
|
$this->team = $_SESSION["team"];
|
||||||
|
$this->tournament = Tournament::fromId($this->tournament_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
ensure($this->name != "" && $this->name != null, "Veuillez spécifier un nom d'équipe.");
|
||||||
|
ensure($this->name == $this->team->getName() || !teamExists($this->name), "Une équipe existe déjà avec ce nom.");
|
||||||
|
ensure(preg_match("#^[A-Z]{3}$#", $this->trigram), "Le trigramme n'est pas valide.");
|
||||||
|
ensure($this->trigram == $this->team->getTrigram() || !trigramExists($this->trigram), "Une équipe a déjà choisi ce trigramme.");
|
||||||
|
ensure($this->tournament != null, "Le tournoi indiqué n'existe pas.");
|
||||||
|
ensure(date("y-m-d H:i:s") <= $this->tournament->getInscriptionDate(), "Les inscriptions sont terminées.");
|
||||||
|
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Votre équipe est déjà validée ou en cours de validation.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateTeam()
|
||||||
|
{
|
||||||
|
global $URL_BASE;
|
||||||
|
|
||||||
|
$this->team->setName($this->name);
|
||||||
|
$this->team->setTrigram($this->trigram);
|
||||||
|
$this->team->setTournamentId($this->tournament_id);
|
||||||
|
|
||||||
|
$_SESSION["tournament"] = $this->tournament;
|
||||||
|
|
||||||
|
header("Location: $URL_BASE/mon_equipe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/mon_equipe.php";
|
66
server_files/controllers/rejoindre_equipe.php
Normal file
66
server_files/controllers/rejoindre_equipe.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (isset($_SESSION["team"]) || !isset($_SESSION["user"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["submitted"])) {
|
||||||
|
$join_team = new JoinTeam($_POST);
|
||||||
|
try {
|
||||||
|
$join_team->makeVerifications();
|
||||||
|
$join_team->joinTeam();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class JoinTeam
|
||||||
|
{
|
||||||
|
private $access_code;
|
||||||
|
private $team;
|
||||||
|
private $min_null_index;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
$this->access_code = strtolower(htmlspecialchars($data["access_code"]));
|
||||||
|
$this->team = Team::fromAccessCode($this->access_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
ensure(preg_match("#[a-z0-9]{6}#", $this->access_code), "Le code d'accès doit comporter 6 caractères alphanumériques.");
|
||||||
|
ensure($this->team != null, "Ce code d'accès est invalide.");
|
||||||
|
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Cette équipe est déjà validée ou en cours de validation, vous ne pouvez pas la rejoindre.");
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $_SESSION["role"] == Role::PARTICIPANT ? 6 : 2; ++$i) {
|
||||||
|
if (($_SESSION["role"] == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrants()[$i - 1]) == NULL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->min_null_index = $i;
|
||||||
|
|
||||||
|
ensure($_SESSION["role"] == Role::PARTICIPANT && $this->min_null_index <= 6 || $_SESSION["role"] == Role::ENCADRANT && $this->min_null_index <= 2, "Il n'y a plus de place pour vous dans l'équipe.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function joinTeam()
|
||||||
|
{
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
|
||||||
|
$user->setTeamId($this->team->getId());
|
||||||
|
|
||||||
|
if ($_SESSION["role"] == Role::ENCADRANT)
|
||||||
|
$this->team->setEncadrant($this->min_null_index, $user->getId());
|
||||||
|
else
|
||||||
|
$this->team->setParticipant($this->min_null_index, $user->getId());
|
||||||
|
|
||||||
|
$_SESSION["team"] = $this->team;
|
||||||
|
$tournament = $_SESSION["tournament"] = Tournament::fromId($this->team->getTournamentId());
|
||||||
|
|
||||||
|
Mailer::sendJoinTeamMail($user, $this->team, $tournament);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/rejoindre_equipe.php";
|
72
server_files/controllers/solutions.php
Normal file
72
server_files/controllers/solutions.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["team"]))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Team $team
|
||||||
|
* @var Tournament $tournament
|
||||||
|
*/
|
||||||
|
$team = $_SESSION["team"];
|
||||||
|
$tournament = Tournament::fromId($team->getTournamentId());
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["send_solution"])) {
|
||||||
|
$save_solution = new SaveSolution();
|
||||||
|
try {
|
||||||
|
$save_solution->makeVerifications();
|
||||||
|
$save_solution->saveSolution();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$solutions = $tournament->getAllSolutions($team->getId());
|
||||||
|
$solutions_final = null;
|
||||||
|
if ($team->isSelectedForFinal())
|
||||||
|
$solutions_final = $FINAL->getAllSolutions($team->getId());
|
||||||
|
|
||||||
|
class SaveSolution
|
||||||
|
{
|
||||||
|
private $problem;
|
||||||
|
private $file;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->file = $_FILES["document"];
|
||||||
|
$this->problem = htmlspecialchars($_POST["problem"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH;
|
||||||
|
|
||||||
|
ensure(preg_match("#[1-9]#", $this->problem), "Le numéro du problème est invalide.");
|
||||||
|
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
|
||||||
|
ensure(!$this->file["error"], "Une erreur est survenue.");
|
||||||
|
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
|
||||||
|
ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenue dans l'envoi du fichier. Veuillez contacter l'administrateur du serveur.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveSolution()
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
|
||||||
|
|
||||||
|
do
|
||||||
|
$id = genRandomPhrase(64);
|
||||||
|
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||||
|
|
||||||
|
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||||
|
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
|
||||||
|
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->problem]);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/solutions.php";
|
24
server_files/controllers/solutions_orga.php
Normal file
24
server_files/controllers/solutions_orga.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
if (isset($_POST["download_zip"])) {
|
||||||
|
$id = $_POST["tournament"];
|
||||||
|
$tournament = Tournament::fromId($id);
|
||||||
|
|
||||||
|
$file_name = getZipFile(DocumentType::SOLUTION, $id);
|
||||||
|
|
||||||
|
header("Content-Type: application/zip");
|
||||||
|
header("Content-Disposition: attachment; filename=\"Solutions du tournoi de " . $tournament->getName() . ".zip\"");
|
||||||
|
header("Content-Length: " . strval(filesize($file_name)));
|
||||||
|
|
||||||
|
readfile($file_name);
|
||||||
|
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
$tournaments = $_SESSION["role"] == Role::ADMIN ? Tournament::getAllTournaments() : $user->getOrganizedTournaments();
|
||||||
|
|
||||||
|
require_once "server_files/views/solutions_orga.php";
|
68
server_files/controllers/syntheses.php
Normal file
68
server_files/controllers/syntheses.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_SESSION["team"]))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Team $team
|
||||||
|
* @var Tournament $tournament
|
||||||
|
*/
|
||||||
|
$team = $_SESSION["team"];
|
||||||
|
$tournament = Tournament::fromId($team->getTournamentId());
|
||||||
|
|
||||||
|
if (isset($_POST["send_synthesis"])) {
|
||||||
|
$save_synthesis = new SaveSynthesis();
|
||||||
|
try {
|
||||||
|
$save_synthesis->makeVerifications();
|
||||||
|
$save_synthesis->saveSynthesis();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$syntheses = $tournament->getAllSyntheses($team->getId());
|
||||||
|
$syntheses_final = null;
|
||||||
|
if ($team->isSelectedForFinal())
|
||||||
|
$syntheses_final = $FINAL->getAllSyntheses($team->getId());
|
||||||
|
|
||||||
|
class SaveSynthesis
|
||||||
|
{
|
||||||
|
private $dest;
|
||||||
|
private $file;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->file = $_FILES["document"];
|
||||||
|
$this->dest = DestType::fromName(strtoupper(htmlspecialchars($_POST["problem"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH;
|
||||||
|
|
||||||
|
ensure($this->dest != DestType::DEFENSEUR, "Le destinataire est invalide.");
|
||||||
|
ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo.");
|
||||||
|
ensure(!$this->file["error"], "Une erreur est survenue.");
|
||||||
|
ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF.");
|
||||||
|
ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenue dans l'envoi du fichier. Veuillez contacter l'administrateur du serveur.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveSynthesis()
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH, $DB, $team, $tournament, $FINAL;
|
||||||
|
do
|
||||||
|
$id = genRandomPhrase(64);
|
||||||
|
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||||
|
|
||||||
|
if (!rename($this->file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||||
|
throw new AssertionError("Une erreur est survenue lors de l'envoi du fichier.");
|
||||||
|
|
||||||
|
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
||||||
|
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->dest]);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/syntheses.php";
|
22
server_files/controllers/syntheses_orga.php
Normal file
22
server_files/controllers/syntheses_orga.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
if (isset($_POST["download_zip"])) {
|
||||||
|
$id = $_POST["tournament"];
|
||||||
|
$tournament = Tournament::fromId($id);
|
||||||
|
|
||||||
|
$file_name = getZipFile(DocumentType::SYNTHESIS, $id);
|
||||||
|
|
||||||
|
header("Content-Type: application/zip");
|
||||||
|
header("Content-Disposition: attachment; filename=\"Notes de syntèses du tournoi de " . $tournament->getName() . ".zip\"");
|
||||||
|
header("Content-Length: " . filesize($file_name));
|
||||||
|
|
||||||
|
readfile($file_name);
|
||||||
|
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
$tournaments = $_SESSION["role"] == Role::ADMIN ? Tournament::getAllTournaments() : $user->getOrganizedTournaments();
|
||||||
|
|
||||||
|
require_once "server_files/views/syntheses_orga.php";
|
125
server_files/controllers/tournoi.php
Normal file
125
server_files/controllers/tournoi.php
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$tournament_name = htmlspecialchars($_GET["name"]);
|
||||||
|
$tournament = Tournament::fromName($tournament_name);
|
||||||
|
|
||||||
|
if ($tournament === null)
|
||||||
|
require_once "server_files/404.php";
|
||||||
|
|
||||||
|
if (isset($_GET["modifier"]) && $_SESSION["role"] != Role::ADMIN && !$tournament->organize($_SESSION["user_id"]))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$has_error = false;
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
if (isset($_POST["edit_tournament"])) {
|
||||||
|
$update_tournament = new UpdateTournament($_POST);
|
||||||
|
try {
|
||||||
|
$update_tournament->makeVerifications();
|
||||||
|
$update_tournament->updateTournament();
|
||||||
|
} catch (AssertionError $e) {
|
||||||
|
$has_error = true;
|
||||||
|
$error_message = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$orgas = $tournament->getOrganizers();
|
||||||
|
$teams = $tournament->getAllTeams();
|
||||||
|
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
||||||
|
|
||||||
|
class UpdateTournament
|
||||||
|
{
|
||||||
|
public $name;
|
||||||
|
public $organizers;
|
||||||
|
public $size;
|
||||||
|
public $place;
|
||||||
|
public $price;
|
||||||
|
public $date_start;
|
||||||
|
public $date_end;
|
||||||
|
public $date_inscription;
|
||||||
|
public $time_inscription;
|
||||||
|
public $date_solutions;
|
||||||
|
public $time_solutions;
|
||||||
|
public $date_syntheses;
|
||||||
|
public $time_syntheses;
|
||||||
|
public $description;
|
||||||
|
public $final;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
global $tournament;
|
||||||
|
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
$this->$key = ($key == "organizers" ? $value : htmlspecialchars($value));
|
||||||
|
|
||||||
|
if ($_SESSION["role"] != Role::ADMIN) {
|
||||||
|
$this->organizers = [];
|
||||||
|
/** @var User $organizer */
|
||||||
|
foreach ($tournament->getOrganizers() as $organizer)
|
||||||
|
$this->organizers[] = $organizer->getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeVerifications()
|
||||||
|
{
|
||||||
|
global $tournament;
|
||||||
|
|
||||||
|
ensure($this->name != null && $this->name != "", "Le nom est invalide.");
|
||||||
|
ensure($this->name == $tournament->getName() || !tournamentExists($this->name), "Un tournoi existe déjà avec ce nom.");
|
||||||
|
ensure(sizeof($this->organizers) > 0, "Aucun organisateur n'a été choisi.");
|
||||||
|
|
||||||
|
$orgas = [];
|
||||||
|
foreach ($this->organizers as $orga_id) {
|
||||||
|
$orga = User::fromId($orga_id);
|
||||||
|
ensure($orga != null, "Un organisateur spécifié n'existe pas.");
|
||||||
|
ensure($orga->getRole() == Role::ORGANIZER || $orga->getRole() == Role::ADMIN, "Une personne indiquée ne peut pas organiser de tournoi.");
|
||||||
|
$orgas[] = $orga;
|
||||||
|
}
|
||||||
|
$this->organizers = $orgas;
|
||||||
|
|
||||||
|
ensure(preg_match("#[0-9]*#", $this->size), "Le nombre d'équipes indiqué n'est pas un nombre valide.");
|
||||||
|
$this->size = intval($this->size);
|
||||||
|
ensure($this->size >= 3 && $this->size <= 15, "Un tournoi doit avoir au moins 3 et au plus 15 équipes.");
|
||||||
|
|
||||||
|
ensure(preg_match("#[0-9]*#", $this->price), "Le tarif pour les participants n'est pas un entier valide.");
|
||||||
|
$this->price = intval($this->price);
|
||||||
|
ensure($this->price >= 0, "Le TFJM² ne va pas payer les élèves pour venir.");
|
||||||
|
ensure($this->price <= 50, "Soyons raisonnable sur le prix.");
|
||||||
|
|
||||||
|
ensure(dateWellFormed($this->date_start), "La date de début n'est pas valide.");
|
||||||
|
ensure(dateWellFormed($this->date_end), "La date de fin n'est pas valide.");
|
||||||
|
ensure(dateWellFormed($this->date_inscription . " " . $this->time_inscription), "La date de clôture des inscriptions n'est pas valide.");
|
||||||
|
ensure(dateWellFormed($this->date_solutions . " " . $this->time_solutions), "La date limite de remise des solutions n'est pas valide.");
|
||||||
|
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse n'est pas valide.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateTournament()
|
||||||
|
{
|
||||||
|
global $URL_BASE, $tournament;
|
||||||
|
|
||||||
|
$tournament->setName($this->name);
|
||||||
|
$tournament->setSize($this->size);
|
||||||
|
$tournament->setPlace($this->place);
|
||||||
|
$tournament->setPrice($this->price);
|
||||||
|
$tournament->setStartDate($this->date_start);
|
||||||
|
$tournament->setEndDate($this->date_end);
|
||||||
|
$tournament->setInscriptionDate("$this->date_inscription $this->time_inscription");
|
||||||
|
$tournament->setSolutionsDate("$this->date_solutions $this->time_solutions");
|
||||||
|
$tournament->setSynthesesDate("$this->date_syntheses $this->time_syntheses");
|
||||||
|
|
||||||
|
foreach ($this->organizers as $organizer) {
|
||||||
|
if (!$tournament->organize($organizer->getId()))
|
||||||
|
Mailer::sendAddOrganizerForTournamentMail($organizer, $tournament);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tournament->clearOrganizers();
|
||||||
|
/** @var User $organizer */
|
||||||
|
foreach ($this->organizers as $organizer)
|
||||||
|
$tournament->addOrganizer($organizer);
|
||||||
|
|
||||||
|
header("Location: $URL_BASE/tournoi/" . $this->name);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/tournoi.php";
|
5
server_files/controllers/tournois.php
Normal file
5
server_files/controllers/tournois.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$tournaments = Tournament::getAllTournaments();
|
||||||
|
|
||||||
|
require_once "server_files/views/tournois.php";
|
78
server_files/controllers/view_file.php
Normal file
78
server_files/controllers/view_file.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!isset($_GET["file_id"])) {
|
||||||
|
header("Location: $URL_BASE");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_SESSION["user_id"]))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$id = htmlspecialchars($_GET["file_id"]);
|
||||||
|
|
||||||
|
$type = DocumentType::SOLUTION;
|
||||||
|
$file = Solution::fromId($id);
|
||||||
|
if ($file === null) {
|
||||||
|
$type = DocumentType::SYNTHESIS;
|
||||||
|
$file = Synthesis::fromId($id);
|
||||||
|
|
||||||
|
if ($file === null) {
|
||||||
|
$file = Document::fromId($id);
|
||||||
|
$type = DocumentType::PARENTAL_CONSENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($file !== null) {
|
||||||
|
$team = Team::fromId($file->getTeamId());
|
||||||
|
$tournament = Tournament::fromId($file->getTournamentId());
|
||||||
|
$trigram = $team->getTrigram();
|
||||||
|
|
||||||
|
if ($_SESSION["role"] == Role::ORGANIZER && !$tournament->organize($_SESSION["user_id"]))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
if ($type == DocumentType::SOLUTION) {
|
||||||
|
$problem = $file->getProblem();
|
||||||
|
$name = "Problème $problem $trigram.pdf";
|
||||||
|
|
||||||
|
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
}
|
||||||
|
else if ($type == DocumentType::SYNTHESIS) {
|
||||||
|
$dest = $file->getDest();
|
||||||
|
$name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf";
|
||||||
|
|
||||||
|
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$user = User::fromId($file->getUserId());
|
||||||
|
$type = $file->getType();
|
||||||
|
|
||||||
|
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && $user->getId() != $_SESSION["user_id"])
|
||||||
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
$surname = $user->getSurname();
|
||||||
|
$first_name = $user->getFirstName();
|
||||||
|
switch ($type) {
|
||||||
|
case DocumentType::PARENTAL_CONSENT:
|
||||||
|
$name = "Autorisation parentale";
|
||||||
|
break;
|
||||||
|
case DocumentType::PHOTO_CONSENT:
|
||||||
|
$name = "Autorisation de droit à l'image";
|
||||||
|
break;
|
||||||
|
case DocumentType::SANITARY_PLUG:
|
||||||
|
$name = "Fiche sanitaire";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$name .= " de $first_name $surname.pdf";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
require_once "server_files/404.php";
|
||||||
|
|
||||||
|
header("Content-Type: application/pdf");
|
||||||
|
header("Content-Disposition: inline; filename=\"$name\"");
|
||||||
|
|
||||||
|
readfile("$LOCAL_PATH/files/$id");
|
||||||
|
|
||||||
|
exit();
|
251
server_files/model.php
Normal file
251
server_files/model.php
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$FINAL = Tournament::getFinalTournament();
|
||||||
|
|
||||||
|
function loadUserValues()
|
||||||
|
{
|
||||||
|
$_SESSION["user"] = $_SESSION["team"] = $_SESSION["tournament"] = null;
|
||||||
|
unset($_SESSION["user"]);
|
||||||
|
unset($_SESSION["role"]);
|
||||||
|
unset($_SESSION["team"]);
|
||||||
|
unset($_SESSION["tournament"]);
|
||||||
|
|
||||||
|
if (isset($_SESSION["user_id"])) {
|
||||||
|
$user = $_SESSION["user"] = User::fromId($_SESSION["user_id"]);
|
||||||
|
$_SESSION["role"] = $user->getRole();
|
||||||
|
|
||||||
|
if ($user->getTeamId() !== null) {
|
||||||
|
$team = $_SESSION["team"] = Team::fromId($user->getTeamId());
|
||||||
|
$_SESSION["tournament"] = Tournament::fromId($team->getTournamentId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["be-admin"])) {
|
||||||
|
quitTeam();
|
||||||
|
$user->setRole(Role::ADMIN);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["be-organizer"])) {
|
||||||
|
quitTeam();
|
||||||
|
$user->setRole(Role::ORGANIZER);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["be-participant"])) {
|
||||||
|
quitTeam();
|
||||||
|
$user->setRole(Role::PARTICIPANT);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["be-encadrant"])) {
|
||||||
|
quitTeam();
|
||||||
|
$user->setRole(Role::ENCADRANT);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function quitTeam()
|
||||||
|
{
|
||||||
|
global $DB, $URL_BASE;
|
||||||
|
|
||||||
|
header("Location: $URL_BASE");
|
||||||
|
|
||||||
|
/** @var User $user */
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
$user_id = $user->getId();
|
||||||
|
$role = $user->getRole();
|
||||||
|
|
||||||
|
if ($role == Role::ADMIN || $role == Role::ORGANIZER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for ($i = 1; $i <= ($role == Role::ENCADRANT ? 2 : 6); ++$i)
|
||||||
|
/** @noinspection SqlResolve */
|
||||||
|
$DB->exec("UPDATE `teams` SET `" . strtolower(Role::getName($role)) . "_$i` = NULL WHERE `" . strtolower(Role::getName($role)) . "_$i` = $user_id;");
|
||||||
|
$user->setTeamId(null);
|
||||||
|
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
|
||||||
|
for ($i = 1; $i <= 5; ++$i) {
|
||||||
|
/** @noinspection SqlResolve */
|
||||||
|
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
|
||||||
|
}
|
||||||
|
|
||||||
|
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = $user_id;");
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||||
|
$DB->exec("DELETE FROM `documents` WHERE `user` = $user_id;");
|
||||||
|
|
||||||
|
if ($DB->exec("DELETE FROM `teams` WHERE `encadrant_1` IS NULL AND `participant_1` IS NULL;") > 0) {
|
||||||
|
$team_id = $user->getTeamId();
|
||||||
|
$req = $DB->query("SELECT `file_id` FROM `solutions` WHERE `team` = $team_id;");
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||||
|
$DB->exec("DELETE FROM `solutions` WHERE `team` = $team_id;");
|
||||||
|
|
||||||
|
$req = $DB->query("SELECT `file_id` FROM `syntheses` WHERE `team` = $team_id;");
|
||||||
|
while (($data = $req->fetch()) !== false)
|
||||||
|
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||||
|
$DB->exec("DELETE FROM `syntheses` WHERE `team` = $team_id;");
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION["team"] = null;
|
||||||
|
unset($_SESSION["team"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function userExists($email)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$req = $DB->prepare("SELECT `id` FROM `users` WHERE `email` = ? AND `year` = '$YEAR';");
|
||||||
|
$req->execute([$email]);
|
||||||
|
return $req->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
function teamExists($name)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$req = $DB->prepare("SELECT `id` FROM `teams` WHERE `name` = ? AND `year` = '$YEAR';");
|
||||||
|
$req->execute([$name]);
|
||||||
|
return $req->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
function trigramExists($trigram)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$req = $DB->prepare("SELECT `id` FROM `teams` WHERE `trigram` = ? AND `year` = '$YEAR';");
|
||||||
|
$req->execute([$trigram]);
|
||||||
|
return $req->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
function tournamentExists($name)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$req = $DB->prepare("SELECT `id` FROM `tournaments` WHERE `name` = ? AND `year` = '$YEAR';");
|
||||||
|
$req->execute([$name]);
|
||||||
|
return $req->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
function canValidate(Team $team, Tournament $tournament)
|
||||||
|
{
|
||||||
|
global $DB, $YEAR;
|
||||||
|
|
||||||
|
$can_validate = $team->getValidationStatus() == ValidationStatus::NOT_READY;
|
||||||
|
$can_validate &= $team->getEncadrants()[0] != NULL;
|
||||||
|
$can_validate &= $team->getParticipants()[3] != NULL;
|
||||||
|
for ($i = 1; $i <= 2; ++$i) {
|
||||||
|
if ($team->getEncadrants()[$i - 1] === NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
|
||||||
|
$req->execute([$team->getEncadrants()[$i - 1], $tournament->getId(), "PHOTO_CONSENT"]);
|
||||||
|
$d = $req->fetch();
|
||||||
|
$can_validate &= $d["version"] > 0;
|
||||||
|
|
||||||
|
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
|
||||||
|
$req->execute([$team->getEncadrants()[$i - 1], $tournament->getId(), "SANITARY_PLUG"]);
|
||||||
|
$d = $req->fetch();
|
||||||
|
$can_validate &= $d["version"] > 0;
|
||||||
|
}
|
||||||
|
for ($i = 1; $i <= 6; ++$i) {
|
||||||
|
if ($team->getParticipants()[$i] === NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
|
||||||
|
$req->execute([$team->getParticipants()[$i], $tournament->getId(), "PHOTO_CONSENT"]);
|
||||||
|
$d = $req->fetch();
|
||||||
|
$can_validate &= $d["version"] > 0;
|
||||||
|
|
||||||
|
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
|
||||||
|
$req->execute([$team->getParticipants()[$i], $tournament->getId(), "SANITARY_PLUG"]);
|
||||||
|
$d = $req->fetch();
|
||||||
|
$can_validate &= $d["version"] > 0;
|
||||||
|
|
||||||
|
$birth_date = $DB->query("SELECT `birth_date` FROM `users` WHERE `id` = " . $team->getParticipants()[$i] . ";")->fetch()["birth_date"];
|
||||||
|
if ($birth_date > strval($YEAR - 18) . substr($tournament->getStartDate(), 4)) {
|
||||||
|
$req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? AND `type` = ?;");
|
||||||
|
$req->execute([$team->getParticipants()[$i], $tournament->getId(), "PARENTAL_CONSENT"]);
|
||||||
|
$d = $req->fetch();
|
||||||
|
$can_validate &= $d["version"] > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $can_validate;
|
||||||
|
}
|
||||||
|
|
||||||
|
function printDocuments($documents)
|
||||||
|
{
|
||||||
|
global $URL_BASE;
|
||||||
|
|
||||||
|
foreach ($documents as $document) {
|
||||||
|
$file_id = $document->getFileId();
|
||||||
|
$user = User::fromId($document->getUserId());
|
||||||
|
$surname = $user->getSurname();
|
||||||
|
$first_name = $user->getFirstName();
|
||||||
|
$name = DocumentType::getTranslatedName($document->getType());
|
||||||
|
$version = $document->getVersion();
|
||||||
|
echo "$name de $first_name $surname (version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getZipFile($document_type, $tournament_id, $team_id = -1)
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH;
|
||||||
|
|
||||||
|
$tournament = Tournament::fromId($tournament_id);
|
||||||
|
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
|
||||||
|
$file_name = tempnam("tmp", "tfjm-");
|
||||||
|
|
||||||
|
if ($zip->open($file_name, ZipArchive::CREATE) !== true) {
|
||||||
|
die("Impossible de créer le fichier zip.");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($document_type) {
|
||||||
|
case DocumentType::SOLUTION:
|
||||||
|
$data = $tournament->getAllSolutions($team_id);
|
||||||
|
break;
|
||||||
|
case DocumentType::SYNTHESIS:
|
||||||
|
$data = $tournament->getAllSyntheses($team_id);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$data = $tournament->getAllDocuments($team_id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var Document | Solution | Synthesis $file */
|
||||||
|
foreach ($data as $file) {
|
||||||
|
$file_id = $file->getFileId();
|
||||||
|
$team = Team::fromId($file->getTeamId());
|
||||||
|
switch ($document_type) {
|
||||||
|
case DocumentType::SOLUTION:
|
||||||
|
$name = "Problème " . $file->getProblem() . " " . $team->getTrigram() . ".pdf";
|
||||||
|
break;
|
||||||
|
case DocumentType::SYNTHESIS:
|
||||||
|
$name = "Note de synthèse " . $team->getTrigram() . " pour " . ($file->getDest() == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$user = User::fromId($file->getUserId());
|
||||||
|
switch ($file->getType()) {
|
||||||
|
case DocumentType::PARENTAL_CONSENT:
|
||||||
|
$name = "Autorisation parentale de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";
|
||||||
|
break;
|
||||||
|
case DocumentType::PHOTO_CONSENT:
|
||||||
|
$name = "Autorisation de droit à l'image de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$name = "Fiche sanitaire de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip->addFile("$LOCAL_PATH/files/$file_id", $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
return $file_name;
|
||||||
|
}
|
130
server_files/services/mail.php
Normal file
130
server_files/services/mail.php
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Mailer
|
||||||
|
{
|
||||||
|
private static function sendMail($email, $subject, $content, $from = "contact")
|
||||||
|
{
|
||||||
|
global $MAIL_DOMAIN, $URL_BASE, $YEAR;
|
||||||
|
|
||||||
|
$content = preg_replace("#{URL_BASE}#", $URL_BASE, $content);
|
||||||
|
$content = preg_replace("#{YEAR}#", $YEAR, $content);
|
||||||
|
|
||||||
|
$headers = "From: \"Contact TFJM²\" <" . $from . "@" . $MAIL_DOMAIN . ">\r\n";
|
||||||
|
$headers .= "Reply-To: \"Contact TFJM²\" <contact@" . $MAIL_DOMAIN . ">\r\n";
|
||||||
|
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
|
||||||
|
|
||||||
|
mail($email, $subject, $content, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getTemplate($name)
|
||||||
|
{
|
||||||
|
global $LOCAL_PATH;
|
||||||
|
return file_get_contents("$LOCAL_PATH/server_files/services/mail_templates/$name.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendRegisterMail(NewUser $new_user)
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("register");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $new_user->first_name, $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $new_user->surname, $content);
|
||||||
|
$content = preg_replace("#{TOKEN}#", $new_user->confirm_email_token, $content);
|
||||||
|
|
||||||
|
self::sendMail($new_user->email, "Inscription au TFJM² $YEAR", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendConfirmEmail(User $user)
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("confirm_email");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $user->getFirstName(), $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
|
||||||
|
$content = preg_replace("#{TOKEN}#", $user->getConfirmEmailToken(), $content);
|
||||||
|
|
||||||
|
self::sendMail($user->getEmail(), "Confirmation d'adresse e-mail – TFJM² $YEAR", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendChangeEmailAddressMail(User $user)
|
||||||
|
{
|
||||||
|
$content = self::getTemplate("change_email_address");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $user->getFirstName(), $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
|
||||||
|
$content = preg_replace("#{TOKEN}#", $user->getConfirmEmailToken(), $content);
|
||||||
|
|
||||||
|
self::sendMail($user->getEmail(), "Changement d'adresse e-mail – TFJM²", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendForgottenPasswordProcedureMail(User $user)
|
||||||
|
{
|
||||||
|
$content = self::getTemplate("forgotten_password");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $user->getFirstName(), $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
|
||||||
|
$content = preg_replace("#{TOKEN}#", $user->getForgottenPasswordToken(), $content);
|
||||||
|
|
||||||
|
self::sendMail($user->getEmail(), "Mot de passe oublié – TFJM²", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendChangePasswordMail(User $user)
|
||||||
|
{
|
||||||
|
$content = self::getTemplate("change_password");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $user->getFirstName(), $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
|
||||||
|
|
||||||
|
self::sendMail($user->getEmail(), "Mot de passe changé – TFJM²", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendAddTeamMail(User $user, Team $team, Tournament $tournament)
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("add_team");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $user->getFirstName(), $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
|
||||||
|
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
|
||||||
|
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
|
||||||
|
$content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content);
|
||||||
|
$content = preg_replace("#{ACCESS_CODE}#", $team->getAccessCode(), $content);
|
||||||
|
|
||||||
|
self::sendMail($user->getEmail(), "Ajout d'une équipe TFJM² $YEAR", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendJoinTeamMail(User $user, Team $team, Tournament $tournament)
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("join_team");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $user->getFirstName(), $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $user->getSurname(), $content);
|
||||||
|
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
|
||||||
|
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
|
||||||
|
$content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content);
|
||||||
|
|
||||||
|
self::sendMail($user->getEmail(), "Équipe rejointe TFJM² $YEAR", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendAddOrganizerMail(NewOrganizer $new_orga)
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("add_organizer");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $new_orga->first_name, $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $new_orga->surname, $content);
|
||||||
|
$content = preg_replace("#{PASSWORD}#", $new_orga->password, $content);
|
||||||
|
|
||||||
|
self::sendMail($new_orga->email, "Ajout d'un organisateur – TFJM² $YEAR", $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendAddOrganizerForTournamentMail(User $organizer, Tournament $tournament)
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("add_organizer_for_tournament");
|
||||||
|
$content = preg_replace("#{FIRST_NAME}#", $organizer->getFirstName(), $content);
|
||||||
|
$content = preg_replace("#{SURNAME}#", $organizer->getSurname(), $content);
|
||||||
|
$content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content);
|
||||||
|
|
||||||
|
self::sendMail($organizer->getEmail(), "Ajout d'un organisateur pour le tournoi " . $tournament->getName() . " – TFJM² $YEAR", $content);
|
||||||
|
}
|
||||||
|
}
|
21
server_files/services/mail_templates/add_organizer.html
Normal file
21
server_files/services/mail_templates/add_organizer.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Organisateur du TFJM²</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br />
|
||||||
|
<br />
|
||||||
|
Vous recevez ce message (envoyé automatiquement) car vous êtes organisateur d'un des tournois du TFJM<sup>2</sup>.
|
||||||
|
Veuillez trouver ci-dessous vos informations d'utilisateur pour le site officiel des inscriptions. Elles vous permettront de gérer les inscriptions des équipes de votre tournoi.<br />
|
||||||
|
<br />
|
||||||
|
Votre mot de passe est : <strong style="color: red; font-size: 18px;">{PASSWORD}</strong><br />
|
||||||
|
<br />
|
||||||
|
Notez bien que ce mot de passe est temporaire, et pour des raisons de sécurité vous devrez le changer lors de votre prochaine connexion sur le site.<br />
|
||||||
|
<br />
|
||||||
|
Merci beaucoup pour votre aide !<br />
|
||||||
|
<br />
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Organisateur du tournoi de {TOURNAMENT_NAME} – TFJM²</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br />
|
||||||
|
<br />
|
||||||
|
Vous venez d'être promu organisateur du tournoi <a href="{URL_BASE}/tournoi/{TOURNAMENT_NAME}">{TOURNAMENT_NAME}</a> du TFJM<sup>2</sup> {YEAR}.<br />
|
||||||
|
<br />
|
||||||
|
Cordialement,<br />
|
||||||
|
<br />
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
16
server_files/services/mail_templates/add_team.html
Normal file
16
server_files/services/mail_templates/add_team.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Nouvelle équipe TFJM² {YEAR}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br />
|
||||||
|
<br />
|
||||||
|
Vous venez de créer l'équipe « {TEAM_NAME} » ({TRIGRAM}) pour le TFJM<sup>2</sup> de {TOURNAMENT_NAME} et nous vous en remercions.<br />
|
||||||
|
Afin de permettre aux autres membres de votre équipe de vous rejoindre, veuillez leur transmettre le code d'accès :
|
||||||
|
{ACCESS_CODE}<br/>
|
||||||
|
<br />
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Changement d'adresse e-mail – TFJM²</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br/>
|
||||||
|
<br/>
|
||||||
|
Vous venez de changer votre adresse e-mail. Veuillez désormais la confirmer en cliquant ici : <a
|
||||||
|
href="{URL_BASE}/confirmer_mail/{TOKEN}">{URL_BASE}/confirmer_mail/{TOKEN}</a><br/>
|
||||||
|
<br/>
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
18
server_files/services/mail_templates/change_password.html
Normal file
18
server_files/services/mail_templates/change_password.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Mot de passe changé – TFJM²</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br/>
|
||||||
|
<br/>
|
||||||
|
Nous vous informons que votre mot de passe vient d'être modifié. Si vous n'êtes pas à l'origine de cette manipulation,
|
||||||
|
veuillez immédiatement vérifier vos accès à votre boîte mail et changer votre mot de passe sur la plateforme
|
||||||
|
d'inscription.<br/>
|
||||||
|
<br/>
|
||||||
|
Cordialement,<br/>
|
||||||
|
<br/>
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
18
server_files/services/mail_templates/confirm_email.html
Normal file
18
server_files/services/mail_templates/confirm_email.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Inscription au TFJM² {YEAR}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br/>
|
||||||
|
<br/>
|
||||||
|
Vous êtes inscrit au TFJM<sup>2</sup> {YEAR} et nous vous en remercions.<br/>
|
||||||
|
Pour valider votre adresse e-mail, veuillez cliquer sur le lien : <a href="{URL_BASE}/confirmer_mail/{TOKEN}">{URL_BASE}/confirmer_mail/{TOKEN}</a><br/>
|
||||||
|
<br/>
|
||||||
|
Cordialement,<br/>
|
||||||
|
<br/>
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
20
server_files/services/mail_templates/forgotten_password.html
Normal file
20
server_files/services/mail_templates/forgotten_password.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Mot de passe oublié – TFJM²</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour,<br/>
|
||||||
|
<br/>
|
||||||
|
Vous avez indiqué avoir oublié votre mot de passe. Veuillez cliquer ici pour le réinitialiser : <a
|
||||||
|
href="{URL_BASE}/connexion/reinitialiser_mdp/{TOKEN}">{URL_BASE}/connexion/reinitialiser_mdp/{TOKEN}</a><br/>
|
||||||
|
<br/>
|
||||||
|
Si vous n'êtes pas à l'origine de cette manipulation, vous pouvez ignorer ce message.<br/>
|
||||||
|
<br/>
|
||||||
|
Cordialement,<br/>
|
||||||
|
<br/>
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
17
server_files/services/mail_templates/join_team.html
Normal file
17
server_files/services/mail_templates/join_team.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Équipe rejointe – TFJM² {YEAR}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br/>
|
||||||
|
<br/>
|
||||||
|
Vous venez de rejoindre l'équipe « {TEAM_NAME} » ({TRIGRAM}) pour le TFJM² de {TOURNAMENT_NAME} et nous vous en
|
||||||
|
remercions.<br/>
|
||||||
|
<br/>
|
||||||
|
Cordialement,<br/>
|
||||||
|
<br/>
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
16
server_files/services/mail_templates/register.html
Normal file
16
server_files/services/mail_templates/register.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Inscription au TFJM² {YEAR}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br />
|
||||||
|
<br />
|
||||||
|
Vous venez de vous inscrire au TFJM<sup>2</sup> {YEAR} et nous vous en remercions.<br />
|
||||||
|
Pour valider votre adresse e-mail, veuillez cliquer sur le lien : <a href="{URL_BASE}/confirmer_mail/{TOKEN}">{URL_BASE}/confirmer_mail/{TOKEN}</a><br />
|
||||||
|
<br />
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
32
server_files/utils.php
Normal file
32
server_files/utils.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function ensure($bool, $error_msg = "")
|
||||||
|
{
|
||||||
|
if (!$bool)
|
||||||
|
throw new AssertionError($error_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate($date = NULL, $with_time = false)
|
||||||
|
{
|
||||||
|
if ($date == NULL)
|
||||||
|
$date = date("yyyy-mm-dd");
|
||||||
|
|
||||||
|
return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date));
|
||||||
|
}
|
||||||
|
|
||||||
|
function dateWellFormed($date, $with_time = false)
|
||||||
|
{
|
||||||
|
return date_parse_from_format($with_time ? "yyyy-mm-dd HH-MM:ss" : "yy-mm-dd", $date) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function genRandomPhrase($size, $uppercase = false)
|
||||||
|
{
|
||||||
|
$alphabet = $uppercase ? "0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" : "0123456789abcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
||||||
|
$phrase = "";
|
||||||
|
for ($i = 0; $i < $size; ++$i) {
|
||||||
|
$phrase .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $phrase;
|
||||||
|
}
|
56
server_files/views/ajouter_equipe.php
Normal file
56
server_files/views/ajouter_equipe.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if (isset($new_team) && !$has_error) { ?>
|
||||||
|
Votre équipe a bien été créée ! Voici le code d'accès à transmettre aux autres membres de votre équipe : <strong><?= $new_team->access_code ?></strong>
|
||||||
|
<?php } elseif ($_SESSION["team"] != NULL) { ?>
|
||||||
|
<h2>Vous êtes déjà dans une équipe.</h2>
|
||||||
|
<?php } else { ?>
|
||||||
|
|
||||||
|
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted" value="true" />
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="name">Nom :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="text" id="name" name="name" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="trigram">Trigramme :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="text" id="trigram" name="trigram" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="tournament_id">Tournoi :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select style="width: 100%;" id="tournament_id" name="tournament_id">
|
||||||
|
<?php
|
||||||
|
while (($data = $tournaments_response->fetch()) !== FALSE) {
|
||||||
|
echo "<option value=\"" . $data["id"] . "\">" . $data["name"] . "</option>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" value="Ajouter une équipe" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
57
server_files/views/ajouter_organisateur.php
Normal file
57
server_files/views/ajouter_organisateur.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if (isset($orga)) {
|
||||||
|
if ($has_error) {
|
||||||
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
|
} else {
|
||||||
|
echo "<h2>Organisateur ajouté avec succès ! Ses identifiants ont été transmis par mail.</h2>";
|
||||||
|
}
|
||||||
|
} ?>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted" value="true"/>
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="surname">Nom :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="text" id="surname" name="surname"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="first_name">Prénom :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="text" id="first_name" name="first_name"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="email">Email :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="email" id="email" name="email"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="admin">Compte administrateur :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="checkbox" id="admin" name="admin"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" value="Ajouter un organisateur"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
127
server_files/views/ajouter_tournoi.php
Normal file
127
server_files/views/ajouter_tournoi.php
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if (isset($tournament)) {
|
||||||
|
if ($has_error) {
|
||||||
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "<h2>Tournoi de " . htmlspecialchars($_POST["name"]) . " ajouté avec succès !</h2>";
|
||||||
|
}
|
||||||
|
}?>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted" value="true" />
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="name">Nom :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="text" id="name" name="name" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="organizers">Organisateurs :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select style="width: 100%;" id="organizers" name="organizers[]" multiple size="4" required>
|
||||||
|
<?php
|
||||||
|
while (($data = $orgas_response->fetch()) !== FALSE) {
|
||||||
|
echo "<option value=\"" . $data["id"] . "\">" . $data["first_name"] . " " . $data["surname"] . "</option>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="size">Nombre d'équipes :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="6" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="place">Lieu :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="text" id="place" name="place" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="price">Prix par participant</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="50" value="21" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="date_start">Dates :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" required /> au <!--suppress HtmlFormInputWithoutLabel -->
|
||||||
|
<input style="width: 45%;" type="date" id="date_end" name="date_end" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="date_inscription">Date limite d'inscription :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" required />
|
||||||
|
<!--suppress HtmlFormInputWithoutLabel -->
|
||||||
|
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="date_solutions">Date limite pour rendre les solutions :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" required />
|
||||||
|
<!--suppress HtmlFormInputWithoutLabel -->
|
||||||
|
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 49%;" type="date" id="date_syntheses" name="date_syntheses" required />
|
||||||
|
<!--suppress HtmlFormInputWithoutLabel -->
|
||||||
|
<input style="width: 49%;" type="time" id="time_syntheses" name="time_syntheses" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="description">Description :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<textarea style="width: 100%;" name="description" id="description" required></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="final">Ce tournoi est la finale nationale :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="checkbox" id="final" name="final" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" value="Ajouter un tournoi" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
100
server_files/views/connexion.php
Normal file
100
server_files/views/connexion.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if ($has_error)
|
||||||
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
|
else {
|
||||||
|
if (isset($recuperate_account))
|
||||||
|
echo "<h2>Le mail de récupération de mot de passe a bien été envoyé.</h2>";
|
||||||
|
elseif (isset($reset_password))
|
||||||
|
echo "<h2>Le mot de passe a bien été changé. Vous pouvez désormais vous connecter.</h2>";
|
||||||
|
elseif (isset($_GET["confirmation-mail"]))
|
||||||
|
echo "<h2>Le mail a bien été renvoyé.</h2>";
|
||||||
|
else if (isset($logging_in_user)) {
|
||||||
|
echo "<h2>Connexion réussie !</h2>";
|
||||||
|
require_once "footer.php";
|
||||||
|
} else if (isset($_SESSION["user_id"])) {
|
||||||
|
echo "<h2>Vous êtes déjà connecté.</h2>";
|
||||||
|
require_once "footer.php";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($_GET["mdp_oublie"])) { ?>
|
||||||
|
<form method="POST">
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="email">E-mail associée au compte :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="email" id="email" name="email"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" name="forgotten_password"
|
||||||
|
value="Envoyer l'e-mail de récupération"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php } elseif (isset($_GET["reset_password"])) {
|
||||||
|
if ($reset_password->user != null) { ?>
|
||||||
|
<form method="POST">
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="password">Nouveau mot de passe :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="password" id="password" name="password"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="confirm_password">Confirmer le mot de passe :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="password" id="confirm_password" name="confirm_password"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" name="reset_password"
|
||||||
|
value="Changer le mot de passe"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php }
|
||||||
|
} elseif (isset($_GET["confirmation-mail"])) { ?>
|
||||||
|
<?php } else { ?>
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted" value="true"/>
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;"><label for="email">E-mail :</label></td>
|
||||||
|
<td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email"
|
||||||
|
value="<?php if (isset($email)) echo $email ?>"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="password">Mot de passe :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="password" id="password" name="password"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<a href="<?= $URL_BASE ?>/connexion/mdp_oublie">Mot de passe oublié ?</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%;" type="submit" value="Se connecter"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
63
server_files/views/equipe.php
Normal file
63
server_files/views/equipe.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php require_once "header.php" ?>
|
||||||
|
|
||||||
|
<h2>Informations sur l'équipe</h2>
|
||||||
|
|
||||||
|
Nom de l'équipe : <?= $team->getName() ?><br/>
|
||||||
|
Trigramme : <?= $team->getTrigram() ?><br/>
|
||||||
|
Tournoi : <a href="<?= $URL_BASE . "/tournoi/" . $tournament->getName() ?>"><?= $tournament->getName() ?></a><br/>
|
||||||
|
<?php
|
||||||
|
for ($i = 1; $i <= 2; ++$i) {
|
||||||
|
if ($team->getEncadrants()[$i - 1] == NULL)
|
||||||
|
continue;
|
||||||
|
$encadrant = User::fromId($team->getEncadrants()[$i - 1]);
|
||||||
|
$id = $encadrant->getId();
|
||||||
|
echo "Encadrant $i : <a href=\"$URL_BASE/informations/$id/" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "\">" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "</a><br />";
|
||||||
|
}
|
||||||
|
for ($i = 1; $i <= 6; ++$i) {
|
||||||
|
if ($team->getParticipants()[$i - 1] == NULL)
|
||||||
|
continue;
|
||||||
|
$participant = User::fromId($team->getParticipants()[$i - 1]);
|
||||||
|
$id = $participant->getId();
|
||||||
|
echo "Participant $i : <a href=\"$URL_BASE/informations/$id/" . $participant->getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "</a><br />";
|
||||||
|
}
|
||||||
|
if ($team->isSelectedForFinal()) {
|
||||||
|
$final_name = $FINAL->getName();
|
||||||
|
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<h2>Autorisations</h2>
|
||||||
|
|
||||||
|
<?php printDocuments($documents) ?>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input style="width: 100%;" type="submit" name="download_zip" value="Télécharger l'archive"/>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php if ($team->isSelectedForFinal()) { ?>
|
||||||
|
<hr/>
|
||||||
|
<h2>Autorisations pour la finale</h2>
|
||||||
|
<?php printDocuments($documents_final) ?>
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="final" value="true" />
|
||||||
|
<input style="width: 100%;" type="submit" name="download_zip" value="Télécharger l'archive"/>
|
||||||
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if ($team->getValidationStatus() == ValidationStatus::WAITING && $_SESSION["role"] == Role::ADMIN) { ?>
|
||||||
|
<form method="POST">
|
||||||
|
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe"/>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$team->isSelectedForFinal() && $_SESSION["role"] == Role::ADMIN) { ?>
|
||||||
|
<hr/>
|
||||||
|
<form method="POST">
|
||||||
|
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale"/>
|
||||||
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
6
server_files/views/footer.php
Normal file
6
server_files/views/footer.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<?php exit() ?>
|
76
server_files/views/header.php
Normal file
76
server_files/views/header.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||||
|
<meta name="viewport" content= "width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Site d'inscription pour le TFJM² <?= $YEAR ?></title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="<?= $URL_BASE ?>/style.css"/>
|
||||||
|
<link REL="shortcut icon" href="<?= $URL_BASE ?>/favicon.ico" />
|
||||||
|
|
||||||
|
<!-- Bootstrap core CSS -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/bootstrap/css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<!-- Custom fonts for this template -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/font-awesome/css/font-awesome.min.css">
|
||||||
|
|
||||||
|
<!-- Plugin CSS -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/datatables/dataTables.bootstrap4.css">
|
||||||
|
|
||||||
|
<!-- Custom styles for this template -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/css2/sb-admin.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<ul id="menu">
|
||||||
|
<li id="menu-logo"><img src="<?= $URL_BASE ?>/logo.svg" alt="Logo TFJM²"></li>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/">Accueil</a></li>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/tournois">Liste des tournois</a></li>
|
||||||
|
<?php if (!isset($_SESSION["user_id"])) { ?>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/connexion">Connexion</a></li>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/inscription">Inscription</a></li>
|
||||||
|
<?php } else { ?>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/mon_compte">Mon compte</a></li>
|
||||||
|
<?php if ($_SESSION["role"] == Role::ENCADRANT || $_SESSION["role"] == Role::PARTICIPANT) { ?>
|
||||||
|
<?php if ($_SESSION["team"] == NULL) { ?>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/ajouter_equipe">Ajouter une équipe</a></li>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/rejoindre_equipe">Rejoindre une équipe</a></li>
|
||||||
|
<?php } else { ?>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/mon_equipe">Mon équipe</a></li>
|
||||||
|
<?php if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::VALIDATED || true) { ?>
|
||||||
|
<li><a href="https://paypal.me/galaxyoyo42">Paiement</a></li>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/solutions">Solutions</a></li>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/syntheses">Notes de synthèse</a></li>
|
||||||
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/ajouter_tournoi">Ajouter un tournoi</a></li>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/ajouter_organisateur">Ajouter un organisateur</a></li>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER) { ?>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/solutions_orga">Solutions</a></li>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/syntheses_orga">Notes de synthèse</a></li>
|
||||||
|
<?php } ?>
|
||||||
|
<li><a href="<?= $URL_BASE ?>/deconnexion">Déconnexion</a></li>
|
||||||
|
<hr />
|
||||||
|
<?php
|
||||||
|
if ($_SESSION["role"] != Role::ADMIN) {
|
||||||
|
echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>\n";
|
||||||
|
}
|
||||||
|
if ($_SESSION["role"] != Role::ORGANIZER) {
|
||||||
|
echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>\n";
|
||||||
|
}
|
||||||
|
if ($_SESSION["role"] != Role::PARTICIPANT) {
|
||||||
|
echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>\n";
|
||||||
|
}
|
||||||
|
if ($_SESSION["role"] != Role::ENCADRANT) {
|
||||||
|
echo "<li><a href=\"?be-encadrant=1\">Devenir encadrant</a></li>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php } ?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div id="main-container">
|
||||||
|
<div id="main-content">
|
||||||
|
<div class="container-fluid">
|
127
server_files/views/index.php
Normal file
127
server_files/views/index.php
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<?php require_once "header.php" ?>
|
||||||
|
|
||||||
|
<!--suppress HtmlUnknownTarget, HtmlDeprecatedAttribute, HtmlDeprecatedTag -->
|
||||||
|
<div class="container-fluid">
|
||||||
|
|
||||||
|
<div id="header">
|
||||||
|
<center>
|
||||||
|
<img src="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/images/header.jpg"
|
||||||
|
alt="" width="720" height="160">
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<h3>Vous souhaitez participer au tournoi ? Votre équipe est déjà formée ?</h3>
|
||||||
|
<h4><a href="<?= $URL_BASE ?>/inscription">Créez un compte</a> pour commencer la procédure d'inscription ou
|
||||||
|
<a href="<?= $URL_BASE ?>/connexion">connectez-vous</a> si votre équipe a déjà un compte.</h4>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<h2>Bienvenue sur le site d'inscription du TFJM<sup>2</sup> !</h2>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
Ce site a été conçu pour gérer les inscriptions au Tournoi Français des Jeunes Mathématiciennes et
|
||||||
|
Mathématiciens.
|
||||||
|
<br>
|
||||||
|
<a href="http://www.tfjm.org/">Cliquez ici pour accéder au site de présentation du tournoi.</a>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<p align="justify"><strong>
|
||||||
|
Attention aux échéances ! Chaque tournoi a une date limite pour les inscriptions et une date limite pour
|
||||||
|
déposer vos solutions. Elles sont affichées avec les informations de chaque tournoi. Merci de vous y
|
||||||
|
référer !
|
||||||
|
<br>
|
||||||
|
Une fois l'échéance passée, le site bloque tout accès aux inscriptions (et respectivement au dépôt des
|
||||||
|
solutions).</strong>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style="color:red;">
|
||||||
|
Attention, modification du règlement par rapport aux années précédentes : article 4.3
|
||||||
|
<br>
|
||||||
|
"l’équipe doit envoyer par mail à contact@tfjm.org, une lettre (au format pdf), répondant aux questions
|
||||||
|
suivantes :
|
||||||
|
<br>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<ul style="color:red;">
|
||||||
|
<li>Comment l’équipe s’est-elle formée ?</li>
|
||||||
|
<li>Comment l’équipe va-t-elle travailler (où peut-elle se rencontrer, à quelle fréquence, rencontres avec
|
||||||
|
l’encadrant•e) ?
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Cette lettre permettra aux organisateurs•trices de vérifier que l’équipe dispose des conditions nécessaires à
|
||||||
|
une participation sérieuse. Sont dispensées les équipes dont la moitié ou plus des membres sont scolarisés dans
|
||||||
|
le même établissement. Le comité National d’Organisation se réserve le droit d’accepter ou non l’inscription des
|
||||||
|
équipes concernées par cette lettre."
|
||||||
|
<br>
|
||||||
|
|
||||||
|
Pour plus de détail, voir le règlement : <a href="https://tfjm.org/infos-tournois/">https://tfjm.org/infos-tournois/</a>
|
||||||
|
<p></p>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<h2>Comment ça marche ?</h2>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<p align="justify">
|
||||||
|
Pour participer à l'un des tournois régionaux, il suffit de créer un compte sur la rubrique
|
||||||
|
<b>Inscription</b>. Il vous faudra une adresse email pour ce faire. Un mail de confirmation sera envoyé à
|
||||||
|
cette adresse. Il vous fournira un nom d'utilisateur et un mot de passe que vous allez devoir changer par la
|
||||||
|
suite.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Vous pouvez accéder à votre compte via la rubrique <b>Connexion</b>. Une fois connecté, vous pourrez :
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>rentrer des informations sur les membres de votre équipe, tant participants qu'encadrants ;</li>
|
||||||
|
<li>enregistrer et télécharger des versions préliminaires de vos solutions (seulement la dernière version
|
||||||
|
enregistrée avant la date limite sera prise en compte pour le tournoi).
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Une fois que vous aurez fourni toutes les informations demandées dans la rubrique <b>Mon Équipe</b>, votre
|
||||||
|
inscription pourra être validée par les organisateurs locaux.
|
||||||
|
<p></p>
|
||||||
|
|
||||||
|
|
||||||
|
<p class="text-danger">
|
||||||
|
ATTENTION ! Votre équipe ne sera considérée comme admissible à participer au tournoi que
|
||||||
|
lorsque cette première étape aura été franchie.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Pensez donc à former une équipe complète (minimum 4 participants et 1 encadrant) le plus tôt possible pour
|
||||||
|
avoir plus de chances de participer, compte tenu du nombre des places disponibles dans chaque tournoi (qui
|
||||||
|
sera dûment affiché sur la rubrique <b>Liste des Tournois</b>). Les équipes restantes seront placées en
|
||||||
|
liste d'attente.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Pour les équipes dont l'inscription aura été validée, des documents à télécharger, remplir et signer
|
||||||
|
deviendront disponibles sur votre compte. Vous allez devoir ensuite les scanner et les télécharger vers le
|
||||||
|
site pour compléter votre inscription.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p class="text-danger">
|
||||||
|
ATTENTION ! Les équipes qui ne respecteront pas les délais pour rendre ces documents
|
||||||
|
risquent d'être disqualifiées et de laisser leur place aux équipes placées en liste d'attente.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<em><strong>NB :</strong> Ce site est récent et il est encore possible que certaines pages ne fonctionnent
|
||||||
|
pas correctement. Si vous remarquez des bugs, merci de les signaler à l'adresse <a
|
||||||
|
href="mailto:contact@tfjm.org">contact@tfjm.org</a>.</em>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
44
server_files/views/informations.php
Normal file
44
server_files/views/informations.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php require_once "header.php" ?>
|
||||||
|
|
||||||
|
<h1><?= $user->getFirstName() . " " . $user->getSurname() ?></h1>
|
||||||
|
|
||||||
|
<?php if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
|
||||||
|
Équipe : <?= $team === null ? "Pas d'équipe" : "<a href=\"$URL_BASE/equipe/" . $team->getTrigram() . "\">" . $team->getName() . " (" . $team->getTrigram() . ")</a>" ?><br />
|
||||||
|
<?php } ?>
|
||||||
|
Date de naissance : <?= formatDate($user->getBirthDate()) ?><br />
|
||||||
|
Sexe : <?= $user->getGender() == "M" ? "Masculin" : "Féminin" ?><br />
|
||||||
|
Adresse : <?= $user->getAddress() . ", " . $user->getPostalCode() . " " . $user->getCity() . ($user->getCountry() == "France" ? "" : ", " . $user->getCountry()) ?><br />
|
||||||
|
Adresse e-mail : <a href="mailto:<?= $user->getEmail() ?>"><?= $user->getEmail() ?></a><br />
|
||||||
|
Numéro de téléphone : <?= $user->getPhoneNumber() ?><br />
|
||||||
|
|
||||||
|
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
|
||||||
|
Lycée : <?= $user->getSchool() ?><br />
|
||||||
|
Classe : <?php SchoolClass::getTranslatedName($user->getClass()) ?><br />
|
||||||
|
Nom du responsable légal : <?= $user->getResponsibleName() ?><br />
|
||||||
|
Numéro de téléphone du responsable légal : <?= $user->getResponsiblePhone() ?><br />
|
||||||
|
Adresse e-mail du responsable légal : <a href="mailto:<?= $user->getResponsibleEmail() ?>"><?= $user->getResponsibleEmail() ?></a>
|
||||||
|
<?php } elseif ($user->getDescription() != "") { ?>
|
||||||
|
Description : <?= $user->getDescription() ?><br />
|
||||||
|
<?php }
|
||||||
|
|
||||||
|
echo "<hr />";
|
||||||
|
|
||||||
|
if ($user->getRole() == Role::ADMIN || $user->getRole() == Role::ORGANIZER) {
|
||||||
|
foreach ($tournaments as $tournament) {
|
||||||
|
echo "Organise le tournoi <a href=\"$URL_BASE/tournoi/" . $tournament->getName(). "\">" . $tournament->getName() . "</a><br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
|
||||||
|
<h2>Autorisations</h2>
|
||||||
|
<?php
|
||||||
|
printDocuments($documents);
|
||||||
|
|
||||||
|
if ($team->isSelectedForFinal()) { ?>
|
||||||
|
<hr />
|
||||||
|
<h2>Autorisations pour la finale</h2>
|
||||||
|
<?php
|
||||||
|
printDocuments($documents_final);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "footer.php";
|
178
server_files/views/inscription.php
Normal file
178
server_files/views/inscription.php
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if ($has_error)
|
||||||
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
/** @var NewUser $user */
|
||||||
|
if (isset($user) && !$has_error) {
|
||||||
|
?>
|
||||||
|
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
|
||||||
|
<?php } else if (isset($_SESSION["user_id"])) { ?>
|
||||||
|
<h2>Vous êtes déjà connecté !</h2>
|
||||||
|
<?php } else { ?>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted" value="true"/>
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;"><label for="email">E-mail :</label></td>
|
||||||
|
<td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email"
|
||||||
|
value="<?php if (isset($user)) echo $user->email ?>"
|
||||||
|
required/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="password">Mot de passe :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="password" id="password" name="password" required/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="password" id="confirm_password" name="confirm_password" required/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="surname">Nom :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="surname" name="surname"
|
||||||
|
value="<?php if (isset($user)) echo $user->surname ?>" required/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="first_name">Prénom :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="first_name" name="first_name"
|
||||||
|
value="<?php if (isset($user)) echo $user->first_name ?>" required/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="birth_date">Date de naissance :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="date" id="birth_date" name="birth_date"
|
||||||
|
value="<?php if (isset($user)) echo $user->birth_date ?>" required/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="gender">Sexe :</label></td>
|
||||||
|
<td><input type="radio" id="male" name="gender" value="M"
|
||||||
|
required <?= isset($_POST["gender"]) && $_POST["gender"] == "M" ? "checked" : "" ?> /><label
|
||||||
|
for="male">Homme</label>
|
||||||
|
<input type="radio" id="female" name="gender" value="F"
|
||||||
|
required <?= isset($_POST["gender"]) && $_POST["gender"] == "F" ? "checked" : "" ?> /><label
|
||||||
|
for="female">Femme</label></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="address">Adresse :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="address" name="address"
|
||||||
|
value="<?php if (isset($user)) echo $user->address ?>"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="postal_code">Code postal :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="number" id="postal_code" name="postal_code"
|
||||||
|
value="<?php if (isset($user)) echo $user->postal_code ?>" min="1000"
|
||||||
|
max="95999" required/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="city">Ville :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="city" name="city"
|
||||||
|
value="<?php if (isset($user)) echo $user->city ?>"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="country">Pays :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="country" name="country"
|
||||||
|
value="<?= isset($user) ? $user->country : "France" ?>" required/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="phone_number" name="phone_number"
|
||||||
|
value="<?php if (isset($user)) echo $user->phone_number ?>"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="role">Rôle :</label></td>
|
||||||
|
<td><select style="width: 100%;" id="role" name="role" onchange="selectRole()">
|
||||||
|
<option value="participant"><?= Role::getTranslatedName(Role::PARTICIPANT) ?></option>
|
||||||
|
<option value="encadrant"><?= Role::getTranslatedName(Role::ENCADRANT) ?></option>
|
||||||
|
</select></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="school" name="school"
|
||||||
|
value="<?php if (isset($user)) echo $user->school ?>"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="class_label" for="class">Classe :</label></td>
|
||||||
|
<td><select style="width: 100%;" id="class" name="class">
|
||||||
|
<option value="terminale"><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?></option>
|
||||||
|
<option value="premiere"><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?></option>
|
||||||
|
<option value="seconde"><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?></option>
|
||||||
|
</select></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="responsible_name_label" for="responsible_name">Nom du responsable légal :</label></td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="responsible_name" name="responsible_name"
|
||||||
|
value="<?php if (isset($user)) echo $user->responsible_name ?>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="responsible_phone_label" for="responsible_phone">Téléphone du responsable légal :</label>
|
||||||
|
</td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="responsible_phone" name="responsible_phone"
|
||||||
|
value="<?php if (isset($user)) echo $user->responsible_phone ?>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="responsible_email_label" for="responsible_email">Email du responsable légal :</label>
|
||||||
|
</td>
|
||||||
|
<td><input style="width: 100%;" type="text" id="responsible_email" name="responsible_email"
|
||||||
|
value="<?php if (isset($user)) echo $user->responsible_email ?>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label id="description_label" for="description">Description :</label></td>
|
||||||
|
<td><textarea style="width: 100%;" id="description"
|
||||||
|
name="description"><?php if (isset($user)) echo $user->description ?></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%;" type="submit" value="S'inscrire"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function selectRole() {
|
||||||
|
switch (document.getElementById("role").value) {
|
||||||
|
case "participant":
|
||||||
|
document.getElementById("school_label").style.display = "block";
|
||||||
|
document.getElementById("school").style.display = "block";
|
||||||
|
document.getElementById("school").require = "true";
|
||||||
|
document.getElementById("class_label").style.display = "block";
|
||||||
|
document.getElementById("class").style.display = "block";
|
||||||
|
document.getElementById("responsible_name_label").style.display = "block";
|
||||||
|
document.getElementById("responsible_name").style.display = "block";
|
||||||
|
document.getElementById("responsible_phone_label").style.display = "block";
|
||||||
|
document.getElementById("responsible_phone").style.display = "block";
|
||||||
|
document.getElementById("responsible_email_label").style.display = "block";
|
||||||
|
document.getElementById("responsible_email").style.display = "block";
|
||||||
|
document.getElementById("description_label").style.display = "none";
|
||||||
|
document.getElementById("description").style.display = "none";
|
||||||
|
break;
|
||||||
|
case "encadrant":
|
||||||
|
document.getElementById("school_label").style.display = "none";
|
||||||
|
document.getElementById("school").style.display = "none";
|
||||||
|
document.getElementById("school").require = "false";
|
||||||
|
document.getElementById("class_label").style.display = "none";
|
||||||
|
document.getElementById("class").style.display = "none";
|
||||||
|
document.getElementById("responsible_name_label").style.display = "none";
|
||||||
|
document.getElementById("responsible_name").style.display = "none";
|
||||||
|
document.getElementById("responsible_phone_label").style.display = "none";
|
||||||
|
document.getElementById("responsible_phone").style.display = "none";
|
||||||
|
document.getElementById("responsible_email_label").style.display = "none";
|
||||||
|
document.getElementById("responsible_email").style.display = "none";
|
||||||
|
document.getElementById("description_label").style.display = "block";
|
||||||
|
document.getElementById("description").style.display = "block";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
selectRole();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
178
server_files/views/mon_compte.php
Normal file
178
server_files/views/mon_compte.php
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if ($has_error)
|
||||||
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
|
|
||||||
|
elseif (isset($my_account) || isset($new_password)) {
|
||||||
|
?>
|
||||||
|
<h2>Votre compte a bien été mis à jour !</h2>
|
||||||
|
<?php
|
||||||
|
if (isset($my_account) && $user->getEmail() != $my_account->email) {
|
||||||
|
echo "Votre adresse mail a bien été changée. Veuillez vérifier votre boîte mail pour valider votre nouvelle adresse, vous en aurez besoin pour vous reconnecter.";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted" value="true"/>
|
||||||
|
<table style="width: 100%">
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%"><label for="email">E-mail :</label></td>
|
||||||
|
<td style="width: 70%"><?= $user->getEmail() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="email" id="email" name="email"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="surname">Nom :</label></td>
|
||||||
|
<td><?= $user->getSurname() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="text" id="surname" name="surname"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="firstname">Prénom :</label></td>
|
||||||
|
<td><?= $user->getFirstName() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="text" id="firstname" name="firstname"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="birth_date">Date de naissance :</label></td>
|
||||||
|
<td><?= formatDate($user->getBirthDate()) ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="date" id="birth_date" name="birth_date"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="gender">Sexe :</label></td>
|
||||||
|
<td><input type="radio" id="male" name="gender" value="M" <?php if ($user->getGender() == "M") echo "checked" ?> /><label for="male">Homme</label>
|
||||||
|
<input type="radio" id="female" name="gender" value="F" <?php if ($user->getGender() == "F") echo "checked" ?> /><label for="female">Femme</label></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="address">Adresse :</label></td>
|
||||||
|
<td><?= $user->getAddress() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="text" id="address" name="address"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="postal_code">Code postal :</label></td>
|
||||||
|
<td><?= $user->getPostalCode() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="number" id="postal_code" name="postal_code" min="1000" max="95999"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="city">Ville :</label></td>
|
||||||
|
<td><?= $user->getCity() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="text" id="city" name="city"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="country">Pays :</label></td>
|
||||||
|
<td><?= $user->getCountry() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="text" id="country" name="country"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||||
|
<td><?= $user->getPhoneNumber() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="text" id="phone_number" name="phone_number"/></td>
|
||||||
|
</tr>
|
||||||
|
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
|
||||||
|
<tr>
|
||||||
|
<td><label for="school">Établissement dans lequel l'élève étudie :</label></td>
|
||||||
|
<td><?= $user->getSchool() ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input style="width: 100%" type="text" id="school" name="school"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="class">Classe :</label></td>
|
||||||
|
<td><select style="width: 100%" id="class" name="class">
|
||||||
|
<option value="terminale" <?php if ($user->getClass() == SchoolClass::TERMINALE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?></option>
|
||||||
|
<option value="premiere" <?php if ($user->getClass() == SchoolClass::PREMIERE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?></option>
|
||||||
|
<option value="seconde" <?php if ($user->getClass() == SchoolClass::SECONDE) echo "selected" ?>><?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?></option>
|
||||||
|
</select></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="responsible_name">Nom du responsable légal :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?= $user->getResponsibleName() ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="text" id="responsible_name" name="responsible_name" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="responsible_phone">Téléphone du responsable légal :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?= $user->getResponsiblePhone() ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%" type="text" id="responsible_phone" name="responsible_phone" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="responsible_email">Email du responsable légal :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?= $user->getResponsibleEmail() ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%" type="email" id="responsible_email" name="responsible_email" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php } else { ?>
|
||||||
|
<tr>
|
||||||
|
<td><label for="description">Description :</label></td>
|
||||||
|
<td><textarea style="width: 100%" id="description" name="description"><?= $user->getDescription() ?></textarea></td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input type="submit" style="width: 100%" value="Mettre à jour mes données"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div style="padding: 20px"></div>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted_password" value="true"/>
|
||||||
|
<table style="width: 100%">
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%"><label for="old_password">Ancien mot de passe :</label></td>
|
||||||
|
<td style="width: 70%"><input style="width: 100%" type="password" id="old_password" name="old_password"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="new_password">Nouveau mot de passe :</label></td>
|
||||||
|
<td><input style="width: 100%" type="password" id="new_password" name="new_password"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
|
||||||
|
<td><input style="width: 100%" type="password" id="confirm_password" name="confirm_password"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input type="submit" style="width: 100%" value="Mettre à jour mon mot de passe"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
161
server_files/views/mon_equipe.php
Normal file
161
server_files/views/mon_equipe.php
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if ($has_error)
|
||||||
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
|
elseif (isset($send_document))
|
||||||
|
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2>Informations sur l'équipe</h2>
|
||||||
|
|
||||||
|
Nom de l'équipe : <?= $team->getName() ?><br/>
|
||||||
|
Trigramme : <?= $team->getTrigram() ?><br/>
|
||||||
|
Tournoi : <a href="<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a><br/>
|
||||||
|
<?php
|
||||||
|
for ($i = 1; $i <= 2; ++$i) {
|
||||||
|
if ($team->getEncadrants()[$i] == NULL)
|
||||||
|
continue;
|
||||||
|
$encadrant = User::fromId($team->getEncadrants()[$i - 1]);
|
||||||
|
$id = $encadrant->getId();
|
||||||
|
echo "Encadrant $i : <a href=\"$URL_BASE/informations/$id/" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "\">" . $encadrant->getFirstName() . " " . $encadrant->getSurname() . "</a><br />";
|
||||||
|
}
|
||||||
|
for ($i = 1; $i <= 6; ++$i) {
|
||||||
|
if ($team->getParticipants()[$i - 1] == NULL)
|
||||||
|
continue;
|
||||||
|
$participant = User::fromId($team->getParticipants()[$i - 1]);
|
||||||
|
$id = $participant->getId();
|
||||||
|
echo "Participant $i : <a href=\"$URL_BASE/informations/$id/" . $participant->getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "</a><br />";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
|
||||||
|
<?php if ($team->isSelectedForFinal()) {
|
||||||
|
$final_name = $FINAL->getName();
|
||||||
|
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong><br />";
|
||||||
|
} ?>
|
||||||
|
|
||||||
|
<?php if (isset($_GET["modifier"])) { ?>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="team_edit" value="true"/>
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="name">Nom :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $team->getName() ?>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="trigram">Trigramme :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="text" id="trigram" name="trigram"
|
||||||
|
value="<?= $team->getTrigram() ?>"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="tournament">Tournoi :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select style="width: 100%;" id="tournament" name="tournament_id">
|
||||||
|
<?php
|
||||||
|
foreach ($tournaments as $tournament)
|
||||||
|
echo "<option value=\"" . $tournament->getId() . "\">" . $tournament->getName() . "</option>\n";
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" value="Modifier l'équipe"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php } else { ?>
|
||||||
|
|
||||||
|
<?php if ($_SESSION["team_validation_status"] == ValidationStatus::NOT_READY) { ?>
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<a href="<?= $URL_BASE ?>/mon_equipe/modifier">Modifier mon équipe</a>
|
||||||
|
<?php } ?>
|
||||||
|
<hr/>
|
||||||
|
<h2>Mes autorisations</h2>
|
||||||
|
<?php
|
||||||
|
printDocuments($documents);
|
||||||
|
|
||||||
|
if ($team->isSelectedForFinal()) { ?>
|
||||||
|
<hr/>
|
||||||
|
<h2>Mes autorisations pour la finale</h2>
|
||||||
|
<?php
|
||||||
|
printDocuments($documents_final);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
||||||
|
<hr />
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="type">Type de document :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select style="width: 100%;" id="type" name="type">
|
||||||
|
<?php if ($_SESSION["user"]->getBirthDate() > strval($YEAR - 18) . substr($tournament->getStartDate(), 4)) { ?>
|
||||||
|
<option value="parental_consent">Autorisation parentale</option>
|
||||||
|
<?php } ?>
|
||||||
|
<option value="photo_consent">Autorisation de droit à l'image</option>
|
||||||
|
<option value="sanitary_plug">Fiche sanitaire</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="file">Fichier :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="file" id="file" name="document"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" name="send_document" value="Envoyer le document"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
|
||||||
|
<hr/>
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tr>
|
||||||
|
<td style="width: 50%;">
|
||||||
|
<form method="post">
|
||||||
|
<input style="width: 100%;" type="submit" name="leave_team" value="Quitter l'équipe"/>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
<?php
|
||||||
|
$can_validate = canValidate($team, $tournament);
|
||||||
|
if ($can_validate) { ?>
|
||||||
|
<td style="width: 50%;">
|
||||||
|
<form method="post">
|
||||||
|
<input style="width: 100%;" type="submit" name="request_validation"
|
||||||
|
value="Demander la validation"/>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
<?php } ?>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
33
server_files/views/rejoindre_equipe.php
Normal file
33
server_files/views/rejoindre_equipe.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php" ;
|
||||||
|
|
||||||
|
if (isset($join_team) && !$has_error) { ?>
|
||||||
|
Vous avez bien rejoint l'équipe <?= $_SESSION["team"]->getName() ?> !
|
||||||
|
<?php } else { ?>
|
||||||
|
|
||||||
|
<?php if ($has_error) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted" value="true" />
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="access_code">Code d'accès :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="text" id="access_code" name="access_code" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" value="Rejoindre l'équipe" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
75
server_files/views/solutions.php
Normal file
75
server_files/views/solutions.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if ($has_error) {
|
||||||
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
|
} elseif (isset($save_solution)) {
|
||||||
|
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if (date("yyyy-mm-dd") < $tournament->getSolutionsDate()) { ?>
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="problem">Problème :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select style="width: 100%;" id="problem" name="problem">
|
||||||
|
<?php
|
||||||
|
for ($i = 1; $i <= 9; ++$i) {
|
||||||
|
echo "<option value=\"$i\">$i</option>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="file">Fichier :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="file" id="file" name="solution"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" name="send_solution" value="Envoyer"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<h2>Solutions soumises :</h2>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
/** @var Solution $sol */
|
||||||
|
foreach ($solutions as $sol) {
|
||||||
|
$file_id = $sol->getFileId();
|
||||||
|
$problem = $sol->getProblem();
|
||||||
|
$version = $sol->getVersion();
|
||||||
|
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($team->isSelectedForFinal()) { ?>
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<h2>Solutions soumises pour la finale :</h2>
|
||||||
|
<?php
|
||||||
|
/** @var Solution $sol */
|
||||||
|
foreach ($solutions_final as $sol) {
|
||||||
|
$file_id = $sol->getFileId();
|
||||||
|
$problem = $sol->getProblem();
|
||||||
|
$version = $sol->getVersion();
|
||||||
|
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "footer.php";
|
25
server_files/views/solutions_orga.php
Normal file
25
server_files/views/solutions_orga.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "server_files/views/header.php";
|
||||||
|
|
||||||
|
foreach ($tournaments as $tournament) {
|
||||||
|
echo "<h1>Tournoi de " . $tournament->getName() . "</h1>\n";
|
||||||
|
$sols = $tournament->getAllSolutions();
|
||||||
|
/** @var Solution $sol */
|
||||||
|
foreach ($sols as $sol) {
|
||||||
|
$file_id = $sol->getFileId();
|
||||||
|
$problem = $sol->getProblem();
|
||||||
|
$version = $sol->getVersion();
|
||||||
|
$team = Team::fromId($sol->getTeamId());
|
||||||
|
$team_name = $team->getName();
|
||||||
|
$team_trigram = $team->getTrigram();
|
||||||
|
echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<form method=\"POST\">\n";
|
||||||
|
echo "<input type=\"hidden\" name=\"tournament\" value=\"" . $tournament->getId() . "\" />\n";
|
||||||
|
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
|
||||||
|
echo "</form><hr />\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/footer.php";
|
79
server_files/views/syntheses.php
Normal file
79
server_files/views/syntheses.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
require_once "header.php";
|
||||||
|
|
||||||
|
if (date("yyyy-mm-dd") < $tournament->getSolutionsDate()) {
|
||||||
|
echo "<h3>Il est trop tôt pour se préoccuper des notes de synthèse, attendez le tirage des poules.</h3>";
|
||||||
|
require_once "server_files/views/footer.php";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($error_message)) {
|
||||||
|
if ($error_message !== false) {
|
||||||
|
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||||
|
}
|
||||||
|
}?>
|
||||||
|
|
||||||
|
<?php if (date("yyyy-mm-dd") < $tournament->getSynthesesDate()) { ?>
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="dest">Destination de la note de synthèse :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select style="width: 100%;" id="dest" name="dest">
|
||||||
|
<option value="opposant">Opposant</option>
|
||||||
|
<option value="rapporteur">Rapporteur</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="file">Fichier :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="file" id="file" name="synthese" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" name="send_synthesis" value="Envoyer" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<div style="padding: 20px"></div>
|
||||||
|
|
||||||
|
<h2>Notes de synthèse soumises :</h2>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
/** @var Synthesis $synthesis */
|
||||||
|
foreach ($syntheses as $synthesis) {
|
||||||
|
$file_id = $synthesis->getFileId();
|
||||||
|
$dest = $synthesis->getDest();
|
||||||
|
$version = $synthesis->getVersion();
|
||||||
|
echo "Note de synthèse pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . " (version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($team->isSelectedForFinal()) { ?>
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<h2>Notes de synthèse soumises pour la finale :</h2>
|
||||||
|
<?php
|
||||||
|
/** @var Synthesis $sol */
|
||||||
|
foreach ($syntheses_final as $synthesis) {
|
||||||
|
$file_id = $synthesis->getFileId();
|
||||||
|
$dest = $synthesis->getDest();
|
||||||
|
$version = $synthesis->getVersion();
|
||||||
|
echo "Note de synthèse pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . " (version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "footer.php";
|
27
server_files/views/syntheses_orga.php
Normal file
27
server_files/views/syntheses_orga.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "server_files/views/header.php";
|
||||||
|
|
||||||
|
/** @var Tournament $tournament */
|
||||||
|
foreach ($tournaments as $tournament) {
|
||||||
|
echo "<h1>Tournoi de " . $tournament->getName() . "</h1>\n";
|
||||||
|
$syntheses = $tournament->getAllSyntheses();
|
||||||
|
/** @var Synthesis $synthesis */
|
||||||
|
foreach ($syntheses as $synthesis) {
|
||||||
|
$file_id = $synthesis->getFileId();
|
||||||
|
$dest = $synthesis->getDest();
|
||||||
|
$version = $synthesis->getVersion();
|
||||||
|
$team = Team::fromId($synthesis->getTeamId());
|
||||||
|
$team_name = $team->getName();
|
||||||
|
$team_trigram = $team->getTrigram();
|
||||||
|
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur")
|
||||||
|
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<form method=\"POST\">\n";
|
||||||
|
echo "<input type=\"hidden\" name=\"tournament\" value=\"" . $tournament->getId() . "\" />\n";
|
||||||
|
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
|
||||||
|
echo "</form><hr />\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once "server_files/views/footer.php";
|
220
server_files/views/tournoi.php
Normal file
220
server_files/views/tournoi.php
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
<?php require_once "header.php" ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ($has_error)
|
||||||
|
echo "<h2>Erreur : $error_message</h2>";
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2>Tournoi de <?= $tournament->getName() ?></h2>
|
||||||
|
|
||||||
|
<strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong>
|
||||||
|
<?php
|
||||||
|
$s = "";
|
||||||
|
/** @var User $orga */
|
||||||
|
foreach ($orgas as $orga) {
|
||||||
|
$orga_id = $orga->getId();
|
||||||
|
$orga_name = $orga->getFirstName() . " " . $orga->getSurname();
|
||||||
|
if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN)
|
||||||
|
$s .= "<a href=\"$URL_BASE/informations/$orga_id/$orga_name\">$orga_name</a>";
|
||||||
|
else
|
||||||
|
$s .= $orga_name;
|
||||||
|
$s .= ", ";
|
||||||
|
}
|
||||||
|
echo substr($s, 0, -2);
|
||||||
|
?>
|
||||||
|
<br />
|
||||||
|
<strong>Nombre d'équipes maximal :</strong> <?= $tournament->getSize() ?><br />
|
||||||
|
<strong>Lieu :</strong> <?= $tournament->getPlace() ?><br />
|
||||||
|
<strong>Prix par partipant :</strong> <?= $tournament->getPrice() == 0 ? "Gratuit" : $tournament->getPrice() . " €" ?><br />
|
||||||
|
<strong>Dates :</strong> Du <?= formatDate($tournament->getStartDate()) ?> au <?= formatDate($tournament->getEndDate()) ?><br />
|
||||||
|
<strong>Clôture des inscriptions :</strong> <?= formatDate($tournament->getInscriptionDate(), true) ?><br />
|
||||||
|
<strong>Date limite d'envoi des solutions :</strong> <?= formatDate($tournament->getSolutionsDate(), true) ?><br />
|
||||||
|
<strong>Date limite d'envoi des notes de synthèse :</strong> <?= formatDate($tournament->getSynthesesDate(), true) ?><br />
|
||||||
|
<strong>Description :</strong> <?= $tournament->getDescription() ?><br />
|
||||||
|
<?php
|
||||||
|
if ($tournament->isFinal())
|
||||||
|
echo "<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong><br />";
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))) { ?>
|
||||||
|
<a href="<?= $URL_BASE ?>/tournoi/<?= $tournament->getName() ?>/modifier">Éditer le tournoi</a>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php if (!isset($_GET["modifier"])) { ?>
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<h2>Équipes inscrites à ce tournoi :</h2>
|
||||||
|
|
||||||
|
<table style="border: 1px solid black; width: 100%;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="border: 1px solid black; text-align: center">
|
||||||
|
Équipe
|
||||||
|
</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">
|
||||||
|
Trigramme
|
||||||
|
</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">
|
||||||
|
Date d'inscription
|
||||||
|
</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">
|
||||||
|
État de validation de l'inscription
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
/** @var Team $team */
|
||||||
|
foreach ($teams as $team) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td style="border: 1px solid black; text-align: center">
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION["role"]) && ($_SESSION["role"] == Role::ADMIN || ($_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))))
|
||||||
|
echo "<a href=\"$URL_BASE/equipe/" . $team->getTrigram() . "\">" . $team->getName(). "</a>";
|
||||||
|
else
|
||||||
|
echo $team->getName();
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td style="border: 1px solid black; text-align: center"><?= $team->getTrigram() ?></td>
|
||||||
|
<td style="border: 1px solid black; text-align: center"><?= formatDate($team->getInscriptionDate()) ?></td>
|
||||||
|
<td style="border: 1px solid black; text-align: center"><?= ValidationStatus::getTranslatedName($team->getValidationStatus()) ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th style="border: 1px solid black; text-align: center">
|
||||||
|
Équipe
|
||||||
|
</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">
|
||||||
|
Trigramme
|
||||||
|
</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">
|
||||||
|
Date d'inscription
|
||||||
|
</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">
|
||||||
|
État de validation de l'inscription
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
?>
|
||||||
|
<form method="POST">
|
||||||
|
<input type="hidden" name="submitted" value="true" />
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 30%;">
|
||||||
|
<label for="name">Nom :</label>
|
||||||
|
</td>
|
||||||
|
<td style="width: 70%;">
|
||||||
|
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $tournament->getName() ?>" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="organizers">Organisateur :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select style="width: 100%;" id="organizers" name="organizers[]" multiple size="4" required>
|
||||||
|
<?php
|
||||||
|
while (($orga_data = $orgas_response->fetch()) !== FALSE) {
|
||||||
|
echo "<option value=\"" . $orga_data["id"] . "\" " . ($tournament->organize($orga_data["id"]) ? "selected" : "")
|
||||||
|
. ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="size">Nombre d'équipes :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="<?= $tournament->getSize() ?>" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="place">Lieu :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="text" id="place" name="place" value="<?= $tournament->getPlace() ?>" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="price">Prix par participant</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="50" value="<?= $tournament->getPrice() ?>" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="date_start">Dates :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" value="<?= $tournament->getStartDate() ?>" required />
|
||||||
|
au <input style="width: 45%;" type="date" id="date_end" name="date_end" value="<?= $tournament->getEndDate() ?>" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="date_inscription">Date limite d'inscription :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" value="<?= substr($tournament->getInscriptionDate(), 0, 10) ?>" required />
|
||||||
|
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" value="<?= substr($tournament->getInscriptionDate(), 11) ?>" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="date_solutions">Date limite pour rendre les solutions :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" value="<?= substr($tournament->getSolutionsDate(), 0, 10) ?>" required />
|
||||||
|
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" value="<?= substr($tournament->getSolutionsDate(),11) ?>" required />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input style="width: 49%;" type="date" id="date_syntheses" name="date_syntheses"
|
||||||
|
value="<?= substr($tournament->getSynthesesDate(), 0, 10) ?>" required/>
|
||||||
|
<input style="width: 49%;" type="time" id="time_syntheses" name="time_syntheses"
|
||||||
|
value="<?= substr($tournament->getSynthesesDate(), 11) ?>" required/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="description">Description :</label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<textarea style="width: 100%;" name="description" id="description" required><?= $tournament->getDescription() ?></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<input style="width: 100%;" type="submit" name="edit_tournament" value="Modifier le tournoi" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
||||||
|
|
41
server_files/views/tournois.php
Normal file
41
server_files/views/tournois.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php require_once "header.php" ?>
|
||||||
|
|
||||||
|
<h2>Liste des tournois</h2>
|
||||||
|
|
||||||
|
<table style="border: 1px solid black; width: 100%">
|
||||||
|
<thead style="border: 1px solid black">
|
||||||
|
<tr>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Nom</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Dates</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Places disponibles</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody style="border: 1px solid black">
|
||||||
|
<?php
|
||||||
|
foreach ($tournaments as $tournament) {
|
||||||
|
?>
|
||||||
|
<tr style="border: 1px solid black">
|
||||||
|
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $tournament->getName() ?>"><?= $tournament->getName() ?></a></td>
|
||||||
|
<td style="border: 1px solid black; text-align: center">Du <?= formatDate($tournament->getStartDate()) ?> au <?= formatDate($tournament->getEndDate()) ?></td>
|
||||||
|
<td style="border: 1px solid black; text-align: center"><?= formatDate($tournament->getSolutionsDate()) ?></td>
|
||||||
|
<td style="border: 1px solid black; text-align: center"><?= formatDate($tournament->getSynthesesDate()) ?></td>
|
||||||
|
<td style="border: 1px solid black; text-align: center"><?= $tournament->getSize() ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
<tfoot style="border: 1px solid black">
|
||||||
|
<tr>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Nom</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Dates</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
|
||||||
|
<th style="border: 1px solid black; text-align: center">Places disponibles</th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php require_once "footer.php" ?>
|
184
setup/create_database.sql
Normal file
184
setup/create_database.sql
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
-- phpMyAdmin SQL Dump
|
||||||
|
-- version 4.6.6deb4
|
||||||
|
-- https://www.phpmyadmin.net/
|
||||||
|
--
|
||||||
|
-- Client : localhost:3306
|
||||||
|
-- Généré le : Dim 08 Septembre 2019 à 19:00
|
||||||
|
-- Version du serveur : 10.3.15-MariaDB-1
|
||||||
|
-- Version de PHP : 7.3.4-2
|
||||||
|
|
||||||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
SET time_zone = "+02:00";
|
||||||
|
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT = @@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS = @@CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET @OLD_COLLATION_CONNECTION = @@COLLATION_CONNECTION */;
|
||||||
|
/*!40101 SET NAMES utf8mb4 */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Base de données : `tfjm`
|
||||||
|
--
|
||||||
|
CREATE DATABASE IF NOT EXISTS `inscription-tfjm` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
USE `inscription-tfjm`;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `documents`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `documents`
|
||||||
|
(
|
||||||
|
`file_id` varchar(64) NOT NULL,
|
||||||
|
`user` int(11) NOT NULL,
|
||||||
|
`team` int(11) NOT NULL,
|
||||||
|
`tournament` int(11) NOT NULL,
|
||||||
|
`type` varchar(64) NOT NULL,
|
||||||
|
`uploaded_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`file_id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `organizers`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `organizers`
|
||||||
|
(
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`organizer` int(11) NOT NULL,
|
||||||
|
`tournament` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `solutions`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `solutions`
|
||||||
|
(
|
||||||
|
`file_id` varchar(64) NOT NULL,
|
||||||
|
`team` int(11) NOT NULL,
|
||||||
|
`tournament` int(11) NOT NULL,
|
||||||
|
`problem` int(11) NOT NULL,
|
||||||
|
`uploaded_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`file_id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `syntheses`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `syntheses`
|
||||||
|
(
|
||||||
|
`file_id` varchar(64) NOT NULL,
|
||||||
|
`team` int(11) NOT NULL,
|
||||||
|
`tournament` int(11) NOT NULL,
|
||||||
|
`dest` varchar(64) NOT NULL,
|
||||||
|
`uploaded_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`file_id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `teams`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `teams`
|
||||||
|
(
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(64) NOT NULL,
|
||||||
|
`trigram` varchar(3) NOT NULL,
|
||||||
|
`tournament` int(8) NOT NULL,
|
||||||
|
`encadrant_1` int(8) DEFAULT NULL,
|
||||||
|
`encadrant_2` int(8) DEFAULT NULL,
|
||||||
|
`participant_1` int(8) DEFAULT NULL,
|
||||||
|
`participant_2` int(8) DEFAULT NULL,
|
||||||
|
`participant_3` int(8) DEFAULT NULL,
|
||||||
|
`participant_4` int(8) DEFAULT NULL,
|
||||||
|
`participant_5` int(8) DEFAULT NULL,
|
||||||
|
`participant_6` int(8) DEFAULT NULL,
|
||||||
|
`inscription_date` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`validation_status` varchar(64) NOT NULL,
|
||||||
|
`final_selection` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`access_code` varchar(6) NOT NULL,
|
||||||
|
`year` int(4) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `tournaments`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `tournaments`
|
||||||
|
(
|
||||||
|
`id` int(8) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(64) NOT NULL,
|
||||||
|
`size` int(1) NOT NULL,
|
||||||
|
`place` varchar(255) NOT NULL,
|
||||||
|
`price` int(4) NOT NULL,
|
||||||
|
`description` varchar(255) NOT NULL,
|
||||||
|
`date_start` date NOT NULL,
|
||||||
|
`date_end` date NOT NULL,
|
||||||
|
`date_inscription` datetime NOT NULL,
|
||||||
|
`date_solutions` datetime NOT NULL,
|
||||||
|
`date_syntheses` datetime NOT NULL,
|
||||||
|
`final` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
`year` int(4) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `users`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `users`
|
||||||
|
(
|
||||||
|
`id` int(8) NOT NULL AUTO_INCREMENT,
|
||||||
|
`email` varchar(255) NOT NULL,
|
||||||
|
`pwd_hash` varchar(64) NOT NULL,
|
||||||
|
`surname` varchar(255) NOT NULL,
|
||||||
|
`first_name` varchar(255) NOT NULL,
|
||||||
|
`birth_date` date DEFAULT NULL,
|
||||||
|
`gender` char(1) DEFAULT NULL,
|
||||||
|
`address` varchar(255) DEFAULT NULL,
|
||||||
|
`postal_code` int(5) DEFAULT NULL,
|
||||||
|
`city` varchar(255) DEFAULT NULL,
|
||||||
|
`country` varchar(255) DEFAULT 'France',
|
||||||
|
`phone_number` varchar(20) DEFAULT NULL,
|
||||||
|
`school` varchar(255) DEFAULT NULL,
|
||||||
|
`class` varchar(255) DEFAULT NULL,
|
||||||
|
`responsible_name` varchar(255) DEFAULT NULL,
|
||||||
|
`responsible_phone` varchar(20) DEFAULT NULL,
|
||||||
|
`responsible_email` varchar(255) DEFAULT NULL,
|
||||||
|
`description` varchar(255) DEFAULT NULL,
|
||||||
|
`role` varchar(64) NOT NULL,
|
||||||
|
`team_id` int(8) DEFAULT NULL,
|
||||||
|
`year` int(4) NOT NULL DEFAULT 2020,
|
||||||
|
`confirm_email` varchar(64) DEFAULT NULL COMMENT 'Jeton de confirmation d''e-mail',
|
||||||
|
`forgotten_password` varchar(64) DEFAULT NULL COMMENT 'Jeton de récupération de mot de passe',
|
||||||
|
`inscription_date` datetime NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8;
|
||||||
|
|
||||||
|
/*!40101 SET CHARACTER_SET_CLIENT = @OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET CHARACTER_SET_RESULTS = @OLD_CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET COLLATION_CONNECTION = @OLD_COLLATION_CONNECTION */;
|
18
setup/msmtprc
Normal file
18
setup/msmtprc
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
defaults
|
||||||
|
auth on
|
||||||
|
tls on
|
||||||
|
tls_starttls off
|
||||||
|
tls_trust_file /etc/ssl/certs/ca-certificates.crt
|
||||||
|
syslog on
|
||||||
|
logfile /var/log/msmtp.log
|
||||||
|
|
||||||
|
account tfjm
|
||||||
|
host ssl0.ovh.net
|
||||||
|
auth on
|
||||||
|
port 465
|
||||||
|
from contact@tfjm.org
|
||||||
|
user contact@tfjm.org
|
||||||
|
passwordeval "echo $TFJM_MAIL_PASSWORD"
|
||||||
|
|
||||||
|
# Set a default account
|
||||||
|
account default : tfjm
|
Loading…
Reference in New Issue
Block a user