Merge branch 'master' into 'django'

# Conflicts:
#   Dockerfile
This commit is contained in:
Yohann D'ANELLO 2020-07-13 19:29:48 +00:00
commit db2ee8f78c
103 changed files with 8460 additions and 0 deletions

7
.htaccess Normal file
View 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]

6
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# Default ignored files
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

10
.idea/TFJM.iml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

15
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="tfjm@ynerant.fr" uuid="ce243a48-c634-4134-8105-e68ea53cd5ed">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://ynerant.fr:3306/tfjm</jdbc-url>
<driver-properties>
<property name="serverTimezone" value="GMT+1" />
</driver-properties>
<time-zone>GMT+1</time-zone>
</data-source>
</component>
</project>

22
.idea/deployment.xml Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" autoUpload="Always" serverName="inscription.tfjm.org" autoUploadExternalChanges="true">
<serverData>
<paths name="inscription.tfjm.org">
<serverdata>
<mappings>
<mapping deploy="/var/inscription-tfjm" local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="ynerant.fr">
<serverdata>
<mappings>
<mapping deploy="/var/www/html/tfjm" local="$PROJECT_DIR$" web="/tfjm" />
</mappings>
</serverdata>
</paths>
</serverData>
<option name="myAutoUpload" value="ALWAYS" />
</component>
</project>

6
.idea/misc.xml Normal file
View 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
View 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/TFJM.iml" filepath="$PROJECT_DIR$/.idea/TFJM.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View 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>

View File

@ -0,0 +1,113 @@
\documentclass[a4paper,french,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
%\usepackage{anyfontsize}
\usepackage{fancybox}
\usepackage{eso-pic,graphicx}
\usepackage{xcolor}
% Specials
\newcommand{\writingsep}{\vrule height 4ex width 0pt}
% Page formating
\hoffset -1in
\voffset -1in
\textwidth 180 mm
\textheight 250 mm
\oddsidemargin 15mm
\evensidemargin 15mm
\pagestyle{fancy}
% Headers and footers
\fancyfoot{}
\lhead{}
\rhead{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{\footnotesize 11 rue Pierre et Marie Curie, 75231 Paris Cedex 05\\ Numéro siret 431 598 366 00018}
\rfoot{\footnotesize Association agréée par\\le Ministère de l'éducation nationale.}
\begin{document}
\includegraphics[height=2cm]{assets/logo_animath.png}\hfill{\fontsize{55pt}{55pt}{$\mathbb{TFJM}^2$}}
\vfill
\begin{center}
\LARGE
Autorisation d'enregistrement et de diffusion de l'image ({TOURNAMENT_NAME})
\end{center}
\normalsize
\thispagestyle{empty}
\bigskip
Je soussign\'e {PARTICIPANT_NAME}\\
demeurant au {ADDRESS}
\medskip
Cochez la/les cases correspondantes.\\
\medskip
\fbox{\textcolor{white}{A}} Autorise l'association Animath, \`a l'occasion du $\mathbb{TFJM}^2$ du {START_DATE} au {END_DATE} {YEAR} à : {PLACE}, \`a me photographier ou \`a me filmer et \`a diffuser les photos et/ou les vid\'eos r\'ealis\'ees \`a cette occasion sur son site et sur les sites partenaires. D\'eclare c\'eder \`a titre gracieux \`a Animath le droit dutiliser mon image sur tous ses supports d'information : brochures, sites web, r\'eseaux sociaux. Animath devient, par la pr\'esente, cessionnaire des droits pendant toute la dur\'ee pour laquelle ont \'et\'e acquis les droits d'auteur de ces photographies.\\
\medskip
Animath s'engage, conform\'ement aux dispositions l\'egales en vigueur relatives au droit \`a l'image, \`a ce que la publication et la diffusion de l'image ainsi que des commentaires l'accompagnant ne portent pas atteinte \`a la vie priv\'ee, \`a la dignit\'e et \`a la r\'eputation de la personne photographiée.\\
\medskip
\fbox{\textcolor{white}{A}} Autorise la diffusion dans les medias (Presse, T\'el\'evision, Internet) de photographies prises \`a l'occasion dune \'eventuelle m\'ediatisation de cet événement.\\
\medskip
Conform\'ement \`a la loi informatique et libert\'es du 6 janvier 1978, vous disposez d'un droit de libre acc\`es, de rectification, de modification et de suppression des donn\'ees qui vous concernent.
Cette autorisation est donc r\'evocable \`a tout moment sur volont\'e express\'ement manifest\'ee par lettre recommand\'ee avec accus\'e de r\'eception adress\'ee \`a Animath, IHP, 11 rue Pierre et Marie Curie, 75231 Paris cedex 05.\\
\medskip
\fbox{\textcolor{white}{A}} Autorise Animath à conserver mes données personnelles, dans le cadre défini par la loi n 78-17 du 6 janvier 1978 relative à l'informatique, aux fichiers et aux libertés et les textes la modifiant, pendant une durée de quatre ans à compter de ma dernière participation à un événement organisé par Animath.\\
\medskip
\fbox{\textcolor{white}{A}} J'accepte d'être tenu informé d'autres activités organisées par l'association et ses partenaires.
\bigskip
Signature pr\'ec\'ed\'ee de la mention \og lu et approuv\'e \fg{}
\medskip
\begin{minipage}[c]{0.5\textwidth}
\underline{L'\'el\`eve :}\\
Fait \`a :\\
le
\end{minipage}
\vfill
\vfill
\begin{minipage}[c]{0.5\textwidth}
\footnotesize 11 rue Pierre et Marie Curie, 75231 Paris Cedex 05\\ Numéro siret 431 598 366 00018
\end{minipage}
\begin{minipage}[c]{0.5\textwidth}
\footnotesize
\begin{flushright}
Association agréée par\\le Ministère de l'éducation nationale.
\end{flushright}
\end{minipage}
\end{document}

View File

@ -0,0 +1,122 @@
\documentclass[a4paper,french,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
%\usepackage{anyfontsize}
\usepackage{fancybox}
\usepackage{eso-pic,graphicx}
\usepackage{xcolor}
% Specials
\newcommand{\writingsep}{\vrule height 4ex width 0pt}
% Page formating
\hoffset -1in
\voffset -1in
\textwidth 180 mm
\textheight 250 mm
\oddsidemargin 15mm
\evensidemargin 15mm
\pagestyle{fancy}
% Headers and footers
\fancyfoot{}
\lhead{}
\rhead{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{\footnotesize 11 rue Pierre et Marie Curie, 75231 Paris Cedex 05\\ Numéro siret 431 598 366 00018}
\rfoot{\footnotesize Association agréée par\\le Ministère de l'éducation nationale.}
\begin{document}
\includegraphics[height=2cm]{assets/logo_animath.png}\hfill{\fontsize{55pt}{55pt}{$\mathbb{TFJM}^2$}}
\vfill
\begin{center}
\LARGE
Autorisation d'enregistrement et de diffusion de l'image
({TOURNAMENT_NAME})
\end{center}
\normalsize
\thispagestyle{empty}
\bigskip
Je soussign\'e \dotfill (p\`ere, m\`ere, responsable l\'egal) \\
agissant en qualit\'e de repr\'esentant de {PARTICIPANT_NAME}\\
demeurant au {ADDRESS}
\medskip
Cochez la/les cases correspondantes.\\
\medskip
\fbox{\textcolor{white}{A}} Autorise l'association Animath, \`a l'occasion du $\mathbb{TFJM}^2$ du {START_DATE} au {END_DATE} {YEAR} à : {PLACE}, \`a photographier ou \`a filmer l'enfant et \`a diffuser les photos et/ou les vid\'eos r\'ealis\'ees \`a cette occasion sur son site et sur les sites partenaires. D\'eclare c\'eder \`a titre gracieux \`a Animath le droit dutiliser l'image de l'enfant sur tous ses supports d'information : brochures, sites web, r\'eseaux sociaux. Animath devient, par la pr\'esente, cessionnaire des droits pendant toute la dur\'ee pour laquelle ont \'et\'e acquis les droits d'auteur de ces photographies.\\
\medskip
Animath s'engage, conform\'ement aux dispositions l\'egales en vigueur relatives au droit \`a l'image, \`a ce que la publication et la diffusion de l'image de l'enfant ainsi que des commentaires l'accompagnant ne portent pas atteinte \`a la vie priv\'ee, \`a la dignit\'e et \`a la r\'eputation de lenfant.\\
\medskip
\fbox{\textcolor{white}{A}} Autorise la diffusion dans les medias (Presse, T\'el\'evision, Internet) de photographies de mon enfant prises \`a l'occasion dune \'eventuelle m\'ediatisation de cet événement.\\
\medskip
Conform\'ement \`a la loi informatique et libert\'es du 6 janvier 1978, vous disposez d'un droit de libre acc\`es, de rectification, de modification et de suppression des donn\'ees qui vous concernent.
Cette autorisation est donc r\'evocable \`a tout moment sur volont\'e express\'ement manifest\'ee par lettre recommand\'ee avec accus\'e de r\'eception adress\'ee \`a Animath, IHP, 11 rue Pierre et Marie Curie, 75231 Paris cedex 05.\\
\medskip
\fbox{\textcolor{white}{A}} Autorise Animath à conserver mes données personnelles, dans le cadre défini par la loi n 78-17 du 6 janvier 1978 relative à l'informatique, aux fichiers et aux libertés et les textes la modifiant, pendant une durée de quatre ans à compter de ma dernière participation à un événement organisé par Animath.\\
\medskip
\fbox{\textcolor{white}{A}} J'accepte d'être tenu informé d'autres activités organisées par l'association et ses partenaires.
\bigskip
Signatures pr\'ec\'ed\'ees de la mention \og lu et approuv\'e \fg{}
\medskip
\begin{minipage}[c]{0.5\textwidth}
\underline{Le responsable l\'egal :}\\
Fait \`a :\\
le :
\end{minipage}
\begin{minipage}[c]{0.5\textwidth}
\underline{L'\'el\`eve :}\\
Fait \`a :\\
le
\end{minipage}
\vfill
\vfill
\begin{minipage}[c]{0.5\textwidth}
\footnotesize 11 rue Pierre et Marie Curie, 75231 Paris Cedex 05\\ Numéro siret 431 598 366 00018
\end{minipage}
\begin{minipage}[c]{0.5\textwidth}
\footnotesize
\begin{flushright}
Association agréée par\\le Ministère de l'éducation nationale.
\end{flushright}
\end{minipage}
\end{document}

View File

@ -0,0 +1,66 @@
\documentclass[a4paper,french,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[french]{babel}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
%\usepackage{anyfontsize}
\usepackage{fancybox}
\usepackage{eso-pic,graphicx}
\usepackage{xcolor}
% Specials
\newcommand{\writingsep}{\vrule height 4ex width 0pt}
% Page formating
\hoffset -1in
\voffset -1in
\textwidth 180 mm
\textheight 250 mm
\oddsidemargin 15mm
\evensidemargin 15mm
\pagestyle{fancy}
% Headers and footers
\fancyfoot{}
\lhead{}
\rhead{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{\footnotesize 11 rue Pierre et Marie Curie, 75231 Paris Cedex 05\\ Numéro siret 431 598 366 00018}
\rfoot{\footnotesize Association agréée par\\le Ministère de l'éducation nationale.}
\begin{document}
\includegraphics[height=2cm]{assets/logo_animath.png}\hfill{\fontsize{55pt}{55pt}{$\mathbb{TFJM}^2$}}
\vfill
\begin{center}
\Large \bf Autorisation parentale pour les mineurs ({TOURNAMENT_NAME})
\end{center}
Je soussigné(e) \hrulefill,\\
responsable légal, demeurant \writingsep\hrulefill\\
\writingsep\hrulefill,\\
\writingsep autorise {PARTICIPANT_NAME},\\
né(e) le {BIRTHDAY},
à participer au Tournoi Français des Jeunes Mathématiciennes et Mathématiciens ($\mathbb{TFJM}^2$) organisé \`a : {PLACE}, du {START_DATE} au {END_DATE} {YEAR}.
{PRONOUN} se rendra au lieu indiqu\'e ci-dessus le vendredi matin et quittera les lieux l'après-midi du dimanche par ses propres moyens et sous la responsabilité du représentant légal.
\vspace{8ex}
Fait à \vrule width 10cm height 0pt depth 0.4pt, le \phantom{232323}/\phantom{XXX}/{YEAR},
\vfill
\vfill
\end{document}

BIN
assets/Fiche synthèse.pdf Normal file

Binary file not shown.

194
assets/Fiche synthèse.tex Normal file
View File

@ -0,0 +1,194 @@
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} % marges
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\newcommand{\N}{{\bf N}}
\newcommand{\Z}{{\bf Z}}
\newcommand{\Q}{{\bf Q}}
\newcommand{\R}{{\bf R}}
\newcommand{\C}{{\bf C}}
\newcommand{\A}{{\bf A}}
\newtheorem{theo}{Théorème}
\newtheorem{theo-defi}[theo]{Théorème-Définition}
\newtheorem{defi}[theo]{Définition}
\newtheorem{lemme}[theo]{Lemme}
\newtheorem{slemme}[theo]{Sous-lemme}
\newtheorem{prop}[theo]{Proposition}
\newtheorem{coro}[theo]{Corollaire}
\newtheorem{conj}[theo]{Conjecture}
\title{Note de synthèse}
\begin{document}
\pagestyle{empty}
\begin{center}
\begin{Huge}
$\mathbb{TFJM}^2$
\end{Huge}
\bigskip
\begin{Large}
NOTE DE SYNTHESE
\end{Large}
\end{center}
Tour \underline{~~~~} poule \underline{~~~~}
\medskip
Problème \underline{~~~~} défendu par l'équipe \underline{~~~~~~~~~~~~~~~~~~~~~~~~}
\medskip
Synthèse par l'équipe \underline{~~~~~~~~~~~~~~~~~~~~~~~~} dans le rôle de : ~ $\square$ Opposant ~ $\square$ Rapporteur
\section*{Questions traitées}
\begin{tabular}{r c l}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Question ~ & ER & ~PR~ & QE & NT \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
\end{tabular}
& ~~ &
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Question ~ & ER & ~PR~ & QE & NT \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
\end{tabular} \\
& & \\
ER : entièrement résolue & & PR : partiellement résolue \\
\smallskip
QE : quelques éléments de réponse & & NT : non traitée
\end{tabular}
~
\smallskip
Remarque : il est possible de cocher entre les cases pour un cas intermédiaire.
\section*{Evaluation qualitative de la solution}
Donnez votre avis concernant la solution. Mettez notamment en valeur les points positifs (des idées
importantes, originales, etc.) et précisez ce qui aurait pu améliorer la solution.
\vfill
\textbf{Evaluation générale :} ~ $\square$ Excellente ~ $\square$ Bonne ~ $\square$ Suffisante ~ $\square$ Passable
\newpage
\section*{Erreurs et imprécisions}
Listez ci-dessous les cinq erreurs et/ou imprécisions les plus importantes selon vous, par ordre d'importance, en précisant la
question concernée, la page, le paragraphe et le type de remarque.
\bigskip
1. Question \underline{~~~~} Page \underline{~~~~} Paragraphe \underline{~~~~}
$\square$ Erreur majeure ~ $\square$ Erreur mineure ~ $\square$ Imprécision ~ $\square$ Autre : \underline{~~~~~~~~}
Description :
\vfill
2. Question \underline{~~~~} Page \underline{~~~~} Paragraphe \underline{~~~~}
$\square$ Erreur majeure ~ $\square$ Erreur mineure ~ $\square$ Imprécision ~ $\square$ Autre : \underline{~~~~~~~~}
Description :
\vfill
3. Question \underline{~~~~} Page \underline{~~~~} Paragraphe \underline{~~~~}
$\square$ Erreur majeure ~ $\square$ Erreur mineure ~ $\square$ Imprécision ~ $\square$ Autre : \underline{~~~~~~~~}
Description :
\vfill
4. Question \underline{~~~~} Page \underline{~~~~} Paragraphe \underline{~~~~}
$\square$ Erreur majeure ~ $\square$ Erreur mineure ~ $\square$ Imprécision ~ $\square$ Autre : \underline{~~~~~~~~}
Description :
\vfill
5. Question \underline{~~~~} Page \underline{~~~~} Paragraphe \underline{~~~~}
$\square$ Erreur majeure ~ $\square$ Erreur mineure ~ $\square$ Imprécision ~ $\square$ Autre : \underline{~~~~~~~~}
Description :
\vfill
\section*{Remarques formelles (facultatif)}
Donnez votre avis concernant la présentation de la solution (lisibilité, etc.).
\vfill
\end{document}

BIN
assets/Fiche_sanitaire.pdf Normal file

Binary file not shown.

88
assets/Instructions.tex Normal file
View File

@ -0,0 +1,88 @@
\documentclass[a4paper,french,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
%\usepackage{anyfontsize}
\usepackage{fancybox}
\usepackage{eso-pic,graphicx}
\usepackage{xcolor}
\usepackage{hyperref}
% Specials
\newcommand{\writingsep}{\vrule height 4ex width 0pt}
% Page formating
\hoffset -1in
\voffset -1in
\textwidth 180 mm
\textheight 250 mm
\oddsidemargin 15mm
\evensidemargin 15mm
\pagestyle{fancy}
% Headers and footers
\fancyfoot{}
\lhead{}
\rhead{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{\footnotesize 11 rue Pierre et Marie Curie, 75231 Paris Cedex 05\\ Numéro siret 431 598 366 00018}
\rfoot{\footnotesize Association agréée par\\le Ministère de l'éducation nationale.}
\begin{document}
\includegraphics[height=2cm]{assets/logo_animath.png}\hfill{\fontsize{50pt}{50pt}{$\mathbb{TFJM}^2$}}
\begin{center}
\Large \bf Instructions ({TOURNAMENT_NAME})
\end{center}
\section{Documents}
\subsection{Autorisation parentale}
Elle est nécessaire si l'élève est mineur au moment du tournoi (y compris si son anniversaire est pendant le tournoi).
\subsection{Autorisation de prise de vue}
Si l'élève est mineur \textbf{au moment de la signature}, il convient de remplir l'autorisation pour les mineurs. En revanche, s'il est majeur \textbf{au moment de la signature}, il convient de remplir la fiche pour majeur.
\subsection{Fiche sanitaire}
Elle est nécessaire si l'élève est mineur au moment du tournoi (y compris si son anniversaire est pendant le tournoi).
\section{Paiement}
\subsection{Montant}
Les frais d'inscription sont fixés à {PRICE} euros. Vous devez vous en acquitter \textbf{avant le {END_PAYMENT_DATE} {YEAR}}. Si l'élève est boursier, il en est dispensé, vous devez alors fournir une copie de sa notification de bourse directement sur la plateforme \textbf{avant le {END_PAYMENT_DATE} {YEAR}}.
\subsection{Procédure}
Si le paiement de plusieurs élèves est fait en une seule opération, merci de contacter \href{mailto: contact@tfjm.org}{contact@tfjm.org} \textbf{avant le paiement} pour garantir l'identification de ce dernier
\subsubsection*{Carte bancaire (uniquement les cartes françaises)}
Le paiement s'effectue en ligne via la plateforme à l'adresse : \url{https://www.helloasso.com/associations/animath/evenements/tfjm-2020}
Vous devez impérativement indiquer dans le champ "Référence" la mention "TFJMpu" suivie des noms et prénoms \textbf{de l'élève}.
\subsubsection*{Virement}
\textbf{Si vous ne pouvez pas utiliser le paiement par carte}, vous pouvez faire un virement sur le compte ci-dessous en indiquant bien dans le champ "motif" (ou autre champ propre à votre banque dont le contenu est communiqué au destinataire) la mention "TFJMpu" suivie des noms et prénoms \textbf{de l'élève}.
IBAN FR76 1027 8065 0000 0206 4290 127
BIC CMCIFR2A
\subsubsection*{Autre}
Si aucune de ces procédures n'est possible pour vous, envoyez un mail à \href{mailto: contact@tfjm.org}{contact@tfjm.org} pour que nous trouvions une solution à vos difficultés.
\end{document}

BIN
assets/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

114
assets/logo.svg Normal file
View 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

BIN
assets/logo_animath.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

47
assets/style.css Normal file
View File

@ -0,0 +1,47 @@
html, body {
height: 100%;
margin: 0;
}
:root {
--navbar-height: 32px;
}
.container {
min-height: 78%;
}
.inner {
margin: 20px;
}
.alert {
text-align: justify;
}
footer .alert {
text-align: center;
}
#navbar-logo {
height: var(--navbar-height);
display: block;
}
ul .deroule {
display: none;
position: absolute;
background: #f8f9fa !important;
list-style-type: none;
padding: 20px;
z-index: 42;
}
li:hover ul.deroule {
display:block;
}
a.nav-link:hover {
background-color: #d8d9da;
}

92
dispatcher.php Normal file
View File

@ -0,0 +1,92 @@
<?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/classes/PaymentMethod.php";
require_once "server_files/classes/Payment.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["^equipe/([A-Z]{3})/(modifier)?$"] = ["server_files/controllers/equipe.php", "trigram", "modifier"];
$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["^(modifier-page)$"] = ["server_files/controllers/index.php", "edit"];
$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["^organisateurs/?$"] = ["server_files/controllers/organisateurs.php"];
$ROUTES["^paiement/?$"] = ["server_files/controllers/paiement.php"];
$ROUTES["^profils/?$"] = ["server_files/controllers/profils.php"];
$ROUTES["^profils-(orphelins)/?$"] = ["server_files/controllers/profils.php", "orphans"];
$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"];
$ROUTES["^Autorisation de droit à l'image.pdf$"] = ["server_files/controllers/autorisation_droit_image.php"];
$ROUTES["^Autorisation parentale.pdf$"] = ["server_files/controllers/autorisation_parentale.php"];
$ROUTES["^Instructions.pdf$"] = ["server_files/controllers/instructions.php"];
# Assets files
$ROUTES["^favicon\.ico$"] = ["assets/favicon.ico", "image/x-icon"];
$ROUTES["^Fiche sanitaire\.pdf$"] = ["assets/Fiche_sanitaire.pdf", "application/pdf"];
$ROUTES["^Note de synthèse.pdf$"] = ["assets/Fiche synthèse.pdf", "application/pdf"];
$ROUTES["^Note de synthèse.tex"] = ["assets/Fiche synthèse.tex", "text/plain"];
$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();
}
$view = $file[0];
/** @noinspection PhpIncludeInspection */
require $view;
exit();
}
}
require_once "server_files/404.php";

12
index.html Normal file
View 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>

16
server_files/403.php Normal file
View File

@ -0,0 +1,16 @@
<?php
require_once "config.php";
require_once "views/header.php";
http_response_code(403);
?>
<div class="alert alert-danger mt-4 mb-4">
<h2 class="display-5">
Vous n'êtes pas autorisé à accéder à cette page.
</h2>
</div>
<?php
require_once "views/footer.php";

16
server_files/404.php Normal file
View File

@ -0,0 +1,16 @@
<?php
require_once "config.php";
require_once "views/header.php";
http_response_code(404);
?>
<div class="alert alert-danger mt-4 mb-4">
<h2 class="display-5">
Cette page n'existe pas.
</h2>
</div>
<?php
require_once "views/footer.php";

View File

@ -0,0 +1,339 @@
<?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 $round;
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 = $data["dest"];
$this->round = $data["round"];
$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 getRound()
{
return $this->round;
}
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;
const SCHOLARSHIP = 5;
const MOTIVATION_LETTER = 6;
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::SCHOLARSHIP:
return "Notification de bourse";
case self::MOTIVATION_LETTER:
return "Lettre de motivation";
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::SCHOLARSHIP:
return "SCHOLARSHIP";
case self::MOTIVATION_LETTER:
return "MOTIVATION_LETTER";
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 "SCHOLARSHIP":
return self::SCHOLARSHIP;
case "MOTIVATION_LETTER":
return self::MOTIVATION_LETTER;
case "SOLUTION":
return self::SOLUTION;
default:
return self::SYNTHESIS;
}
}
}

View File

@ -0,0 +1,152 @@
<?php
class Payment
{
private $id;
private $user_id;
private $tournament_id;
private $amount;
private $method;
private $transaction_infos;
private $validation_status;
private function __construct() {}
public static function fromId($id)
{
global $DB;
$req = $DB->prepare("SELECT * FROM `payments` WHERE `id` = ?;");
$req->execute([htmlspecialchars($id)]);
$data = $req->fetch();
if ($data === false)
return null;
$payment = new Payment();
$payment->fill($data);
return $payment;
}
private function fill($data)
{
$this->id = $data["id"];
$this->user_id = $data["user"];
$this->tournament_id = $data["tournament"];
$this->amount = $data["amount"];
$this->method = PaymentMethod::fromName($data["method"]);
$this->transaction_infos = $data["transaction_infos"];
$this->validation_status = ValidationStatus::fromName($data["validation_status"]);
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return int
*/
public function getAmount()
{
return $this->amount;
}
/**
* @param mixed $amount
*/
public function setAmount($amount)
{
global $DB;
$this->amount = $amount;
$DB->prepare("UPDATE `payments` SET `amount` = ? WHERE `id` = ?;")->execute([$amount, $this->id]);
}
/**
* @return int
*/
public function getMethod()
{
return $this->method;
}
/**
* @param int $method
*/
public function setMethod($method)
{
global $DB;
$this->method = $method;
$DB->prepare("UPDATE `payments` SET `method` = ? WHERE `id` = ?;")->execute([PaymentMethod::getName($method), $this->id]);
}
/**
* @return int
*/
public function getTournamentId()
{
return $this->tournament_id;
}
/**
* @return Tournament|null
*/
public function getTournament()
{
return Tournament::fromId($this->getTournamentId());
}
/**
* @return int
*/
public function getUserId()
{
return $this->user_id;
}
/**
* @return User|null
*/
public function getUser()
{
return User::fromId($this->getUserId());
}
/**
* @return string
*/
public function getTransactionInfos()
{
return $this->transaction_infos;
}
/**
* @param string $transaction_infos
*/
public function setTransactionInfos($transaction_infos)
{
global $DB;
$this->transaction_infos = $transaction_infos;
$DB->prepare("UPDATE `payments` SET `transaction_infos` = ? WHERE `id` = ?;")->execute([$transaction_infos, $this->id]);
}
/**
* @return int
*/
public function getValidationStatus()
{
return $this->validation_status;
}
/**
* @param int $validation_status
*/
public function setValidationStatus($validation_status)
{
global $DB;
$this->validation_status = $validation_status;
$DB->prepare("UPDATE `payments` SET `validation_status` = ? WHERE `id` = ?;")->execute([ValidationStatus::getName($validation_status), $this->id]);
}
}

View File

@ -0,0 +1,62 @@
<?php
class PaymentMethod
{
const CREDIT_CARD = 1;
const BANK_CHECK = 2;
const BANK_TRANSFER = 3;
const CASH = 4;
const SCHOLARSHIP = 5;
const NOT_PAID = 0;
public static function getTranslatedName($status) {
switch ($status) {
case self::CREDIT_CARD:
return "Carte bancaire";
case self::BANK_CHECK:
return "Chèque";
case self::BANK_TRANSFER:
return "Virement";
case self::CASH:
return "Espèce";
case self::SCHOLARSHIP:
return "Je suis boursier";
default:
return "Pas encore payé";
}
}
public static function getName($status) {
switch ($status) {
case self::CREDIT_CARD:
return "CREDIT_CARD";
case self::BANK_CHECK:
return "BANK_CHECK";
case self::BANK_TRANSFER:
return "BANK_TRANSFER";
case self::CASH:
return "CASH";
case self::SCHOLARSHIP:
return "SCHOLARSHIP";
default:
return "NOT_PAID";
}
}
public static function fromName($name) {
switch ($name) {
case "CREDIT_CARD":
return self::CREDIT_CARD;
case "BANK_CHECK":
return self::BANK_CHECK;
case "BANK_TRANSFER":
return self::BANK_TRANSFER;
case "CASH":
return self::CASH;
case "SCHOLARSHIP":
return self::SCHOLARSHIP;
default:
return self::NOT_PAID;
}
}
}

View File

@ -0,0 +1,55 @@
<?php
class Role
{
const OBSERVER = -1;
const PARTICIPANT = 0;
const ENCADRANT = 1;
const ORGANIZER = 2;
const ADMIN = 3;
public static function getTranslatedName($role) {
switch ($role) {
case self::OBSERVER:
return "Observateur";
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::OBSERVER:
return "OBSERVER";
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 "OBSERVER":
return self::OBSERVER;
case "ENCADRANT":
return self::ENCADRANT;
case "ORGANIZER":
return self::ORGANIZER;
case "ADMIN":
return self::ADMIN;
default:
return self::PARTICIPANT;
}
}
}

View File

@ -0,0 +1,54 @@
<?php
class SchoolClass
{
const SECONDE = 0;
const PREMIERE = 1;
const TERMINALE = 2;
const ADULT = 3;
public static function getTranslatedName($class) {
switch ($class) {
case self::SECONDE:
return "Seconde ou inférieur";
case self::PREMIERE:
return "Première";
case self::TERMINALE:
return "Terminale";
case self::ADULT:
return "Adulte";
default:
return null;
}
}
public static function getName($class) {
switch ($class) {
case self::SECONDE:
return "SECONDE";
case self::PREMIERE:
return "PREMIERE";
case self::TERMINALE:
return "TERMINALE";
case self::ADULT:
return "ADULT";
default:
return null;
}
}
public static function fromName($name) {
switch ($name) {
case "SECONDE":
return self::SECONDE;
case "PREMIERE":
return self::PREMIERE;
case "TERMINALE":
return self::TERMINALE;
case "ADULT":
return self::ADULT;
default:
return null;
}
}
}

View File

@ -0,0 +1,209 @@
<?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"], $data["encadrant_3"]];
$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;
}
/**
* @return Tournament
*/
public function getEffectiveTournament()
{
return $this->isSelectedForFinal() ? Tournament::getFinalTournament() : Tournament::fromId($this->getTournamentId());
}
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;
}
public static function getAllTeams($only_not_validated = false)
{
global $DB, $YEAR;
$req = $DB->query("SELECT * FROM `teams` WHERE " . ($only_not_validated ? "`validation_status` = 0 AND " : "") . "`year` = $YEAR;");
$teams = [];
while (($data = $req->fetch()) != false) {
$team = new Team();
$team->fill($data);
$teams[] = $team;
}
return $teams;
}
}

View File

@ -0,0 +1,385 @@
<?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 $date_solutions_2;
private $date_syntheses_2;
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_solutions_2 = $data["date_solutions_2"];
$this->date_syntheses = $data["date_syntheses"];
$this->date_syntheses_2 = $data["date_syntheses_2"];
$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 getSolutionsDate2()
{
return $this->date_solutions_2;
}
public function setSolutionsDate2($date)
{
global $DB;
$this->date_solutions_2 = $date;
$DB->prepare("UPDATE `tournaments` SET `date_solutions_2` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
}
public function getSynthesesDate2()
{
return $this->date_syntheses_2;
}
public function setSynthesesDate2($date)
{
global $DB;
$this->date_syntheses_2 = $date;
$DB->prepare("UPDATE `tournaments` SET `date_syntheses_2` = ? 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`, `round`, `tournament`, MAX(`uploaded_at`) AS `last_upload`, COUNT(`team`) AS `version` FROM `syntheses` GROUP BY `tournament`, `team`, `dest`, `round`) `t2` "
. "ON `t1`.`team` = `t2`.`team` AND `t1`.`dest` = `t2`.`dest` AND `t1`.`tournament` = `t2`.`tournament` AND `t1`.`round` = `t2`.`round` "
. "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`.`round`, `t1`.`dest`;");
$syntheses = [];
while (($data = $req->fetch()) !== false)
$syntheses[] = Synthesis::fromData($data);
return $syntheses;
}
}

View File

@ -0,0 +1,481 @@
<?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 static function getOrganizers()
{
global $DB, $YEAR;
$admins = [];
$req = $DB->query("SELECT * FROM `users` WHERE `role` = 'ORGANIZER' OR `role` = 'ADMIN' AND `year` = $YEAR ORDER BY `role` DESC, `surname`, `first_name`;");
while (($data = $req->fetch()) !== false) {
$admin = new User();
$admin->fill($data);
$admins[] = $admin;
}
return $admins;
}
public static function getAdmins()
{
global $DB, $YEAR;
$users = [];
$req = $DB->query("SELECT * FROM `users` WHERE (`role` = 'ADMIN') "
. "AND `year` = $YEAR ORDER BY `role`, `inscription_date`;");
while (($data = $req->fetch()) !== false) {
$orphan = new User();
$orphan->fill($data);
$users[] = $orphan;
}
return $users;
}
public static function getAllUsers()
{
global $DB, $YEAR;
$users = [];
$req = $DB->query("SELECT * FROM `users` WHERE `year` = $YEAR ORDER BY `role` DESC, `inscription_date`;");
while (($data = $req->fetch()) !== false) {
$orphan = new User();
$orphan->fill($data);
$users[] = $orphan;
}
return $users;
}
public static function getOrphanUsers()
{
global $DB, $YEAR;
$orphans = [];
$req = $DB->query("SELECT * FROM `users` WHERE `role` != 'ADMIN' AND `team_id` IS NULL "
. "AND `year` = $YEAR ORDER BY `role`, `inscription_date`;");
while (($data = $req->fetch()) !== false) {
$orphan = new User();
$orphan->fill($data);
$orphans[] = $orphan;
}
return $orphans;
}
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([$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);
if ($this->team_id > 0) {
$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`.`team` = $this->team_id "
. "AND `t1`.`type` = 'MOTIVATION_LETTER';");
while (($data = $req->fetch()) !== false)
$docs[] = Document::fromData($data);
}
return $docs;
}
public function getPayment() {
global $DB;
$team = Team::fromId($this->team_id);
$tournament = $team->getEffectiveTournament();
$req = $DB->prepare("SELECT `id` FROM `payments` WHERE `user` = ?;");
$req->execute([$this->id]);
if (($data = $req->fetch()) !== false)
return Payment::fromId($data["id"]);
$req = $DB->prepare("INSERT INTO `payments`(`user`, `tournament`, `amount`, `method`, `transaction_infos`, `validation_status`) VALUES (?, ?, ?, ?, ?, ?);");
$req->execute([$this->id, $tournament->getId(), 0, PaymentMethod::getName(PaymentMethod::NOT_PAID), "L'inscription n'est pas encore payée.", ValidationStatus::getName(ValidationStatus::NOT_READY)]);
return $this->getPayment();
}
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;
}
}

View 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;
}
}
}

31
server_files/config.php Normal file
View File

@ -0,0 +1,31 @@
<?php
/**
* Config options
*/
$YEAR = getenv("TFJM_YEAR");
$URL_BASE = getenv("TFJM_URL_BASE");
$LOCAL_PATH = getenv("TFJM_LOCAL_PATH");
$MAIL_DOMAIN = getenv("TFJM_MAIL_DOMAIN");
/**
* DB infos
*/
$DB_HOST = getenv("TFJM_DB_HOST");
$DB_NAME = getenv("TFJM_DB_NAME");
$DB_USER = getenv("TFJM_DB_USER");
$DB_PASSWORD = getenv("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());
}
date_default_timezone_set("Europe/Paris");
session_start();
setlocale(LC_ALL, "fr_FR.utf8");

View 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_TIMESTAMP AND `year` = $YEAR;");
$has_error = false;
$error_message = null;
if (isset($_POST["add_team"])) {
$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::getName(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";

View File

@ -0,0 +1,59 @@
<?php
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$has_error = false;
$error_message = null;
if (isset($_POST["add_orga"])) {
$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 $token;
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 = isset($this->admin) ? 1 : 0;
}
public function register() {
global $DB, $YEAR;
$this->password = genRandomPhrase(16, true);
$this->token = genRandomPhrase(64);
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `surname`, `first_name`, `role`, `forgotten_password`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?);");
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->surname, $this->first_name, $this->admin ? "ADMIN" : "ORGANIZER", $this->token, $YEAR]);
Mailer::sendAddOrganizerMail($this);
}
}
require_once "server_files/views/ajouter_organisateur.php";

View File

@ -0,0 +1,111 @@
<?php
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$has_error = false;
$error_message = null;
if (isset($_POST["add_tournament"])) {
$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 $date_solutions_2;
public $time_solutions_2;
public $date_syntheses_2;
public $time_syntheses_2;
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 pour le tour 1 n'est pas valide.");
ensure(dateWellFormed($this->date_solutions_2 . " " . $this->time_solutions_2), "La date limite de visibilité des solutions du tour 2 n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses . " " . $this->time_syntheses), "La date limite de remise des notes de synthèse pour le tour 2 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`,
`date_solutions_2`, `date_syntheses_2`, `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->date_solutions_2 $this->time_solutions_2",
"$this->date_syntheses_2 $this->time_syntheses_2", $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";

View File

@ -0,0 +1,52 @@
<?php
/**
* @var User $user
* @var Team $team
* @var Tournament $tournament
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
if (!isset($user) || isset($_GET["blank"]) || $_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
$tournament = Tournament::fromName($_GET["blank"]);
$majeur = isset($_GET["mineur"]) ? 0 : 1;
$tex = file_get_contents("assets/Autorisation_droit_image_" . ($majeur ? "majeur" : "mineur") . ".tex");
if ($tournament == null)
require_once "server_files/403.php";
$tex = preg_replace("#{PARTICIPANT_NAME}#", "\\dotfill .", $tex);
$tex = preg_replace("#{BIRTHDAY}#", "\phantom{232323}/\phantom{232323}/\phantom{232323}", $tex);
$tex = preg_replace("#{ADDRESS}#", "\dotfill .\\\n.\dotfill .", $tex);
}
else {
$tournament = $team->getEffectiveTournament();
$majeur = $user->getBirthDate() > strval($YEAR - 18) . substr($tournament->getStartDate(), 4);
$tex = file_get_contents("assets/Autorisation_droit_image_" . ($majeur ? "majeur" : "mineur") . ".tex");
$tex = preg_replace("#{PARTICIPANT_NAME}#", "\\texttt{" . $user->getFirstName() . " " . $user->getSurname() . "}", $tex);
$tex = preg_replace("#{BIRTHDAY}#", "\\texttt{" . strftime("%d %B %G", strtotime($user->getBirthDate())) . "}", $tex);
$tex = preg_replace("#{ADDRESS}#", "\\texttt{" . $user->getAddress() . ", " . $user->getPostalCode() . ", " . $user->getCity()
. ($user->getCountry() == "France" ? "" : $user->getCountry()) . "}.", $tex);
}
$tex = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $tex);
$tex = preg_replace("#{PLACE}#", $tournament->getPlace(), $tex);
$tex = preg_replace("#{START_DATE}#", strftime("%d %B", strtotime($tournament->getStartDate())), $tex);
$tex = preg_replace("#{END_DATE}#", strftime("%d %B", strtotime($tournament->getEndDate())), $tex);
$tex = preg_replace("#{YEAR}#", $YEAR, $tex);
shell_exec("mkdir tmp");
file_put_contents("tmp/file.tex", $tex);
shell_exec("pdflatex -synctex=1 -interaction=nonstopmode -shell-escape -output-directory=tmp tmp/file.tex");
header("Content-type: application/pdf");
readfile("tmp/file.pdf");
exit(0);

View File

@ -0,0 +1,44 @@
<?php
$tex = file_get_contents("assets/Autorisation_parentale.tex");
/**
* @var User $user
* @var Team $team
* @var Tournament $tournament
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
if (!isset($user) || isset($_GET["blank"]) || $_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
$tournament = Tournament::fromName($_GET["blank"]);
if ($tournament == null)
require_once "server_files/403.php";
$tex = preg_replace("#{PARTICIPANT_NAME}#", "\\hrulefill", $tex);
$tex = preg_replace("#{BIRTHDAY}#", "\phantom{232323}/\phantom{232323}/\phantom{232323}", $tex);
$tex = preg_replace("#{PRONOUN}#", "Elle/il", $tex);
}
else {
$tournament = $team->getEffectiveTournament();
$tex = preg_replace("#{PARTICIPANT_NAME}#", "\\texttt{" . $user->getFirstName() . " " . $user->getSurname() . "}", $tex);
$tex = preg_replace("#{BIRTHDAY}#", "\\texttt{" . strftime("%d %B %G", strtotime($user->getBirthDate())) . "}", $tex);
$tex = preg_replace("#{PRONOUN}#", $user->getGender() == "M" ? "Il" : "Elle", $tex);
}
$tex = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $tex);
$tex = preg_replace("#{PLACE}#", $tournament->getPlace(), $tex);
$tex = preg_replace("#{START_DATE}#", strftime("%d %B", strtotime($tournament->getStartDate())), $tex);
$tex = preg_replace("#{END_DATE}#", strftime("%d %B", strtotime($tournament->getEndDate())), $tex);
$tex = preg_replace("#{YEAR}#", $YEAR, $tex);
shell_exec("mkdir tmp");
file_put_contents("tmp/file.tex", $tex);
shell_exec("pdflatex -synctex=1 -interaction=nonstopmode -shell-escape -output-directory=tmp tmp/file.tex");
header("Content-type: application/pdf");
readfile("tmp/file.pdf");
exit(0);

View File

@ -0,0 +1,22 @@
<?php
$token = $_GET["token"];
$alert = "danger";
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.";
$alert = "success";
}
}
else {
$error_message = "Il n'y a pas de compte à valider !";
$alert = "warning";
}
require_once "server_files/views/header.php";
echo "<div class=\"alert alert-$alert\"><h2>$error_message</h2></div>";
require_once "server_files/views/footer.php";

View File

@ -0,0 +1,170 @@
<?php
$has_error = false;
$error_message = null;
if (isset($_POST["login"]) && !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";

View File

@ -0,0 +1,14 @@
<?php
unset($_SESSION["user_id"]);
session_destroy();
require_once "server_files/views/header.php";
?>
<div class="alert alert-success">
Déconnexion réussie !
</div>
<?php
require_once "server_files/views/footer.php";

View File

@ -0,0 +1,173 @@
<?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 ($_SESSION["role"] == Role::ORGANIZER && !$tournament->organize($_SESSION["user_id"]))
require_once "server_files/403.php";
if ($team === null)
require_once "server_files/404.php";
if (isset($_POST["team_edit"])) {
$edit_team = new EditTeam($_POST);
try {
$edit_team->makeVerifications();
$edit_team->updateTeam();
}
catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
if (isset($_POST["validate"])) {
$team->setValidationStatus(ValidationStatus::VALIDATED);
Mailer::sendValidateTeam($team, $_POST["message"]);
}
elseif (isset($_POST["unvalidate"])) {
$team->setValidationStatus(ValidationStatus::NOT_READY);
Mailer::sendUnvalidateTeam($team, $_POST["message"]);
}
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->getProblem()]);
}
}
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();
}
if (isset($_POST["select_tournament"])) {
$new_tournament = Tournament::fromId($_POST["select_tournament"]);
ensure($new_tournament != null, "Le tournoi indiqué n'existe pas.");
$team->setTournamentId($new_tournament->getId());
$DB->prepare("UPDATE `documents` SET `tournament` = ? WHERE `team` = ?;")->execute([$tournament->getId(), $team->getId()]);
$DB->prepare("UPDATE `solutions` SET `tournament` = ? WHERE `team` = ?;")->execute([$tournament->getId(), $team->getId()]);
$DB->prepare("UPDATE `syntheses` SET `tournament` = ? WHERE `team` = ?;")->execute([$tournament->getId(), $team->getId()]);
foreach ($team->getParticipants() as $user) {
if ($user != null)
$DB->prepare("UPDATE `payments` SET `tournament` = ? WHERE `user` = ?;")->execute([$tournament->getId(), $user]);
}
foreach ($team->getEncadrants() as $user) {
if ($user != null)
$DB->prepare("UPDATE `payments` SET `tournament` = ? WHERE `user` = ?;")->execute([$tournament->getId(), $user]);
}
$tournament = $new_tournament;
}
if (isset($_POST["delete_team"])) {
foreach ($team->getEncadrants() as $encadrant_id) {
quitTeam($encadrant_id);
}
foreach ($team->getParticipants() as $participant_id) {
quitTeam($participant_id);
}
header("Location: /");
return;
}
class EditTeam
{
public $name;
public $trigram;
public $tournament_id;
private $team;
private $tournament;
public function __construct($data)
{
global $team;
foreach ($data as $key => $value)
$this->$key = htmlspecialchars($value);
$this->trigram = strtoupper($this->trigram);
$this->team = $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($this->tournament_id == $this->team->getTournamentId() || $_SESSION["role"] == Role::ADMIN, "Vous n'avez pas la permission pour changer cette équipe de tournoi.");
}
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/equipe/$this->trigram");
}
}
$documents = $tournament->getAllDocuments($team->getId());
$documents_final = null;
if ($team->isSelectedForFinal())
$documents_final = $FINAL->getAllDocuments($team->getId());
$emails = [];
if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
foreach ($team->getEncadrants() as $encadrant_id) {
$encadrant = User::fromId($encadrant_id);
if ($encadrant != null) {
$emails[] = $encadrant->getEmail();
}
}
foreach ($team->getParticipants() as $participant_id) {
$participant = User::fromId($participant_id);
if ($participant != null) {
$emails[] = $participant->getEmail();
if ($participant->getResponsibleEmail() != null) {
$emails[] = $participant->getResponsibleEmail();
}
}
}
}
require_once "server_files/views/equipe.php";

View File

@ -0,0 +1,20 @@
<?php
if (!file_exists("index"))
file_put_contents("index", file_get_contents("server_files/views/index.html"));
if (isset($_GET["edit"])) {
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
if (isset($_POST["edit_page"])) {
$content = $_POST["content"];
file_put_contents("index", $content);
header("Location: /");
exit(0);
}
}
require_once "server_files/views/index.php";

View File

@ -0,0 +1,176 @@
<?php
if (!isset($_SESSION["role"]))
require_once "server_files/403.php";
$id = $_GET["id"];
$user = User::fromId($id);
if ($user == null)
require_once "server_files/404.php";
$team = Team::fromId($user->getTeamId());
if ($_SESSION["role"] != Role::ADMIN) {
if ($_SESSION["role"] == Role::ORGANIZER) {
if (($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::PARTICIPANT) && ($team == null || $team->getTournamentId() == null || !Tournament::fromId($team->getTournamentId())->organize($_SESSION["user_id"])))
require_once "server_files/403.php";
}
elseif ($user->getId() != $_SESSION["user_id"])
require_once "server_files/403.php";
}
if ($user === null)
require_once "server_files/404.php";
if ($team != null) {
$documents = $user->getAllDocuments($team->getTournamentId());
$documents_final = $user->getAllDocuments($FINAL->getId());
$payment = $user->getPayment();
$tournament = Tournament::fromId($team->getTournamentId());
}
$has_error = false;
$error_message = null;
if (isset($_POST["kick"])) {
if ($team == null) {
$has_error = true;
$error_message = "La personne à expulser n'est dans aucune équipe.";
}
else {
quitTeam($id);
$team = null;
}
}
if (isset($_POST["attribute_team"])) {
$attribute_team = new AttributeTeam($_POST);
try {
$attribute_team->makeVerifications();
$attribute_team->attribute();
} catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
if (isset($_POST["validate_payment"])) {
$validate_payment = new ValidatePayment($_POST);
try {
$validate_payment->makeVerifications();
$validate_payment->validate();
} catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
if (isset($_POST["view_as"]) && $_SESSION["role"] == Role::ADMIN) {
if (!isset($_SESSION["admin"]))
$_SESSION["admin"] = $_SESSION["user_id"];
$_SESSION["user_id"] = $user->getId();
header("Location: /");
exit();
}
if (isset($_POST["delete_account"]) && $team == null && $_SESSION["role"] == Role::ADMIN) {
$DB->prepare("DELETE FROM `documents` WHERE `user` = ?;")->execute([$user->getId()]);
$DB->prepare("DELETE FROM `organizers` WHERE `organizer` = ?;")->execute([$user->getId()]);
$DB->prepare("DELETE FROM `users` WHERE `id` = ?;")->execute([$user->getId()]);
header("Location: /");
exit();
}
class AttributeTeam
{
private $team_id;
private $team;
private $min_null_index;
public function __construct($data)
{
$this->team_id = htmlspecialchars($data["team"]);
$this->team = Team::fromId($this->team_id);
}
public function makeVerifications()
{
global $user;
ensure($user->getConfirmEmailToken() == null, "Ce participant n'a pas encore validé son adresse e-mail.");
ensure($this->team_id != "no_team", "Vous n'avez pas choisi d'équipe.");
ensure($this->team != null, "Cette équipe n'existe pas.");
ensure($user->getTeamId() <= 0, "Cette personne est déjà dans une équipe !");
ensure($this->team->getValidationStatus() == ValidationStatus::NOT_READY, "Cette équipe est déjà validée ou en cours de validation.");
$role = $user->getRole();
for ($i = 1; $i <= $role == Role::ENCADRANT ? 3 : 6; ++$i) {
if (($role == Role::PARTICIPANT ? $this->team->getParticipants()[$i - 1] : $this->team->getEncadrants()[$i]) == NULL)
break;
}
$this->min_null_index = $i;
ensure($role == Role::PARTICIPANT && $this->min_null_index <= 6 || $role == Role::ENCADRANT && $this->min_null_index <= 2,
"Il n'y a plus de place pour vous dans l'équipe.");
}
public function attribute()
{
global $user, $team;
$user->setTeamId($this->team->getId());
if ($user->getRole() == Role::ENCADRANT)
$this->team->setEncadrant($this->min_null_index, $user->getId());
else
$this->team->setParticipant($this->min_null_index, $user->getId());
Mailer::sendJoinTeamMail($user, $this->team, Tournament::fromId($this->team->getTournamentId()));
$team = $this->team;
global $documents, $payment, $tournament;
$documents = $user->getAllDocuments($team->getTournamentId());
$payment = $user->getPayment();
$tournament = Tournament::fromId($team->getTournamentId());
}
}
class ValidatePayment
{
private $accept, $reject;
private $message;
private $payment;
public function __construct($data)
{
global $user;
foreach ($data as $key => $value)
$this->$key = htmlspecialchars($value);
$this->payment = $user->getPayment();
}
public function makeVerifications()
{
ensure($this->payment->getValidationStatus() == ValidationStatus::WAITING, "Le paiement n'était pas en attente.");
ensure(isset($this->accept) ^ isset($this->reject), "La sélection de validation est invalide.");
}
public function validate()
{
global $user, $team, $tournament;
if ($this->accept)
$this->payment->setValidationStatus(ValidationStatus::VALIDATED);
else
$this->payment->setValidationStatus(ValidationStatus::NOT_READY);
Mailer::sendValidatePayment($user, $team, $tournament, $this->payment, $this->message);
}
}
require_once "server_files/views/informations.php";

View File

@ -0,0 +1,99 @@
<?php
$has_error = false;
$error_message = null;
if (isset($_POST["register"])) {
$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", "Merci de spécifier un genre.");
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 && strlen($this->phone_number) <= 20, "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.");
}
}
else {
$this->class = SchoolClass::ADULT;
}
if (count(User::getAllUsers()) == 0)
$this->role = Role::ADMIN;
$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`, `responsible_name`, `responsible_phone`, `responsible_email`, `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, $this->responsible_name, $this->responsible_phone, $this->responsible_email, $YEAR]);
Mailer::sendRegisterMail($this);
}
}
require_once "server_files/views/inscription.php";

View File

@ -0,0 +1,36 @@
<?php
$tex = file_get_contents("assets/Instructions.tex");
/**
* @var User $user
* @var Team $team
* @var Tournament $tournament
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
if (!isset($user) || isset($_GET["blank"]) || $_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
$tournament = Tournament::fromName($_GET["blank"]);
if ($tournament == null)
require_once "server_files/403.php";
}
else {
$tournament = $team->getEffectiveTournament();
}
$tex = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $tex);
$tex = preg_replace("#{PLACE}#", $tournament->getPlace(), $tex);
$tex = preg_replace("#{PRICE}#", $tournament->getPrice(), $tex);
$tex = preg_replace("#{END_PAYMENT_DATE}#", strftime("%d %B", strtotime($tournament->getInscriptionDate())), $tex);
$tex = preg_replace("#{YEAR}#", $YEAR, $tex);
shell_exec("mkdir tmp");
file_put_contents("tmp/file.tex", $tex);
shell_exec("pdflatex -synctex=1 -interaction=nonstopmode -shell-escape -output-directory=tmp tmp/file.tex");
header("Content-type: application/pdf");
readfile("tmp/file.pdf");
shell_exec("rm -rf tmp");
exit(0);

View File

@ -0,0 +1,220 @@
<?php
if (!isset($_SESSION["user_id"]))
require_once "server_files/403.php";
/**
* @var User $user
* @var Team $team
* @var Tournament $tournament
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
if ($team != null)
$tournament = Tournament::fromId($team->getTournamentId());
$has_error = false;
$error_message = null;
if (isset($_POST["update_account"])) {
$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["update_password"])) {
$new_password = new NewPassword($_POST);
try {
$new_password->makeVerifications();
$new_password->updatePassword();
}
catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
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();
}
}
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(strtoupper($this->class));
else
$this->class = SchoolClass::ADULT;
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", "Merci de spécifier un genre.");
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);
}
}
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.");
$mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]);
ensure($mime == "application/pdf" || $mime = "image/png" || $mime == "image/jpeg", "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, $this->type == DocumentType::getName(DocumentType::MOTIVATION_LETTER) ? -1 : $_SESSION["user_id"], $_SESSION["team"]->getId(),
$_SESSION["team"]->isSelectedForFinal() ? $FINAL->getId() : $_SESSION["team"]->getTournamentId(), $this->type]);
}
}
if ($team != null) {
$documents = $user->getAllDocuments($team->getTournamentId());
if ($team->isSelectedForFinal())
$documents_final = $user->getAllDocuments($FINAL->getId());
}
require_once "server_files/views/mon_compte.php";

View File

@ -0,0 +1,193 @@
<?php
if (isset($_POST["leave_team"])) {
quitTeam();
exit();
}
$tournaments = Tournament::getAllTournaments(false, true);
$has_error = false;
$error_message = null;
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($_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 = $tournament->getAllDocuments($team->getId());
if ($team->isSelectedForFinal())
$documents_final = $FINAL->getAllDocuments($team->getId());
}
else
require_once "server_files/403.php";
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 {
$team->setValidationStatus(ValidationStatus::WAITING);
Mailer::sendRequestValidationMail($team, $team->isSelectedForFinal() ? $FINAL : $tournament);
}
}
$DUMPS = [
["TKT", 6, "PGA", 3, "IRD", 1],
["OUI", 8, "LEP", 1, "REX", 7],
["ASP", 1, "ABC", 3, "TDP", 6],
["GIF", 8, "ETM", 1, "LPC", 3],
["MST", 6, "LQF", 1, "WAL", 2],
];
$DUMPS_2 = [
["TKT", 4, "PGA", 1, "IRD", 6],
["LEP", 6, "OUI", 5, "REX", 8],
["ASP", 5, "ABC", 8, "TDP", 4],
["ETM", 8, "LPC", 4, "GIF", 6],
["MST", 5, "LQF", 4, "WAL", 8],
];
foreach ($DUMPS as $dump) {
$team1 = Team::fromTrigram($dump[0]);
$team2 = Team::fromTrigram($dump[2]);
$team3 = Team::fromTrigram($dump[4]);
$problem1 = $dump[1];
$problem2 = $dump[3];
$problem3 = $dump[5];
$req1 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req1->execute([$team1->getId(), $problem1]);
$data1 = $req1->fetch();
$sol1 = Solution::fromData($data1);
$req2 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req2->execute([$team2->getId(), $problem2]);
$data2 = $req2->fetch();
$sol2 = Solution::fromData($data2);
$req3 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req3->execute([$team3->getId(), $problem3]);
$data3 = $req3->fetch();
$sol3 = Solution::fromData($data3);
$req1 = $DB->prepare("UPDATE `teams` SET `opposed_problem` = ?, `rapported_problem` = ? WHERE `id` = ?;");
$req1->execute([$sol2->getFileId(), $sol3->getFileId(), $team1->getId()]);
$req2 = $DB->prepare("UPDATE `teams` SET `opposed_problem` = ?, `rapported_problem` = ? WHERE `id` = ?;");
$req2->execute([$sol3->getFileId(), $sol1->getFileId(), $team2->getId()]);
$req3 = $DB->prepare("UPDATE `teams` SET `opposed_problem` = ?, `rapported_problem` = ? WHERE `id` = ?;");
$req3->execute([$sol1->getFileId(), $sol2->getFileId(), $team3->getId()]);
}
foreach ($DUMPS_2 as $dump) {
$team1 = Team::fromTrigram($dump[0]);
$team2 = Team::fromTrigram($dump[2]);
$team3 = Team::fromTrigram($dump[4]);
$problem1 = $dump[1];
$problem2 = $dump[3];
$problem3 = $dump[5];
$req1 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req1->execute([$team1->getId(), $problem1]);
$data1 = $req1->fetch();
$sol1 = Solution::fromData($data1);
$req2 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req2->execute([$team2->getId(), $problem2]);
$data2 = $req2->fetch();
$sol2 = Solution::fromData($data2);
$req3 = $DB->prepare("SELECT * FROM `solutions` WHERE `team` = ? AND `problem` = ? ORDER BY uploaded_at DESC LIMIT 1");
$req3->execute([$team3->getId(), $problem3]);
$data3 = $req3->fetch();
$sol3 = Solution::fromData($data3);
$req1 = $DB->prepare("UPDATE `teams` SET `opposed_problem_2` = ?, `rapported_problem_2` = ? WHERE `id` = ?;");
$req1->execute([$sol2->getFileId(), $sol3->getFileId(), $team1->getId()]);
$req2 = $DB->prepare("UPDATE `teams` SET `opposed_problem_2` = ?, `rapported_problem_2` = ? WHERE `id` = ?;");
$req2->execute([$sol3->getFileId(), $sol1->getFileId(), $team2->getId()]);
$req3 = $DB->prepare("UPDATE `teams` SET `opposed_problem_2` = ?, `rapported_problem_2` = ? WHERE `id` = ?;");
$req3->execute([$sol1->getFileId(), $sol2->getFileId(), $team3->getId()]);
}
$req = $DB->prepare("SELECT opposed_problem, rapported_problem, opposed_problem_2, rapported_problem_2 FROM teams WHERE id = ?;");
$req->execute([$team->getId()]);
$data = $req->fetch();
$opposed_solution = Solution::fromId($data["opposed_problem"]);
$rapported_solution = Solution::fromId($data["rapported_problem"]);
$opposed_solution_2 = Solution::fromId($data["opposed_problem_2"]);
$rapported_solution_2 = Solution::fromId($data["rapported_problem_2"]);
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, $DB;
$this->team->setName($this->name);
$this->team->setTrigram($this->trigram);
$this->team->setTournamentId($this->tournament_id);
$DB->prepare("UPDATE `documents` SET `tournament` = ? WHERE `team` = ?;")->execute([$this->tournament_id, $this->team->getId()]);
$DB->prepare("UPDATE `solutions` SET `tournament` = ? WHERE `team` = ?;")->execute([$this->tournament_id, $this->team->getId()]);
$DB->prepare("UPDATE `syntheses` SET `tournament` = ? WHERE `team` = ?;")->execute([$this->tournament_id, $this->team->getId()]);
foreach ($this->team->getParticipants() as $user) {
if ($user != null)
$DB->prepare("UPDATE `payments` SET `tournament` = ? WHERE `user` = ?;")->execute([$this->tournament_id, $user]);
}
foreach ($this->team->getEncadrants() as $user) {
if ($user != null)
$DB->prepare("UPDATE `payments` SET `tournament` = ? WHERE `user` = ?;")->execute([$this->tournament_id, $user]);
}
$_SESSION["tournament"] = $this->tournament;
header("Location: $URL_BASE/mon-equipe");
}
}
require_once "server_files/views/mon_equipe.php";

View File

@ -0,0 +1,8 @@
<?php
if ($_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
require_once "server_files/403.php";
$organizers = User::getOrganizers();
require_once "server_files/views/organisateurs.php";

View File

@ -0,0 +1,83 @@
<?php
if (!isset($_SESSION["user_id"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
require_once "server_files/403.php";
/**
* @var User $user
* @var Team $team
* @var Tournament $tournament
*/
$user = $_SESSION["user"];
$team = $_SESSION["team"];
$tournament = $team->getEffectiveTournament();
$payment = $user->getPayment();
if ($team->getValidationStatus() != ValidationStatus::VALIDATED)
require_once "server_files/403.php";
if (isset($_POST["pay"])) {
$pay = new Pay($_POST);
try {
$pay->makeVerifications();
$pay->submit();
}
catch (AssertionError $e) {
$has_error = true;
$error_message = $e->getMessage();
}
}
class Pay {
private $method;
private $infos;
private $scholarship;
public function __construct($data)
{
foreach ($data as $key => $value)
$this->$key = htmlspecialchars($value);
$this->method = PaymentMethod::fromName(strtoupper($this->method));
$this->scholarship = $_FILES["scholarship"];
}
public function makeVerifications()
{
global $payment;
ensure($payment->getValidationStatus() == ValidationStatus::NOT_READY, "Un paiement est déjà initié.");
ensure($this->method != PaymentMethod::NOT_PAID, "Vous n'avez pas payé.");
ensure($this->method == PaymentMethod::SCHOLARSHIP || ($this->infos != null && strlen($this->infos) > 0), "Merci d'indiquer des informations pour retrouver votre paiement.");
ensure($this->method != PaymentMethod::SCHOLARSHIP || ($this->scholarship != null && !$this->scholarship["error"]), "Si vous êtes boursier, vous devez indiquer votre notifcation de bourse (une erreur est survenue).");
}
public function submit()
{
global $DB, $LOCAL_PATH, $payment, $user, $team, $tournament;
$payment->setMethod($this->method);
$payment->setAmount($this->method == PaymentMethod::SCHOLARSHIP ? 0 : $tournament->getPrice());
$payment->setValidationStatus(ValidationStatus::WAITING);
if ($this->method == PaymentMethod::SCHOLARSHIP) {
do
$id = genRandomPhrase(64);
while (file_exists("$LOCAL_PATH/files/$id"));
if (!rename($this->scholarship["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(), $tournament->getId(), DocumentType::getName(DocumentType::SCHOLARSHIP)]);
$payment->setTransactionInfos($id);
}
else
$payment->setTransactionInfos($this->infos);
Mailer::requestPaymentValidation($user, $team, $tournament, $payment);
}
}
require_once "server_files/views/paiement.php";

View File

@ -0,0 +1,16 @@
<?php
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ADMIN)
require_once "server_files/403.php";
$orphans = isset($_GET["orphans"]);
$users = $orphans ? User::getOrphanUsers() : User::getAllUsers();
$emails = [];
if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
foreach ($users as $user)
$emails[] = $user->getEmail();
}
require_once "server_files/views/profils.php";

View File

@ -0,0 +1,68 @@
<?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["join_team"])) {
$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 : 3; ++$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 <= 3, "Il n'y a plus de place pour vous dans l'équipe.");
}
public function joinTeam()
{
global $team;
$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());
$team = $_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";

View 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["solution"];
$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";

View 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";

View File

@ -0,0 +1,73 @@
<?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 $round;
private $file;
public function __construct()
{
$this->file = $_FILES["synthese"];
$this->round = htmlspecialchars($_POST["round"]);
$this->dest = DestType::fromName(strtoupper(htmlspecialchars($_POST["dest"])));
}
public function makeVerifications()
{
global $LOCAL_PATH, $tournament;
ensure($this->dest != DestType::DEFENSEUR, "La source est invalide.");
ensure($this->round == 1 || $this->round == 2, "Le tour est invalide.");
$now = date("Y-m-d H:i");
ensure($this->round == 1 && $now < $tournament->getSynthesesDate() || $this->round == 2 && $now < $tournament->getSynthesesDate2(), "Vous ne pouvez plus rendre de note de synthèse pour le tour $this->round.");
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`, `round`, `dest`) VALUES (?, ?, ?, ?, ?);");
$req->execute([$id, $team->getId(), $team->isSelectedForFinal() ? $FINAL->getId() : $tournament->getId(), $this->round, $this->dest]);
return false;
}
}
require_once "server_files/views/syntheses.php";

View 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";

View File

@ -0,0 +1,167 @@
<?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();
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 $date_solutions_2;
public $time_solutions_2;
public $date_syntheses_2;
public $time_syntheses_2;
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 pour le tour 1 n'est pas valide.");
ensure(dateWellFormed($this->date_solutions_2 . " " . $this->time_solutions_2), "La date limite de visibilité des solutions du tour 2 n'est pas valide.");
ensure(dateWellFormed($this->date_syntheses_2 . " " . $this->time_syntheses_2), "La date limite de remise des notes de synthèse pour le tour 2 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");
$tournament->setSolutionsDate2("$this->date_solutions_2 $this->time_solutions_2");
$tournament->setSynthesesDate2("$this->date_syntheses_2 $this->time_syntheses_2");
$tournament->setDescription($this->description);
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();
}
}
if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
$emails = [];
$emails_validated = [];
foreach ($tournament->getOrganizers() as $organizer) {
$emails[] = $organizer->getEmail();
$emails_validated[] = $organizer->getEmail();
}
foreach ($teams as $team) {
foreach ($team->getEncadrants() as $encadrant_id) {
$encadrant = User::fromId($encadrant_id);
if ($encadrant != null) {
$emails[] = $encadrant->getEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $encadrant->getEmail();
}
}
foreach ($team->getParticipants() as $participant_id) {
$participant = User::fromId($participant_id);
if ($participant != null) {
$emails[] = $participant->getEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $participant->getEmail();
if ($participant->getResponsibleEmail() != null) {
$emails[] = $participant->getResponsibleEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $participant->getResponsibleEmail();
}
}
}
}
}
require_once "server_files/views/tournoi.php";

View File

@ -0,0 +1,42 @@
<?php
$tournaments = Tournament::getAllTournaments();
$emails = [];
$emails_validated = [];
if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
foreach ($tournaments as $tournament) {
foreach ($tournament->getOrganizers() as $organizer) {
$emails[] = $organizer->getEmail();
$emails_validated[] = $organizer->getEmail();
}
foreach ($tournament->getAllTeams() as $team) {
foreach ($team->getEncadrants() as $encadrant_id) {
$encadrant = User::fromId($encadrant_id);
if ($encadrant != null) {
$emails[] = $encadrant->getEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $encadrant->getEmail();
}
}
foreach ($team->getParticipants() as $participant_id) {
$participant = User::fromId($participant_id);
if ($participant != null) {
$emails[] = $participant->getEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $participant->getEmail();
if ($participant->getResponsibleEmail() != null) {
$emails[] = $participant->getResponsibleEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $participant->getResponsibleEmail();
}
}
}
}
}
}
require_once "server_files/views/tournois.php";

View File

@ -0,0 +1,102 @@
<?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";
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId())) {
$req = $DB->prepare("SELECT opposed_problem, rapported_problem, opposed_problem_2, rapported_problem_2 FROM teams WHERE id = ?;");
$req->execute([$_SESSION["team"]->getId()]);
$data = $req->fetch();
if ($id != $data["opposed_problem"] && $id != $data["rapported_problem"]) {
if (date("Y-m-d H:i") < $tournament->getSolutionsDate2() || ($id != $data["opposed_problem_2"] && $id != $data["rapported_problem_2"]))
require_once "server_files/403.php";
}
}
}
else if ($type == DocumentType::SYNTHESIS) {
$dest = $file->getDest();
$name = "Note de synthèse $trigram " . ($dest == DestType::OPPOSANT ? "de l'opposant" : "du rapporteur");
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)) {
if ($type != DocumentType::MOTIVATION_LETTER && $user->getId() != $_SESSION["user_id"] || $file->getTeamId() != $team->getId())
require_once "server_files/403.php";
}
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;
case DocumentType::SCHOLARSHIP:
$name = "Notification de bourse";
break;
}
if ($type == DocumentType::MOTIVATION_LETTER)
$name = "Lettre de motivation de l'équipe $trigram";
else {
$surname = $user->getSurname();
$first_name = $user->getFirstName();
$name .= " de $first_name $surname";
}
}
}
else
require_once "server_files/404.php";
$mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), "$LOCAL_PATH/files/$id");
if ($mime == "application/pdf")
$name .= ".pdf";
elseif ($mime == "image/png")
$name .= ".png";
else
$name = ".jpg";
header("Content-Type: $mime");
header("Content-Disposition: inline; filename=\"$name\"");
readfile("$LOCAL_PATH/files/$id");
exit();

267
server_files/model.php Normal file
View File

@ -0,0 +1,267 @@
<?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["view-as-admin"])) {
if (isset($_SESSION["admin"])) {
$_SESSION["user_id"] = $_SESSION["admin"];
unset($_SESSION["admin"]);
}
header("Location: /");
exit();
}
}
}
function quitTeam($user_id = -1)
{
global $DB, $URL_BASE;
header("Location: $URL_BASE");
/** @var User $user */
$user = $_SESSION["user"];
if ($user_id == -1)
$user_id = $user->getId();
else
$user = User::fromId($user_id);
$role = $user->getRole();
if ($role == Role::ADMIN || $role == Role::ORGANIZER)
return;
for ($i = 1; $i <= ($role == Role::ENCADRANT ? 3 : 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;");
$DB->exec("UPDATE `teams` SET `encadrant_2` = `encadrant_3`, `encadrant_3` = NULL WHERE `encadrant_2` 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;
// Le TFJM² 2020 se déroulant en ligne, les papiers ne sont plus nécessaires
/* 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;
}*/
// Le TFJM² 2020 se déroulant en ligne, les papiers ne sont plus nécessaires
/* 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;
$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;
$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;
}
} */
// La lettre de motivation n'est plus nécessaire, mais existe toujours
/* $req = $DB->prepare("SELECT COUNT(*) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` = ? AND `type` = ?;");
$req->execute([$team->getId(), $tournament->getId(), "MOTIVATION_LETTER"]);
$d = $req->fetch();
$can_validate &= $d["version"] > 0;*/
$can_validate &= date("Y-m-d H:i:s") <= $tournament->getInscriptionDate();
return $can_validate;
}
function printDocuments($documents)
{
if (sizeof($documents) == 0) {
echo "<div class=\"alert alert-warning\">\nPas de document envoyé pour le moment.\n</div>\n";
return;
}
echo "<div class=\"alert alert-info\">\n";
foreach ($documents as $document) {
$file_id = $document->getFileId();
$name = DocumentType::getTranslatedName($document->getType());
$version = $document->getVersion();
if ($document->getType() == DocumentType::MOTIVATION_LETTER) {
$team = Team::fromId($document->getTeamId());
echo "Lettre de motivation de l'équipe " . $team->getTrigram();
}
else {
$user = User::fromId($document->getUserId());
$surname = $user->getSurname();
$first_name = $user->getFirstName();
echo "$name de $first_name $surname";
}
echo " (version $version) : <a data-turbolinks=\"false\" href=\"/file/$file_id\"><strong>Télécharger</strong></a><br />\n";
}
echo "</div>\n";
}
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;
case DocumentType::SCHOLARSHIP:
$name = "Notification de bourse de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf";
break;
case DocumentType::MOTIVATION_LETTER:
$name = "Lettre de motivation de l'équipe " . $team->getTrigram() . ".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;
}

View File

@ -0,0 +1,263 @@
<?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 broadcastToTeam(Team $team, $subject, $content, $from = "contact")
{
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
foreach ($team->getEncadrants() as $participant_id) {
$participant = User::fromId($participant_id);
if ($participant == null)
continue;
$c = preg_replace("#{FIRST_NAME}#", $participant->getFirstName(), $content);
$c = preg_replace("#{SURNAME}#", $participant->getSurname(), $c);
self::sendMail($participant->getEmail(), $subject, $c, $from);
}
foreach ($team->getParticipants() as $participant_id) {
$participant = User::fromId($participant_id);
if ($participant == null)
continue;
$c = preg_replace("#{FIRST_NAME}#", $participant->getFirstName(), $content);
$c = preg_replace("#{SURNAME}#", $participant->getSurname(), $c);
self::sendMail($participant->getEmail(), $subject, $c, $from);
}
}
private static function broadcastToAdmins($subject, $content, $from = "contact")
{
/** @var User $admin */
foreach (User::getAdmins() as $admin) {
$c = preg_replace("#{FIRST_NAME}#", $admin->getFirstName(), $content);
$c = preg_replace("#{SURNAME}#", $admin->getSurname(), $c);
self::sendMail($admin->getEmail(), $subject, $c, $from);
}
}
private static function brodcastToOrgas(Tournament $tournament, $subject, $content, $from = "contact")
{
foreach ($tournament->getOrganizers() as $orga) {
if ($orga->getRole() == Role::ADMIN)
continue;
$c = preg_replace("#{FIRST_NAME}#", $orga->getFirstName(), $content);
$c = preg_replace("#{SURNAME}#", $orga->getSurname(), $c);
self::sendMail($orga->getEmail(), $subject, $c, $from);
}
self::broadcastToAdmins($subject, $content, $from);
}
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("#{TOKEN}#", $new_orga->token, $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);
}
public static function requestPaymentValidation(User $user, Team $team, Tournament $tournament, Payment $payment)
{
global $YEAR, $URL_BASE;
$content = self::getTemplate("request_payment_validation");
$content = preg_replace("#{USER_FIRST_NAME}#", $user->getFirstName(), $content);
$content = preg_replace("#{USER_SURNAME}#", $user->getSurname(), $content);
$content = preg_replace("#{USER_ID}#", $user->getId(), $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("#{AMOUNT}#", $payment->getAmount(), $content);
$content = preg_replace("#{PAYMENT_METHOD}#", PaymentMethod::getTranslatedName($payment->getMethod()), $content);
if ($payment->getMethod() == PaymentMethod::SCHOLARSHIP)
$content = preg_replace("#{PAYMENT_INFOS}#", "<a href=\"$URL_BASE/file/" . $payment->getTransactionInfos() . "\">Voir la notification de bourse</a>", $content);
else
$content = preg_replace("#{PAYMENT_INFOS}#", $payment->getTransactionInfos(), $content);
self::broadcastToAdmins("Demande de validation de paiement pour le tournoi " . $tournament->getName() . " TFJM² $YEAR", $content);
}
public static function sendRequestValidationMail(Team $team, Tournament $tournament)
{
global $YEAR;
$content = self::getTemplate("request_validation");
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
$content = preg_replace("#{TOURNAMENT}#", $tournament->getName(), $content);
$content = preg_replace("#{ACCESS_CODE}#", $team->getAccessCode(), $content);
self::brodcastToOrgas($tournament, "Demande de validation TFJM² $YEAR", $content);
}
public static function sendValidateTeam($team, $message)
{
global $YEAR;
$content = self::getTemplate("validate_team");
if (strlen($message) > 0)
$message = " L'équipe d'organisation vous transmet le message suivant :\n\n" . $message;
$message = preg_replace("#\n#", "<br/>\n", $message);
$content = preg_replace("#{MESSAGE}#", $message, $content);
self::broadcastToTeam($team, "Équipe validée TFJM² $YEAR", $content);
}
public static function sendUnvalidateTeam($team, $message)
{
global $YEAR;
$content = self::getTemplate("unvalidate_team");
if (strlen($message) > 0)
$message = " L'équipe d'organisation vous transmet le message suivant :\n\n" . $message;
$message = preg_replace("#\n#", "<br/>\n", $message);
$content = preg_replace("#{MESSAGE}#", $message, $content);
self::broadcastToTeam($team, "Équipe non validée Correspondances des Jeunes Mathématicien·ne·s $YEAR", $content);
}
public static function sendValidatePayment(User $user, Team $team, Tournament $tournament, Payment $payment, $message)
{
global $YEAR, $URL_BASE;
$content = self::getTemplate($payment->getValidationStatus() == ValidationStatus::VALIDATED ? "validate_payment" : "unvalidate_payment");
$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("#{AMOUNT}#", $payment->getAmount(), $content);
$content = preg_replace("#{PAYMENT_METHOD}#", PaymentMethod::getTranslatedName($payment->getMethod()), $content);
if ($payment->getMethod() == PaymentMethod::SCHOLARSHIP)
$content = preg_replace("#{PAYMENT_INFOS}#", "<a href=\"$URL_BASE/file/" . $payment->getTransactionInfos() . "\">Voir la notification de bourse</a>", $content);
else
$content = preg_replace("#{PAYMENT_INFOS}#", $payment->getTransactionInfos(), $content);
if (isset($message) && strlen($message) > 0) {
$content = preg_replace("#{MESSAGE}#", "L'équipe d'organisation vous transmet les informations suivantes :<br /><br />" . $message . "<br />", $content);
}
self::sendMail($user->getEmail(), "Paiement pour le tournoi " . $tournament->getName() . " TFJM² $YEAR", $content);
}
}

View 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>.<br /><br />
Un compte organisateur vous a été créé par l'un des administrateurs. Un mot de passe aléatoire vous a été attribué, mais que vous
devez changer pour des raisons de sécurité sur le lien suivant :
<a href="{URL_BASE}/connexion/reinitialiser_mdp/{TOKEN}">{URL_BASE}/connexion/reinitialiser_mdp/{TOKEN}</a><br />
<br />
Une fois le mot de passe changé, vous pourrez vous <a href="{URL_BASE}/connexion">connecter sur la plateforme</a>.<br />
<br />
Merci beaucoup pour votre aide !<br />
<br />
Le comité national d'organisation du TFJM<sup>2</sup>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!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 />
Ce message vous a été envoyé automatiquement. En cas de problème, merci de répondre à ce message.
<br />
Cordialement,<br />
<br />
Le comité national d'organisation du TFJM<sup>2</sup>
</body>
</html>

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

View File

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

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

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

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

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

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

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<!--suppress HtmlUnknownTarget -->
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Demande de validation de paiement pour le TFJM² {YEAR}</title>
</head>
<body>
Bonjour {FIRST_NAME} {SURNAME},<br />
<br />
{USER_FIRST_NAME} {USER_SURNAME} de l'équipe {TEAM_NAME} ({TRIGRAM}) annonce avoir réglé sa participation pour le tournoi {TOURNAMENT_NAME}.
Les informations suivantes ont été communiquées :<br /><br />
<strong>Équipe :</strong> {TEAM_NAME} ({TRIGRAM})<br />
<strong>Tournoi :</strong> {TOURNAMENT_NAME}<br />
<strong>Moyen de paiement :</strong> {PAYMENT_METHOD}<br />
<strong>Montant :</strong> {AMOUNT} €<br />
<strong>Informations sur le paiement :</strong> {PAYMENT_INFOS}<br />
<br />
Vous pouvez désormais vérifier ces informations, puis valider (ou non) le paiement sur
<a href="{URL_BASE}/informations/{USER_ID}/">la page associée à ce participant</a>.
<br />
Cordialement,
<br />
Le comité national d'organisation du TFJM<sup>2</sup>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<!--suppress HtmlUnknownTarget -->
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Demande de validation - TFJM²</title>
</head>
<body>
Bonjour {FIRST_NAME} {SURNAME},<br />
<br />
L'équipe « {TEAM_NAME} » ({TRIGRAM}) vient de demander à valider son équipe pour participer au tournoi {TOURNAMENT} du
TFJM². Vous pouvez décider d'accepter ou de refuser l'équipe en vous rendant sur la page de l'équipe :
<a href="{URL_BASE}/equipe/{TRIGRAM}">{URL_BASE}/equipe/{TRIGRAM}</a><br/>
<br/>
Cordialement,<br/>
<br />
Le comité national d'organisation du TFJM<sup>2</sup>
</body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<!--suppress HtmlUnknownTarget -->
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Non-validation du paiement pour le TFJM² {YEAR}</title>
</head>
<body>
Bonjour {FIRST_NAME} {SURNAME},<br />
<br />
Votre paiement pour le TFJM² {YEAR} a malheureusement été rejeté. Pour rappel, vous aviez fourni ces informations :<br /><br />
<strong>Équipe :</strong> {TEAM_NAME} ({TRIGRAM})<br />
<strong>Tournoi :</strong> {TOURNAMENT_NAME}<br />
<strong>Moyen de paiement :</strong> {PAYMENT_METHOD}<br />
<strong>Montant :</strong> {AMOUNT} €<br />
<strong>Informations sur le paiement :</strong> {PAYMENT_INFOS}<br />
<br />
{MESSAGE}
<br />
Cordialement,
<br />
Le comité national d'organisation du TFJM<sup>2</sup>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Équipe non validée TFJM² {YEAR}</title>
</head>
<body>
Bonjour {FIRST_NAME} {SURNAME},<br/>
<br/>
Maleureusement, votre équipe « {TEAM_NAME} » ({TRIGRAM}) n'a pas été validée. Veuillez vérifier que vos autorisations sont correctes.
{MESSAGE}<br />
<br />
N'hésitez pas à nous contacter à l'adresse <a href="contact@tfjm.org">contact@tfjm.org</a> pour plus d'informations.
<br/>
Cordialement,<br/>
<br/>
Le comité national d'organisation du TFJM<sup>2</sup>
</body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<!--suppress HtmlUnknownTarget -->
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Validation du paiement pour le TFJM² {YEAR}</title>
</head>
<body>
Bonjour {FIRST_NAME} {SURNAME},<br />
<br />
Votre paiement pour le TFJM² {YEAR} a bien été validé. Pour rappel, vous aviez fourni ces informations :<br /><br />
<strong>Équipe :</strong> {TEAM_NAME} ({TRIGRAM})<br />
<strong>Tournoi :</strong> {TOURNAMENT_NAME}<br />
<strong>Moyen de paiement :</strong> {PAYMENT_METHOD}<br />
<strong>Montant :</strong> {AMOUNT} €<br />
<strong>Informations sur le paiement :</strong> {PAYMENT_INFOS}<br />
<br />
{MESSAGE}
<br />
Cordialement,
<br />
Le comité national d'organisation du TFJM<sup>2</sup>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Équipe validée TFJM² {YEAR}</title>
</head>
<body>
Bonjour {FIRST_NAME} {SURNAME},<br/>
<br/>
Félicitations ! Votre équipe « {TEAM_NAME} » ({TRIGRAM}) est désormais validée ! Vous êtes désormais apte à travailler sur
vos problèmes et publier vos solutions sur la plateforme.
{MESSAGE}<br />
<br/>
Cordialement,<br/>
<br/>
Le comité national d'organisation du TFJM<sup>2</sup>
</body>
</html>

32
server_files/utils.php Normal file
View 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("Y-m-d H:i");
return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date));
}
function dateWellFormed($date, $with_time = false)
{
return date_parse_from_format($with_time ? "Y-m-d H:i:s" : "Y-m-d", $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;
}

View File

@ -0,0 +1,53 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Ajouter une équipe</h1>
</div>
<?php if (isset($new_team) && !$has_error) { ?>
<div class="alert alert-success">
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>
</div>
<?php } elseif ($_SESSION["team"] != NULL) { ?>
<div class="alert alert-danger">
Vous êtes déjà dans une équipe.
</div>
<?php } else { ?>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-6">
<label for="name">Nom (<em>Pas de caractères spéciaux</em>) :</label>
<input class="form-control" type="text" id="name" name="name" pattern="[A-Za-zÀ-ÿ ]+"
value="<?php if (isset($new_team)) echo $new_team->name ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="trigram">Trigramme (<em>identifiant unique à trois lettres de l'équipe</em>) :</label>
<input class="form-control" type="text" id="trigram" name="trigram"
value="<?php if (isset($new_team)) echo $new_team->trigram ?>" pattern="[A-Z]{3}" maxlength="3" required/>
</div>
</div>
<div class="form-group row">
<label for="tournament_id">Tournoi :</label>
<select id="tournament_id" name="tournament_id" class="custom-select">
<option value="0">Choisir un tournoi ...</option>
<?php
while (($data = $tournaments_response->fetch()) !== FALSE) {
echo "<option value=\"" . $data["id"] . "\">" . $data["name"] . "</option>\n";
}
?>
</select>
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="add_team" type="submit" value="Ajouter une équipe"/>
</div>
</form>
<?php } ?>
<?php require_once "footer.php" ?>

View File

@ -0,0 +1,51 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Ajouter un organisateur</h1>
</div>
<?php if (isset($orga) && !$has_error) { ?>
<div class="alert alert-success">
Organisateur ajouté avec succès ! Ses identifiants ont été transmis par mail.
</div>
<?php } ?>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-6">
<label for="surname">Nom :</label>
<input class="form-control" type="text" id="surname" name="surname"
value="<?php if (isset($orga)) echo $orga->surname ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="first_name">Prénom :</label>
<input class="form-control" type="text" id="first_name" name="first_name"
value="<?php if (isset($orga)) echo $orga->first_name ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="email">E-mail :</label>
<input class="form-control" type="email" id="email" name="email"
value="<?php if (isset($orga)) echo $orga->email ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="admin">Compte administrateur :</label>
<input type="checkbox" id="admin" name="admin"
value="<?php if (isset($orga)) echo $orga->admin ?>"/>
</div>
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="add_orga" type="submit" value="Ajouter un organisateur" />
</div>
</form>
<?php require_once "footer.php" ?>

View File

@ -0,0 +1,128 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Ajouter un tournoi</h1>
</div>
<?php
/** @var NewTournament $tournament */
if (isset($tournament) && !$has_error) { ?>
<div class="alert alert-success">
Tournoi de <?= $tournament->name ?> ajouté avec succès !
</div>
<?php } ?>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-6">
<label for="name">Nom du tournoi :</label>
<input class="form-control" type="text" id="name" name="name" pattern="[A-Za-zÀ-ÿ\- ]+"
value="<?php if (isset($tournament)) echo $tournament->name ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="place">Lieu :</label>
<input class="form-control" type="text" id="place" name="place"
value="<?php if (isset($tournament)) echo $tournament->place ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="organizers">Organisateurs :</label>
<select style="width: 100%;" id="organizers" name="organizers[]" multiple size="4" class="custom-select" required>
<?php
foreach (User::getOrganizers() as $organizer) {
echo "<option value=\"" . $organizer->getId(). "\">" . $organizer->getFirstName() . " " . $organizer->getSurname() . "</option>\n";
}
?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="size">Nombre d'équipes :</label>
<input class="form-control" type="number" id="size" name="size"
value="<?php if (isset($tournament)) echo $tournament->size; else echo 6; ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="price">Prix par participant :</label>
<input class="form-control" type="number" id="price" name="price"
value="<?php if (isset($tournament)) echo $tournament->price; else echo 0; ?>" required/>
</div>
</div>
<div class="form-group row">
<div class="form-group col-md-6">
<label for="date_start">Début du tournoi :</label>
<input class="form-control" type="date" id="date_start" name="date_start"
value="<?= isset($tournament) ? $tournament->date_start : date('Y-m-d') ?>"/>
</div>
<div class="form-group col-md-6">
<label for="date_end">Fin du tournoi :</label>
<input class="form-control" type="date" id="date_end" name="date_end"
value="<?= isset($tournament) ? $tournament->date_end : date('Y-m-d') ?>"/>
</div>
</div>
<div class="form-group row">
<div class="form-group col-md-4">
<label for="date_inscription">Date limite d'inscription :</label>
<input class="form-control" type="date" id="date_inscription" name="date_inscription"
value="<?= isset($tournament) ? $tournament->date_inscription : date('Y-m-d') ?>"/>
<input class="form-control" type="time" id="time_inscription" name="time_inscription"
value="<?= isset($tournament) ? $tournament->time_inscription : date('H:i') ?>"/>
</div>
<div class="form-group col-md-4">
<label for="date_solutions">Date limite de remise des solutions :</label>
<input class="form-control" type="date" id="date_solutions" name="date_solutions"
value="<?= isset($tournament) ? $tournament->date_solutions : date('Y-m-d') ?>"/>
<input class="form-control" type="time" id="time_solutions" name="time_solutions"
value="<?= isset($tournament) ? $tournament->time_solutions: date('H:i') ?>"/>
</div>
<div class="form-group col-md-4">
<label for="date_syntheses">Date limite de remise des notes de synthèse -- tour 1 :</label>
<input class="form-control" type="date" id="date_syntheses" name="date_syntheses"
value="<?= isset($tournament) ? $tournament->date_syntheses : date('Y-m-d') ?>"/>
<input class="form-control" type="time" id="time_syntheses" name="time_syntheses"
value="<?= isset($tournament) ? $tournament->time_syntheses : date('H:i') ?>"/>
</div>
</div>
<div class="form-group row">
<div class="form-group col-md-6">
<label for="date_solutions_2">Date à partir de laquelle les solutions du tour 2 sont disponibles :</label>
<input class="form-control" type="date" id="date_solutions_2" name="date_solutions_2"
value="<?= isset($tournament) ? $tournament->date_solutions : date('Y-m-d') ?>"/>
<input class="form-control" type="time" id="time_solutions_2" name="time_solutions_2"
value="<?= isset($tournament) ? $tournament->time_solutions: date('H:i') ?>"/>
</div>
<div class="form-group col-md-6">
<label for="date_syntheses">Date limite de remise des notes de synthèse -- tour 2 :</label>
<input class="form-control" type="date" id="date_syntheses_2" name="date_syntheses_2"
value="<?= isset($tournament) ? $tournament->date_syntheses_2 : date('Y-m-d') ?>"/>
<input class="form-control" type="time" id="time_syntheses_2" name="time_syntheses_2"
value="<?= isset($tournament) ? $tournament->time_syntheses_2 : date('H:i') ?>"/>
</div>
</div>
<div class="form-group row">
<div class="form-group col-md-12">
<label for="description">Description :</label>
<textarea class="form-control" id="description" name="description"><?= isset($tournament) ? $tournament->description : "" ?></textarea>
</div>
</div>
<label for="final">Ce tournoi est la finale nationale :</label>
<input type="checkbox" id="final" name="final" /><br /><br />
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="add_tournament" type="submit" value="Ajouter un tournoi" />
</div>
</form>
<?php require_once "footer.php" ?>

View File

@ -0,0 +1,65 @@
<?php
require_once "header.php";
if (!$has_error) {
if (isset($recuperate_account))
echo "<div class=\"alert alert-warning\">Le mail de récupération de mot de passe a bien été envoyé.</div>";
elseif (isset($reset_password) && isset($_POST["password"]))
echo "<div class=\"alert alert-success\">Le mot de passe a bien été changé. Vous pouvez désormais vous connecter.</div>";
elseif (isset($_GET["confirmation-mail"]))
echo "<div class=\"alert alert-success\">Le mail a bien été renvoyé.</div>";
else if (isset($logging_in_user)) {
echo "<div class=\"alert alert-success\">Connexion réussie !</div>";
require_once "footer.php";
} else if (isset($_SESSION["user_id"])) {
echo "<div class=\"alert alert-danger\">Vous êtes déjà connecté !</div>";
require_once "footer.php";
}
}
if (isset($_GET["mdp_oublie"])) { ?>
<form method="POST" class="jumbotron mt-5">
<h1 class="display-4">Réinitialisation du mot de passe</h1>
<label for="email">E-mail associée au compte :</label>
<input type="email" class="form-control" id="email" name="email" required/>
<input class="btn btn-lg btn-primary btn-block" type="submit" name="forgotten_password"
value="Envoyer l'e-mail de récupération"/>
</form>
<?php } elseif (isset($reset_password) && $reset_password->user != null && ($has_error || !isset($_POST["password"]))) { ?>
<form method="POST" class="jumbotron mt-5">
<h1 class="display-4">Connexion</h1>
<input type="hidden" name="token" value="<?= $_GET["token"] ?>"/>
<div class="form-group">
<label for="password">Nouveau mot de passe :</label>
<input type="password" id="password" name="password" class="form-control" required/>
</div>
<div class="form-group">
<label for="confirm_password">Confirmer le mot de passe :</label>
<input type="password" id="confirm_password" name="confirm_password" class="form-control" required/>
</div>
<input type="submit" name="reset_password" class="btn btn-block btn-primary"
value="Changer le mot de passe"/>
</form>
<?php } elseif (isset($_GET["confirmation-mail"])) { ?>
<?php } else { ?>
<form method="POST" class="jumbotron mt-5">
<h1 class="display-4">Connexion</h1>
<hr class="mt-2 mb-4"/>
<div class="form-group">
<label for="email">E-mail :</label>
<input class="form-control" type="email" id="email" name="email"
value="<?php if (isset($email)) echo $email ?>" required/>
</div>
<div class="form-group">
<label for="password">Mot de passe :</label>
<input class="form-control" type="password" id="password" name="password" required/>
</div>
<input class="btn btn-primary btn-block" name="login" type="submit" value="Se connecter"/>
</form>
<div class="alert">
<!--suppress HtmlUnknownTarget -->
<a href="/connexion/mdp-oublie">Mot de passe oublié ?</a>
</div>
<?php } ?>
<?php require_once "footer.php" ?>

View File

@ -0,0 +1,161 @@
<?php require_once "header.php" ?>
<div class="mt-4 mb-4">
<h1 class="display-4">Informations sur l'équipe</h1>
</div>
<div class="alert alert-info">
<strong>Nom de l'équipe :</strong> <?= $team->getName() ?>
</div>
<div class="alert alert-info">
<strong>Trigramme :</strong> <?= $team->getTrigram() ?>
</div>
<div class="alert alert-info">
<?php if ($team->getValidationStatus() != ValidationStatus::VALIDATED) { ?>
<label for="tournament">Tournoi :</label>
<form method="POST">
<select class="custom-select" id="tournament" name="select_tournament" onchange="this.form.submit()">
<option value="0">Pas de tournoi sélectionné</option>
<?php
foreach (Tournament::getAllTournaments(false, true) as $t) { ?>
<option value="<?= $t->getId() ?>" <?= $team->getTournamentId() == $t->getId() ? "selected" : "" ?>>
<?= $t->getName() ?>
</option>
<?php } ?>
</select>
</form>
<?php } else { ?>
<strong>Tournoi :</strong> <a href="<?= "/tournoi/" . $tournament->getName() ?>">
<?= $team->getTournamentId() == 0 ? "Pas de tournoi choisi" : $tournament->getName() ?>
</a>
<?php } ?>
</div>
<div class="alert alert-<?= $team->getValidationStatus() == ValidationStatus::VALIDATED ? "success" : ($team->getValidationStatus() == ValidationStatus::WAITING ? "warning" : "danger") ?>">
<strong>Validation de l'équipe
:</strong> <?= ValidationStatus::getTranslatedName($team->getValidationStatus()) ?>
</div>
<div class="alert alert-info">
<?php
for ($i = 1; $i <= 3; ++$i) {
if ($team->getEncadrants()[$i - 1] == NULL)
continue;
$encadrant = User::fromId($team->getEncadrants()[$i - 1]);
$id = $encadrant->getId();
echo "<strong>Encadrant :</strong> <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 "<strong>Participant $i :</strong> <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=\"/tournoi/$final_name\">finale nationale</a>.</strong>";
}
?>
</div>
<div class="alert alert-info">
<a href="mailto:contact@tfjm.org?subject=TFJM²%20<?= $YEAR ?>&bcc=<?= join(",", $emails) ?>">Envoyer un mail à toute l'équipe</a>
</div>
<?php if (isset($_GET["modifier"])) { ?>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-6">
<label for="name">Nom :</label>
<input class="form-control" type="text" id="name" name="name" pattern="[A-Za-zÀ-ÿ ]+"
value="<?= $team->getName() ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="trigram">Trigramme :</label>
<input class="form-control" type="text" id="trigram" name="trigram"
value="<?= $team->getTrigram() ?>" pattern="[A-Z]{3}" maxlength="3" required/>
</div>
</div>
<div class="form-group row">
<label for="tournament">Tournoi :</label>
<select id="tournament" name="tournament_id" class="custom-select">
<option value="0">Choisir un tournoi ...</option>
<?php
foreach (Tournament::getAllTournaments(false, true) as $tournament)
echo "<option value=\"" . $tournament->getId() . "\" "
. ($tournament->getId() == $team->getTournamentId() ? "selected" : "") . ">"
. $tournament->getName() . "</option>\n";
?>
</select>
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="team_edit" type="submit"
value="Modifier l'équipe"/>
</div>
</form>
<?php }
if ($team->getValidationStatus() != ValidationStatus::VALIDATED) { ?>
<hr/>
<a href="/equipe/<?= $team->getTrigram() ?>/modifier"><button class="btn btn-secondary btn-lg btn-block">Modifier l'équipe</button></a>
<?php } ?>
<hr/>
<h2>Documents</h2>
<?php printDocuments($documents) ?>
<form method="POST">
<input class="btn btn-secondary btn-lg btn-block" type="submit" name="download_zip" value="Télécharger l'archive"/>
</form>
<?php if ($team->isSelectedForFinal()) { ?>
<hr/>
<h2>Documents pour la finale</h2>
<?php printDocuments($documents_final) ?>
<form method="POST">
<input class="btn btn-secondary btn-lg btn-block" type="submit" name="download_zip_final" value="Télécharger l'archive"/>
</form>
<?php } ?>
<?php if ($team->getValidationStatus() == ValidationStatus::WAITING) { ?>
<form method="POST">
<div class="form-group row">
<label for="message">Message à adresser à l'équipe :</label>
<textarea class="form-control" id="message" name="message"></textarea>
</div>
<div class="form-group">
<div class="form-group row col-mod-6">
<input type="submit" class="btn btn-secondary btn-lg btn-block" name="unvalidate"
value="Refuser l'équipe"/>
<input type="submit" class="btn btn-primary btn-lg btn-block" name="validate" value="Valider l'équipe"/>
</div>
</div>
</form>
<?php
}
if (!$team->isSelectedForFinal() && $team->getValidationStatus() == ValidationStatus::VALIDATED) { ?>
<hr/>
<form method="POST">
<input class="btn btn-primary btn-lg btn-block" type="submit" name="select" value="Sélectionner pour la finale nationale"/>
</form>
<?php }
if ($team->getValidationStatus() == ValidationStatus::NOT_READY && $_SESSION["role"] == Role::ADMIN) { ?>
<hr/>
<form method="POST">
<input type="submit" class="btn btn-primary btn-lg btn-block" name="delete_team" value="Supprimer l'équipe"
style="background-color: #ff2e34"/>
</form>
<?php }?>
<?php require_once "footer.php" ?>

View File

@ -0,0 +1,18 @@
<div class="mt-4 mb-4">
</div>
</div>
<footer>
<hr/>
<div class="container.fluid">
<div class="alert alert-light inner">
<em>Ce site a été conçu pour Animath, avec amour et passion. Il est récent et il est 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><br/>
© <?= $YEAR ?> Tournoi Français des Jeunes Mathématiciennes et Mathématiciens
</div>
</div>
</footer>
</body>
</html>
<?php exit() ?>

View File

@ -0,0 +1,163 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="description" content="Inscrivez-vous pour le TFJM² <?= $YEAR ?> !">
<meta name="keywords" content="TFJM,TFJM²,Tournoi,Français,Jeunes,Mathématiciennes,Mathématiciens">
<meta name="author" content="Yohann D'ANELLO (yohann.danello[at]animath.fr)">
<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="/style.css">
<link REL="shortcut icon" href="/favicon.ico">
<!-- Bootstrap CSS -->
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/v4-shims.css">
<!-- JQuery, Bootstrap and Turbolinks JavaScript -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js"
crossorigin="anonymous"></script>
</head>
<body>
<div class="container.fluid bg-light">
<nav class="navbar navbar-expand-md navbar-light bg-light fixed-navbar shadow-sm">
<a class="navbar-brand" href="https://tfjm.org/">
<img src="/logo.svg" alt="Logo TFJM²" id="navbar-logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarNavDropdown"
aria-controls="navbarNavDropdown" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbarNavDropdown" class="collapse navbar-collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a href="/" class="nav-link"><i class="fas fa-home"></i>Accueil</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/tournois"><i class="fas fa-calendar"></i>Liste des tournois</a>
<?php if ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER) { ?>
<ul class="deroule">
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<li class="nav-item active"><a class="nav-link" href="/profils-orphelins"><i class="fas fa-user"></i> Profils orphelins</a></li>
<li class="nav-item active"><a class="nav-link" href="/profils"><i class="fas fa-users"></i> Tous les profils</a></li>
<?php } ?>
<li class="nav-item active"><a class="nav-link" href="/organisateurs"><i class="fas fa-user-tie"></i> Organisateurs</a></li>
</ul>
<?php } ?>
</li>
<?php if (isset($_SESSION["user_id"])) { ?>
<li class="nav-item active">
<a class="nav-link" href="/mon-compte"><i class="fas fa-user"></i>Mon compte</a>
</li>
<?php if ($_SESSION["role"] == Role::ENCADRANT || $_SESSION["role"] == Role::PARTICIPANT) { ?>
<?php if ($_SESSION["team"] == NULL) { ?>
<li class="nav-item active">
<a class="nav-link" href="/ajouter_equipe"><i class="fas fa-folder-plus"></i>Ajouter une équipe</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/rejoindre_equipe"><i class="fas fa-users"></i>Rejoindre une équipe</a>
</li>
<?php } else { ?>
<li class="nav-item active">
<a class="nav-link" href="/mon-equipe"><i class="fas fa-users-cog"></i>Mon équipe</a>
</li>
<?php if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::VALIDATED) { ?>
<!-- <li class="nav-item active">
<a class="nav-link" href="/paiement">Paiement</a>
</li> -->
<li class="nav-item active">
<a class="nav-link" href="/solutions"><i class="fas fa-lightbulb"></i>Solutions</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/syntheses"><i class="fas fa-feather"></i>Notes de synthèse</a>
</li>
<?php } ?>
<?php } ?>
<?php } ?>
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<li class="nav-item active">
<a class="nav-link" href="/ajouter_tournoi"><i class="fas fa-calendar-plus"></i>Ajouter un tournoi</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/ajouter_organisateur"><i class="fas fa-user-plus"></i>Ajouter un organisateur</a>
</li>
<?php } ?>
<?php if ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER) { ?>
<li class="nav-item active">
<a class="nav-link" href="/solutions_orga"><i class="fas fa-lightbulb"></i>Solutions</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/syntheses_orga"><i class="fas fa-feather"></i>Notes de synthèse</a>
</li>
<?php } ?>
<?php } ?>
<li class="nav-item active">
<a class="nav-link" href="https://www.helloasso.com/associations/animath/formulaires/5/widget"><i class="fas fa-hand-holding-heart"></i>Faire un don</a>
</li>
</ul>
<ul class="navbar-nav">
<?php if (!isset($_SESSION["user_id"])) { ?>
<li class="nav-item active">
<a class="nav-link" href="/connexion"><i class="fas fa-sign-in-alt"></i>Connexion</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/inscription"><i class="fas fa-user-plus"></i>Inscription</a>
</li>
<?php } else { ?>
<?php if (isset($_SESSION["admin"])) { ?>
<li class="nav-item active">
<a class="nav-link" href="/?view-as-admin"><i class="fas fa-tools"></i>Retourner en vue administrateur</a>
</li>
<?php } ?>
<li class="nav-item active">
<a class="nav-link" href="/deconnexion"><i class="fas fa-sign-out-alt"></i>Déconnexion</a>
</li>
<?php } ?>
</ul>
</div>
</nav>
</div>
<div class="container">
<div class="mt-4 mb-4">
</div>
<?php
if ($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) {
if ($_SESSION["team"] != null && $_SESSION["team"]->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<div class="alert alert-danger">
Votre équipe n'est pas validée. Rendez-vous sur la page <a href="mon-equipe">Mon équipe</a> pour demander à
valider votre équipe. Si vous aviez déjà effectué cette procédure par le passé, sachez qu'en raison du
changement de format de l'édition 2020 du TFJM<sup>2</sup>, toutes les validations ont été retirées, et
vous devez à nouveau demander à valider votre équipe. Plus d'informations sur <a href="/">la page d'accueil</a>.
</div>
<?php }
}
?>
<?php
if (isset($has_error) && $has_error) { ?>
<div class="alert alert-danger">
<strong>Erreur :</strong> <?= $error_message ?>
</div>
<?php }

View File

@ -0,0 +1,112 @@
<div>
<div class="jumbotron bg-white">
<div class="row">
<h1 class="display-3">
Bienvenue sur le site d'inscription au <a href="https://tfjm.org">𝕋𝔽𝕁𝕄<sup>2</sup></a> !
</h1>
<h2 class="display-4 text-muted">
Le Tournoi Français des Jeunes Mathématiciens et Mathématiciennes
</h2>
</div>
</div>
<div class="row jumbotron bg-white">
<div class="col-sm">
<h3>
Tu souhaites participer au tournoi ?
<br/>
Ton équipe est déjà formée ?
</h3>
</div>
<div class="col-sm text-right">
<div class="btn-group-vertical">
<a class="btn btn-primary btn-lg" href="/inscription" role="button">Inscris-toi maintenant!</a>
<a class="btn btn-light btn-lg" href="/connexion" role="button">J'ai déjà un compte</a>
</div>
</div>
</div>
<div class="alert alert-warning">
<h5 class="alert-heading">Attentions aux échéances</h5>
<p class="mb-0">
Chaque tournoi a une date limite pour les inscriptions et une date limite pour
déposer vos solutions. <a href="https://tfjm.org/infos-tournois/">En savoir plus</a>
</p>
</div>
<div class="alert alert-info" href="mailto:contact@tfjm.org">
<h5 class="alert-heading">Modification du règlement</h5>
<p class="mb-0">
Depuis l'année dernière, l'équipe doit envoyer par mail à contact@tfjm.org les informations suivantes:
<ul>
<li>Comment léquipe sest-elle formée ?</li>
<li>
Comment léquipe va-t-elle travailler (où peut-elle se rencontrer, à quelle fréquence, rencontres
avec lencadrant•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 dOrganisation se réserve le droit daccepter ou non
linscription des équipes concernées par cette lettre.
</p>
</div>
<div class="spacer" style="height: 48px"></div>
<div class="jumbotron">
<h5 class="display-4">Comment ça marche ?</h5>
<p>
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>
<p>
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>
<div class="alert alert-warning">
<strong>Attention!</strong> Votre équipe ne sera considérée comme admissible à participer au tournoi que
lorsque cette première étape aura été franchie.
</div>
<div class="alert alert-info">
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.
</div>
<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>
<div class="alert alert-warning">
<strong>Attention</strong> 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.
</div>
</div>
<div class="alert alert-light">
Ce site est récent et il est encore possible que certaines pages ne fonctionnent
pas correctement.
<br/>
Si vous remarquez des bugs, merci de les signaler à l'adresse
<a href="mailto:contact@tfjm.org">contact@tfjm.org</a>.</em>
</div>
</div>

View File

@ -0,0 +1,28 @@
<?php require_once "header.php";
$html = file_get_contents("index");
if (isset($_GET["edit"])) { ?>
<form method="POST">
<label for="content">Contenu de la page :</label>
<textarea id="content" name="content" class="form-control" rows="<?= substr_count($html, "\n") + 1 ?>"><?php echo $html ?></textarea>
<hr />
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="edit_page" type="submit" value="Modifier"/>
</div>
</form>
<?php }
else {
echo $html;
if (isset($_SESSION["user_id"]) && $_SESSION["role"] == Role::ADMIN) { ?>
<hr/>
<a class="btn btn-primary btn-block btn-lg" style="background-color: #ff2e34;" href="/modifier-page">
Modifier la page
</a>
<?php }
}
require_once "footer.php";

View File

@ -0,0 +1,201 @@
<?php require_once "header.php" ?>
<div class="mt-4 mb-4">
<h1 class="display-4"><?= $user->getFirstName() . " " . $user->getSurname() ?></h1>
</div>
<?php
if (!$has_error) {
if (isset($_POST["kick"])) { ?>
<div class="alert alert-success">
La personne a bien été exclue de l'équipe !
</div>
<?php } elseif (isset($attribute_team)) { ?>
<div class="alert alert-success">
La personne a bien rejoint l'équipe !
</div>
<?php } elseif (isset($validate_payment)) { ?>
<div class="alert alert-success">
La paiement a bien été validé / rejeté ! Un mail a été transmis au participant.
</div>
<?php } ?>
<?php } ?>
<div class="alert alert-info">
<strong>Rôle :</strong> <?= Role::getTranslatedName($user->getRole()) ?>
</div>
<?php if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
<div class="alert alert-info">
<strong>Équipe
:</strong> <?= $team === null ? "Pas d'équipe" : "<a href=\"/equipe/" . $team->getTrigram() . "\">"
. $team->getName() . " (" . $team->getTrigram() . ")</a>" ?>
<?php if ($team == null) { ?>
<form method="POST">
<div class="form-group row">
<div class="form-group col-md-12">
<label for="team">Attribuer une équipe :</label>
<select class="custom-select" id="team" name="team">
<option value="no_team">Choisir une équipe ...</option>
<?php
/** @var Team $t */
foreach (Team::getAllTeams(true) as $t) {
if ($t->getValidationStatus() != ValidationStatus::NOT_READY)
continue;
$team_name = $t->getName() . " (" . $t->getTrigram() . "), "
. ($t->getTournamentId() == 0 ? "pas de tournoi choisi" : "tournoi " . Tournament::fromId($t->getTournamentId())->getName());
$team_id = $t->getId();
echo "<option value=\"$team_id\">$team_name</option>\n";
}
?>
</select>
</div>
</div>
<div class="form-group row">
<input type="submit" class="btn btn-secondary btn-lg btn-block" name="attribute_team"
value="Affecter dans une équipe"/>
</div>
</form>
<?php } elseif ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<form method="POST">
<input type="hidden" name="kick"/>
<a href="#" onclick="this.parentNode.submit()">Exclure de l'équipe</a>
</form>
<?php } ?>
</div>
<?php } ?>
<?php
if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) {
?>
<div class="alert alert-info">
<strong>Date de naissance :</strong> <?= formatDate($user->getBirthDate()) ?><br />
</div>
<div class="alert alert-info">
<strong>Genre :</strong> <?= $user->getGender() == "M" ? "Masculin" : "Féminin" ?><br />
</div>
<div class="alert alert-info">
<strong>Adresse :</strong> <?= $user->getAddress() . ", " . $user->getPostalCode() . " " . $user->getCity() . ($user->getCountry() == "France" ? "" : ", " . $user->getCountry()) ?><br />
</div>
<?php } ?>
<div class="alert alert-info">
<strong>Adresse e-mail :</strong> <a href="mailto:<?= $user->getEmail() ?>"><?= $user->getEmail() ?></a><br />
</div>
<div class="alert alert-info">
<strong>Numéro de téléphone :</strong> <?= $user->getPhoneNumber() ?><br />
</div>
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
<div class="alert alert-info">
Lycée : <?= $user->getSchool() ?><br />
Classe : <?= SchoolClass::getTranslatedName($user->getClass()) ?>
</div>
<div class="alert alert-info">
Nom du responsable légal : <?= $user->getResponsibleName() ?>
</div>
<div class="alert alert-info">
Numéro de téléphone du responsable légal : <?= $user->getResponsiblePhone() ?>
</div>
<div class="alert alert-info">
Adresse e-mail du responsable légal : <a href="mailto:<?= $user->getResponsibleEmail() ?>"><?= $user->getResponsibleEmail() ?></a>
</div>
<?php /*if ($user->getRole() == Role::PARTICIPANT && $user->getTeamId() > 0) { ?>
<div class="alert alert-info">
<strong>Récapitulatif du paiement :</strong><br /><br />
<?php if ($payment->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<div class="alert alert-danger">
Cette personne n'a pas encore payé sa participation.
</div>
<?php } else { ?>
<strong>Tournoi :</strong> <?= $tournament->getName() ?><br />
<strong>Montant :</strong> <?= $payment->getAmount() ?> €<br />
<strong>Moyen de paiement :</strong> <?= PaymentMethod::getTranslatedName($payment->getMethod()) ?><br />
<?php if ($payment->getMethod() == PaymentMethod::SCHOLARSHIP) { ?>
<strong>Notification de bourse :</strong> <a href="/file/<?= $payment->getTransactionInfos() ?>">Télécharger</a><br /><br />
<?php } else { ?>
<strong>Informations sur le paiement :</strong> <?= $payment->getTransactionInfos() ?><br /><br />
<?php }
if ($payment->getValidationStatus() == ValidationStatus::WAITING) { ?>
<div class="alert alert-warning">
Le paiement n'a pas encore été validé.
<form method="POST">
<input type="hidden" name="validate_payment" value=""/>
<div class="form-group row">
<label for="message">Message à adresser au participant :</label>
<textarea class="form-control" id="message" name="message"></textarea>
</div>
<input class="btn btn-primary btn-lg" style="width: 49%;"
type="submit" name="accept" value="Valider le paiement"/>
<input class="btn btn-light btn-lg" style="width: 49%;" type="submit" name="reject"
value="Rejeter le paiement"/>
</form>
</div>
<?php } else { ?>
<div class="alert alert-success">
Le paiement a été validé.
</div>
<?php } ?>
<?php } ?>
</div>
<?php }*/ ?>
<div class="alert alert-warning">
En raison du changement de format du TFJM² 2020, le tournoi est devenu gratuit. Il n'y a plus d'informations de
paiement à donner.
</div>
<?php } elseif ($user->getDescription() != "") { ?>
<div class="alert alert-info">
Description : <?= $user->getDescription() ?>
</div>
<?php }
if ($user->getRole() == Role::ADMIN || $user->getRole() == Role::ORGANIZER) {
foreach ($user->getOrganizedTournaments() as $tournament) {
echo "<div class=\"alert alert-info\">Organise le tournoi <a href=\"/tournoi/" . $tournament->getName(). "\">" . $tournament->getName() . "</a></div>";
}
}
elseif (($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) && $user->getTeamId() !== NULL) { ?>
<h2>Documents</h2>
<?php
printDocuments($documents);
if ($team->isSelectedForFinal()) { ?>
<hr />
<h2>Documents pour la finale</h2>
<?php
printDocuments($documents_final);
}
}
if ($_SESSION["role"] == Role::ADMIN) {
if ($user->getRole() != Role::ADMIN && $team == null) { ?>
<hr/>
<form method="POST">
<input type="submit" name="delete_account" class="btn btn-secondary btn-lg btn-block"
style="background-color: #ff2e34" value="Supprimer le compte"/>
</form>
<?php } ?>
<hr />
<form method="POST">
<input type="submit" name="view_as" class="btn btn-secondary btn-lg btn-block" style="background-color: #2ba42b"
value="Afficher le site en tant que <?= $user->getFirstName() . " " . $user->getSurname() ?>"/>
</form>
<?php }
require_once "footer.php";

View File

@ -0,0 +1,211 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Formulaire d'inscription</h1>
</div>
<?php
/** @var NewUser $user */
if (isset($user) && !$has_error) {
?>
<div class="alert alert-success">
Vous êtes bien inscrit ! Merci désormais de confirmer votre boîte mail pour valider votre adresse. Pensez à vérifier
vos courriers indésirables.
</div>
<?php } else if (isset($_SESSION["user_id"])) { ?>
<div class="alert alert-danger">
Vous êtes déjà connecté !
</div>
<?php } else { ?>
<form method="POST">
<div class="form-group row">
<div class="form-group col-md-12">
<label for="role">Rôle :</label>
<select id="role" name="role" onchange="selectRole()" class="custom-select">
<option value="participant"><?= Role::getTranslatedName(Role::PARTICIPANT) ?></option>
<option value="encadrant"><?= Role::getTranslatedName(Role::ENCADRANT) ?></option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="surname">Nom :</label>
<input class="form-control" type="text" id="surname" name="surname"
value="<?php if (isset($user)) echo $user->surname ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="first_name">Prénom :</label>
<input class="form-control" type="text" id="first_name" name="first_name"
value="<?php if (isset($user)) echo $user->first_name ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="email">E-mail :</label>
<input class="form-control" type="email" id="email" name="email"
value="<?php if (isset($user)) echo $user->email ?>"
required/>
</div>
<div class="form-group col-md-6">
<label for="phone_number">Numéro de téléphone :</label>
<input class="form-control" type="text" id="phone_number" name="phone_number"
value="<?php if (isset($user)) echo $user->phone_number ?>"/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="password">Mot de passe :</label>
<input class="form-control" type="password" id="password" name="password" required/>
</div>
<div class="form-group col-md-6">
<label for="confirm_password">Confirmer le mot de passe :</label>
<input class="form-control" type="password" id="confirm_password" name="confirm_password" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="gender" class="mr-2">Genre :</label>
<br/>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" id="male" name="gender" value="M"
required <?= isset($_POST["gender"]) && $_POST["gender"] == "M" ? "checked" : "" ?> />
<label for="male" class="custom-control-label">Homme</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" id="female" name="gender" value="F"
required <?= isset($_POST["gender"]) && $_POST["gender"] == "F" ? "checked" : "" ?> />
<label for="female" class="custom-control-label">Femme</label>
</div>
</div>
<div class="form-group col-md-6">
<label for="birth_date">Date de naissance : (au format aaaa-mm-jj si votre navigateur supporte mal les formulaires)</label>
<input class="form-control" type="date" id="birth_date" name="birth_date"
value="<?php if (isset($user)) echo $user->birth_date ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-5">
<label for="address">Adresse :</label>
<input class="form-control" type="text" id="address" name="address"
value="<?php if (isset($user)) echo $user->address ?>"/>
</div>
<div class="form-group col-md-2">
<label for="postal_code">Code postal :</label>
<input class="form-control" type="number" id="postal_code" name="postal_code"
value="<?php if (isset($user)) echo $user->postal_code ?>" min="1000"
max="95999" required/>
</div>
<div class="form-group col-md-3">
<label for="city">Ville :</label>
<input class="form-control" type="text" id="city" name="city"
value="<?php if (isset($user)) echo $user->city ?>"/>
</div>
<div class="form-group col-md-2">
<label for="country">Pays :</label>
<input class="form-control" type="text" id="country" name="country"
value="<?= isset($user) ? $user->country : "France" ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label>
<input class="form-control" type="text" id="school" name="school"
value="<?php if (isset($user)) echo $user->school ?>"/>
</div>
<div class="form-group col-md-6">
<label id="class_label" for="class">Classe :</label>
<select id="class" name="class" class="custom-select">
<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>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label id="responsible_name_label" for="responsible_name">Nom du responsable légal :</label>
<input class="form-control" type="text" id="responsible_name" name="responsible_name"
value="<?php if (isset($user)) echo $user->responsible_name ?>"/>
</div>
<div class="form-group col-md-4">
<label id="responsible_phone_label" for="responsible_phone">Téléphone du responsable légal :</label>
<input class="form-control" type="text" id="responsible_phone" name="responsible_phone"
value="<?php if (isset($user)) echo $user->responsible_phone ?>"/>
</div>
<div class="form-group col-md-4">
<label id="responsible_email_label" for="responsible_email">Email du responsable légal :</label>
<input class="form-control" type="text" id="responsible_email" name="responsible_email"
value="<?php if (isset($user)) echo $user->responsible_email ?>"/>
</div>
</div>
<div class="form-group row">
<label id="description_label" for="description">Description :</label>
<textarea class="form-control" id="description"
name="description"><?php if (isset($user)) echo $user->description ?></textarea>
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="register" type="submit" value="S'inscrire"/>
</div>
</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" ?>

View File

@ -0,0 +1,266 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Mon compte</h1>
</div>
<?php if (!$has_error && isset($send_document)) { ?>
<div class="alert alert-success">
Le fichier a été correctement envoyé !
</div>
<?php } ?>
<?php
if (!$has_error && (isset($my_account) || isset($new_password))) {
?>
<div class="alert alert-success">
Votre compte a bien été mis à jour !
</div>
<?php
if (isset($my_account) && $user->getEmail() != $my_account->email) { ?>
<div class="alert alert-info">
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.
</div>
<?php } ?>
<?php } ?>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-6">
<label for="surname">Nom :</label>
<input class="form-control" type="text" id="surname" name="surname"
value="<?= $user->getSurname() ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="first_name">Prénom :</label>
<input class="form-control" type="text" id="first_name" name="first_name"
value="<?= $user->getFirstName() ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="email">E-mail :</label>
<input class="form-control" type="email" id="email" name="email"
value="<?= $user->getEmail() ?>"
required/>
</div>
<div class="form-group col-md-6">
<label for="phone_number">Numéro de téléphone :</label>
<input class="form-control" type="text" id="phone_number" name="phone_number"
value="<?= $user->getPhoneNumber() ?>"/>
</div>
</div>
<?php if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
<div class="form-row">
<div class="form-group col-md-6">
<label for="gender" class="mr-2">Genre :</label>
<br/>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" id="male" name="gender" value="M"
required <?= $user->getGender() == "M" ? "checked" : "" ?> />
<label for="male" class="custom-control-label">Homme</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" id="female" name="gender" value="F"
required <?= $user->getGender() == "F" ? "checked" : "" ?> />
<label for="female" class="custom-control-label">Femme</label>
</div>
</div>
<div class="form-group col-md-6">
<label for="birth_date">Date de naissance :</label>
<input class="form-control" type="date" id="birth_date" name="birth_date"
value="<?= $user->getBirthDate() ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-5">
<label for="address">Adresse :</label>
<input class="form-control" type="text" id="address" name="address"
value="<?= $user->getAddress() ?>"/>
</div>
<div class="form-group col-md-2">
<label for="postal_code">Code postal :</label>
<input class="form-control" type="number" id="postal_code" name="postal_code"
value="<?= $user->getPostalCode() ?>" min="1000"
max="95999" required/>
</div>
<div class="form-group col-md-3">
<label for="city">Ville :</label>
<input class="form-control" type="text" id="city" name="city"
value="<?= $user->getCity() ?>"/>
</div>
<div class="form-group col-md-2">
<label for="country">Pays :</label>
<input class="form-control" type="text" id="country" name="country"
value="<?= $user->getCountry() ?>" required/>
</div>
</div>
<?php } ?>
<?php if ($user->getRole() == Role::PARTICIPANT) { ?>
<div class="form-row">
<div class="form-group col-md-6">
<label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label>
<input class="form-control" type="text" id="school" name="school"
value="<?= $user->getSchool() ?>"/>
</div>
<div class="form-group col-md-6">
<label id="class_label" for="class">Classe :</label>
<select id="class" name="class" class="custom-select">
<option value="terminale" <?= $user->getClass() == SchoolClass::TERMINALE ? "selected" : "" ?>>
<?= SchoolClass::getTranslatedName(SchoolClass::TERMINALE) ?>
</option>
<option value="premiere" <?= $user->getClass() == SchoolClass::PREMIERE ? "selected" : "" ?>>
<?= SchoolClass::getTranslatedName(SchoolClass::PREMIERE) ?>
</option>
<option value="seconde" <?= $user->getClass() == SchoolClass::SECONDE ? "selected" : "" ?>>
<?= SchoolClass::getTranslatedName(SchoolClass::SECONDE) ?>
</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label id="responsible_name_label" for="responsible_name">Nom du responsable légal :</label>
<input class="form-control" type="text" id="responsible_name" name="responsible_name"
value="<?= $user->getResponsibleName() ?>"/>
</div>
<div class="form-group col-md-4">
<label id="responsible_phone_label" for="responsible_phone">Téléphone du responsable légal :</label>
<input class="form-control" type="text" id="responsible_phone" name="responsible_phone"
value="<?= $user->getResponsiblePhone() ?>"/>
</div>
<div class="form-group col-md-4">
<label id="responsible_email_label" for="responsible_email">Email du responsable légal :</label>
<input class="form-control" type="text" id="responsible_email" name="responsible_email"
value="<?= $user->getResponsibleEmail() ?>"/>
</div>
</div>
<?php } else { ?>
<div class="form-group row">
<label id="description_label" for="description">Activité professionnelle :</label>
<textarea class="form-control" id="description"
name="description"><?= $user->getDescription() ?></textarea>
</div>
<?php } ?>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="update_account" type="submit" value="Mettre à jour mes données" />
</div>
</form>
<div style="padding: 20px"></div>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-4">
<label for="old_password">Ancien mot de passe :</label>
<input class="form-control" type="password" id="old_password" name="old_password" required/>
</div>
<div class="form-group col-md-4">
<label for="new_password">Nouveau mot de passe :</label>
<input class="form-control" type="password" id="new_password" name="new_password" required/>
</div>
<div class="form-group col-md-4">
<label for="confirm_password">Confirmer le mot de passe :</label>
<input class="form-control" type="password" id="confirm_password" name="confirm_password" required/>
</div>
</div>
<div class="form-group row">
<input class="btn btn-secondary btn-lg btn-block" type="submit" name="update_password"
value="Mettre à jour mon mot de passe"/>
</div>
</form>
<?php if (isset($_SESSION["team"]) && ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT)) {
$not_validated = $_SESSION["team"]->getValidationStatus() == ValidationStatus::NOT_READY;
?>
<hr/>
<div class="mt-4 mb-4">
<h1 class="display-5">Mes documents</h1>
</div>
<?php if ($not_validated) { ?>
<div class="alert alert-warning">
Ces documents peuvent être modifiés tant que l'équipe n'est pas validée. Les fichiers doivent peser au maximum 2 Mo et doivent
être au format PDF.
</div>
<div class="alert alert-danger">
En raison du changement de format du TFJM² 2020, il n'y a plus de document nécessaire à envoyer. Seule la lettre de motivation
pourra être considérée, même si son envoi n'est plus obligatoire. Merci de ne pas prêter attention à la partie qui suit.
</div>
<div class="alert alert-info">
<strong>Modèle de fiche sanitaire :</strong> <a data-turbolinks="false" href="/Fiche sanitaire.pdf">Télécharger</a><br />
<?php if ($_SESSION["user"]->getBirthDate() > strval($YEAR - 18) . substr($tournament->getStartDate(), 4)) { ?>
<strong>Modèle d'autorisation parentale :</strong> <a data-turbolinks="false" href="/Autorisation parentale.pdf">Télécharger</a>
- <a href="/Autorisation parentale.pdf?blank=<?= $tournament->getName() ?>">Modèle vierge</a><br />
<?php } ?>
<strong>Modèle d'autorisation de droit à l'image :</strong> <a data-turbolinks="false" href="/Autorisation de droit à l'image.pdf">Télécharger</a>
- <a href="/Autorisation de droit à l'image.pdf?blank=<?= $tournament->getName() ?>">Modèle vierge</a>
</div>
<?php } ?>
<?php printDocuments($documents); ?>
<?php if ($not_validated) { ?>
<div class="alert alert-warning">
Les fichiers doivent être au format PDF, PNG ou JPEG et peser moins de 2 Mo.
</div>
<form method="POST" enctype="multipart/form-data">
<div class="form-row">
<div class="form-group col-md-12">
<label for="type">Type de document</label>
<select class="custom-select" 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> -->
<option value="motivation_letter">Lettre de motivation (pour toute l'équipe)</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="document">Fichier :</label>
<input class="form-control" type="file" id="document" name="document" required/>
</div>
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" type="submit" name="send_document"
value="Envoyer le document"/>
</div>
</form>
<?php } ?>
<?php } ?>
<?php require_once "footer.php" ?>

View File

@ -0,0 +1,184 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Mon équipe</h1>
</div>
<div class="alert alert-info">
<strong>Nom de l'équipe :</strong> <?= $team->getName() ?>
</div>
<div class="alert alert-info">
<strong>Trigramme :</strong> <?= $team->getTrigram() ?>
</div>
<div class="alert alert-info">
<strong>Tournoi :</strong>
<?= $tournament == null ? "Pas de tournoi attribué" : "<a href=\"/tournoi/" . $tournament->getName() . "\">" . $tournament->getName() . "</a>" ?>
</div>
<div class="alert alert-info">
<?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 "<strong>Encadrant $i :</strong> <a href=\"/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 "<strong>Participant $i :</strong> <a href=\"/informations/$id/" . $participant->getFirstName() . " " . $participant->getSurname() . "\">" . $participant->getFirstName() . " " . $participant->getSurname() . "</a><br />";
}
?>
</div>
<div class="alert alert-info">
Code d'accès : <strong><?= $team->getAccessCode() ?></strong>
</div>
<?php if ($team->isSelectedForFinal()) {
$final_name = $FINAL->getName();
echo "<div class=\"alert aler-success\">Équipe sélectionnée pour la <a href=\"/tournoi/$final_name\">finale nationale</a>.</div>";
} ?>
<?php if (isset($_GET["modifier"])) { ?>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-6">
<label for="name">Nom :</label>
<input class="form-control" type="text" id="name" name="name" pattern="[A-Za-zÀ-ÿ ]+"
value="<?= $team->getName() ?>" required/>
</div>
<div class="form-group col-md-6">
<label for="trigram">Trigramme :</label>
<input class="form-control" type="text" id="trigram" name="trigram"
value="<?= $team->getTrigram() ?>" pattern="[A-Z]{3}" maxlength="3" required/>
</div>
</div>
<div class="form-group row">
<label for="tournament">Tournoi :</label>
<select id="tournament" name="tournament_id" class="custom-select">
<option value="0">Choisir un tournoi ...</option>
<?php
foreach ($tournaments as $tournament)
echo "<option value=\"" . $tournament->getId() . "\" "
. ($tournament->getId() == $team->getTournamentId() ? "selected" : "") . ">"
. $tournament->getName() . "</option>\n";
?>
</select>
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="team_edit" type="submit"
value="Modifier l'équipe"/>
</div>
</form>
<?php } else { ?>
<?php if ($_SESSION["team"]->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<!--suppress HtmlUnknownTarget -->
<a href="/mon-equipe/modifier">
<button class="btn btn-secondary btn-lg btn-block">Modifier mon équipe</button>
</a>
<?php } ?>
<?php if ($team->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<hr/>
<form method="POST">
<input class="btn btn-primary btn-lg btn-block" type="submit" name="leave_team" style="background-color: #ff2e34"
value="Quitter l'équipe"/>
</form>
<?php
$can_validate = canValidate($team, $tournament);
if ($can_validate) { ?>
<hr />
<form method="post">
<label for="engage">Je m'engage à participer à l'intégralité du TFJM²</label>
<input type="checkbox" name="engage" id="engage" required/>
<div class="alert alert-warning">
<strong>Attention !</strong> Une fois votre équipe validée, vous ne pourrez plus modifier le nom
de l'équipe, le trigramme ou la composition de l'équipe.
</div>
<input class="btn btn-primary btn-lg btn-block" type="submit" name="request_validation"
value="Demander la validation"/>
</form>
<?php } else { ?>
<hr />
<div class="alert alert-warning">
Pour demander à valider votre équipe, vous devez avoir au moins un encadrant, quatre participants
et soumis une autorisation de droit à l'image, une fiche sanitaire et une autorisation
parentale (si besoin) par participant, ainsi qu'une lettre de motivation à transmettre aux organisateurs.
Les encadrants doivent également fournir une autorisation de droit à l'image.
</div>
<?php } ?>
<hr>
<div class="alert alert-danger">
En raison du changement de format du TFJM² 2020, il n'y a plus de document obligatoire à envoyer. Les autorisations
précédemment envoyées ont été détruites. Seules les lettres de motivation ont été conservées, mais leur envoi
n'est plus obligatoire.
</div>
<?php }
elseif ($team->getValidationStatus() == ValidationStatus::WAITING) { ?>
<div class="alert alert-warning">
Votre équipe est en attente de validation.
</div>
<?php } ?>
<hr />
<h2>Documents de l'équipe</h2>
<?php printDocuments($documents);
if ($team->isSelectedForFinal()) { ?>
<hr />
<h2>Documents de l'équipe pour la finale</h2>
<?php printDocuments($documents_final); ?>
<?php } ?>
<?php } ?>
<?php if ($team->getValidationStatus() == ValidationStatus::VALIDATED) { ?>
<hr>
<h2>Solutions à opposer/rapporter</h2>
<div class="alert alert-warning">
Modèle vierge de note de synthèse (<a data-turbolinks="false" href="Note de synthèse.pdf">PDF</a> -- <a data-turbolinks="false" href="Note de synthèse.tex">TEX</a>)
</div>
<?php
if ($opposed_solution == null && $rapported_solution == null) { ?>
<div class="alert alert-warning">
Les solutions du tour 1 seront disponibles sur cette page peu après le tirage.
</div>
<?php } else if (date("Y-m-d H:i", true) < $tournament->getSolutionsDate2()) { ?>
<div class="alert alert-warning">
Les solutions du tour 2 pourront être téléchargées sur cette page à partir du <?= formatDate($tournament->getSolutionsDate2(), true) ?>.
</div>
<?php
}
foreach ([[$opposed_solution, DestType::OPPOSANT, 1], [$rapported_solution, DestType::RAPPORTEUR, 1],
[$opposed_solution_2, DestType::OPPOSANT, 2], [$rapported_solution_2, DestType::RAPPORTEUR, 2]] as $arr) {
$sol = $arr[0];
$source = $arr[1];
$round = $arr[2];
if ($sol === null)
continue;
$file_id = $sol->getFileId();
$problem = $sol->getProblem();
$t = Team::fromId($sol->getTeamId());
$trigram = $t->getTrigram();
echo "<div class=\"alert alert-" . ($round == 2 && date("Y-m-d H:i") < $tournament->getSolutionsDate2() ? "danger" : "info") . "\"><strong>Problème $problem "
. " de l'équipe $trigram " . ($source == DestType::OPPOSANT ? "opposé" : "rapporté") . ", tour $round</strong> : <a data-turbolinks=\"false\" href=\"/file/$file_id\">Télécharger</a></div>\n";
}
?>
<?php } ?>
<?php require_once "footer.php" ?>

View File

@ -0,0 +1,76 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Liste des organisateurs</h1>
</div>
<hr />
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th scope="col">
Nom
</th>
<th scope="col">
Prénom
</th>
<th scope="col">
Adresse e-mail
</th>
<th>
Est administrateur
</th>
</tr>
</thead>
<tbody>
<?php
/** @var User $orga */
foreach ($organizers as $orga) {
?>
<tr>
<td>
<a href="/informations/<?= $orga->getId() ?>/<?= $orga->getFirstName() . " " . $orga->getSurname() ?>">
<?= $orga->getSurname() ?>
</a>
</td>
<td>
<a href="/informations/<?= $orga->getId() ?>/<?= $orga->getFirstName() . " " . $orga->getSurname() ?>">
<?= $orga->getFirstName() ?>
</a>
</td>
<td>
<a href="mailto:<?= $orga->getEmail() ?>">
<?= $orga->getEmail() ?>
</a>
</td>
<td>
<?= $orga->getRole() == Role::ADMIN ? "oui" : "non" ?>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th>
Nom
</th>
<th>
Prénom
</th>
<th>
Adresse e-mail
</th>
<th>
Est administrateur
</th>
</tr>
</tfoot>
</table>
<?php
require_once "footer.php";

View File

@ -0,0 +1,95 @@
<?php
require_once "header.php"
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Paiement</h1>
</div>
<?php
if ($payment->getValidationStatus() == ValidationStatus::NOT_READY) { ?>
<div class="alert alert-warning">
Le prix du tournoi est de <?= $tournament->getPrice() ?> €. Vous pouvez par carte bancaire via
<a href="https://www.helloasso.com/associations/animath/evenements/tfjm-2020">la plateforme dédiée</a>,
et indiquer sur cette page les informations de paiement qui nous permettront de le retrouver.
Si ce n'est pas possible, vous pouvez également procéder à un virement sur le compte :<br /><br />
<strong>IBAN :</strong> FR76 1027 8065 0000 0206 4290 127<br />
<strong>BIC :</strong> CMCIFR2A<br /><br />
en précisant bien en référence du virement la mention <strong>TFJMpu</strong> suivie des nom et prénom de l'élève.<br /><br />
Si aucune de ces procédures nest possible pour vous, envoyez un mail à <a href="mailto:contact@tfjm.org">contact@tfjm.org</a>
pour que nous trouvions une solution à vos difficultés.
</div>
<div class="alert alert-info">
<form method="POST" enctype="multipart/form-data">
<label for="method"><strong>Mode de paiement :</strong></label>
<select class="custom-select" id="method" name="method" onchange="displayInfos()">
<?php
for ($method = PaymentMethod::NOT_PAID; $method <= PaymentMethod::SCHOLARSHIP; ++$method) {
if ($method == PaymentMethod::CASH || $method == PaymentMethod::BANK_CHECK)
continue;
?>
<option value="<?= strtolower(PaymentMethod::getName($method)) ?>"><?= PaymentMethod::getTranslatedName($method) ?></option>
<?php } ?>
</select>
<label id="infos_label" for="infos"><strong>Informations sur le paiement :</strong></label>
<textarea class="form-control" name="infos" id="infos"></textarea>
<label id="scholarship_label" for="scholarship"><strong>Notification de bourse :</strong></label>
<input type="file" class="form-control" name="scholarship" id="scholarship" />
<input class="btn btn-primary btn-block" type="submit" name="pay" value="Envoyer" />
</form>
</div>
<script>
function displayInfos() {
console.log("value = " + document.getElementById("method").value);
switch (document.getElementById("method").value) {
case "scholarship":
document.getElementById("scholarship_label").style.display = "block";
document.getElementById("scholarship").style.display = "block";
document.getElementById("scholarship").require = "true";
document.getElementById("infos_label").style.display = "none";
document.getElementById("infos").style.display = "none";
document.getElementById("infos").require = "false";
break;
default:
document.getElementById("scholarship_label").style.display = "none";
document.getElementById("scholarship").style.display = "none";
document.getElementById("scholarship").require = "false";
document.getElementById("infos_label").style.display = "block";
document.getElementById("infos").style.display = "block";
document.getElementById("infos").require = "true";
break;
}
}
displayInfos();
</script>
<?php } else {
if ($payment->getValidationStatus() == ValidationStatus::WAITING) { ?>
<div class="alert alert-warning">
Votre paiement est en attente de validation.
</div>
<?php } else { ?>
<div class="alert alert-success">
Votre paiement a bien été validé.
</div>
<?php } ?>
<div class="alert alert-info">
<strong>Récapitulatif du paiement :</strong><br /><br />
<strong>Tournoi :</strong> <?= $tournament->getName() ?><br />
<strong>Montant :</strong> <?= $payment->getAmount() ?> €<br />
<strong>Moyen de paiement :</strong> <?= PaymentMethod::getTranslatedName($payment->getMethod()) ?><br />
<?php if ($payment->getMethod() == PaymentMethod::SCHOLARSHIP) { ?>
<strong>Notification de bourse :</strong> <a data-turbolinks="false" href="/file/<?= $payment->getTransactionInfos() ?>">Télécharger</a><br />
<?php } else { ?>
<strong>Informations sur le paiement :</strong> <?= $payment->getTransactionInfos() ?><br />
<?php } ?>
</div>
<?php }
require_once "footer.php";

View File

@ -0,0 +1,67 @@
<?php
require_once "header.php";
?>
<div class="mt-4 mb-4">
<h2 class="display-3"><?= $orphans ? "Profils orphelins" : "Tous les profils" ?></h2>
</div>
<div>
Cette page recense tous les utilisateurs inscrits<?= $orphans ? " mais qui n'ont pas rejoint d'équipe" : "" ?>.
</div>
<div class="alert alert-info">
<a href="mailto:contact@tfjm.org?<? foreach ($emails as $email) echo "bcc=" . $email . "&" ?>subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites</a>
</div>
<br />
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th scope="col">
Nom
</th>
<th scope="col">
Rôle
</th>
<th scope="col">
Inscrit le
</th>
</tr>
</thead>
<tbody>
<?php
/** @var User $user */
foreach ($users as $user) {
?>
<tr>
<th scope="row">
<a href="/informations/<?= $user->getId() . "/" . $user->getFirstName() . " " . $user->getSurname() ?>">
<?= $user->getFirstName() . " " . $user->getSurname() ?>
</a>
</th>
<td><?= Role::getTranslatedName($user->getRole()) ?></td>
<td><?= formatDate($user->getInscriptionDate(), true) ?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th scope="col">
Nom
</th>
<th scope="col">
Rôle
</th>
<th scope="col">
Inscrit le
</th>
</tr>
</tfoot>
</table>
<?php
require_once "footer.php";

View File

@ -0,0 +1,35 @@
<?php
require_once "header.php" ; ?>
<div class="mt-4 mb-4">
<h1 class="display-4">Rejoindre une équipe</h1>
</div>
<?php if (isset($join_team) && !$has_error) { ?>
<div class="alert alert-success">
Vous avez bien rejoint l'équipe <?= $team->getName() ?> !
</div>
<?php } else { ?>
<?php if ($_SESSION["role"] == Role::ENCADRANT && sizeof($_SESSION["teams"]) > 0) { ?>
<div class="alert alert-warning">
Vous êtes déjà inscrit dans une équipe. Vous pouvez toutefois encadrer plusieurs équipes.
</div>
<?php } ?>
<form method="POST">
<div class="form-row">
<div class="form-group col-md-12">
<label for="access_code">Code d'accès :</label>
<input class="form-control" type="text" id="access_code" name="access_code" pattern="[A-Za-z0-9]{6}" required/>
</div>
</div>
<div class="form-group row">
<input class="btn btn-primary btn-lg btn-block" name="join_team" type="submit" value="Rejoindre l'équipe"/>
</div>
</form>
<?php } ?>
<?php require_once "footer.php" ?>

View File

@ -0,0 +1,62 @@
<?php
require_once "header.php";
if (!$has_error && isset($save_solution)) { ?>
<div class="alert alert-success">
Le fichier a été correctement envoyé !
</div>
<?php } ?>
<?php if (date("Y-m-d H:i:s") < $tournament->getSolutionsDate()) { ?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
<div class="form-row">
<div class="form-group col-md-6">
<label for="problem">Problème :</label>
<select class="custom-select" id="problem" name="problem">
<?php
for ($i = 1; $i <= 9; ++$i) {
echo "<option value=\"$i\">$i</option>\n";
}
?>
</select>
</div>
<div class="form-group col-md-6">
<label for="file">Fichier :</label>
<input class="form-control" type="file" id="file" name="solution"/>
</div>
</div>
<input class="btn btn-lg btn-primary btn-block" type="submit" name="send_solution" value="Envoyer" />
</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 "<div class=\"alert alert-info\"><strong>Problème $problem</strong> (Version $version) : <a data-turbolinks=\"false\" href=\"/file/$file_id\">Télécharger</a></div>\n";
}
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 "<div class=\"alert alert-info\"><strong>Problème $problem</strong> (Version $version) : <a data-turbolinks=\"false\" href=\"/file/$file_id\">Télécharger</a></div>\n";
}
}
require_once "footer.php";

View File

@ -0,0 +1,30 @@
<?php
require_once "server_files/views/header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Solutions</h1>
</div>
<?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 "<div class=\"alert alert-info\"><strong>Problème n°$problem de l'équipe $team_name</strong> ($team_trigram), version $version : <a data-turbolinks=\"false\" href=\"/file/$file_id\">Télécharger</a></div>";
}
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"tournament\" value=\"" . $tournament->getId() . "\" />\n";
echo "<input class=\"btn btn-lg btn-primary btn-block\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
echo "</form>\n";
}
require_once "server_files/views/footer.php";

View File

@ -0,0 +1,80 @@
<?php
require_once "header.php";
if (date("Y-m-d H:i:s") < $tournament->getSolutionsDate()) {
echo "<div class=\"alert alert-danger\"><h4>Il est trop tôt pour se préoccuper des notes de synthèse, attendez le tirage des poules.</h4></div>";
require_once "server_files/views/footer.php";
}
if (isset($save_synthesis) && !$has_error) { ?>
<div class="alert alert-success">
Le fichier a été correctement envoyé !
</div>
<?php } ?>
<?php if (date("Y-m-d H:i:s") < $tournament->getSynthesesDate2()) {
if (date("Y-m-d H:i:s") < $tournament->getSynthesesDate()) {
?>
<div class="alert alert-warning">
Attention : la date butoir de soumission des notes de synthèse pour le tour 1 est passée. Les prochaines notes de synthèses compteront pour le second tour.
</div>
<?php } ?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
<div class="form-row">
<div class="form-group col-md-4">
<label for="dest">Rôle :</label>
<select class="custom-select" id="dest" name="dest">
<option value="opposant">Opposant</option>
<option value="rapporteur">Rapporteur</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="round">Tour :</label>
<select class="custom-select" id="round" name="round">
<option value="1">Tour 1</option>
<option value="2" <?= date("Y-m-d H:i") >= $tournament->getSynthesesDate() ? "selected" : "" ?>>Tour 2</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="file">Fichier :</label>
<input class="form-control" type="file" id="file" name="synthese" />
</div>
</div>
<input class="btn btn-lg btn-primary btn-block" type="submit" name="send_synthesis" value="Envoyer" />
</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();
$round = $synthesis->getRound();
$version = $synthesis->getVersion();
echo "<div class=\"alert alert-info\"><strong>Note de synthèse " . ($dest == DestType::OPPOSANT ? "de l'opposant" : "du rapporteur") . ", tour $round</strong> (version $version) : <a data-turbolinks=\"false\" href=\"/file/$file_id\">Télécharger</a></div>";
}
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();
$round = $synthesis->getRound();
$version = $synthesis->getVersion();
echo "<div class=\"alert alert-info\"><strong>Note de synthèse " . ($dest == DestType::OPPOSANT ? "de l'opposant" : "du rapporteur") . ", tour $round</strong> (version $version) : <a data-turbolinks=\"false\" href=\"/file/$file_id\">Télécharger</a></div>";
}
}
require_once "footer.php";

View File

@ -0,0 +1,33 @@
<?php
require_once "server_files/views/header.php";
?>
<div class="mt-4 mb-4">
<h1 class="display-4">Notes de synthèse</h1>
</div>
<?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();
$round = $synthesis->getRound();
$version = $synthesis->getVersion();
$team = Team::fromId($synthesis->getTeamId());
$team_name = $team->getName();
$team_trigram = $team->getTrigram();
echo "<div class=\"alert alert-info\"><strong>Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur")
. ", tour $round</strong>, version $version : <a data-turbolinks=\"false\" href=\"/file/$file_id\">Télécharger</a></div>";
}
echo "<form method=\"POST\">\n";
echo "<input type=\"hidden\" name=\"tournament\" value=\"" . $tournament->getId() . "\" />\n";
echo "<input class=\"btn btn-lg btn-primary btn-block\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
echo "</form>\n";
}
require_once "server_files/views/footer.php";

View File

@ -0,0 +1,241 @@
<?php require_once "header.php" ?>
<div class="mt-4 mb-4">
<h1 class="display-4">Tournoi de <?= $tournament->getName() ?></h1>
</div>
<!--<div class="alert alert-info">
<strong>Instructions :</strong> <a data-turbolinks="false" href="/Instructions.pdf?blank=<?= $tournament->getName() ?>">Télécharger</a><br />
<strong>Autorisation de droit à l'image - majeur :</strong> <a data-turbolinks="false" href="/Autorisation de droit à l'image.pdf?blank=<?= $tournament->getName() ?>">Télécharger</a><br />
<strong>Autorisation de droit à l'image - mineur :</strong> <a data-turbolinks="false" href="/Autorisation de droit à l'image.pdf?mineur&blank=<?= $tournament->getName() ?>">Télécharger</a><br />
<strong>Autorisation parentale :</strong> <a data-turbolinks="false" href="/Autorisation parentale.pdf?blank=<?= $tournament->getName() ?>">Télécharger</a><br />
<strong>Fiche sanitaire :</strong> <a data-turbolinks="false" href="/Fiche sanitaire.pdf?blank=<?= $tournament->getName() ?>">Télécharger</a>
</div>-->
<div class="alert alert-info">
<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=\"/informations/$orga_id/$orga_name\">$orga_name</a>";
else
$s .= $orga_name;
$s .= ", ";
}
echo substr($s, 0, -2);
?>
</div>
<div class="alert alert-info">
<strong>Nombre d'équipes maximal :</strong> <?= $tournament->getSize() ?>
</div>
<div class="alert alert-info">
<strong>Lieu :</strong> <?= $tournament->getPlace() ?>
</div>
<!--<div class="alert alert-info">
<strong>Prix par partipant :</strong> <?= $tournament->getPrice() == 0 ? "Gratuit" : $tournament->getPrice() . "" ?>
</div>-->
<div class="alert alert-info">
<strong>Dates :</strong> Du <?= formatDate($tournament->getStartDate()) ?> au <?= formatDate($tournament->getEndDate()) ?>
</div>
<div class="alert alert-info">
<strong>Clôture des inscriptions :</strong> <?= formatDate($tournament->getInscriptionDate(), true) ?>
</div>
<div class="alert alert-info">
<strong>Date limite d'envoi des solutions :</strong> <?= formatDate($tournament->getSolutionsDate(), true) ?>
</div>
<div class="alert alert-info">
<strong>Date limite d'envoi des notes de synthèse - tour 1 :</strong> <?= formatDate($tournament->getSynthesesDate(), true) ?>
</div>
<div class="alert alert-info">
<strong>Date à partir de laquelle les solutions du tour 2 sont disponibles :</strong> <?= formatDate($tournament->getSolutionsDate2(), true) ?>
</div>
<div class="alert alert-info">
<strong>Date limite d'envoi des notes de synthèse - tour 2 :</strong> <?= formatDate($tournament->getSynthesesDate2(), true) ?>
</div>
<div class="alert alert-info">
<strong>Description :</strong> <?= $tournament->getDescription() ?>
</div>
<?php
if ($tournament->isFinal())
echo "<div class=\"alert alert-info\">\n\t<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong>\n</div>\n";
?>
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))) { ?>
<div class="alert alert-info">
<a href="mailto:contact@tfjm.org?bcc=<?= join(",", $emails) ?>&subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi</a><br>
<a href="mailto:contact@tfjm.org?bcc=<?= join(",", $emails) ?>&subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi dans une équipe validée</a>
</div>
<a href="/tournoi/<?= $tournament->getName() ?>/modifier"><button class="btn btn-secondary btn-lg btn-block">Éditer le tournoi</button></a>
<?php } ?>
<?php if (!isset($_GET["modifier"])) { ?>
<hr/>
<h2>Équipes inscrites à ce tournoi :</h2>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>
Équipe
</th>
<th>
Trigramme
</th>
<th>
Date d'inscription
</th>
<th>
État de validation de l'inscription
</th>
</tr>
</thead>
<tbody>
<?php
/** @var Team $team */
foreach ($teams as $team) {
?>
<tr>
<td>
<?php
if (isset($_SESSION["role"]) && ($_SESSION["role"] == Role::ADMIN || ($_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))))
echo "<a href=\"/equipe/" . $team->getTrigram() . "\">" . $team->getName(). "</a>";
else
echo $team->getName();
?>
</td>
<td><?= $team->getTrigram() ?></td>
<td><?= formatDate($team->getInscriptionDate()) ?></td>
<td><?= ValidationStatus::getTranslatedName($team->getValidationStatus()) ?></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th>
Équipe
</th>
<th>
Trigramme
</th>
<th>
Date d'inscription
</th>
<th>
État de validation de l'inscription
</th>
</tr>
</tfoot>
</table>
<?php
}
else {
?>
<form method="POST">
<div class="form-row">
<label for="name">Nom :</label>
<input class="form-control" type="text" id="name" name="name" value="<?= $tournament->getName() ?>" required/>
</div>
<?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<div class="form-row">
<label for="organizers">Organisateur·s :</label>
<select class="custom-select" id="organizers" name="organizers[]" multiple size="4" required>
<?php
foreach (User::getOrganizers() as $orga) {
echo "<option value=\"" . $orga->getId() . "\" " . ($tournament->organize($orga->getId()) ? "selected" : "")
. ">" . $orga->getFirstName() . " " . $orga->getSurname() . "</option>\n";
}
?>
</select>
</div>
<?php } ?>
<div class="form-row">
<div class="form-group col-md-4">
<label for="size">Nombre d'équipes :</label>
<input class="form-control" type="number" id="size" name="size" min="3" max="12" value="<?= $tournament->getSize() ?>" required/>
</div>
<div class="form-group col-md-4">
<label for="place">Lieu :</label>
<input class="form-control" type="text" id="place" name="place" value="<?= $tournament->getPlace() ?>" required/>
</div>
<div class="form-group col-md-4">
<label for="price">Prix par participant</label>
<input class="form-control" type="number" id="price" name="price" min="0" max="50" value="<?= $tournament->getPrice() ?>" required />
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="date_start">Date de début de tournoi :</label>
<input class="form-control" type="date" id="date_start" name="date_start" value="<?= $tournament->getStartDate() ?>" required />
</div>
<div class="form-group col-md-6">
<label for="date_end">Date de fin de tournoi :</label>
<input class="form-control" type="date" id="date_end" name="date_end" value="<?= $tournament->getEndDate() ?>" required />
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="date_inscription">Date limite d'inscription :</label>
<input class="form-control" type="date" id="date_inscription" name="date_inscription" value="<?= substr($tournament->getInscriptionDate(), 0, 10) ?>" required />
<input class="form-control" type="time" id="time_inscription" name="time_inscription" value="<?= substr($tournament->getInscriptionDate(), 11, 5) ?>" required />
</div>
<div class="form-group col-md-4">
<label for="date_solutions">Date limite pour rendre les solutions :</label>
<input class="form-control" type="date" id="date_solutions" name="date_solutions" value="<?= substr($tournament->getSolutionsDate(), 0, 10) ?>" required />
<input class="form-control" type="time" id="time_solutions" name="time_solutions" value="<?= substr($tournament->getSolutionsDate(),11, 5) ?>" required />
</div>
<div class="form-group col-md-4">
<label for="date_syntheses">Date limite pour rendre les notes de synthèse -- tour 1 :</label>
<input class="form-control" type="date" id="date_syntheses" name="date_syntheses"
value="<?= substr($tournament->getSynthesesDate(), 0, 10) ?>" required/>
<input class="form-control" type="time" id="time_syntheses" name="time_syntheses"
value="<?= substr($tournament->getSynthesesDate(), 11, 5) ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="date_solutions">Date à partir de laquelle les solutions du tour 2 sont disponibles :</label>
<input class="form-control" type="date" id="date_solutions" name="date_solutions_2" value="<?= substr($tournament->getSolutionsDate2(), 0, 10) ?>" required />
<input class="form-control" type="time" id="time_solutions" name="time_solutions_2" value="<?= substr($tournament->getSolutionsDate2(),11, 5) ?>" required />
</div>
<div class="form-group col-md-6">
<label for="date_syntheses">Date limite pour rendre les notes de synthèse -- tour 2 :</label>
<input class="form-control" type="date" id="date_syntheses" name="date_syntheses_2"
value="<?= substr($tournament->getSynthesesDate2(), 0, 10) ?>" required/>
<input class="form-control" type="time" id="time_syntheses" name="time_syntheses_2"
value="<?= substr($tournament->getSynthesesDate2(), 11, 5) ?>" required/>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="description">Description :</label>
<textarea class="form-control" name="description" id="description" required><?= $tournament->getDescription() ?></textarea>
</div>
</div>
<input class="btn btn-primary btn-lg btn-block" type="submit" name="edit_tournament" value="Modifier le tournoi" />
</form>
<?php } ?>
<?php require_once "footer.php" ?>

Some files were not shown because too many files have changed in this diff Show More