Compare commits

...

10 Commits

Author SHA1 Message Date
Mysaa
66ac4b8973 Changement de BDD et tests de cartes 2021-06-06 13:09:24 +02:00
Mysaa
3488323439 NOUVELLE VERSION !!! Des nouvelles classes de partout, et des supers procédures SQL. 2021-06-06 13:03:33 +02:00
Mysaa
e59898b0bb Nouvelle classe Membre, différente. D'autres modifs.... 2021-06-06 12:54:42 +02:00
Mysaa
38ec48c9fc Maintenant, tout dans le executor.php. Fin de tempPreMega.
Ajout d'un super simulateur de tours de Monoï dans la page 404.
2021-06-06 12:48:11 +02:00
Mysaa
228f54d140 Fin du dossier megaprocess, encore de nouvelles classesx 2021-06-06 12:29:03 +02:00
Mysaa
fba5123944 Encore plus de nouvelles classes
Tests sur les nombres univers
2021-06-06 12:24:05 +02:00
Mysaa
c9589d2cf6 Découpage du traitement en ercore plus de classes 2021-06-06 12:15:10 +02:00
Mysaa
6c9434e092 Ajout de quelques fonctions pour les projets 2021-06-05 20:25:50 +02:00
Mysaa
b3975e3cd1 Ajout de plus de classe, on va y arriver 2021-06-05 20:24:16 +02:00
Mysaa
2ea296cd61 Woooh, plein de nouveaux fichiers. Ajout des discussions avec des jolies classes. 2021-06-05 20:09:07 +02:00
104 changed files with 7826 additions and 800 deletions

49
404.php
View File

@ -2,42 +2,33 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<base href="http://www.bernard.890m.com/"/>
<?php include 'includes/meta.php'; ?> <?php include 'includes/meta.php'; ?>
</head> </head>
<body> <body>
<?php include 'includes/header.php'; ?> <?php include 'includes/header.php'; ?>
<h1>404 Not Found</h1> <h1>404 Not Found</h1>
<p>La page demand&eacute;e demeure introuvable.<br/>
Cette derni&egrave;re n'existe plus ou pas encore.<br/>
Bah au pire c'est pareil xD</p>
<a href="#" onclick="history.go(-1);" style="text-decoration:none"><input type="button" value="Page pr&eacute;c&eacute;dente" /></a><br/>
Si vous le voulez , vous pouvez essayer de trouver le code html de votre page web l&agrave; dedans:<br/> <p>
La page demand&eacute;e demeure introuvable.<br/>
<div id="universe_text"> Cette derni&egrave;re n'existe plus ou pas encore.<br/>
Bah au pire c'est pareil xD
</div> </p>
<div id="add_universe">Plus</div>
<script> <button onclick="window.history.go(-1);" >Page pr&eacute;c&eacute;dente</button><br/>
var charsMaxPerPlus = 1000;
var n = 1; <?php
var clics = 0; switch(rand(0,1)){
var plus = document.getElementById('add_universe'); case 1:
function addUniverseText(){ include 'allein/pieces.php';
var textToAdd = ''; break;
clics+=1; default:
while(textToAdd.length < charsMaxPerPlus*clics){ include 'allein/univers.php';
textToAdd+=n*n;
n+=1;
}
var div = document.getElementById("universe_text");
div.innerHTML+=textToAdd;
} }
plus.onclick = addUniverseText; ?>
addUniverseText();
</script>
<?php include 'includes/footer.php'; ?> <?php include 'includes/footer.php'; ?>
</body> </body>
</html> </html>

306
admin.php Normal file
View File

@ -0,0 +1,306 @@
<?php
session_start ();
include_once 'clazz/Zincluder.php';
if( !isset($_SESSION ['session_id']) or !isset($_SESSION ['session_mdp']) ) {
header ( 'Location:401.php' );
exit ();
}
$me = new Membre ( $_SESSION ['session_id'] );
$me->connect ( $_SESSION ['session_mdp'] );
if ($me->isAdminLevelLowerThan ( 15 )) {
header ( 'Location:401.php' );
exit ();
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/adminStyle.css"/>
<meta charset="utf-8"/>
<title>La console d'admin</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>jQuery.fn.extend({disable: function(state){return this.each(function(){this.disabled=state;});}});</script>
<section class="commander">
<div class="commanderCommandSelector">
Commande :
<select id="commandSelector">
<option value="get" selected="true">get</option>
<option value="set">set</option>
<option value="remove">remove</option>
<option value="add">add</option>
<option value="bdd">bdd</option>
</select><br/>
</div>
<div class="commander" id="getCommander" style="display: block;">
<label for="getCommanderCibleSelector">Cible :</label>
<input type="text" id="getCommanderCibleSelector" alt="Un selecteur" title="Un selecteur"/>
</div>
<div class="commander" id="setCommander" style="display: none;">
<label for="setCommanderCibleSelector">Cible :</label>
<input type="text" id="setCommanderCibleSelector" alt="Un selecteur" title="Un selecteur"/><br/>
<label for="setCommanderAttributeSelector">Attribut :</label>
<input type="text" id="setCommanderAttributeSelector" alt="Un nom d'attribut" title="Un nom d'attribut"/><br/>
<label for="setCommanderValeurSelector">Valeur :</label>
<input type="text" id="setCommanderValeurSelector" alt="Une valeur" title="Une valeur"/><br/>
</div>
<div class="commander" id="addCommander" style="display: none;">
Sujet :
<select id="addClassSelector">
<option value="membre" selected="true">Membre</option>
<option value="discussion">Discussion</option>
<option value="message">Message</option>
<option value="projet">Projet</option>
<option value="version">Version</option>
</select><br/>
<div class="addDivAttribute" id="addDivAttributeMembre" style="display: block;">
<span>Pseudo :<input type="text" class="addCommanderAttribute pseudo" alt="Un pseudonyme valide" title="Un pseudonyme valide"/></span><br/>
<span>Mot de passe :<input type="text" class="addCommanderAttribute mdp" alt="Un mot de passe valide" title="Un mot de passe valide"/></span><br/>
<span>Email :<input type="text" class="addCommanderAttribute email" alt="Une adresse mail valide (outrepasse la vérification)" title="Une adresse mail valide (outrepasse la v&eacute;rification)"/></span><br/>
<span class="facultatif">Date de cr&eacute;ation :<input type="text" class="addCommanderAttribute dateCreation" alt="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de r&eacute;ception de la requ&ecirc;te" title="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de r&eacute;ception de la requ&ecirc;te"/></span><br/>
<span class="facultatif">Banni&egrave;re :<input type="text" class="addCommanderAttribute banniere" alt="Un chemin vers une image, si vide, alors utilise la banni&egrave;re de base" title="Un chemin vers une image, si vide, alors utilise la banni&egrave;re de base"/></span><br/>
<span class="facultatif">Message :<input type="text" class="addCommanderAttribute message" alt="Une chaine de caract&egrave;res, si vide, aucun message ne sera affiché" title="Une chaine de caract&egrave;res, si vide, aucun message ne sera affich&eacute;"/></span><br/>
</div>
<div class="addDivAttribute" id="addDivAttributeDiscussion" style="display: none;">
<span>Nom :<input type="text" class="addCommanderAttribute nom" alt="Un nom de discussion valide" title="Un nom de discussion valide"/></span><br/>
<span>Cr&eacute;ateur :<input type="text" class="addCommanderAttribute createur" alt="Un s&eacute;l&eacute;cteur de membre ou un nombre (ID du membre)" title="Un s&eacute;l&eacute;cteur de membre ou un nombre (ID du membre)"/></span><br/>
<span class="facultatif">Date de cr&eacute;ation :<input type="text" class="addCommanderAttribute dateCreation" alt="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de r&eacute;ception de la requ&ecirc;te" title="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de r&eacute;ception de la requ&ecirc;te"/></span><br/>
<span class="facultatif">Autorisations :<input type="text" class="addCommanderAttribute autorisations" alt="Une chaine de la forme permission :&#10;a10 -> niveau d'administration &ge; 10&#10;p -> pas de restrictions&#10;x13,35,87 -> autorise les membres &agrave; l'ID &eacute;gal &agrave; 13, 35 ou 87&#10;Si vide, publique" title="Une chaine de la forme permission :&#10;a10 -> niveau d'administration &ge; 10&#10;p -> pas de restrictions&#10;x13,35,87 -> autorise les membres &agrave; l'ID &eacute;gal &agrave; 13, 35 ou 87&#10;Si vide, publique"/></span><br/>
</div>
<div class="addDivAttribute" id="addDivAttributeMessage" style="display: none;">
<span>Texte :<input type="text" class="addCommanderAttribute texte" alt="Un texte de message" title="Un texte de message"/></span><br/>
<span>Sender :<input type="text" class="addCommanderAttribute sender" alt="Un s&eacute;l&eacute;cteur de membre ou un nombre (ID du membre)" title="Un s&eacute;l&eacute;cteur de membre ou un nombre (ID du membre)"/></span><br/>
<span>Discussion :<input type="text" class="addCommanderAttribute discussion" alt="Un selecteur de discussion ou un nombre (ID de la discussion)" title="Un selecteur de discussion ou un nombre (ID de la discussion)"/></span><br/>
<span class="facultatif">Date d'envoi :<input type="text" class="addCommanderAttribute dateEnvoi" alt="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de r&eacute;ception de la requ&ecirc;te" title="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de r&eacute;ception de la requ&ecirc;te"/></span><br/>
</div>
<div class="addDivAttribute" id="addDivAttributeProjet" style="display: none;">
<span>Nom :<input type="text" class="addCommanderAttribute nom" alt="Un nom de projet valide" title="Un nom de projet valide"/></span><br/>
<div class="pocesseur">
<span>Pocesseur :<input type="text" class="addCommanderAttribute pocesseur" alt="Un s&eacute;l&eacute;cteur de membre ou un nombre (ID du membre)" title="Un s&eacute;l&eacute;cteur de membre ou un nombre (ID du membre)"/></span><br/>
<button id="addProjetAddPocesseur">Ajouter un pocesseur</button><br/>
</div>
<span class="facultatif">Permissions :<input type="text" class="addCommanderAttribute permissions" alt="Quatre bits pour les permissions, si vide: 1000" title="Quatre bits pour les permissions, si vide: 1000"/></span><br/>
</div>
<div class="addDivAttribute" id="addDivAttributeVersion" style="display: none;">
<span>Nom :<input type="text" class="addCommanderAttribute nom" alt="Un nom de version valide" title="Un nom de version valide"/></span><br/>
<span>Projet :<input type="text" class="addCommanderAttribute projet" alt="Un selecteur de projet ou un nombre (ID du projet)" title="Un selecteur de projet ou un nombre (ID du projet)"/></span><br/>
<span class="facultatif">Version absolue :<input type="text" class="addCommanderAttribute versionAbsolue" alt="Un nombre pour trier les versions, si vide, le nombre suivant la plus grande valeur de version absolue pour toute les versions de ce projet" title="Un nombre pour trier les versions, si vide, le nombre suivant la plus grande valeur de version absolue pour toute les versions de ce projet"/></span><br/>
<span class="facultatif">Langage :<input type="text" class="addCommanderAttribute langage" alt="Un nombre correspondant au langage de programmation&#10;0->Java&#10;1->VBA&#10;Si vide, 0 s&eacute;lectionn&eacute; (Java)" title="Un nombre correspondant au langage de programmation&#10;0->Java&#10;1->VBA&#10;Si vide, 0 s&eacute;lectionn&eacute; (Java)"/></span><br/>
</div>
</div>
<div class="commander" id="removeCommander" style="display: none;">
<label for="removeCommanderSelector">Cible :</label>
<input type="text" id="removeCommanderSelector" alt="Un selecteur" title="Un selecteur"/>
</div>
<div class="commander" id="bddCommander" style="display: none;">
Action :
<select id="bddActionSelector">
<option value="sort" selected="true">Sort</option>
<option value="save">Save</option>
<option value="retieve">Retieve</option>
</select><br/>
</div>
</section>
<script type="text/javascript">
function updateCommandSelector(){
$('div.commander').hide();
switch($('#commandSelector').val()){
case 'get':
$('#getCommander').show();
break;
case 'set':
$('#setCommander').show();
break;
case 'add':
$('#addCommander').show();
break;
case 'remove':
$('#removeCommander').show();
break;
case 'bdd':
$('#bddCommander').show();
break;
}
}
$('#commandSelector').change(updateCommandSelector);
function updateAddCommandClassSelector(){
$('div.addDivAttribute').hide();
switch($('#addClassSelector').val()){
case 'membre':
$('#addDivAttributeMembre').show();
break;
case 'discussion':
$('#addDivAttributeDiscussion').show();
break;
case 'message':
$('#addDivAttributeMessage').show();
break;
case 'projet':
$('#addDivAttributeProjet').show();
break;
case 'version':
$('#addDivAttributeVersion').show();
break;
}
}
$('#addClassSelector').change(updateAddCommandClassSelector);
updateCommandSelector();
updateAddCommandClassSelector();
function addProjetAddPocesseur(){
$('#addProjetAddPocesseur').before('<span>Pocesseur :<input type="text" class="addCommanderAttribute pocesseur" alt="Un s&eacute;l&eacute;cteur de membre ou un nombre (ID du membre)" title="Un s&eacute;l&eacute;cteur de membre ou un nombre (ID du membre)"/></span>');
$($('#addProjetAddPocesseur').prev().children()[0]).keyup(updateCommandOutput);
$('#addProjetAddPocesseur').before('<button class="addProjetRemovePocesseur">-</button>')
$('#addProjetAddPocesseur').prev().click(addProjetRemovePocesseur);
$('#addProjetAddPocesseur').before('<br/>');
updateCommandOutput();
}
$('#addProjetAddPocesseur').click(addProjetAddPocesseur);
function addProjetRemovePocesseur(e){
$(e.target).prev().remove();
$(e.target).next().remove();
$(e.target).remove();
updateCommandOutput();
}
$('.addProjetRemovePocesseur').click(addProjetRemovePocesseur);
var commandMode = 'gui';
function switchCommandMode(){
}
$('#switchMode').click(switchCommandMode);
</script>
<script>
var command = "";
var allRequiredFieldsFilled = false;
function updateCommandOutput(e){
switch($('#commandSelector').val()){
case 'get':
var cible = $('#getCommanderCibleSelector').val();
command = 'GET' + ' ' + cible;
allRequiredFieldsFilled = !!cible;
break;
case 'set':
var cible = $('#setCommanderCibleSelector').val();
var attribut = $('#setCommanderAttributeSelector').val();
var valeur = $('#setCommanderValeurSelector').val();
allRequiredFieldsFilled = !!cible && !!attribut && !!valeur;
command = 'SET' + ' ' + cible + ' ' + attribut + ' ' + valeur;
break;
case 'remove':
var cible = $('#removeCommanderSelector').val();
command = 'REMOVE' + ' ' + cible;
allRequiredFieldsFilled = !!cible;
break;
case 'add':
command = 'ADD ' + $('#addClassSelector').val() + ' ';
switch($('#addClassSelector').val()){
case 'membre':
var pseudo = $('#addDivAttributeMembre > span > .pseudo').val();
var mdp = $('#addDivAttributeMembre > span > .mdp').val();
var email = $('#addDivAttributeMembre > span > .email').val();
var dateCreation = $('#addDivAttributeMembre > span > .dateCreation').val();
var banniere = $('#addDivAttributeMembre > span > .banniere').val();
var message = $('#addDivAttributeMembre > span > .message').val();
command += 'pseudo "' + pseudo + '"' + ' mdp "' + mdp + '"' + ' email "' + email + '"' + ((dateCreation!='')?' dateCreation "' + dateCreation + '"' : '') + ((banniere!='')?' banniere "' + banniere + '"' : '') + ((message!='')?' message "' + message + '"' : '');
allRequiredFieldsFilled = !!pseudo && !!mdp && !!email;
break;
case 'discussion':
var nom = $('#addDivAttributeDiscussion > span > .nom').val();
var createur = $('#addDivAttributeDiscussion > span > .createur').val();
var dateCreation = $('#addDivAttributeDiscussion > span > .dateCreation').val();
var autorisations = $('#addDivAttributeDiscussion > span > .autorisations').val();
command += 'nom "' + nom + '"' + ' createur ' + ((createur!='')?createur:'???') + '' + ((dateCreation!='')?' dateCreation "' + dateCreation + '"' : '') + ((autorisations!='')?' autorisations "' + autorisations + '"' : '');
allRequiredFieldsFilled = !!nom && !!createur;
break;
case 'message':
var texte = $('#addDivAttributeMessage > span > .texte').val();
var sender = $('#addDivAttributeMessage > span > .sender').val();
var discussion = $('#addDivAttributeMessage > span > .discussion').val();
var dateEnvoi = $('#addDivAttributeMessage > span > .dateEnvoi').val();
command += 'texte "' + texte + '"' + ' sender ' + ((sender!='')?sender:'???') + ' discussion ' + ((discussion!='')?discussion:'???') + ((dateEnvoi!='')?' dateEnvoi "' + dateEnvoi + '"' : '');
allRequiredFieldsFilled = !!texte && !!sender && !!discussion;
break;
case 'projet':
var nom = $('#addDivAttributeProjet > span > .nom').val();
var permissions = $('#addDivAttributeProjet > span > .permissions').val();
pocesseurs = [];
$('.addCommanderAttribute.pocesseur').each(function(i) {
if($(this).val() != "")pocesseurs.push($(this).val());
});
command += 'nom "' + nom + '"' + ((permissions!='')?' permissions "' + permissions + '"' : '') + ' pocesseurs [ ' + pocesseurs.join(' ') +' ]';
allRequiredFieldsFilled = !!nom && pocesseurs.length > 0;
break;
case 'version':
var nom = $('#addDivAttributeVersion > span > .nom').val();
var projet = $('#addDivAttributeVersion > span > .projet').val();
var versionAbsolue = $('#addDivAttributeVersion > span > .versionAbsolue').val();
var langage = $('#addDivAttributeVersion > span > .langage').val();
command += 'nom "' + nom + '"' + ' projet ' + ((projet!='')?projet:'???') + ((versionAbsolue!='')?' versionAbsolue ' + versionAbsolue:'') + ((langage!='')?' langage ' + langage:'');
allRequiredFieldsFilled = !!nom && !!projet;
}
break;
case 'bdd':
var action = $('#bddActionSelector').val();
command = 'BDD' + ' ' + action;
allRequiredFieldsFilled = true;
break;
}
$('#send').disable(!allRequiredFieldsFilled);
$('#currentCommand').text(command);
}
$('select').change(updateCommandOutput);
$('input[type="text"]').keyup(updateCommandOutput);
</script>
<br/>
<section>
Commande :&laquo;<span id="currentCommand">...</span>&raquo;
<button id="send">Envoyer la requ&ecirc;te</button>
<button id="switchMode">Passer en mode commande</button>
</section>
<br/>
<section class="reponce">
<h3>Dialogue :</h3>
<samp id="adminDialogAnswer">
Hello !!!<br />
</samp>
</section>
<footer>
<h5>Syntaxes :</h5>
GET selector<br/>
SET selector attributeName value<br/>
REMOVE selector<br/>
ADD class attributeName attributeValue attributeName attributeValue<br/>
</footer>
</body>
</html>

283
admindialog.php Normal file
View File

@ -0,0 +1,283 @@
<?php
session_start();
include_once 'clazz/Zincluder.php';
$me = new Membre($_SESSION ['session_id']);
$me->connect($_SESSION ['session_mdp']);
if(!$me->isConnected()){
echo 'Your must being connected to have access to this page';
exit;
}elseif($me->isAdminLevelLowerThan(15)){
echo 'Your admin level is too low (15 or more required)';
exit;
}elseif(!isset($_POST['command'])){
echo 'Please set an command in the URL (POST method ,name:"command")';
exit;
}
function isAlphaNumeric($char){
return isAlphabetic($char) or isNumeric($char);
}
function isAlphabetic($char){
return preg_match('#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]$#',$char) === 1;
}
function isNumeric($char){
return preg_match('#^[0123456789]$#',$char) === 1;
}
function error($pos,$reason){
echo 'Error at char '.$pos.' : '.$reason;
exit;
}
function readAlphabetic($command){
global $pos;
$out = "";
while (isAlphaNumeric($command[$pos])) {
$out .= $command[$pos];
$pos+=1;
}
return $out;
}
function readNumeric($command){
//TODO Add non-integer support (virgule , puissance , autres bases ...)
global $pos;
$out = "";
while (isNumeric($command[$pos])) {
$out .= $command[$pos];
$pos+=1;
}
return intval($out);
}
function readString($command,$startChar='\"'){
global $pos;
$out = "";
$startChar = $command[$pos];
$pos+=1;
while (TRUE) {
$char = $command[$pos];
if($char === $startChar)
break;
if($char === '\\'){
$pos+=1;
switch ($command[$pos]){
case '\\':
$char = '\\';
break;
case $startChar:
$char = $startChar;
break;
default:
error($pos,'Unexpected "'.$command['pos'].'" after "\\"');
}
}
$out .= $char;
$pos+=1;
}
$pos +=1;
return $out;
}
$operators = array('=','!=','>','<','>=','=>','<=','=<','&has;','&nhas;');
$operatorsChars = array('=','!','<','>','&');
function readOperator($command,$endChar = 'abcdefghijklmnopqrstuvwxytABCDEFGHIJKLMNOPQRSTUVWZYZ0123456789"\''){
global $pos,$operators;
if($command[$pos] === '&'){
$pos+=1;
$inOperator = readAlphabetic($command);
if($command[$pos] !== ';'){
error($pos, 'Unexepted character at the end of the operator ' . $inOperator);
}
return '&'.$inOperator.';';
}
$reading = '';
$lastOperator = '';
$maxPos=min(strlen($command),$pos+4);
$tPos = $pos;
while ($tPos<$maxPos) {
//echo $reading;
$reading .= $command[$tPos];
$tPos+=1;
if(in_array($reading,$operators,TRUE))
$lastOperator=$reading;
}
$pos += strLen($lastOperator);
if(!in_array($lastOperator,$operators))
error($pos, 'Unknown operator : '.$out);
return $lastOperator;
}
function readSelector($command){
global $pos,$operatorsChars;
$out = array();
$pos += 1;//@
if(!isAlphabetic($command[$pos]))
error($pos,'Unexepted non-alphabetic char "'.$command[$pos].'" after @');
$className = readAlphabetic($command,'[');
$pos += 1;//[ +1
$attributes = array();
while($command[$pos] !== ']'){
if($command[$pos] === ',')
$pos+=1;
$attributeName = readAlphabetic($command,implode($operatorsChars));
$operator = readOperator($command);
$data = null;
$type = $command[$pos];
if(isAlphabetic($type)){
$data = array('a',readAlphabetic($command));
}elseif (isNumeric($type)){
$data = array('0',readNumeric($command));
}elseif ($type === '"' or $type === '\''){
$data = array('"',readString($command));
}elseif ($type === "@"){
$data = array('@',readSelector($command));
}
$attribute = array();
$attribute[0] = $attributeName;
$attribute[1] = $operator;
$attribute[2] = $data;
$attributes[] = $attribute;
}
$pos+=1;//after "["
if($command[$pos] == ':'){
$pos+=1;//letter after ":"
$selectedAttribute = readAlphabetic($command);
return array($className,$attributes,$selectedAttribute);
}
return array($className,$attributes);
}
$command=$_POST['command'].' ';
$nommes=array();
$pos=0;
while ($pos<strlen($command)) {
echo $pos;
$nomme = array();
$type=$command[$pos];
if(isAlphabetic($type)){
$nomme[0] = 'a';
$nomme[1] = readAlphabetic($command);
}elseif (isNumeric($type)){
$nomme[0] = '0';
$nomme[1] = readNumeric($command);
}elseif ($type === '"' or $type === '\''){
$nomme[0] = '"';
$nomme[1] = readString($command);
}elseif (in_array($type,$operatorsChars,TRUE)){
$nomme[0] = "=";
$nomme[1] = readOperator($command);
}elseif ($type === "@"){
$nomme[0] = "@";
$nomme[1] = readSelector($command);
//TODO Add @Selector[]:var type ':' support
}
elseif ($type === ' ')break;
else error($pos, 'Unexpected char "'.$command[$pos].'" , cannot get the term type');
$nommes[] = $nomme;
$pos+=1;
}
echo '<pre>';
print_r($nommes);
echo '</pre>';
function exception($reason){
echo 'An exception occurred : '.$reason;
exit;
}
function getObjects($selector){
}
if($nommes[0][0] == 'a'){
//Command
$fonction = strtoupper($nommes[0][1]);
switch ($fonction){
case 'SET':
/*
SET selector attributeName value
*/
if(count($nommes) !== 4)
exception('La fonction n\'a pas recu le bon nombre d\'arguments (4)');
if($nommes[1][0] !== '@')
exception('Le deuxième argument doit etre un selecteur');
$objectsToSet=NULL;
switch ($nommes[1][1][0]){
case 'Membre':
$objectsToSet = Membre::getFromAttributes($nommes[1][1][1]);
echo '<br/><pre>';
print_r($objectsToSet);
echo '</pre>';
break;
case 'Projet':
//TODO add others class support
break;
case 'Version':
break;
case 'Discussion':
break;
case 'Message':
break;
default:
exception('Unknown selector class :'.$nommes[1][1][0]);
}
if($nommes[2][0] !== 'a')
exception('Le troisième paramètre doit etre une chaine de commande (chaine de caractères alphanumériques commensant par une lettre sans guillemets');
if($nommes[3][0] !== '"' and $nommes[3][0] !== '0' and $nommes[3][0] !== ':')
exception('Le quatrième paramètre doit etre une variable (chaine de caractères entre guillemets, nombre ou variable de selecteur');
$attributeToSetName = $nommes[2][1];
$varToSet = $nommes[3];
//TODO add @Selector[]:var support
foreach($objectsToSet as $objectToSet){
$objectToSet->setAttribute($attributeToSetName,$varToSet[1],$varToSet[0]);
}
echo 'SET the value '.$varToSet[1].' at attribute '.$attributeToSetName.' of '.count($objectsToSet).' objects';
break;
case 'GET':
/*
GET selector
*/
if(count($nommes) !== 2)
exception('La fonction n\'a pas recu le bon nombre d\'arguments (2)');
if($nommes[1][0] !== '@')
exception('Le deuxième argument doit etre un selecteur');
$objectsToSet=NULL;
switch ($nommes[1][1][0]){
case 'Membre':
$objectsToSet = Membre::getFromAttributes($nommes[1][1][1]);
break;
case 'Projet':
//TODO add others class support
break;
case 'Version':
break;
case 'Discussion':
break;
case 'Message':
break;
default:
exception('Unknown selector class :'.$nommes[1][1][0]);
}
echo '<br/><pre>';
print_r($objectsToSet);
echo '</pre>';
break;
case 'DELETE':
break;
default:
exception('Unknown function '.$fonction);
}
}

156
allein/pieces.html Normal file
View File

@ -0,0 +1,156 @@
<span id="out"></span><br/>
<canvas id="pieces" width="1000" height="500"></canvas>
<script type="text/javascript">
var pieceColor = "#33E722";
var backColor = "#212121";
var canvas = document.getElementById('pieces');
var drawWidth = document.body.clientWidth - 50
canvas.width = drawWidth;
var ctx = canvas.getContext('2d');
ctx.fillStyle = backColor;
ctx.fillRect(0,0,drawWidth,500);
roundRect(ctx,10,10,100,70,5,true,false);
var tas=[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],[],[]];
//var tas=[[0,1,2],[],[]];
var X = [drawWidth/4,drawWidth/2,3*drawWidth/4];
var Y = 450;
var Yhigh = 30;
var moves = [];
var pieceHeigth = 7;
var pieceLevitation = 1;
var speed = 5;
var pieceDelta = 1;
var getWidthFromSize = function(x){return 7*x+10;}
var entreDeux = 200;
document.getElementById('out').innerHTML="Géneration des déplacements";
bouge(0,2,1,19);
document.getElementById('out').innerHTML="Placement des pieces";
redraw();
function bouge(a,b,c,z){
if(z===1){moves.push([a,b]);return;}
bouge(a,c,b,z-1);
bouge(a,b,c,1);
bouge(c,b,a,z-1);
}
da = moves[moves.length-1][0];
db = moves[moves.length-1][1];
deplacer(da,db);
function pieceDeplacing(){
var signe = (da>db)?-1:1;
ctx.fillStyle = backColor;
ctx.fillRect(oldX,oldY,L,pieceHeigth);
oldX = oldX + (signe * pieceDelta);
if((signe===1)?oldX>=endX:oldX<=endX){
setTimeout(pieceDescending,speed);
oldX = endX;
}else
setTimeout(pieceAscending,speed);
ctx.fillStyle = pieceColor;
ctx.fillRect(oldX,oldY,L,pieceHeigth);
}
function pieceAscending(){
ctx.fillStyle = backColor;
ctx.fillRect(oldX,oldY,L,pieceHeigth);
oldY = oldY-pieceDelta;
if(oldY<=topY){
oldY = topY
setTimeout(pieceDeplacing,speed);
}else
setTimeout(pieceAscending,speed);
ctx.fillStyle = pieceColor;
ctx.fillRect(oldX,oldY,L,pieceHeigth);
}
function pieceDescending(){
ctx.fillStyle = backColor;
ctx.fillRect(oldX,oldY,L,pieceHeigth);
oldY = oldY + pieceDelta;
if(oldY>=endY){
oldY = endY;
setTimeout(finishDeplacing,speed);
}else
setTimeout(pieceAscending,speed);
ctx.fillStyle = pieceColor;
ctx.fillRect(oldX,oldY,L,pieceHeigth);
}
function redraw(){
ctx.fillStyle = backColor;
ctx.fillRect(0,0,drawWidth,500);
ctx.fillStyle = pieceColor;
for(var t = 0;t<tas.length;t++){//Pour chaque tas (t)
for(var i = 0;i<tas[t].length;i++){//Pour chaque piece du tas (i du tas t)
L = getWidthFromSize(tas[t][i]);
oldX = Math.round(X[t]- (L/2));
oldY = Math.round(Y-(pieceHeigth+pieceLevitation)*(tas[t].length-i));
ctx.fillRect(oldX,oldY,L,pieceHeigth);
}
}
}
function deplacer(a,b){
document.getElementById('out').innerHTML=a+'->'+b;
da=a;
db=b;
L = getWidthFromSize(tas[da][0]);
topY = Math.round(Yhigh-pieceHeigth/2);
endX = X[db] - L/2;
endY = Math.round(Y-(pieceHeigth+pieceLevitation)*(tas[db].length + 1));
oldX = Math.round(X[da]- (L/2));
oldY = Math.round(Y-(pieceHeigth+pieceLevitation)*(tas[da].length));
ctx.fillStyle = backColor;
ctx.fillRect(oldX,oldY,L,pieceHeigth);
setTimeout(pieceAscending,entreDeux);//TODO timeout variatisation
}
function finishDeplacing(){
tas[db].unshift(tas[da][0]);
tas[da].shift();
moves.shift();
if(moves.length>0){
console.log(moves[0][0]+'->'+moves[0][1]);
setTimeout(function(){deplacer(moves[0][0],moves[0][1]);},entreDeux);
//redraw();
}else{
//redraw();
console.log("Done !!!");
}
}
function roundRect(ctx,x,y,width,height,radius,fill,stroke){
//console.log('roundRect('+x+','+y+','+width+','+height+')');
if(typeof stroke === 'undefined')
stroke = true;
if(typeof radius === 'undefined')
radius = 5;
if(typeof radius === 'number')
radius = {tl:radius,tr:radius,br:radius,bl:radius};
else{
var defaultRadius = {tl:0,tr:0,br:0,bl:0};
for(var side in defaultRadius)
radius[side] = radius[side] || defaultRadius[side];
}
ctx.beginPath();
ctx.moveTo(x+radius.tl, y);
ctx.lineTo(x+width-radius.tr, y);
ctx.quadraticCurveTo(x+width,y,x+width,y+radius.tr);
ctx.lineTo(x+width, y+height-radius.br);
ctx.quadraticCurveTo(x+width,y+height,x+width-radius.br,y+height);
ctx.lineTo(x+radius.bl, y+height);
ctx.quadraticCurveTo(x,y+height,x,y+height-radius.br);
ctx.lineTo(x, y+radius.tl);
ctx.quadraticCurveTo(x,y,x+radius.tl,y);
ctx.closePath();
if(fill)
ctx.fill();
if(stroke)
ctx.stroke();
}
</script>

60
allein/univers.php Normal file
View File

@ -0,0 +1,60 @@
Si vous le voulez , vous pouvez essayer de trouver le code html de votre page web l&agrave; dedans:<br/>
<samp id="universe_text"></samp>
<div id="add_universe" style="width:34px;height:21px;">
Plus
</div><br/>
<span id="progress"></span><br/>
<div id="egg" style="color:#222;">
egg
</div><br/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://peterolson.github.com/BigInteger.js/BigInteger.min.js"></script>
<script>
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
var chars = ['a','z','e','r','t','y','u','i','o','p','q','s','d','f','g','h','j','k','l','m','w','x','c','v','b','n', 'A','Z','E','R','T','Y','U','I','O','P','Q','S','D','F','G','H','J','K','L','M','W','X','C','V','B','N', '1','2','3','4','5','6','7','8','9','0','?',',',';','.','/',':','!','&amp;','&quot;','&lt;','&gt;','#','{','(','[','-','|','\\','_','@',')',']','=','}','+',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '];
var charsMaxPerPlus = 5000;
var n = bigInt.one;
var clics = bigInt.one;
var mode = 'txt';
var textToAdd = '';
function addOneUniverseText(){
textToAdd += bigInt(2).pow(n).toString();
n = n.add(1);
$('#progress').text(textToAdd.length + '/' + clics.multiply(charsMaxPerPlus));
txtToAdd = 0;
if(textToAdd.length < clics.multiply(charsMaxPerPlus))setTimeout(addOneUniverseText,1);
else {
for(var i = 0;i<textToAdd.length/2;i+=2)
txtToAdd += chars[parseInt(textToAdd.substring(i,i+2))];
document.getElementById("universe_text").innerHTML += txtToAdd;
}
}
var plus = document.getElementById('add_universe');
plus.addEventListener('click',function(){
textToAdd = '';
clics = clics.add(1);
setTimeout(addOneUniverseText,1)
});
var egg = document.getElementById('egg');
egg.addEventListener('click',function(){
clics = clics.add(500);
});
addOneUniverseText();
</script>

View File

@ -1,15 +0,0 @@
<?php
session_start();
include_once 'includes/bdd.php';
?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<div id="passwordChangedText">Votre mot de passe &agrave; bien &eacute;t&eacute; chang&eacute; !</div>
<?php include 'includes/footer.php'; ?>
</body>
</html>

27
clazz/2/Article.class.php Normal file
View File

@ -0,0 +1,27 @@
<?php
class Article {
public static function getNewest($count){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM articles ORDER BY lastNoticeableChangeDate DESC LIMIT '.intval($count));
$req->execute();
$reps = array();
while($rep = $req->fetch()){
$reps[] = array();
$reps[count($reps)-1]['title'] = $rep['title'];
$reps[count($reps)-1]['short'] = $rep['short'];
$reps[count($reps)-1]['text'] = $rep['text'];
$reps[count($reps)-1]['picPath'] = $rep['picPath'];
}
return $reps;
}
}

View File

@ -0,0 +1,88 @@
<?php
class Discussion{
public static function createDiscussion($sid,$mdp,$name){
$sid = intval($pseudo);
$mdp = PDO::quote(strval($mdp));
$name = PDO::quote(strval($name));
$rep = $GLOBALS['bdd']->exec('CALL `CreateDiscussion`('.$sid.','.$mdp.','.$name.', @p3 , @p4); SELECT @p3 AS ndiscutID , ID AS outputCode , errorMessage AS message , htmlErrorMessage AS htmlMessage FROM errorReturns WHERE ID = @p4;')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode'],$rep['message'],$rep['htmlMessage']);
return $rep['ndiscutId'];
}
public static function getMessages($sid,$mdp,$did){
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE smz (ID INT,senderID INT,senderPseudo VARCHAR(255),texte TEXT,sendTime DATETIME,rights INT(1))');
$req = $GLOBALS['bdd']->prepare('CALL `GetDiscutMessages`(:sid,:mdp,:did, @o)');
$req->bindValue(':sid', $sid);
$req->bindValue(':mdp', $mdp);
$req->bindValue(':did', $did);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
$req = $GLOBALS['bdd']->query('SELECT * FROM smz');
$jmsgs = array();
while($rep=$req->fetch()){
$jmsg = array();
$jmsg['messageID'] = $rep['ID'];
$jmsg['senderID'] = $rep['senderID'];
$jmsg['pseudo'] = $rep['senderPseudo'];
$jmsg['texte'] = $rep['texte'];
$jmsg['sendTime'] = $rep['sendTime'];
$jmsg['sendTimestamp'] = strToTime($rep['sendTime']);
$jmsg['rights'] = $rep['rights'] == 1;
$jmsgs[] = $jmsg;
}
return $jmsgs;
}
public static function getVisibleDiscuts($sid,$mdp){
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE discuts (ID INT,name VARCHAR(255),creatorPseudo VARCHAR(255))');
//$rep = $GLOBALS['bdd']->exec('INSERT @t');
$req = $GLOBALS['bdd']->prepare('CALL `GetVisibleDiscuts`(:sid, :mdp, @o, @canCreate)');
$req->bindValue(':sid', $sid);
$req->bindValue(':mdp', $mdp);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode, @canCreate AS canCreate')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
$out = array();
$out['canCreate'] = $rep['canCreate'] == 1;
$req = $GLOBALS['bdd']->query('SELECT * FROM discuts');
$out['discuts'] = array();
while($rep = $req->fetch()){
$dout = array();
$dout['ID'] = intval($rep['ID']);
$dout['name'] = $rep['name'];
$dout['creatorPseudo'] = $rep['creatorPseudo'];
$out['discuts'][] = $dout;
}
return $out;
}
public static function getDiscutInfo($sessionID,$sessionPassword,$did){
$req = $GLOBALS['bdd']->prepare('CALL `GetDiscutInfo`(:ssi,:ssp,:did,@o,@c);');
$req->bindValue(':ssi', $sessionID);
$req->bindValue(':ssp', $sessionPassword);
$req->bindValue(':did', $did);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode, @c AS connected')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
$out = array();
$out['connected'] = $rep['connected'] == 1;
$out['ID'] = intval($did);
return $out;
}
const MALFORMED_DATE = 'La date de cr&eacute;ation doit &ecirc;tre de la forme "AAAA:MM:JJ hh:mm:ss"';
const DATE_CREATION_CHANGED = 'La date de cr&eacute;ation a bien &eacute;t&eacute; chang&eacute;e';
}

88
clazz/2/Langage.class.php Normal file
View File

@ -0,0 +1,88 @@
<?php
class Langage{
//FIXME const
public static $java;
public static $vba;
public static $languages = array();
protected $ID;
protected $name;
protected $avalivableFiles;//String "jar xlsx javadoc" in constructor , stored as a string array
public function __construct($ID,$name,$avalivableFiles){
$this->ID = $ID;
$this->name = $name;
$this->avalivableFiles = explode(" ",$avalivableFiles);
Langage::$languages[] = $this;
}
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getAvalivableFiles(){
return $this->avalivableFiles;
}
public function isJarAvalivable(){
return in_array("jar",$this->avalivableFiles);
}
public function isJavaAvalivable(){
return in_array("java",$this->avalivableFiles);
}
public function isJavadocAvalivable(){
return in_array("javadoc",$this->avalivableFiles);
}
public function isXlsmAvalivable(){
return in_array("xlsm",$this->avalivableFiles);
}
public function isVbAvalivable(){
return in_array("vb",$this->avalivableFiles);
}
public function isJarAccessible($fileAccessibility){
return $this->isJarAvalivable() AND ($fileAccessibility >> array_search("jar",$this->avalivableFiles)) % 2 === 1;
}
public function isJavaAccessible($fileAccessibility){
return $this->isJavaAvalivable() AND ($fileAccessibility >> array_search("java",$this->avalivableFiles)) % 2 === 1;
}
public function isJavadocAccessible($fileAccessibility){
return $this->isJavadocAvalivable() AND ($fileAccessibility >> array_search("javadoc",$this->avalivableFiles)) % 2 === 1;
}
public function isXlsmAccessible($fileAccessibility){
return $this->isXlsmAvalivable() AND ($fileAccessibility >> array_search("xlsm",$this->avalivableFiles)) % 2 === 1;
}
public function isVbAccessible($fileAccessibility){
return $this->isVbAvalivable() AND ($fileAccessibility >> array_search("vb",$this->avalivableFiles)) % 2 === 1;
}
public static function getFromID($ID){
foreach(Langage::$languages AS $language){
if($language->getID() == $ID)
return $language;
}
return NULL;
}
public static function getFromName($name){
foreach(Langage::$languages AS $language){
if($language->getName() == $name)
return $language;
}
return NULL;
}
public static function getLanguagesFromVersions($versions){
$languages = array();
foreach($versions AS $version)
array_push($languages,$version->getLanguage());
$languages = array_unique($languages,SORT_REGULAR);
return $languages;
}
}
Langage::$java = new Langage(0, "Java", "jar java javadoc");
Langage::$vba = new Langage(1, "VBA", "xlsm vb");

View File

@ -0,0 +1,327 @@
<?php
class Membre {
protected $ID;
protected $accountID;
protected $accountPassword;
protected $owner;
protected $liberties;// [ [ read , read ],[ write , write ] ]
protected $path;
protected $size;
protected $valid;
public function __construct($ID) {
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM megaStockages WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->accountID = $rep['accountID'];
$this->accountPassword = $rep['accountPassword'];
$this->owner = new Membre($rep['owner']);
$this->liberties = /* TODO parse liberties */$rep['liberties'];
$this->path = $rep['path'];
$this->size = $rep['size'];
}else{
$this->valid = FALSE;
}
}
public function __toString(){
$out = 'MegaStockage\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tAccount ID:' . $this->accountID . '\n';
$out .= '\tAccount password' . $this->adminLevel . '\n';
$out .= '\tOwner:' . $this->owner->__toString() . '\n';
$out .= '\tLiberties:' . $this->liberties . '\n';
$out .= '\tPath:' . $this->path . '\n';
$out .= '\tSize:' . $this->size . '\n';
return $out;
}
public function exists(){
return $this->valid;
}
//Getters
//TODO gen getters
//Useful getters
public function canRead($he){
$read = $this->liberties[0];
if($read=='public')
return TRUE;
else if(in_array($he->getID(),$read))
return TRUE;
return FALSE;
}
public function canWrite($he){
$write = $this->liberties[1];
if($write=='public')
return TRUE;
else if(in_array($he->getID(),$write))
return TRUE;
return FALSE;
}
//Setters
public function setAttribute($attribute,$value,$valueType){
//TODO todo
$json=FALSE;
switch ($attribute){
case 'ID':
if($valueType !== '0'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($value);
break;
case 'pseudo':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'hashedPseudo':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'adminLevel':
if($valueType !== '0'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($value);
break;
case 'dateCreation':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.$value.'"';
break;
case 'requiredBanner'://FIXME jsonMysqlProblem
$json=TRUE;
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'personnalMessage':
$json=TRUE;
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
default:
echo 'Undefined attribute "'.$attribute.'" for the class Membre';
exit;
}
$restrictionValues[] = $value;
if($json){
//TODO Set command for json
}else{
$command = 'UPDATE membres SET ' . $attribute . '=' . $value . ' WHERE ID=' . $this->ID;
}
echo $command.'</br>';
$req = $GLOBALS['bdd']->prepare($command);
$req->execute(array());
if($req->errorInfo()[0] != 0){
echo 'Eine MYSQL Exception hat geworft. Einschuldigung';
exit;
}
}
/**
*
* @return Objects which matchs the specified restrictions
*/
public static function getFromAttributes($restrictions){
$whereCommands = array();
$restrictionValues = array();
foreach ($restrictions as $restriction){
$whereCommand = NULL;
$attribute = $restriction[0];
$json = FALSE;
$operator = NULL;
$value = NULL;
try {
switch ($attribute){
case 'ID':
if($restriction[2][0] !== '0'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($restriction[2][1]);
$operator = Utility::getIntegerSqlOperator($restriction[1]);
break;
case 'pseudo':
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'hashedPseudo':
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'adminLevel':
if($restriction[2][0] !== '0'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($restriction[2][1]);
$operator = Utility::getIntegerSqlOperator($restriction[1]);
break;
case 'dateCreation':
if($restriction[2][0] !== '"'){//TODO add type date
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.$restriction[2][1].'"';
$operator = Utility::getDateSqlOperator($restriction[1]);
break;
case 'requiredBanner'://FIXME jsonMysqlProblem
$json=TRUE;
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'personnalMessage':
$json=TRUE;
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
default:
echo 'Undefined attribute "'.$attribute.'" for the class Membre';
exit;
}
}catch(InvalidOperatorException $e){
echo $e->getMessage().' when reading attribute "'.$attribute.'"';
exit;
}
$restrictionValues[] = $value;
if($json){
$whereCommand = '((data->"$.'.$attribute.'" IS NOT NULL) AND (data->"$.'.$attribute.'" '.$operator.' ? ))';
}else{
$whereCommand = $attribute . ' ' . $operator . ' ' . $value;
}
$whereCommands[] = $whereCommand;
}
$wherePart = "";
if(count($whereCommands) >0)
$wherePart = 'WHERE '.implode(' AND ',$whereCommands);
$command = 'SELECT * FROM membres '.$wherePart;
$req = $GLOBALS['bdd']->prepare($command);
$req->execute($restrictionValues);
echo $command.'</br>';
if($req->errorInfo()[0] != 0)
echo 'Erreur SQL, veuillez verifier les selecteurs';
$out = array();
while($rep = $req->fetch())
$out[] = new Membre($rep['ID']);
//Choose return value
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getFromPseudo($pseudo){
return Membre::getFromAttributes(array(['pseudo','=',['"',$pseudo]]));
}
public static function getFromAdminLevel($level){
return Membre::getFromAttributes(array(['adminLevel','=',['0',$level]]));
}
public static function getFromDateCreation($date){
return Membre::getFromAttributes(array(['dateCreation','=',['0',$date]]));
}
public static function getCreatedLaterThan($date){
return Membre::getFromAttributes(array(['dateCreation','>',['"',$date]]));
}
public static function getCreatedEarlierThan($date){
return Membre::getFromAttributes(array(['dateCreation','<',['"',$date]]));
}
public static function getAdminGreaterThan($min){
return Membre::getFromAttributes(array(['adminLevel','>',['0',$min]]));
}
public static function getAdminLowerThan($max){
return Membre::getFromAttributes(array(['adminLevel','<',['0',$max]]));
}
public static function me(){
if(!isset($_SESSION['session_id']))
return NULL;
$me = new Membre($_SESSION['session_id']);
if(!$me->exists())
return NULL;
return $me;
}
//Membre creator
public static function registerPerson($pseudo, $mdp) {
if (Membre::getFromPseudo($pseudo))
return Membre::USED_USERNAME;
$req = $GLOBALS ['bdd']->prepare ('INSERT INTO membres(pseudo,mdp,date_creation) VALUES (?,?,NOW())');
$req->execute (array($pseudo,password_hash( $mdp, PASSWORD_DEFAULT)));
return Membre::PERSON_REGISTERED;
}
//Operateurs
public function __is_identical($copain){
return $this->getID() == $copain->getID();
}
//Outputs texts
//changePassword
const PASSWORD_TOO_LONG = 'Le mot de passe est trop long ! (Max : 255 caract&egrave;res)';
const PASSWORD_CHANGED = 'Le mot de passe a bien &eacute;t&eacute; chang&eacute;';
//registerPerson
const USED_USERNAME = 'Le pseudonyme est d&eacute;j&agrave; utilis&eacute;';
const PERSON_REGISTERED = 'Le membre a bien &eacute;t&eacute; inscrit !';
}

75
clazz/2/Membre.class.php Normal file
View File

@ -0,0 +1,75 @@
<?php
class Membre {
const DEFAULT_BANNER = "pictures/bande.png";
public static function registerPerson($pseudo,$password){
$req = $GLOBALS['bdd']->prepare('CALL `RegisterPerson`(:ps,:pw,@o);');
$req->bindValue(':ps', $pseudo);
$req->bindValue(':pw', $password);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode, @sid AS membreId')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
}
public static function headerInfos($sessionID,$sessionPassword){
$req = $GLOBALS['bdd']->prepare('CALL `HeaderInfos`(:ssi,:ssp,@o,@c,@p);');
$req->bindValue(':ssi', $sessionID);
$req->bindValue(':ssp', $sessionPassword);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode, @c AS connected, @p AS pseudo')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
$out = array();
$out['connected'] = $rep['connected'] == 1;
$out['pseudo'] = $rep['pseudo'];
return $out;
}
public static function checkLogin($pseudo,$sessionPassword){
$req = $GLOBALS['bdd']->prepare('CALL `CheckLogin`(:ssps,:sspw,@o,@sid);');
$req->bindValue(':ssps', $pseudo);
$req->bindValue(':sspw', $sessionPassword);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode, @sid AS membreId')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
return $rep['membreId'];
}
public static function checkIdLogin($sid,$sessionPassword){
$req = $GLOBALS['bdd']->prepare('CALL `CheckIdLogin`(:sid,:sspw,@o);');
$req->bindValue(':sid', $sid);
$req->bindValue(':sspw', $sessionPassword);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
}
public static function changePassword($sid,$rmdp,$mdp){
var_dump($sid);
var_dump($rmdp);
var_dump($mdp);
$req = $GLOBALS['bdd']->prepare('CALL `ChangePassword`(:ssi,:rmdp,:nmdp,@o);');
$req->bindValue(':ssi', $sid);
$req->bindValue(':rmdp', $rmdp);
$req->bindValue(':nmdp', $mdp);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
}
}

32
clazz/2/Message.class.php Normal file
View File

@ -0,0 +1,32 @@
<?php
class Message{
public static function postMessage($sid,$mdp,$did,$text){
$req = $GLOBALS['bdd']->prepare('CALL `PostMessage`(:sid,:mdp,:did,:text,@o);');
$req->bindValue(':sid', $sid);
$req->bindValue(':mdp', $mdp);
$req->bindValue(':did', $did);
$req->bindValue(':text', $text);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
}
public static function deleteMessage($sid,$mdp,$mid){
$req = $GLOBALS['bdd']->prepare('CALL `DeleteMessage`(:sid,:mdp,:mid,@o);');
$req->bindValue(':sid', $sid);
$req->bindValue(':mdp', $mdp);
$req->bindValue(':mid', $mid);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
}
}

96
clazz/2/Projet.class.php Normal file
View File

@ -0,0 +1,96 @@
<?php
class Projet{
public static function getAuthorizedProjectsForPresentation($sid,$mdp){
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE projects (projectID INT,projectName VARCHAR(255),versionID INT,versionName VARCHAR(255))');
//$rep = $GLOBALS['bdd']->exec('INSERT @t');
$req = $GLOBALS['bdd']->prepare('CALL `GetAuthorizedProjectsForPresentation`(:sid, :mdp, @o)');
$req->bindValue(':sid', $sid);
$req->bindValue(':mdp', $mdp);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
$req = $GLOBALS['bdd']->query('SELECT * FROM projects');
$out = array();
while($rep = $req->fetch()){
$pout = array();
$pout['projectID'] = $rep['projectID'];
$pout['projectName'] = $rep['projectName'];
$pout['versionID'] = $rep['versionID'];
$pout['versionName'] = $rep['versionName'];
$out[] = $pout;
}
return $out;
}
public static function getPublicProjectsForPresentation($sid,$mdp){
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE projects (projectID INT,projectName VARCHAR(255),versionID INT,versionName VARCHAR(255))');
//$rep = $GLOBALS['bdd']->exec('INSERT @t');
$req = $GLOBALS['bdd']->prepare('CALL `GetPublicProjectsForPresentation`(:sid, :mdp, @o)');
$req->bindValue(':sid', $sid);
$req->bindValue(':mdp', $mdp);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
$req = $GLOBALS['bdd']->query('SELECT * FROM projects');
$out = array();
while($rep = $req->fetch()){
$pout = array();
$pout['projectID'] = $rep['projectID'];
$pout['projectName'] = $rep['projectName'];
$pout['versionID'] = $rep['versionID'];
$pout['versionName'] = $rep['versionName'];
$out[] = $pout;
}
return $out;
}
public static function showProject($sid,$mdp,$pid){
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE verzions (language INT,ID INT,name VARCHAR(255));
CREATE TEMPORARY TABLE sowners (pseudo VARCHAR(255));');
$req = $GLOBALS['bdd']->prepare('CALL `PresentProject`(:sid, :mdp, :pid, @o, @public, @name, @ownerID, @ownerPseudo)');
$req->bindValue(':sid', $sid);
$req->bindValue(':mdp', $mdp);
$req->bindValue(':pid', $pid);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode,@public AS public,@name AS name,@ownerPseudo AS ownerPseudo,@ownerID AS ownerID')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
//Output
$out = array();
$out['public'] = $rep['public'] == 1;
$out['name'] = $rep['name'];
$out['ownerID'] = $rep['ownerID'];
$out['ownerPseudo'] = $rep['ownerPseudo'];
$req = $GLOBALS['bdd']->query('SELECT * FROM sowners');
$out['sowners'] = array();
while($rep = $req->fetch()){
$sowner = array();
$sowner['pseudo'] = $rep['pseudo'];
$out['sowners'][] = $sowner;
}
$req = $GLOBALS['bdd']->query('SELECT * FROM verzions');
$out['versions'] = array();
while($rep = $req->fetch()){
$version = array();
$version['language'] = $rep['language'];
$version['ID'] = $rep['ID'];
$version['name'] = $rep['name'];
$out['versions'][] = $version;
}
return $out;
}
}

View File

@ -0,0 +1,30 @@
<?php
class SQLProcessingException extends Exception{
private $errorCode;
private $Dmessage;
private $htmlMessage;
private $preferredRedirection;
public function __construct($errorCode){
$req = $GLOBALS['bdd']->prepare('SELECT errorMessage,htmlErrorMessage,preferredRedirection FROM errorReturns WHERE ID=?');
$req->execute(array(intval($errorCode)));
$rep = $req->fetch();
$this->errorCode = $errorCode;
$this->Dmessage = $rep['errorMessage'];
$this->htmlMessage = $rep['htmlErrorMessage'] ?? $rep['errorMessage'];
$this->preferredRedirection = (empty($rep['preferredRedirection'] != ""))?NULL:$rep['preferredRedirection'];
parent::__construct('Erreur '.$errorCode.' : '.$this->Dmessage);
error_log($this);
}
public function getPreferredRedirection(){
return $this->preferredRedirection;
}
public function getHtmlMessage(){
return $this->htmlMessage;
}
}

153
clazz/2/Utility.class.php Normal file
View File

@ -0,0 +1,153 @@
<?php
class InvalidOperatorException extends Exception{
public $type;
public $operator;
public function __construct ($type,$operator){
parent::__construct('Invalid operator "'.$operator.'" for the type '.$type);
}
}
class Utility{
/*
* <> ou !=
...les deux valeurs ne sont pas égales
<
...la valeur de gauche est strictement inférieure à celle de droite
>
...la valeur de gauche est strictement supérieure à celle de droite
<=
...la valeur de gauche est strictement inférieure ou égale à celle de droite
>=
...la valeur de gauche est strictement supérieure ou égale à celle de droite
BETWEEN..AND
...la valeur testée est située entre deux valeurs données
IN
...la valeur testée se situe dans une liste valeurs données
NOT IN
...la valeur testée ne se situe pas dans une liste de valeurs données
LIKE
...la valeur de gauche correspond à celle de droite (celle de droite peux utiliser le caractère % pour simuler n'importe quel nombre de caractère, et _ pour un seul caractère
NOT LIKE
...les deux valeurs ne correspondent pas
REGEXP ou RLIKE
...la valeur de gauche correspond à l'expression régulière donnée
NOT REGEXP
...la valeur de gauche ne correspond pas à l'expression régulière donnée
*/
public static function getIntegerSqlOperator($operator){
switch ($operator){
case '=':
return '=';
case '<':
return '<';
case '>':
return '>';
case '<=':
return '<=';
case '>=':
return '>=';
case '=<':
return '<=';
case '<>':
return '<>';
case '!=':
return '!=';
case '!<':
return '!<';
case '!>':
return '!>';
default:
throw new InvalidOperatorException('integer',$operator);
}
}
public static function getStringSqlOperator($operator){
switch ($operator){
case '=':
return '=';
case '&like;':
return 'LIKE';
default:
throw new InvalidOperatorException('string',$operator);
}
}
public static function getDateSqlOperator($operator){
switch ($operator){
case '=':
return '=';
case '<':
return '<';
case '>':
return '>';
case '<=':
return '<=';
case '>=':
return '>=';
case '=<':
return '<=';
case '<>':
return '<>';
case '!=':
return '!=';
case '!<':
return '!<';
case '!>':
return '!>';
default:
throw new InvalidOperatorException('date',$operator);
}
}
public static function arrayIfNot($var){
if(!is_array($var))
return $var!=NULL?array($var):NULL;
return $var;
}
public static function getHierarchicCouple(){
return array("Pr&eacute;sident","Ministres");
}
public static function sqlProcedure($procedureName,$params,$output){
$Nparams = array();
$Oparams = array();
foreach($params AS $value)
switch(gettype($value)){
case 'boolean':$Nparams[]=($value)?'TRUE':'FALSE';break;
case 'integer':$Nparams[]=strval($value);break;
case 'double':$Nparams[]=strval($value);break;
case 'string':$Nparams[]=PDO::quote($value);break;
default:$Nparams[]='NULL';break;
}
for($i=0;$i<count($output);$i++){
$Nparams[]='@'.strval($i);
$Oparams[]='@'.strval($i).' AS '.PDO::quote($output[$i]);
}
$rep = $GLOBALS['bdd']->exec('CALL '.PDO::quote($procedureName).'('.implode($Nparams,',').'); SELECT @p2 AS `outputCode`;');
}
const SUCESSFULLY_REGISTERED = 'Vous avez d&eacute;j&agrave; &eacute;t&eacute; correctement inscrit sur bernard.com';
const SUCESSFULLY_LOGGED_IN = 'Vous &ecirc;tes bien connect&eacute; (vous l\'avez &eacute;t&eacute; et le serez &eacute;galement)!';
const SUCESSFULLY_CHANGED_PASSWORD = 'Vos dispositifs d\'identification ont &eacute;t&eacute; correctement chang&eacute;s';
const SUCESSFULLY_CREATED_DISCUSSION = 'C\'est fait !!! (la cr&eacute;ation de ta discussion bien s&ucirc;r)';
const LOGIN_NEEDED_FOR_PROJECTS = 'Je veut bien &ecirc;tre un site web parfait, mais j\'aimerai bien qut tu te conn&egrave;cte pour que je puisse te montrer tes projets';
}

58
clazz/2/Version.class.php Normal file
View File

@ -0,0 +1,58 @@
<?php
class Version{
public static function editVersion ($sid,$mdp,$v,$name,$langage,$tags,$insertIndex){
$sid = intval($sid);
$mdp = $GLOBALS['bdd']->quote(strval($mdp));
$v = intval($v);
$name = $name?$GLOBALS['bdd']->quote(strval($name)):'NULL';
$langage = $langage?intval($langage):'NULL';
$tags = $tags?$GLOBALS['bdd']->quote($tags):'NULL';
$insertIndex = $insertIndex?intval($insertIndex):'NULL';
$rep = $GLOBALS['bdd']->exec('CALL `EditVersion`('.$sid.','.$mdp.','.$v.','.$name.','.$langage.','.$tags.','.$insertIndex.', @p8); SELECT ID AS outputCode , errorMessage AS message , htmlErrorMessage AS htmlMessage FROM errorReturns WHERE ID = @p8;')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode'],$rep['message'],$rep['htmlMessage']);
}
public static function showVersion($sid,$mdp,$vid){
$GLOBALS['bdd']->exec('CREATE TEMPORARY TABLE verzions (language INT,ID INT,name VARCHAR(255));');
$req = $GLOBALS['bdd']->prepare('CALL `PresentVersion`(:sid, :mdp, :vid, @o, @su,@ssu,@langageID,@projectName,@name,@fileAccessibility,@projectID,@tags)');
$req->bindValue(':sid', $sid);
$req->bindValue(':mdp', $mdp);
$req->bindValue(':vid', $vid);
$req->execute();
$rep = $GLOBALS['bdd']->query('SELECT @o AS outputCode,@su AS su,@ssu AS ssu,@langageID AS langage,@projectName AS projectName,@name AS name,@fileAccessibility AS fileAccessibility,@projectID AS projectID,@tags AS tags')->fetch();
if($rep['outputCode'] != 42)throw new SQLProcessingException($rep['outputCode']);
//Output
$out = array();
$out['su'] = $rep['su'] == 1;
$out['ssu'] = $rep['ssu'] == 1;
$out['langage'] = $rep['langage'];
$out['projectName'] = $rep['projectName'];
$out['name'] = $rep['name'];
$out['ID'] = $vid;
$out['fileAccessibility'] = $rep['fileAccessibility'];
$out['projectID'] = $rep['projectID'];
$out['alpha'] = ($rep['tags'] >> 0) % 2 === 1;
$out['beta'] = ($rep['tags'] >> 1) % 2 === 1;
$out['release'] = ($rep['tags'] >> 2) % 2 === 1;
$out['bugged'] = ($rep['tags'] >> 3) % 2 === 1;
$req = $GLOBALS['bdd']->query('SELECT * FROM verzions');
$out['brothers'] = array();
while($rep = $req->fetch()){
$version = array();
$version['language'] = $rep['language'];
$version['ID'] = $rep['ID'];
$version['name'] = $rep['name'];
$out['brothers'][] = $version;
}
return $out;
}
}

20
clazz/2/Zincluder.php Normal file
View File

@ -0,0 +1,20 @@
<?php
try{
$link = mysql_connect("localhost", "u890869027", "*******************");
//$GLOBALS['bdd'] = new PDO('mysql:host=localhost;dbname=u890869027_bcom2;charset=utf8', 'u890869027', '*******************', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));error_reporting(E_ALL);
//$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************');
}catch(Exception $e){
die ('Erreur : ' . $e->getMessage());
}
//TODO in the classes , do more test of exists in setters
include_once 'clazz/2/Utility.class.php';
include_once 'clazz/2/Langage.class.php';
include_once 'clazz/2/Membre.class.php';
include_once 'clazz/2/Discussion.class.php';
include_once 'clazz/2/Message.class.php';
include_once 'clazz/2/Projet.class.php';
include_once 'clazz/2/Article.class.php';
//TODO Use class's consts for file names
include_once 'clazz/2/Version.class.php';

145
clazz/Article.class.php Normal file
View File

@ -0,0 +1,145 @@
<?php
class Article {
protected $ID;
protected $title;
protected $short;
protected $text;
protected $postDate;
protected $lastNoticeableChangeDate;
protected $lastChange;
protected $picPath;
protected $valid;
public function __construct($ID) {
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM articles WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->title = $rep['title'];
$this->short = $rep['short'];
$this->text = $rep['text'];
$this->postDate = $rep['postDate'];
$this->lastNoticeableChangeDate = $rep['lastNoticeableChangeDate'];
$this->lastChange = $rep['lastChangeDate'];
$this->picPath = $rep['picPath'];
}else{
$this->valid = FALSE;
}
}
public function __toString(){
$out = 'MegaStockage\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tTitle:' . $this->title . '\n';
$out .= '\tShort description' . $this->short . '\n';
$out .= '\tText:' . $this->text . '\n';
$out .= '\tPost article date:' . $this->postDate . '\n';
$out .= '\tLast noticeable change date:' . $this->lastNoticeableChangeDate . '\n';
$out .= '\tLast change date:' . $this->lastChangeDate . '\n';
$out .= '\tPic(ture) path:' . $this->picPath . '\n';
return $out;
}
public function exists(){
return $this->valid;
}
//Getters
public function getID(){
return $this->ID;
}
public function setID($ID){
$this->ID = $ID;
}
public function getTitle(){
return $this->title;
}
public function setTitle($title){
$this->title = $title;
}
public function getShort(){
return $this->short;
}
public function setShort($short){
$this->short = $short;
}
public function getText(){
return $this->text;
}
public function setText($text){
$this->text = $text;
}
public function getPostDate(){
return $this->postDate;
}
public function setPostDate($postDate){
$this->postDate = $postDate;
}
public function getLastNoticeableChangeDate(){
return $this->lastNoticeableChangeDate;
}
public function setLastNoticeableChangeDate($lastNoticeableChangeDate){
$this->lastNoticeableChangeDate = $lastNoticeableChangeDate;
}
public function getLastChange(){
return $this->lastChange;
}
public function setLastChange($lastChange){
$this->lastChange = $lastChange;
}
public function getPicPath(){
return $this->picPath;
}
public function setPicPath($picPath){
$this->picPath = $picPath;
}
//Useful getters
//Gross getters
public static function getNewest($count){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM articles ORDER BY lastNoticeableChangeDate DESC LIMIT '.intval($count));
$req->execute();
$reps = array();
while($rep = $req->fetch()){
$reps[] = new Article($rep['ID']);
}
return $reps;
}
//Setters
//
//Operateurs
//Outputs texts
}

234
clazz/Discussion.class.php Normal file
View File

@ -0,0 +1,234 @@
<?php
class Discussion{
protected $ID;
protected $name;
protected $creator;
protected $dateCreation;
protected $accessibility;
protected $valid;
public function __construct($ID){
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->name = $rep['name'];
$this->creator = new Membre($rep['creatorID']);
$this->dateCreation = $rep['dateCreation'];
$this->accessibility = $rep['accessibility'];
}else{
$this->valid = FALSE;
}
}
public function exists(){
return $this->valid;
}
public function __toString(){
$out = 'Discussion\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tName:' . $this->name . '\n';
$out .= '\tCreator:{' . substr(str_replace('\n\t',';',$this->creator->__toString()),0,-1) . '}\n';
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
$out .= '\tAccessibility:' . $this->accessibility . '\n';
return $out;
}
//Getters
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getCreator(){
return $this->creator;
}
public function getDateCreation(){
return $this->dateCreation;
}
public function getAccessibility(){
return $this->accessibility;
}
//Useful Getters
public function canAccess($membre){
if($this->accessibility === 'p')
return TRUE;
if($membre->getID() === $this->creator->getID())
return TRUE;
if(preg_match ( "#^a[0-9]+$#", $this->accessibility ) == 1)
if(intval ( substr ( $this->accessibility, 1 ) ) <= $membre->getAdminLevel())
return TRUE;
if(preg_match ( '#^x([0-9]+,)*' . $membre->getID() . '(,[0-9]+)*$#', $this->accessibility ))
return TRUE;
if($membre->getAdminLevel() >= 14)
return TRUE;
return FALSE;
}
public function isPublic(){
if($this->accessibility === 'p')
return TRUE;
return FALSE;
}
//Setters
public function rename($newName){
if(!exists())
return NULL;
if(getFromName($newName))
return Discussion::NAME_ALREADY_USED;
if(strlen($newName)>255)
return Discussion::TOO_LONG_NAME;
$regex = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.
'éèàµ_\\-\'()\\[\\]\\\\/,;:.§!ù%£$¤=+\\-*\\#~"|ç@';
$regex = '#^['.$regex.']+$#';
if(preg_match($regex,$newName) != 1)
return Discussion::ILLEGAL_NAME;
$req->$GLOBALS['bdd']->prepare('UPDATE discussions SET name=? WHERE ID=?');
$req->execute(array($newName,$this->ID));
return Discussion::NAME_CHANGED;
}
public function changeAccessibility($newAccessibility){
if(!exists())
return NULL;
if($newAccessibility !== 'p' and
preg_match('#x([0-9]+;)*[0-9]+#',$newAccessibility) != 1 and
preg_match('#a[0-9]+#',$newAccessibility) != 1)
return Discussion::MALFORMED_ACCESIBILITY;
$req = $GLOBALS['bdd']->prepare('UPDATE discussions SET accessibility=? WHERE ID=?');
$req->execute(array($newAccessibility,$this->ID));
return Discussion::ACCESSIBILITY_CHANGED;
}
public function setDateCreation($newDateCreation){
if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $date, $matches) != 1)
return Discussion::MALFORMED_DATE;
if (!checkdate($matches[2], $matches[3], $matches[1]))
return Discussion::MALFORMED_DATE;
$req = $GLOBALS['bdd']->prepare('UPDATE discussions SET dateCreation=? WHERE ID=?');
$req->execute(array($newDateCreation,$this->ID));
return Discussion::DATE_CREATION_CHANGED;
}
//Discussions getters
private static function discussionGetterOutput($req){
$out = array();
while($rep = $req->fetch())
$out[] = new Discussion($rep['ID']);
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getFromName($name){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE name=?');
$req->execute(array($name));
return Discussion::discussionGetterOutput($req);
}
public static function getFromCreator($creator){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
$req->execute(array($creator->getID()));
return Discussion::discussionGetterOutput($req);
}
public static function getFromDateCreation($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation=?');
$req->execute(array($date));
return Discussion::discussionGetterOutput($req);
}
public static function getFromAccessibility($accessibility){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
$req->execute(array($accessibility));
return Discussion::discussionGetterOutput($req);
}
public static function getCreatedLaterThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation>?');
$req->execute(array($date));
return Discussion::discussionGetterOutput($req);
}
public static function getCreatedEarlierThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation<?');
$req->execute(array($date));
return Discussion::discussionGetterOutput($req);
}
public static function getPublics(){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE accessibility LIKE "p%"');
$req->execute();
return Discussion::discussionGetterOutput($req);
}
public static function getWhichHeCanAccess($he){
//TODO utiliser une regex dans la requete SQL pour selectionner les discussions autorisées
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions');
$req->execute(array());
$out = array();
while ( $rep = $req->fetch()) {
$disc = new Discussion($rep['ID']);
if ($disc->canAccess($he))
$out[] = $disc;
}
if($out)
return $out;
else
return NULL;
}
//Discussion creator
public static function createDiscussion($name, $owner) {
if(Discussion::getFromName($name))
return Discussion::NAME_ALREADY_USED;
if(strlen($name)>255)
return Discussion::TOO_LONG_NAME;
$regex = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 éèà&mu;_\\-\'()\\[\\]\\\\/,;:.§!ù%£$¤=+\\-*\\#~"|ç@';
$regex = '#^['.$regex.']+$#';
if(preg_match($regex,$name) != 1)
return Discussion::ILLEGAL_NAME;
$req = $GLOBALS ['bdd']->prepare ("INSERT INTO `discussions`(`ID`, `name`, `creatorID`, `dateCreation`, `accessibility`) VALUES (NULL,?,?,NOW(),'p')" );
$req->execute ( array (
$name,
$owner
) );
return 'ok';
}
// Exceptions texts
//rename()
const NAME_ALREADY_USED = 'Nom d&eacute;j&agrave; utilis&eacute;';
const ILLEGAL_NAME = 'Le nom de la discussion est incorrect : les caract&egrave;res autoris&eacutes sont :'.
'<br/> abcdefghijklmnopqrstuvwxyz<wbr/>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<wbr/>'.
'&eacute;&egrave;&agrave;&mu;_-\'()[\\]\\\\/<wbr/>,;:.&sect;!&ugrave;%&pound;$&curren;=+-*\\#~"|&ccedil;@';
const TOO_LONG_NAME = 'Le nom est trop long : maximum 256 caract&egrave;res';
const NAME_CHANGED = 'Le nom a bien &eacute;t&eacute; chang&eacute; !';
//changeAccessibility()
const MALFORMED_ACCESSIBILITY = 'L\'accessibilit&eacute; doit être de la forme : "p" ou "x31;41;59;26;53" ou "a42"';
const ACCESSIBILITY_CHANGED = 'L\'accessibilit&eacute; a bien &eacute;t&eacute; chang&eacute;e !';
//setDateCreation()
const MALFORMED_DATE = 'La date de cr&eacute;ation doit &ecirc;tre de la forme "AAAA:MM:JJ hh:mm:ss"';
const DATE_CREATION_CHANGED = 'La date de cr&eacute;ation a bien &eacute;t&eacute; chang&eacute;e';
}

71
clazz/Langage.class.php Normal file
View File

@ -0,0 +1,71 @@
<?php
class Langage{
//FIXME const
public static $java;
public static $vba;
public static $languages = array();
protected $ID;
protected $name;
protected $avalivableFiles;//String "jar xlsx javadoc" in constructor , stored as a string array
public function __construct($ID,$name,$avalivableFiles){
$this->ID = $ID;
$this->name = $name;
$this->avalivableFiles = explode(" ",$avalivableFiles);
Langage::$languages[] = $this;
}
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getAvalivableFiles(){
return $this->avalivableFiles;
}
public function isJarAvalivable(){
return in_array("jar",$this->avalivableFiles);
}
public function isJavaAvalivable(){
return in_array("java",$this->avalivableFiles);
}
public function isJavadocAvalivable(){
return in_array("javadoc",$this->avalivableFiles);
}
public function isXlsmAvalivable(){
return in_array("xlsm",$this->avalivableFiles);
}
public function isVbAvalivable(){
return in_array("vb",$this->avalivableFiles);
}
public static function getFromID($ID){
foreach(Langage::$languages AS $language){
if($language->getID() == $ID)
return $language;
}
return NULL;
}
public static function getFromName($name){
foreach(Langage::$languages AS $language){
if($language->getName() == $name)
return $language;
}
return NULL;
}
public static function getLanguagesFromVersions($versions){
$languages = array();
foreach($versions AS $version)
array_push($languages,$version->getLanguage());
$languages = array_unique($languages,SORT_REGULAR);
return $languages;
}
}
Langage::$java = new Langage(0, "Java", "jar java javadoc");
Langage::$vba = new Langage(1, "VBA", "xlsm vb");

View File

@ -0,0 +1,327 @@
<?php
class Membre {
protected $ID;
protected $accountID;
protected $accountPassword;
protected $owner;
protected $liberties;// [ [ read , read ],[ write , write ] ]
protected $path;
protected $size;
protected $valid;
public function __construct($ID) {
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM megaStockages WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->accountID = $rep['accountID'];
$this->accountPassword = $rep['accountPassword'];
$this->owner = new Membre($rep['owner']);
$this->liberties = /* TODO parse liberties */$rep['liberties'];
$this->path = $rep['path'];
$this->size = $rep['size'];
}else{
$this->valid = FALSE;
}
}
public function __toString(){
$out = 'MegaStockage\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tAccount ID:' . $this->accountID . '\n';
$out .= '\tAccount password' . $this->adminLevel . '\n';
$out .= '\tOwner:' . $this->owner->__toString() . '\n';
$out .= '\tLiberties:' . $this->liberties . '\n';
$out .= '\tPath:' . $this->path . '\n';
$out .= '\tSize:' . $this->size . '\n';
return $out;
}
public function exists(){
return $this->valid;
}
//Getters
//TODO gen getters
//Useful getters
public function canRead($he){
$read = $this->liberties[0];
if($read=='public')
return TRUE;
else if(in_array($he->getID(),$read))
return TRUE;
return FALSE;
}
public function canWrite($he){
$write = $this->liberties[1];
if($write=='public')
return TRUE;
else if(in_array($he->getID(),$write))
return TRUE;
return FALSE;
}
//Setters
public function setAttribute($attribute,$value,$valueType){
//TODO todo
$json=FALSE;
switch ($attribute){
case 'ID':
if($valueType !== '0'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($value);
break;
case 'pseudo':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'hashedPseudo':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'adminLevel':
if($valueType !== '0'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($value);
break;
case 'dateCreation':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.$value.'"';
break;
case 'requiredBanner'://FIXME jsonMysqlProblem
$json=TRUE;
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'personnalMessage':
$json=TRUE;
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
default:
echo 'Undefined attribute "'.$attribute.'" for the class Membre';
exit;
}
$restrictionValues[] = $value;
if($json){
//TODO Set command for json
}else{
$command = 'UPDATE membres SET ' . $attribute . '=' . $value . ' WHERE ID=' . $this->ID;
}
echo $command.'</br>';
$req = $GLOBALS['bdd']->prepare($command);
$req->execute(array());
if($req->errorInfo()[0] != 0){
echo 'Eine MYSQL Exception hat geworft. Einschuldigung';
exit;
}
}
/**
*
* @return Objects which matchs the specified restrictions
*/
public static function getFromAttributes($restrictions){
$whereCommands = array();
$restrictionValues = array();
foreach ($restrictions as $restriction){
$whereCommand = NULL;
$attribute = $restriction[0];
$json = FALSE;
$operator = NULL;
$value = NULL;
try {
switch ($attribute){
case 'ID':
if($restriction[2][0] !== '0'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($restriction[2][1]);
$operator = Utility::getIntegerSqlOperator($restriction[1]);
break;
case 'pseudo':
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'hashedPseudo':
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'adminLevel':
if($restriction[2][0] !== '0'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($restriction[2][1]);
$operator = Utility::getIntegerSqlOperator($restriction[1]);
break;
case 'dateCreation':
if($restriction[2][0] !== '"'){//TODO add type date
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.$restriction[2][1].'"';
$operator = Utility::getDateSqlOperator($restriction[1]);
break;
case 'requiredBanner'://FIXME jsonMysqlProblem
$json=TRUE;
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'personnalMessage':
$json=TRUE;
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
default:
echo 'Undefined attribute "'.$attribute.'" for the class Membre';
exit;
}
}catch(InvalidOperatorException $e){
echo $e->getMessage().' when reading attribute "'.$attribute.'"';
exit;
}
$restrictionValues[] = $value;
if($json){
$whereCommand = '((data->"$.'.$attribute.'" IS NOT NULL) AND (data->"$.'.$attribute.'" '.$operator.' ? ))';
}else{
$whereCommand = $attribute . ' ' . $operator . ' ' . $value;
}
$whereCommands[] = $whereCommand;
}
$wherePart = "";
if(count($whereCommands) >0)
$wherePart = 'WHERE '.implode(' AND ',$whereCommands);
$command = 'SELECT * FROM membres '.$wherePart;
$req = $GLOBALS['bdd']->prepare($command);
$req->execute($restrictionValues);
echo $command.'</br>';
if($req->errorInfo()[0] != 0)
echo 'Erreur SQL, veuillez verifier les selecteurs';
$out = array();
while($rep = $req->fetch())
$out[] = new Membre($rep['ID']);
//Choose return value
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getFromPseudo($pseudo){
return Membre::getFromAttributes(array(['pseudo','=',['"',$pseudo]]));
}
public static function getFromAdminLevel($level){
return Membre::getFromAttributes(array(['adminLevel','=',['0',$level]]));
}
public static function getFromDateCreation($date){
return Membre::getFromAttributes(array(['dateCreation','=',['0',$date]]));
}
public static function getCreatedLaterThan($date){
return Membre::getFromAttributes(array(['dateCreation','>',['"',$date]]));
}
public static function getCreatedEarlierThan($date){
return Membre::getFromAttributes(array(['dateCreation','<',['"',$date]]));
}
public static function getAdminGreaterThan($min){
return Membre::getFromAttributes(array(['adminLevel','>',['0',$min]]));
}
public static function getAdminLowerThan($max){
return Membre::getFromAttributes(array(['adminLevel','<',['0',$max]]));
}
public static function me(){
if(!isset($_SESSION['session_id']))
return NULL;
$me = new Membre($_SESSION['session_id']);
if(!$me->exists())
return NULL;
return $me;
}
//Membre creator
public static function registerPerson($pseudo, $mdp) {
if (Membre::getFromPseudo($pseudo))
return Membre::USED_USERNAME;
$req = $GLOBALS ['bdd']->prepare ('INSERT INTO membres(pseudo,mdp,date_creation) VALUES (?,?,NOW())');
$req->execute (array($pseudo,password_hash( $mdp, PASSWORD_DEFAULT)));
return Membre::PERSON_REGISTERED;
}
//Operateurs
public function __is_identical($copain){
return $this->getID() == $copain->getID();
}
//Outputs texts
//changePassword
const PASSWORD_TOO_LONG = 'Le mot de passe est trop long ! (Max : 255 caract&egrave;res)';
const PASSWORD_CHANGED = 'Le mot de passe a bien &eacute;t&eacute; chang&eacute;';
//registerPerson
const USED_USERNAME = 'Le pseudonyme est d&eacute;j&agrave; utilis&eacute;';
const PERSON_REGISTERED = 'Le membre a bien &eacute;t&eacute; inscrit !';
}

385
clazz/Membre.class.php Normal file
View File

@ -0,0 +1,385 @@
<?php
class Membre {
const DEFAULT_BANNER = "pictures/bande.png";
protected $ID;
protected $pseudo;
protected $hashedPassword;
protected $adminLevel;
protected $dateCreation;
protected $requiredBanner;
protected $personnalMessage;
protected $connected;
protected $valid;
public function __construct($ID) {
$this->ID = $ID;
$this->connected = FALSE;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->pseudo = $rep['pseudo'];
$this->adminLevel = $rep['adminLevel'];
$this->dateCreation = $rep['dateCreation'];
$this->hashedPassword = $rep['hashedPassword'];
$this->decodeData($rep['data']);
}else{
$this->valid = FALSE;
}
}
public function connect($password) {
$this->connected = password_verify ($password, $this->hashedPassword );
return $this->connected;
}
public function __toString(){
$out = 'Membre\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tPseudo:' . $this->pseudo . '\n';
$out .= '\tAdmin level:' . $this->adminLevel . '\n';
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
$out .= '\tRequired banner:' . $this->requiredBanner . '\n';
$out .= '\tPersonnal message:' . $this->personnalMessage . '\n';
return $out;
}
public function isConnected(){
return $this->connected;
}
public function exists(){
return $this->valid;
}
private function decodeData($data) {
$jsonData = json_decode ( $data ,TRUE);
// Set the data's required_banner if it is defined , otherwise sets the DEFAULT_BANNER
$this->requiredBanner = $jsonData ['requiredBanner'] ?? self::DEFAULT_BANNER;
$this->personnalMessage = $jsonData ['personnalMessage'] ?? NULL;
}
//Getters
public function getID(){
return $this->ID;
}
public function getPseudo(){
return $this->pseudo;
}
public function getAdminLevel() {
return $this->adminLevel;
}
public function getDateCreation(){
return $this->dateCreation;
}
public function getRequiredBanner() {
return $this->requiredBanner;
}
public function getPersonnalMessage(){
return $this->personnalMessage;
}
//Useful getters
public function isAdminLevelLowerThan($max){
return $this->adminLevel<$max;
}
public function isAdminLevelGreaterThan($min){
return $this->adminLevel>$min;
}
public function isAdminLevelLowerOrEqualThan($max){
return $this->adminLevel<$max;
}
public function isAdminLevelGreaterOrEqualThan($min){
return $this->adminLevel>$max;
}
public function hasPersonnalMessage() {
return isset ( $this->personnalMessage );
}
public function showPersonnalMessage() {
$msg = $this->personnalMessage;
$this->setPersonnalMessage = NULL;
return $msg;
}
//Setters
public function changePassword($newPassword){
if(strlen($newPassword)>255)
return Membre::PASSWORD_TOO_LONG;
$req = $GLOBALS['bdd']->prepare('UPDATE membres SET hashedPassword=? WHERE ID=?');
$req->execute(array(password_hash ( $newPassword, PASSWORD_DEFAULT ),$this->ID));
return Membre::PASSWORD_CHANGED;
}
public function setAttribute($attribute,$value,$valueType){
$json=FALSE;
switch ($attribute){
case 'ID':
if($valueType !== '0'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($value);
break;
case 'pseudo':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'hashedPseudo':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'adminLevel':
if($valueType !== '0'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($value);
break;
case 'dateCreation':
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.$value.'"';
break;
case 'requiredBanner'://FIXME jsonMysqlProblem
$json=TRUE;
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
case 'personnalMessage':
$json=TRUE;
if($valueType !== '"'){
echo 'Error : the type "'.$valueType.'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($value).'"';
break;
default:
echo 'Undefined attribute "'.$attribute.'" for the class Membre';
exit;
}
$restrictionValues[] = $value;
if($json){
//TODO Set command for json
}else{
$command = 'UPDATE membres SET ' . $attribute . '=' . $value . ' WHERE ID=' . $this->ID;
}
echo $command.'</br>';
$req = $GLOBALS['bdd']->prepare($command);
$req->execute(array());
if($req->errorInfo()[0] != 0){
echo 'Eine MYSQL Exception hat geworft. Einschuldigung';
exit;
}
}
/**
*
* @return Objects which matchs the specified restrictions
*/
public static function getFromAttributes($restrictions){
$whereCommands = array();
$restrictionValues = array();
foreach ($restrictions as $restriction){
$whereCommand = NULL;
$attribute = $restriction[0];
$json = FALSE;
$operator = NULL;
$value = NULL;
try {
switch ($attribute){
case 'ID':
if($restriction[2][0] !== '0'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($restriction[2][1]);
$operator = Utility::getIntegerSqlOperator($restriction[1]);
break;
case 'pseudo':
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'hashedPseudo':
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'adminLevel':
if($restriction[2][0] !== '0'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = intval($restriction[2][1]);
$operator = Utility::getIntegerSqlOperator($restriction[1]);
break;
case 'dateCreation':
if($restriction[2][0] !== '"'){//TODO add type date
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.$restriction[2][1].'"';
$operator = Utility::getDateSqlOperator($restriction[1]);
break;
case 'requiredBanner'://FIXME jsonMysqlProblem
$json=TRUE;
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
case 'personnalMessage':
$json=TRUE;
if($restriction[2][0] !== '"'){
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
exit;
}
$value = '"'.strval($restriction[2][1]).'"';
$operator = Utility::getStringSqlOperator($restriction[1]);
break;
default:
echo 'Undefined attribute "'.$attribute.'" for the class Membre';
exit;
}
}catch(InvalidOperatorException $e){
echo $e->getMessage().' when reading attribute "'.$attribute.'"';
exit;
}
$restrictionValues[] = $value;
if($json){
$whereCommand = '((data->"$.'.$attribute.'" IS NOT NULL) AND (data->"$.'.$attribute.'" '.$operator.' ? ))';
}else{
$whereCommand = $attribute . ' ' . $operator . ' ' . $value;
}
$whereCommands[] = $whereCommand;
}
$wherePart = "";
if(count($whereCommands) >0)
$wherePart = 'WHERE '.implode(' AND ',$whereCommands);
$command = 'SELECT * FROM membres '.$wherePart;
$req = $GLOBALS['bdd']->prepare($command);
$req->execute($restrictionValues);
//echo $command.'</br>';
if($req->errorInfo()[0] != 0)
echo 'Erreur SQL, veuillez verifier les selecteurs';
$out = array();
while($rep = $req->fetch())
$out[] = new Membre($rep['ID']);
//Choose return value
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getFromPseudo($pseudo){
return Membre::getFromAttributes(array(['pseudo','=',['"',$pseudo]]));
}
public static function getFromAdminLevel($level){
return Membre::getFromAttributes(array(['adminLevel','=',['0',$level]]));
}
public static function getFromDateCreation($date){
return Membre::getFromAttributes(array(['dateCreation','=',['0',$date]]));
}
public static function getCreatedLaterThan($date){
return Membre::getFromAttributes(array(['dateCreation','>',['"',$date]]));
}
public static function getCreatedEarlierThan($date){
return Membre::getFromAttributes(array(['dateCreation','<',['"',$date]]));
}
public static function getAdminGreaterThan($min){
return Membre::getFromAttributes(array(['adminLevel','>',['0',$min]]));
}
public static function getAdminLowerThan($max){
return Membre::getFromAttributes(array(['adminLevel','<',['0',$max]]));
}
public static function me(){
if(!isset($_SESSION['session_id']))
return NULL;
$me = new Membre($_SESSION['session_id']);
if(!$me->exists())
return NULL;
return $me;
}
//Membre creator
public static function registerPerson($pseudo, $mdp) {
if (Membre::getFromPseudo($pseudo))
return Membre::USED_USERNAME;
$req = $GLOBALS ['bdd']->prepare ('INSERT INTO membres(pseudo,mdp,date_creation) VALUES (?,?,NOW())');
$req->execute (array($pseudo,password_hash( $mdp, PASSWORD_DEFAULT)));
return Membre::PERSON_REGISTERED;
}
//Operateurs
public function __is_identical($copain){
return $this->getID() == $copain->getID();
}
//Outputs texts
//changePassword
const PASSWORD_TOO_LONG = 'Le mot de passe est trop long ! (Max : 255 caract&egrave;res)';
const PASSWORD_CHANGED = 'Le mot de passe a bien &eacute;t&eacute; chang&eacute;';
//registerPerson
const USED_USERNAME = 'Le pseudonyme est d&eacute;j&agrave; utilis&eacute;';
const PERSON_REGISTERED = 'Le membre a bien &eacute;t&eacute; inscrit !';
}

143
clazz/Message.class.php Normal file
View File

@ -0,0 +1,143 @@
<?php
class Message{
protected $ID;
protected $sender;
protected $sendDate;
protected $text;
protected $discussion;
protected $valid;
public function __construct($ID){
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->sender = new Membre($rep['senderID']);
$this->sendDate = $rep['sendTime'];
$this->text = $rep['texte'];
$this->discussion = new Discussion($rep['discussionID']);
}else{
$this->valid = FALSE;
}
}
public function exists(){
return $this->valid;
}
public function __toString(){
$out = 'Message\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tSender:{' . substr(str_replace('\n\t',';',$this->sender->__toString()),0,-1) . '}\n';
$out .= '\tSend date:' . $this->sendDate . '\n';
$out .= '\tText:' . $this->text . '}\n';
$out .= '\tDiscussion:' . substr(str_replace('\n\t',';',$this->discussion->__toString()),0,-1) . '\n';
return out;
}
//Getters
public function getID(){
return $this->ID;
}
public function getSender(){
return $this->sender;
}
public function getSendDate(){
return $this->sendDate;
}
public function getText(){
return $this->text;
}
public function getDiscussion(){
return $this->discussion;
}
//Useful getters
public function canEdit($person){
return $person->isAdminLevelGreaterOrEqualThan(6) || $person->getID() == $this->sender->getID();
}
//Setters
public function editText($newText){
$this->text = htmlSepcialChars($newText);
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
$req->execute (array ($this->discussion->getID(),$this->text,$this->sender->getID()));
}
//Message getter
private static function messagesGetterOutput($req){
$out = array();
while($rep = $req->fetch())
$out[] = new Message($rep['ID']);
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getFromSender($param) {
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE senderID=?');
$req->execute(array($sender->getID()));
return Message::messagesGetterOutput($req);
}
public static function getFromSendDate($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate=?');
$req->execute(array($date));
return Message::messagesGetterOutput($req);
}
public static function getSendedLaterThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate>?');
$req->execute(array($date));
return Message::messagesGetterOutput($req);
}
public static function getSendedEarlierThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate<?');
$req->execute(array($date));
return Message::messagesGetterOutput($req);
}
public static function getFromText($text) {
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE text=?');
$req->execute(array($text));
return Message::messagesGetterOutput($req);
}
public static function getFromDiscussion($discut){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE discussionID=?');
$req->execute(array($discut->getID()));
return Message::messagesGetterOutput($req);
}
//Message creator
public static function sendMessage($sender,$discussion,$text){
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussionID,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
$req->execute (array($discussion->getID(),htmlspecialchars ($text),$sender->getID()));
}
public function removeMessage(){
$req = $GLOBALS ['bdd']->prepare ( 'DELETE FROM messages WHERE ID=?' );
$req->execute (array($this->getID()));
}
}

251
clazz/Projet.class.php Normal file
View File

@ -0,0 +1,251 @@
<?php
class Projet{
protected $ID;
protected $name;
protected $dateCreation;
protected $owner;
protected $secondaryOwners;
protected $publik;
protected $valid;
public function __construct($ID){
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->name = $rep['name'];
$this->owner = new Membre($rep['ownerID']);
$this->dateCreation = $rep['dateCreation'];
$this->secondaryOwners = array();
foreach (($rep['secondaryOwnersID']!="")?explode(';',$rep['secondaryOwnersID']):[] AS $secondaryOwner)
$this->secondaryOwners[] = new Membre($secondaryOwner);
$this->publik = $rep['public'];
}else{
$this->valid = FALSE;
}
}
public function exists(){
return $this->valid;
}
public function __toString(){
$out = 'Projet\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tName:' . $this->name . '\n';
$out .= '\tOwner:{' . substr(str_replace('\n\t',';',$this->owner->__toString()),0,-1) . '}\n';
foreach($this->secondaryOwners AS $secondaryOwner)
$out .= '\tSecondary owner:{' . substr(str_replace('\n\t',';',$secondaryOwner->__toString()),0,-1) . '}\n';
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
$out .= '\tPublic:' . $this->publik == "1" . '\n';
return $out;
}
//Getters
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getOwner(){
return $this->owner;
}
public function getSecondaryOwners(){
return $this->secondaryOwners;
}
public function getDateCreation(){
return $this->dateCreation;
}
public function isPublic(){
return $this->publik;
}
//Useful getters
public function haveRights($member){
return $member->getID() == $this->owner->getID() or in_array($member,$this->secondaryOwners);
}
//Setters
public function setSecondaryOwners($secondaryOwners){
$this->secondaryOwners = $secondaryOwners;
$secondaryOwnersID = array();
foreach($secondaryOwners as $secondaryOwner)$secondaryOwnersID[] = $secondaryOwner->getID();
$req = $GLOBALS['bdd']->prepare('UPDATE projets SET secondaryOwnersID=? WHERE ID=?');
$req->execute(array(implode(';',$secondaryOwnersID),$this->getID()));
}
public function setPublicy($publicy){
$this->publik = $publicy;
$req = $GLOBALS['bdd']->prepare('UPDATE projets SET public=? WHERE ID=?');
$req->execute(array($publicy?1:0,$this->getID()));
}
public function setOwner($nOwner){
$this->owner = $nOwner;
$req = $GLOBALS['bdd']->prepare('UPDATE projets SET ownerID=? WHERE ID=?');
$req->execute(array($nOwner->getID(),$this->getID()));
}
public function addSecondaryOwner($secondaryOwner){
$this->secondaryOwners[] = $secondaryOwner;
$this->setSecondaryOwners($this->secondaryOwners);
}
public function delSecondaryOwner($secondaryOwner){
$this->secondaryOwners = array_diff($this->secondaryOwners,array($secondaryOwner));
$this->setSecondaryOwners($this->secondaryOwners);
}
//Project getters
private static function projectGetterOutput($req){
$out = array();
while($rep = $req->fetch())
$out[] = new Projet($rep['ID']);
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getFromName($name){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE name=?');
$req->execute(array($name));
return projectGetterOutput($req);
}
public static function getFromOwner($owner){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE owner=?');
$req->execute(array($owner->getID()));
return projectGetterOutput($req);
}
public static function getFromSecondaryOwner($secondaryOwner){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
$req->execute();
$out = array();
while ($rep = $req->fetch()) {
$projet = new Projet($rep['ID']);
if ($projet->haveRights($secondaryOwner))
$out[] = $projet;
}
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getFromDateCreation($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation=?');
$req->execute(array($date));
return projectGetterOutput($req);
}
public static function getCreatedLaterThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE dateCreation>?');
$req->execute(array($date));
return projectGetterOutput($req);
}
public static function getCreatedEarlierThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE dateCreation<?');
$req->execute(array($date));
return projectGetterOutput($req);
}
public static function getWhichHeCanAccess($he){
//TODO Faire la selection directement gràce à une reqete SQL
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
$req->execute(array());
$out = array();
while ( $rep = $req->fetch()) {
$projet = new Projet($rep['ID']);
if ($projet->haveRights($he))
$out[] = $projet;
}
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getOthers($he){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
$req->execute(array());
$out = array();
while ( $rep = $req->fetch()) {
$projet = new Projet($rep['ID']);
if ($he?$he->isAdminLevelGreaterThan(12):FALSE || $projet->isPublic() == '1')
$out[] = $projet;
}
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public function delete(){
$req = $GLOBALS['bdd']->prepare('DELETE FROM projets WHERE ID=?');
$req->execute(array($this->getID()));
$this->valid = FALSE;
}
public function newVersion($name,$langage,$tags,$insertIndex){
if(Version::getFromProjectAndName($this, $name))
return USED_NAME;
if(!preg_match("#^[a-zA-Z0-9\\-_+ ]+$#", $name ))
return INVALID_NAME;
if(Version::getFromProjectLanguageAndVersionAbs($this,$langage, $insertIndex))
return USED_INDEX;
$req = $GLOBALS['bdd']->prepare('INSERT INTO versions (name,sendDate,publicFiles,tags,projectID,languageID,versionAbs) VALUES (?,NOW(),"",?,?,?,?)');
$req->execute(array($name,$tags,$this->getID(),$langage->getID(),$insertIndex));
return VERSION_CREATED;
}
public function editVersion($versionToEdit,$name,$langage,$tags,$insertIndex){
$namedVersion = Version::getFromProjectAndName($this, $name);
if(($namedVersion)?$namedVersion->getID() != $versionToEdit->getID():FALSE)
return USED_NAME;
if(!preg_match("#^[a-zA-Z0-9\\-_+ ]+$#", $name ))
return INVALID_NAME;
$versionedVersion = Version::getFromProjectLanguageAndVersionAbs($this,$langage, $insertIndex);
if(($versionedVersion)?$versionedVersion->getID() != $versionToEdit->getID():FALSE)
return USED_INDEX;
$req = $GLOBALS['bdd']->prepare('UPDATE versions SET name=?,tags=?,languageID=?,versionAbs=? WHERE ID=?');
$req->execute(array($name,$tags,$langage->getID(),$insertIndex,$versionToEdit->getID()));
return VERSION_EDITED;
}
const INVALID_NAME = "sfygmal";
const USED_NAME = "cflmfyqsdlm";
const USED_INDEX = "jhmvm";
const VERSION_CREATED = "jzbtdbgv";
const VERSION_EDITED = "jzbqgsderftdbgv";
}

139
clazz/Utility.class.php Normal file
View File

@ -0,0 +1,139 @@
<?php
class InvalidOperatorException extends Exception{
public $type;
public $operator;
public function __construct ($type,$operator){
parent::__construct('Invalid operator "'.$operator.'" for the type '.$type);
}
}
class Utility{
public static const PasswordMissmatch = 'Tu auras du rentrer deux fois le m&ecirc;me mot de passe (tu permet aussi de rendre le champs "Recopier le mot de passe" utile)';
public static const InvalidPseudo = 'Le pseudo sera incorrect : Les seuls caract&egrave;res autoris&eacute;s sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
public static const InvalidPassword = 'Le mot de passe fut incorrect : Les seuls caract&egrave;res autoris&eacute;s sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&&eacute;&egrave;&agrave;&ugrave;&ccedil;&mu;"#\'{}()[]|^@<40>+=$<24><>*!<21>:/;.,?<3F>'
public static function isPseudoValid($pseudo){
return preg_match ( "#^[a-zA-Z0-9\\-_]+$#", $pseudo ) === 1;
}
public static function isPasswordValid($password){
return preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&<26><><EFBFBD><EFBFBD><EFBFBD>\"\\#'{}()[\\]|\\^@<40>+=\$<EFBFBD><EFBFBD>*!<21>:/;.,?<3F>]+$#", $password ) === 1;
}
/*
* <> ou !=
...les deux valeurs ne sont pas égales
<
...la valeur de gauche est strictement inférieure à celle de droite
>
...la valeur de gauche est strictement supérieure à celle de droite
<=
...la valeur de gauche est strictement inférieure ou égale à celle de droite
>=
...la valeur de gauche est strictement supérieure ou égale à celle de droite
BETWEEN..AND
...la valeur testée est située entre deux valeurs données
IN
...la valeur testée se situe dans une liste valeurs données
NOT IN
...la valeur testée ne se situe pas dans une liste de valeurs données
LIKE
...la valeur de gauche correspond à celle de droite (celle de droite peux utiliser le caractère % pour simuler n'importe quel nombre de caractère, et _ pour un seul caractère
NOT LIKE
...les deux valeurs ne correspondent pas
REGEXP ou RLIKE
...la valeur de gauche correspond à l'expression régulière donnée
NOT REGEXP
...la valeur de gauche ne correspond pas à l'expression régulière donnée
*/
public static function getIntegerSqlOperator($operator){
switch ($operator){
case '=':
return '=';
case '<':
return '<';
case '>':
return '>';
case '<=':
return '<=';
case '>=':
return '>=';
case '=<':
return '<=';
case '<>':
return '<>';
case '!=':
return '!=';
case '!<':
return '!<';
case '!>':
return '!>';
default:
throw new InvalidOperatorException('integer',$operator);
}
}
public static function getStringSqlOperator($operator){
switch ($operator){
case '=':
return '=';
case '&like;':
return 'LIKE';
default:
throw new InvalidOperatorException('string',$operator);
}
}
public static function getDateSqlOperator($operator){
switch ($operator){
case '=':
return '=';
case '<':
return '<';
case '>':
return '>';
case '<=':
return '<=';
case '>=':
return '>=';
case '=<':
return '<=';
case '<>':
return '<>';
case '!=':
return '!=';
case '!<':
return '!<';
case '!>':
return '!>';
default:
throw new InvalidOperatorException('date',$operator);
}
}
public static function arrayIfNot($var){
if(!is_array($var))
return $var!=NULL?array($var):NULL;
return $var;
}
public static function getHierarchicCouple(){
return array("Pr&eacute;sident","Ministres");
}
}

346
clazz/Version.class.php Normal file
View File

@ -0,0 +1,346 @@
<?php
class Version{
protected $ID;
protected $name;
protected $sendDate;
protected $publicFiles;//String "jar xlsx javadoc" in bdd , stored as a string array
protected $tags;//String "beta bugged" in bdd , stored as a string array
protected $project;
protected $language;
protected $versionAbs;
public function __construct($ID){
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->name = $rep['name'];
$this->sendDate = $rep['sendDate'];
$this->publicFiles = explode(" ",$rep['publicFiles']);
$this->tags = explode(" ",$rep['tags']);
$this->project = new Projet($rep['projectID']);
$this->language = Langage::getFromID(intval($rep['languageID']));
$this->versionAbs = $rep['versionAbs'];
}else{
$this->valid = FALSE;
}
}
public function exists(){
return $this->valid;
}
public function __toString(){
try{
$out = 'Version\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tName:{' . $this->name . '}\n';
$out .= '\tSend date:' . $this->sendDate . '\n';
$out .= '\tPublic files:"' . implode(' ',$this->publicFiles) . '"}\n';
$out .= '\tTags:"' . implode(' ',$this->tags) . '"}\n';
$out .= '\tProject:' . substr(str_replace('\n\t',';',$this->project->__toString()),0,-1) . '\n';
$out .= '\tLanguage:' . $this->language->getName() . '\n';
$out .= '\tVersion absolue:' . $this->versionAbs . '\n';
return $out;
}catch(Error $e){
echo '#' . $this->language . "#";
return $e->__toString();
}
}
//Getters
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getSendDate(){
return $this->sendDate;
}
public function getPublicFiles(){
//returns a string array
return $this->publicFiles;
}
public function getTags(){
//returns a string array
return $this->tags;
}
public function getProject(){
return $this->project;
}
public function getLanguage(){
return $this->language;
}
public function getVersionAbs(){
return $this->versionAbs;
}
//Useful Getters
//TODO make all of the following 'is' functions using haveTag
public function haveTag($tag){
return in_array($tag,$this->tags);
}
public function isJarPublic(){
return in_array("jar",$this->publicFiles);
}
public function isJavaPublic(){
return in_array("java",$this->publicFiles);
}
public function isJavadocPublic(){
return in_array("javadoc",$this->publicFiles);
}
public function isXlsmPublic(){
return in_array("xlsm",$this->publicFiles);
}
public function isVbPublic(){
return in_array("vb",$this->publicFiles);
}
public function isAlpha(){
return in_array("alpha",$this->tags);
}
public function isBeta(){
return in_array("beta",$this->tags);
}
public function isRelease(){
return in_array("release",$this->tags);
}
public function isTest(){
return in_array("test",$this->tags);
}
public function isBugged(){
return in_array("bugged",$this->tags);
}
//Setters
public function storeTags(){
$rep = $GLOBALS['bdd']->prepare('UPDATE versions SET tags=? WHERE ID=?');
$rep->execute(array(implode(' ',$this->tags),$this->ID));
}
public function addTag($tag,$store = TRUE){
$this->deleteTag($tag,FALSE);
$this->tags[] = $tag;
if($store)$this->storeTags();
}
public function deleteTag($tag,$store = TRUE){
$this->tags = array_diff($this->tags,array($tag));
if($store)$this->storeTags();
}
public function setARelease(){
$this->deleteTag('alpha',FALSE);
$this->deleteTag('beta',FALSE);
$this->addTag('release',FALSE);
$this->storeTags();
}
public function setAnAlpha(){
$this->deleteTag('beta',FALSE);
$this->deleteTag('release',FALSE);
$this->addTag('alpha',FALSE);
$this->storeTags();
}
public function setABeta(){
$this->deleteTag('alpha',FALSE);
$this->deleteTag('release',FALSE);
$this->addTag('beta',FALSE);
$this->storeTags();
}
public function setATest(){
$this->addTag('test');
}
public function setNotATest(){
$this->delTag('test');
}
public function setBugged(){
$this->addTag('bugged');
}
public function setNotBugged(){
$this->delTag('bugged');
}
public function storePublicFiles(){
$rep = $GLOBALS['bdd']->prepare('UPDATE versions SET publicFiles=? WHERE ID=?');
$rep->execute(array(implode(' ',$this->publicFiles),$this->ID));
}
public function addPublicFile($file,$store = TRUE){
$this->deletePublicFile($file,FALSE);
$this->publicFiles[] = $file;
if($store)$this->storePublicFiles();
}
public function deletePublicFile($file,$store = TRUE){
$this->publicFiles = array_diff($this->publicFiles,array($file));
if($store)$this->storePublicFiles();
}
public function setJarPublic(){
$this->addPublicFile('jar');
}
public function setJarNotPublic(){
$this->deletePublicFile('jar');
}
public function setJavaPublic(){
$this->addPublicFile('java');
}
public function setJavaNotPublic(){
$this->deletePublicFile('java');
}
public function setJavadocPublic(){
$this->addPublicFile('javadoc');
}
public function setJavadocNotPublic(){
$this->deletePublicFile('javadoc');
}
public function setXlsmPublic(){
$this->addPublicFile('xlsm');
}
public function setXlsmNotPublic(){
$this->deletePublicFile('xlsm');
}
public function setVbPublic(){
$this->addPublicFile('vb');
}
public function setVbNotPublic(){
$this->deletePublicFile('vb');
}
//Version Getter
private static function versionGetterOutput($req){
$out = array();
while($rep = $req->fetch())
$out[] = new Version($rep['ID']);
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
}
public static function getFromProjectAndName($project,$name){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE projectID=? AND name=?');
$req->execute(array($project->getID(),$name));
return Version::versionGetterOutput($req);
}
public static function getFromProjectLanguageAndVersionAbs($project,$language,$versionAbs){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE projectID=? AND languageID=? AND versionAbs=?');
$req->execute(array($project->getID(),$language->getID(),$versionAbs));
return Version::versionGetterOutput($req);
}
public static function getFromLanguage($language){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE languageID=?');
$req->execute(array($language->getID()));
return Version::versionGetterOutput($req);
}
public static function getFromProject($project){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE projectID=?');
$req->execute(array($project->getID()));
return Version::versionGetterOutput($req);
}
public static function getHighestFromProject($project){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE projectID=? and versionAbs=(SELECT MAX(versionAbs) FROM versions WHERE projectID=?)');
$req->execute(array($project->getID(),$project->getID()));
return Version::versionGetterOutput($req);
}
public static function getFromName($name){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE name=?');
$req->execute(array($name));
return Version::versionGetterOutput($req);
}
public static function getFromTag($tag){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions');
$req->execute();
$out = array();
while ($rep = $req->fetch()) {
$projet = new Version($rep['ID']);
if ($projet->haveTag($tag))
$out[] = $projet;
}
switch(count($out)){
case 0:
return NULL;
case 1:
return $out[0];
default:
return $out;
}
return Version::versionGetterOutput($req);
}
public static function getFromSendDate($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate=?');
$req->execute(array($date));
return Version::versionGetterOutput($req);
}
public static function getSendedLaterThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate>?');
$req->execute(array($date));
return Version::versionGetterOutput($req);
}
public static function getSendedEarlierThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate<?');
$req->execute(array($date));
return Version::versionGetterOutput($req);
}
public function delete(){
$req = $GLOBALS['bdd']->prepare('DELETE FROM versions WHERE ID=?');
$req->execute(array($this->getID()));
$this->valid = FALSE;
}
}

21
clazz/Zincluder.php Normal file
View File

@ -0,0 +1,21 @@
<?php
try{
//$GLOBALS['bdd'] = new PDO('mysql:host=127.0.0.1;dbname=u890869027_bcom;charset=utf8;port=3306', 'u890869027', '*******************', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));error_reporting(E_ALL);
$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************',array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));error_reporting(E_ALL);
//$GLOBALS['bdd'] = new PDO('mysql:host=fdb6.awardspace.net;port=3306;dbname=2516148_bcom;charset=utf8', '2516148_bcom', '*******************');
}catch(Exception $e){
die ('Erreur : ' . $e->getMessage());
}
//TODO in the classes , do more test of exists in setters
include_once 'clazz/2/SQLProcessingException.class.php';
include_once 'clazz/2/Utility.class.php';
include_once 'clazz/2/Langage.class.php';
include_once 'clazz/2/Membre.class.php';
include_once 'clazz/2/Discussion.class.php';
include_once 'clazz/2/Message.class.php';
include_once 'clazz/2/Projet.class.php';
include_once 'clazz/2/Article.class.php';
//TODO Use class's consts for file names
include_once 'clazz/2/Version.class.php';

19
clazz/Zincluder_old.php Normal file
View File

@ -0,0 +1,19 @@
<?php
try{
$GLOBALS['bdd'] = new PDO('mysql:host=localhost;dbname=u890869027_bcom2;charset=utf8', 'u890869027', '*******************', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));error_reporting(E_ALL);
//$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************');
}catch(Exception $e){
die ('Erreur : ' . $e->getMessage());
}
//TODO in the classes , do more test of exists in setters
include_once 'clazz/Utility.class.php';
include_once 'clazz/Langage.class.php';
include_once 'clazz/Membre.class.php';
include_once 'clazz/Discussion.class.php';
include_once 'clazz/Message.class.php';
include_once 'clazz/Projet.class.php';
include_once 'clazz/Article.class.php';
//TODO Use class's consts for file names
include_once 'clazz/Version.class.php';

29
css/adminStyle.css Normal file
View File

@ -0,0 +1,29 @@
#adminDialogAnswer{
border-top: 2px solid black;
display: block;
padding: 5px;
}
section.reponce{
border: 1px solid black;
}
section.reponce > h3{
margin-top: 5px;
margin-bottom: 8px;
}
section.reponce > samp{
background-color: #111;
color: #0F0;
}
section.commander{
border: 3px double black;
padding: 3px;
}
div.commander{
padding: 2px;
}
section.commander > .commanderCommandSelector{
border-bottom: 1px solid black;
}
.facultatif{
border-bottom: 1px dotted silver;
}

4
css/firefoxStyle.css Normal file
View File

@ -0,0 +1,4 @@
*::-moz-selection {
background-color: rgb(100, 200, 40);
color: #222;
}

4
css/noFirefoxStyle.css Normal file
View File

@ -0,0 +1,4 @@
*::selection {
background-color: rgb(100, 200, 40);
color: #222;
}

View File

@ -1,224 +1,370 @@
/* General */ /* General */
#postMessageForm textarea,#editMessageForm textarea{
background-color:#292828;
resize: none;
width:95%;
color:#5dd528;
text-align: center;
}
.fullscreen{
position:fixed;
top:0;
right:0;
width:100%;
height:100%;
vertical-align:middle;
}
.big-background-semi-opaque{
background-color: rgba(34,34,34,0.75);
}
.big-background-opaque{
background-color: rgba(34,34,34,1);
}
.opaque{
opacity: 1;
}
.absent {
display:none;
}
.screen-vertical-centered{
text-align:center;
margin-top: 50vh;
transform: translateY(-50%);
}
.full-text{
font-size:42px;
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
ul.gone-puce{
margin: 0 auto;
padding:0;
list-style-type: none;
}
.gray-bordered{
border: 3px #999 outset;
}
.fast-full-width{
width:90%;
margin-left: auto;
margin-right: auto;
}
.screen-horizontal-centered{
display:inline;
opacity:1;
}
ul li.selected{
background-color: rgba(100, 200, 40,1);
color: #222;
}
li.potentialPos{
border: 1px rgb(100, 200, 40) dashed;
}
.redMessage{
background-color: red;
color: yellow;
}
.bigText{
position: absolute;
top:0;
right:0;
background-color: #DDD;
color: rgb(155,55,215);
height : 100%;
width : 100%;
text-align : center;
}
a { a {
background-color: #222; color: rgb(100, 200, 40);
color: rgb(100, 200, 40);
text-align: center;
} }
body{ body {
background-color: #222; background-color: #222;
color: rgb(100, 200, 40); color: rgb(100, 200, 40);
text-align: center; text-align : center;
} }
body::selection, br::selection { article{
background-color: rgb(100, 200, 40); margin: 20px;
color: #222; padding: 5px;
border: 3px #999 outset;
text-align: center;
}
.articlePic{
text-align: left;
border: px rgb(100, 200, 40) outset;
margin: 20px;
}
.articleTitle{
float: center;
text-decoration:underline;
}
.articleText{
text-align: left;
margin: 5%;
} }
article { h1 {
margin: 20px; text-decoration:underline;
padding: 5px;
border: 3px #999 outset;
} }
header { header {
background-color: #222; color: rgb(100, 200, 40);
color: rgb(100, 200, 40); margin: 0px;
margin: 0px; padding: 10px;
padding: 10px; border-bottom: 3px rgb(100, 200, 40) solid;
border-bottom: 3px rgb(100, 200, 40) solid; text-align: center;
text-align: center;
} }
header a { header a {
color: rgb(100, 200, 40); color: rgb(100, 200, 40);
}
nav {
text-align: center;
} }
#navLinks a { #navLinks a {
color: rgb(100, 200, 40); color: rgb(100, 200, 40);
padding-left: 70px; padding-left: 30px;
padding-right: 70px; padding-right: 30px;
background-color: #222; font-size: 4ex;
font-size: 4ex; border: 3px rgb(100, 200, 40) outset;
border: 3px rgb(100, 200, 40) outset; border-collapse: collapse;
border-collapse: collapse; text-decoration: none;
text-decoration: none;
} }
footer { footer {
border-top: 10px rgb(100, 200, 40) double; border-top: 10px rgb(100, 200, 40) double;
background-color: #222; text-align: center;
text-align: center; height: 250px
height: 250px
} }
#bienvenue { #bienvenue {
border-bottom: 3px rgb(100, 200, 40) solid; border-bottom: 3px rgb(100, 200, 40) solid;
font-size: 20px; font-size: 20px;
} }
#bande { #bande {
display: block; display: block;
padding-bottom: 5px; padding-bottom: 0px;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
padding-top: 5px;
} }
#copyright { #copyright {
float: left; float: left;
color: rgb(100, 200, 40); color: rgb(100, 200, 40);
} }
#me_contacter { #nous_contacter {
float: right; float: right;
color: rgb(100, 200, 40); color: rgb(100, 200, 40);
} }
a #haut_de_page { a #haut_de_page {
background-color: rgb(100, 200, 40); background-color: rgb(100, 200, 40);
color: #222; color: #222;
position: relative; position: relative;
top: 10px; top: 10px;
padding: 10px; padding: 10px;
} }
/* 404 */ /* 404 */
#universe_text{ #universe_text {
word-wrap: break-word; word-wrap: break-word;
} }
#add_universe{
#add_universe {
text-align: center; text-align: center;
margin : 50px auto; margin: 15px auto;
border: 5px solid rgb(100, 200, 40); border: 5px solid rgb(100, 200, 40);
background-color: #222;
} }
/* Login & Register */ /* Login & Register */
#loginForm { #loginForm {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
margin-bottom: 100px; margin-bottom: 100px;
margin-top: 100px; margin-top: 100px;
} }
#headDisconnectForm { #headDisconnectForm {
display: inline; display: inline;
} }
#disconnectText, #passwordChangedText { #disconnectText, #passwordChangedText {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
margin-bottom: 100px; margin-bottom: 100px;
margin-top: 20px; margin-top: 20px;
font-size: 30px; font-size: 30px;
} }
#headLoginForm { #headLoginForm {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
margin-bottom: 0px; margin-bottom: 0px;
margin-top: 0px; margin-top: 0px;
display: inline; display: inline;
}
#headLittleLoginForm {
margin-left: auto;
margin-right: auto;
margin-bottom: 0px;
margin-top: 0px;
display: none;
} }
#headRegisterForm { #headRegisterForm {
display: inline; display: inline;
} }
#registerForm, #changePasswordForm{ #registerForm, #changePasswordForm {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
margin-bottom: 100px; margin-bottom: 100px;
margin-top: 20px; margin-top: 20px;
} }
/* Projet/Versions */ /* Projet/Versions */
.project_option_img { .project_option_img {
display: inline; display: inline;
} }
.disabeled{ .disabeled {
opacity : 0.2; opacity: 0.2;
} }
.project_option { .project_option {
color:#222;
} }
.versionTable { .versionTable {
margin-left: auto; display: inline;
margin-right: auto; border-collapse: collapse;
margin-bottom: 50px;
margin-top: 0px;
border-collapse: collapse;
} }
td, th { td, th {
background-color: #222; color: rgb(100, 200, 40);
color: rgb(100, 200, 40); text-align: center;
text-align: center; border: 1px solid black;
border: 1px solid black; }
/* Forum */
#createNewDiscForm{
display: none;
}
section.message {
padding-left: 5px;
padding-right: 5px;
padding-top: 5px;
padding-bottom: 10px;
margin-top: 5px;
margin-bottom: 5px;
margin-left: auto;
margin-right: auto;
border: 1px solid rgb(100, 200, 40);
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
section.message div {
padding-left: auto;
padding-right: auto;
padding-top: 10px;
text-align: right;
}
samp#universe_text{
text-align: justify;
} }
/* Disposition with width */
/* HEADER STYLE */
.nav2x2{ .nav3x2 {
display:none; display: none;
} }
.navV{ #navLinks a {
display:none; display: inline-block;
width: 250px;
font-size: 3ex;
padding-left: 30px;
padding-right: 30px;
margin-top: 5px;
} }
@media screen and (max-width: 1050px){ /* Cacher bandeau */ .navV {
#bande{ display: none;
display:none; }
@media screen and (max-width: 1050px) { /* Cacher bandeau */
#bande {
display: none;
} }
} }
@media screen and (max-width: 705px){ /* Cacher login/register */ @media screen and (max-width: 705px) { /* Cacher login/register */
#headLoginForm , #headRegisterForm{ #headLoginForm {
display:none; display: none;
}
#headLittleLoginForm {
display: inline
}
#headLittleLoginForm {
display: inline;
} }
} }
@media screen and (max-width: 1180px){ /* Afficher nav2x2 */ @media screen and (max-width: 1180px) { /* Afficher nav3x2 */
.nav2x2{ .nav2x3 {
display:inline; display: inline;
}
}
@media screen and (max-width: 400px) { /* Afficher navV */
.navV {
display: inline;
} }
#navLinks a { #navLinks a {
display: inline-block; display: inline-block;
width : 250px; width: 200px;
font-size: 3ex;
padding-left: 30px;
padding-right: 30px;
margin-top: 5px;
}
}
@media screen and (max-width: 615px){ /* Afficher navV */
.navV{
display:inline;
}
#navLinks a {
display: inline-block;
width:200px;
font-size: 2ex; font-size: 2ex;
padding-left: 30px;
padding-right: 30px;
} }
} }

View File

@ -1,21 +0,0 @@
<?php session_start();
$_SESSION = array(); ?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php
include 'includes/head.php';
?>
<div id="disconnectText">Vous avez été correctement déconnécté !</div>
<?php
include 'includes/foot.php'
?>
</body>
</html>

158
discut.php Normal file
View File

@ -0,0 +1,158 @@
<?php
session_start();
include_once 'clazz/Zincluder.php';
try{
$discut = Discussion::getDiscutInfo($_SESSION['session_id'] ?? NULL,$_SESSION['session_mdp'] ?? NULL,$_GET['d'] ?? NULL);
}catch(SQLProcessingException $e){
error_log($e);
echo $e->getHtmlMessage();
$_SESSION ['current_error'] = $e->getHtmlMessage();
header ( 'Location:' . $e->getPreferredRedirection() ?? 'discuts.php' );
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<script type="text/javascript" src="includes/he.js"></script>
<?php include 'includes/header.php'; ?>
<?php
if ($discut['connected']) {?>
<form id="postMessageForm" action="executor.php?action=postMessage&amp;d=<?php echo $_GET['d'];?>" method="post">
<textarea row="5" placeholder="Votre message :" name="msg" autofocus="autofocus" required="required"></textarea>
<input type="submit" value="Poster le message">
</form>
<!-- TODO : Entrée->envoyer le message (dégeulasse) -->
<script type="text/javascript">
function genListener(){
//Entrée -> envoi
$('#postMessageForm textarea').on('keypress',function(e){
if(e.which == 13){
$('#postMessageForm input').trigger('click');
e.stopPropagation();
}
});
}
</script>
<?php }else{ ?>
<div>Vous devez vous connecter pour envoyer des messages !</div>
<?php } ?>
<!-- Dans cette balise, le contenu de la discussion géré en javascript -->
<main></main>
<script type="text/javascript" defer>
function reloadEditListeners(){
$('.editLink').on('click',function(e){
editingLink = e.target;
e.target.innerHTML = 'Edition';
$('#editMessageFullScreen').css('display','block');
$('#editMessageFullScreen div div form').attr('action','editing_message.php?d='+$(e.target).data('messageID'));
$('#editMessageFullScreen').animate({opacity:0.97},1000);
e.stopPropagation();
});
$('.delLink').on('click',function(e){
e.target.innerHTML = 'Supression';
window.clearTimeout(currentClock);
$.post('executor.php?action=deleteMessage&m='+$(e.target).data('messageID'),{},askData);
e.stopPropagation();
});
$('#abortEdition').on('click',function(e){
editingLink.innerHTML = 'Editer';
$('#editMessageFullScreen div div form').attr('action','js_waiting');
$('#editMessageFullScreen').animate({opacity:0.00},1000,function(e){
$('#editMessageFullScreen').css('display','none');
});
});
}
</script>
<!-- Messages download -->
<script type="text/javascript">
var currentClock = null;
var askData = function(){
console.log('dataasked<?php echo $discut['ID'];?>');
$.post('executor.php?action=getDiscutsMessages&did=<?php echo $discut['ID'];?>',{},dataGet);
}
var dataGet = function(data,status){
var newData = eval(data);
newData = newData.sort(function(a,b){return b.sendTimestamp-a.sendTimestamp;});
var messageGlobal = document.createElement('main');
for(messagePos in newData){
var message = newData[messagePos];
//console.log(message);
var section = document.createElement('section');
section.className = 'message';
var messageText = document.createTextNode(he.decode(message.texte).replace(/\n/g, "<br />"));
section.appendChild(messageText);
section.appendChild(document.createElement('br'));
var messageData = document.createElement('div');
var pseudoText = document.createTextNode(message.pseudo);
var pseudoTimeSeparator = document.createTextNode(' ');//Quatre espaces
var time = document.createElement('time');
var sendTimeText = document.createTextNode(message.sendTime);
time.appendChild(sendTimeText);
messageData.appendChild(pseudoText);
messageData.appendChild(pseudoTimeSeparator);
messageData.appendChild(time);
section.appendChild(messageData);
if(message.rights){
var editPane = document.createElement('nav');
editPane.className = 'editPaneMessages';
var editLink = document.createElement('a');
editLink.className = 'editLink';
$(editLink).data('messageID',message.messageID);
editLink.appendChild(document.createTextNode('Editer'));
var delLink = document.createElement('a');
delLink.className = 'delLink';
$(delLink).data('messageID',message.messageID);
delLink.appendChild(document.createTextNode('Supprimer'));
editPane.appendChild(editLink);
editPane.appendChild(document.createTextNode(' '));
editPane.appendChild(delLink);
section.appendChild(editPane);
}
messageGlobal.appendChild(section);
}
document.body.replaceChild(messageGlobal,document.getElementsByTagName('main')[0]);
reloadEditListeners();
currentClock = setTimeout(askData,15000);
}
if(window.addEventListener)
window.addEventListener('load', askData, false)
else
window.attachEvent("onload", askData);
if(window.addEventListener)
window.addEventListener('load', genListener, false)
else
window.attachEvent("onload", genListener);
</script>
<!-- Edit message div -->
<div id="editMessageFullScreen" class="fullscreen absent">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered">
<form id="editMessageForm" action="js modified" method="post">
<textarea row="5" placeholder="Le nouveau message :" name="msg" autofocus="autofocus" required="required"></textarea>
<input value="Modifier le message" type="submit">
<input id="abortEdition" value="Annuler" type="button"/>
</form>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>
</body>
</html>

59
discuts.php Normal file
View File

@ -0,0 +1,59 @@
<?php
session_start ();
include_once 'clazz/Zincluder.php';
try{
$discuts = Discussion::getVisibleDiscuts($_SESSION['session_id'] ?? NULL,$_SESSION['session_mdp'] ?? NULL);
}catch(SQLProcessingException $e){
var_dump($e);
echo $e->getHtmlMessage();
$_SESSION ['current_error'] = $e->getHtmlMessage();
header ( 'Location:' . ($e->getPreferredRedirection() ?? 'index.php') );
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<br />
<?php
foreach ($discuts['discuts'] as $discut) {
echo '<a href="discut.php?d=' . $discut['ID'] . '">' . $discut['name'] . ' par ' . $discut['creatorPseudo'] . '</a><br/>';
}
?>
<br />
<?php if($discuts['canCreate']){?>
<span id="createNewDiscBefore">Creer une nouvelle discussion</span>
<form id="createNewDiscForm" action="executor.php?action=createDiscussion" method="post">
<label for="newDiscText"></label><input id="newDiscText" type="text" name="name" />
<input type="submit" value="Cr&eacute;er la discussion" />
</form>
<script type="text/javascript">
//Creer nouvelle discussion click event //TODO upgrade to jquery
var span = document.getElementById('createNewDiscBefore');
span.addEventListener('click',function(){
document.getElementById('createNewDiscBefore').style.display = 'none';
document.getElementById('createNewDiscForm').style.display = 'block';
});
</script>
<br />
<br />
<?php }?>
<?php include 'includes/footer.php'; ?>
</body>
</html>

415
executor.php Normal file
View File

@ -0,0 +1,415 @@
<?php
session_start ();
include_once 'clazz/Zincluder.php';
/*
TODO add $_GET['p'] => should return on $_SESSION ['current_error'] (0) or via echo (1)
*/
function exiting($message,$location='index.php'){
if($message instanceof SQLProcessingException){
echo $message->getMessage();
$_SESSION ['current_error'] = $message->getHtmlMessage();
}else if($message instanceof Exception){
echo $message->getMessage();
$_SESSION ['current_error'] = htmlSpecialChars($message->getMessage());
}else{
$_SESSION ['current_error'] = $message;
}
header ( 'Location:' . $location );
exit;
}
if (! isset ( $_GET ['action'] ))
exiting(NULL,'40A.php');
switch ($_GET ['action']) {
case 'disconnect' :
unset($_SESSION['session_id']);
unset($_SESSION['session_mdp']);
header('Location:index.php');//TODO lastpageredirection
$_SESSION['current_error'] = 'La d&eacute;connexion se sera correctement pass&eacutee!';
exit;
case 'register' :
//Action : register
$pseudo = $_POST ['pseudo'] ?? NULL;
$mdp = $_POST ['mdp'] ?? NULL;
$mdp2 = $_POST ['mdp2'] ?? NULL;
try{
assert($pseudo,new MissingDataException('pseudo','POST'));
assert($mdp,new MissingDataException('mdp','POST'));
assert($mdp2,new MissingDataException('mdp2','POST'));
assert($mdp===$mdp2,new DataException('mdp and mdp2 should be equal'));
Membre::registerPerson ($pseudo,$mdp);
}catch(Exception $e){
exiting($e);
}
exiting(Utility::SUCESSFULLY_REGISTERED,'login.php');
case 'login' :
//Action : login
$pseudo = $_POST ['pseudo'] ?? NULL;
$mdp = $_POST ['mdp'] ?? NULL;
try{
assert($pseudo,new MissingDataException('pseudo','POST'));
assert($mdp,new MissingDataException('mdp','POST'));
$_SESSION['session_id'] = Membre::checkLogin ($pseudo,$mdp);
$_SESSION['session_mdp'] = $mdp;
}catch(Exception $e){
exiting($e);
}
exiting(Utility::SUCESSFULLY_LOGGED_IN,'index.php');//TODO Do a "previousContentPageRedirection"
case 'changePassword' :
//Action : change password
$sid = $_SESSION ['session_id'] ?? NULL;
$rmdp = $_POST ['rmdp'] ?? NULL;
$mdp = $_POST ['nmdp'] ?? NULL;
$mdp2 = $_POST ['nmdp2'] ?? NULL;
var_dump($_POST);
try{
assert($rmdp,new MissingDataException('rmdp','POST'));
assert($mdp,new MissingDataException('mdp','POST'));
assert($mdp2,new MissingDataException('mdp2','POST'));
assert($mdp===$mdp2,new DataException('mdp and mdp2 should be equal'));
Membre::changePassword ($sid,$rmdp,$mdp);
}catch(Exception $e){
exiting($e);
}
exiting(Utility::SUCESSFULLY_CHANGED_PASSWORD,'login.php');
case 'createDiscussion' :
//Action : create discussion
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$name = $_POST ['name'] ?? NULL;
try{
assert($sid,new LoginNeededException());
assert($rmdp,new MissingDataException('rmdp','POST'));
assert($mdp,new MissingDataException('mdp','POST'));
assert($mdp2,new MissingDataException('mdp2','POST'));
$did = Discussion::createDiscussion ($sid,$mdp,$name);
}catch(Exception $e){
exiting($e);
}
exiting(Utility::SUCESSFULLY_CREATED_DISCUSSION,'discut.php?d='.$did);
case 'postMessage' :
//Action : post message
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$did = $_GET ['d'] ?? NULL;
$text = $_POST ['msg'] ?? NULL;
var_dump($text);
try{
assert($sid,new LoginNeddedException());
assert($did,new MissingDataException('d','GET'));
assert($text,new MissingDataException('text','POST'));
Message::postMessage ($sid,$mdp,$did,$text);
}catch(Exception $e){
exiting($e);
}
exiting(NULL,'discut.php?d='.$did);
case 'deleteMessage' :
//Action : delete message
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$mid = $_GET ['m'] ?? NULL;
try{
assert($sid,new LoginNeddedException());
assert($mid,new MissingDataException('m','GET'));
$did = Message::deleteMessage ($sid,$mdp,$mid);
}catch(Exception $e){
exiting($e);
}
exiting(NULL,'discut.php?d='.$did);
case 'editVersion' :
//Action : edit version
// Data : name langage tags insertIndex -> facultatifs
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$v = $_GET['v'] ?? NULL;
$name = $_POST['name'] ?? NULL;
$langage = $_POST['langage'] ?? NULL;
$tags = $_POST['tags'] ?? NULL;
$insertIndex = $_POST['insertIndex'] ?? NULL;
try{
assert($sid,new LoginNeededException());
assert($v,new MissingDataException('v','GET'));
Version::editVersion ($sid,$mdp,$v,$name,$langage,$tags,$insertIndex);
}catch(Exception $e){
exiting($e);
}
exiting(Utility::SUCESSFULLY_CHANGED_PASSWORD,'login.php');
case 'getDiscutsMessages' :
//Action : get discut's messages
//TODO precise output type (via $_GET)
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$did = $_GET ['did'] ?? NULL;
try{
assert($sid,new LoginNeededException());
assert($did,new MissingDataException('did','GET'));
$jmsgs = Discussion::getMessages ($sid,$mdp,$did);
echo json_encode ( $jmsgs );
flush ();
exit;
}catch(Exception $e){
exiting($e);
}
exit;
case 'getPeopleList' :
//Action : get project's secondary owners
//TODO precise output type (via $_GET)
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$pid = $_GET ['p'] ?? NULL;
try{
assert($sid,new LoginNeededException());
assert($pid,new MissingDataException('pid','GET'));
$secondaryOwners = Projet::getSecondaryOwners ($sid,$mdp,$pid);
$jsowns = array();
foreach($secondaryOwners as $sOwner){
$jsown = array();
$jsown['ID'] = $sOwner['ID'];
$jsown['pseudo'] = $sOwner['pseudo'];
array_push($jsowns,$jsown);
}
echo json_encode ( $jsowns );
flush ();
exit;
}catch(Exception $e){
exiting($e);
}
exit;
case 'removePeople' :
//Action : remove secodary owner
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$pid = $_GET ['pid'] ?? NULL;
$peopleIDs = $_POST['peopleIDs'] ?? NULL;
try{
assert($sid,new LoginNeddedException());
assert($pid,new MissingDataException('pid','GET'));
$did = Projet::removeSecondaryOwner ($sid,$mdp,$pid,explode(',',$peopleIDs));
}catch(Exception $e){
exiting($e);
}
exiting(NULL,'projet.php?p='.$pid);
exit;
case 'addPeople' :
//Action : add secondary owner
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$pid = $_GET ['pid'] ?? NULL;
$personName = $_POST['personName'] ?? NULL;
try{
assert($sid,new LoginNeddedException());
assert($pid,new MissingDataException('pid','GET'));
assert($pid,new MissingDataException('personName','POST'));
$did = Projet::addSecondaryOwner ($sid,$mdp,$pid,explode(',',$personName));
}catch(Exception $e){
exiting($e);
}
exiting(NULL,'projet.php?p='.$pid);
case 'nameOwner' :
//Action : name a new Owner
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$pid = $_GET ['pid'] ?? NULL;
$personId = $_POST['personId'] ?? NULL;
try{
assert($sid,new LoginNeddedException());
assert($pid,new MissingDataException('pid','GET'));
assert($personId,new MissingDataException('personId','POST'));
Projet::nameOwner ($sid,$mdp,$pid,explode(',',$personId));
}catch(Exception $e){
exiting($e);
}
exiting(NULL,'projet.php?p='.$pid);
case 'delProject' :
//Action : delete this project
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$pid = $_GET ['pid'] ?? NULL;
try{
assert($sid,new LoginNeddedException());
assert($pid,new MissingDataException('pid','GET'));
Projet::removeProject ($sid,$mdp,$pid);
}catch(Exception $e){
exiting($e);
}
exiting(NULL,'projets.php');
case 'getVersionList' :
//Action : get project's versions
//TODO precise output type (via $_GET)
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$pid = $_GET ['p'] ?? NULL;
try{
assert($sid,new LoginNeededException());
assert($pid,new MissingDataException('pid','GET'));
$versions = Version::getFromProject ($sid,$mdp,$pid);
$jvs = array();
foreach($versions as $version){
$jv = array();
$jv['ID'] = $version['ID'];
$jv['name'] = $version['pseudo'];
$jv['versionAbs'] = $version['versionAbs'];
array_push($jvs,$jv);
}
echo json_encode ( $jvs );
flush ();
exit;
}catch(Exception $e){
exiting($e);
}
exit;
case 'createVersion' :
//Action : add new version
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$pid = $_GET ['pid'] ?? NULL;
$name = $_POST ['name'] ?? NULL;
$tags = $_POST ['tags'] ?? NULL;
$language = $_POST ['language'] ?? NULL;
$insertIndex = $_POST ['insertIndex'] ?? NULL;
try{
assert($sid,new LoginNeddedException());
assert($pid,new MissingDataException('pid','GET'));
assert($text,new MissingDataException('name','POST'));
assert($text,new MissingDataException('tags','POST'));
assert($text,new MissingDataException('language','POST'));
$vid = Version::createVerion ($sid,$mdp,$pid,$name,$tags,$language,$insertIndex);
}catch(Exception $e){
exiting($e);
}
exiting(NULL,'version.php?v='.$vid);
case 'editVersion' :
//Action : add secodary owner
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$vid = $_GET ['vid'] ?? NULL;
$name = $_POST ['name'] ?? NULL;
$tags = $_POST ['tags'] ?? NULL;
$language = $_POST ['language'] ?? NULL;
$insertIndex = $_POST ['insertIndex'] ?? NULL;
try{
assert($sid,new LoginNeddedException());
assert($pid,new MissingDataException('vid','GET'));
assert($text,new MissingDataException('name','POST'));
assert($text,new MissingDataException('tags','POST'));
assert($text,new MissingDataException('language','POST'));
$vid = Version::editVerion ($sid,$mdp,$vid,$name,$tags,$language,$insertIndex);
}catch(Exception $e){
exiting($e);
}
//TODO make auto version_abs sorting according to $_POST ['insertIndex']
//TODO verify tags and langage
exiting(NULL,'version.php?v='.$vid);
case 'delVersion' :
//Action : delete this version
$sid = $_SESSION ['session_id'] ?? NULL;
$mdp = $_SESSION ['session_mdp'] ?? NULL;
$vid = $_GET ['vid'] ?? NULL;
try{
assert($sid,new LoginNeddedException());
assert($pid,new MissingDataException('vid','GET'));
$pid = Version::removeVersion ($sid,$mdp,$vid);
}catch(Exception $e){
exiting($e);
}
exiting(NULL,'projet.php?p=' . $pid);
}

423
extras/Nexecutor.php Normal file
View File

@ -0,0 +1,423 @@
<?php
session_start ();
include_once 'clazz/Zincluder.php';
$me = Membre::me();
/*
TODO add $_GET['p'] => should return on $_SESSION ['current_error'] (0) or via echo (1)
*/
function exiting($message,$location='index.php'){
header ( 'Location:' . $location );
$_SESSION ['current_error'] = $message;
exit;
}
if (! isset ( $_GET ['action'] ))
exiting(NULL,'40A.php');
switch ($_GET ['action']) {
case 'register' :
//Action : register
if (!(isset ( $_POST ['pseudo'] ) && isset ( $_POST ['mdp'] ) && isset ( $_POST ['mdp2'] )))
exiting('Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!');
if ($_POST ['mdp'] === $_POST ['mdp2'])
exiting('Tu auras du rentrer deux fois le m&ecirc;me mot de passe (tu permet aussi de rendre le champs "Recopier le mot de passe" utile)');
if (preg_match ( "#^[a-zA-Z0-9\\-_]+$#", $_POST ['pseudo'] ))
exiting('Le pseudo sera incorrect : Les seuls caract&egrave;res autoris&eacute;s sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_');
if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&<26><><EFBFBD><EFBFBD><EFBFBD>\"\\#'{}()[\\]|\\^@<40>+=\$<EFBFBD><EFBFBD>*!<21>:/;.,?<3F>]+$#", $_POST ['mdp'] ))
exiting('Le mot de passe fut incorrect : Les seuls caract&egrave;res autoris&eacute;s sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&&eacute;&egrave;&agrave;&ugrave;&ccedil;&mu;"#\'{}()[]|^@<40>+=$<24><>*!<21>:/;.,?<3F>');
$out = Membre::registerPerson ($_POST ['pseudo'],$_POST ['mdp']);
if($out ===Membre::USED_USERNAME)
exiting('Le pseudonyme est d&eacute;j&agrave; utilis&eacute; (par une entit&eacute; differente de vous)');
exiting('Vous avez d&eacute;j&agrave; &eacute;t&eacute; correctement inscrit sur bernard.com','login.php');
case 'login' :
//Action : login
if (!( isset ( $_POST ['pseudo'] ) && isset ( $_POST ['mdp'] ) ))
exiting('Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!');
$me = Membre::getFromPseudo($_POST['pseudo']);
if(!$me)
exiting('Kik&egrave;tvou ? Pseudo inconnu ...');
if(!$me->connect($_POST ['mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$_SESSION['session_id'] = $me->getID();
$_SESSION['session_mdp'] = $_POST['mdp'];
exiting('Vous &ecirc;tes bien connect&eacute; (vous l\'avez &eacute;t&eacute; et le serez &eacute;galement)!');
case 'changePassword' :
//Action : change password
if(!(isset($_POST['rmdp']) && isset($_POST['nmdp']) && isset($_POST['nmdp2'])))
exiting('Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!');
if(!$me)
exiting('Si tu ne te connectes pas, comment veut tu que je sache quel mot de passe changer !');
if(!$me->connect($_POST['rmdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
if($_POST['nmdp'] !== $_POST['nmdp2'])
exiting('Tu auras du rentrer deux fois le m&ecirc;me mot de passe (tu permet aussi de rendre le champs "Recopier le mot de passe" utile)');
$out = $me->changePassword($_POST['nmdp']);
if($out == Membre::PASSWORD_TOO_LONG)
exiting('Mot de passe &ne; roman (255 caract&egrave;res maximum)');
exiting('Vos dispositifs d\'identification ont &eacute;t&eacute; correctement chang&eacute;s');
case 'createDiscussion' :
//Action : create discussion
if(!isset($_POST['name']))
exiting('Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!');
if(!$me)
exiting('Veuillez vous identifier pour acceder &agrave; cette section !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
if($me->isAdminLevelLowerThan(2))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 2 ou plus)');
$out = Discussion::createDiscussion($_POST ['name'],$_SESSION ['session_id']);
if($out === Discussion::NAME_ALREADY_USED)
exiting('Mince j\'ai d&eacute;j&agrave; utilis&eacute; l\'&eacute;criteau avec ce nom ... t\'en as pas un autre ?');
if($out === Discussion::ILLEGAL_NAME)
exiting('Y a des trucs qui ne me plaisent pas dans le nom que tu as donn&eacute; &agrave; ta discussion ...<br/>Je n\'accepte que les caract&egrave;res abcdefghijklmnopqrstuvwxyz<wbr/>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<wbr/>&eacute;&egrave;&agrave;&mu;_-\'()[\\]\\\\/<wbr/>,;:.&sect;!&ugrave;%&pound;$&curren;=+-*\\#~"|&ccedil;@');
if($out === Discussion::TOO_LONG_NAME)
exiting('Nom de discussion &ne; roman (255 caract&egrave;res maximum)');
exiting('C\'est fait !!! (la cr&eacute;ation de ta discussion bien s&ucirc;r)');
case 'postMessage' :
//Action : post message
if(!$me)
exiting('Veuillez vous identifier pour acceder &agrave; cette section !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting($me.'Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$discussion = new Discussion($_GET ['d']);
if(!$discussion->exists())
exiting('Pour des raisons d\'int&eacute;grit&eacute; du site, nous avons d&eacute;cid&eacute; de ne pas autoriser les messages dans les discussions inexistantes (pour les superadmins, c\'est possible en forcant la bdd &128516; )');
if(!$discussion->canAccess($me))
exiting('Tu pensais que tu pouvais &eacute;crire des messages dans une discussion &agrave; laquelle tu n\'as pas acc&egrave;s !!! Tu te crois o&ugrave; ?');
Message::sendMessage($me,$discussion,$_POST ['msg']);
exiting(NULL,'discut.php?d='.$discussion->getID());
case 'deleteMessage' :
//Action : delete message
if(!isset($_GET ['m']))
exiting('c');
if(!$me)
exiting('Veuillez vous identifier pour supprimer un message !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$message = new Message($_GET['m']);
if(!$message->exists())
exiting('Je vais avoir du mal &agrave; supprimer le message n&ecute;ant ...');
if($me->isAdminLevelLowerThan(6) && $me->getID() !== $message->getSender()->getID())
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 6 ou plus OU etre l\'auteur de ce message');
$message->removeMessage();
exiting(NULL,'discut.php?d='.$message->getDiscussion()->getID());
case 'editVersion' :
//Action : edit version
if(!isset($_GET ['v']))
exiting('Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!');
if(!$me)
exiting('Veuillez vous identifier pour &eacute;diter une version !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$version = new Version($_GET['v']);
if(!$version->exists())
exiting('Je vais avoir du mal &agrave; &eacute;diter la version n&ecute;ant ...');
if($me->isAdminLevelLowerThan(13) && $version->getProject()->haveRights($me))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 6 ou plus OU etre un des pocesseurs du projet');
//TODO concretly modify the version, with all the options (remove included)
exit;
case 'getDiscutsMessages' :
//Action : get discut's messages
//TODO precise output type (via $_GET)
$query = 'SELECT m.ID AS messageID,u.ID AS senderID, u.pseudo AS pseudo, m.texte AS texte, m.sendTime AS sendTime, UNIX_TIMESTAMP(m.sendTime) AS sendTimestamp FROM users AS u INNER JOIN messages AS m ON u.ID = m.senderID WHERE m.discussion_id=?';
$data = array ();
if(!isset($_GET ['d'])){
echo 'ERROR : NO DISCUSSION PROVIDED';
exit;
}
if($me?!$me->connect($_SESSION['session_mdp']):FALSE){
echo 'Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)';
exit;
}
$discut = new Discussion($_GET ['d']);
if(!$discut->exists()){
echo 'Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!';
exit;
}
$messages = Utility::arrayIfNot(Message::getFromDiscussion($discut));
$jmsgs = array();
foreach($messages as $message){
$jmsg = array();
$jmsg['messageID'] = $message->getID();
$jmsg['senderID'] = $message->getSender()->getID();
$jmsg['pseudo'] = $message->getSender()->getPseudo();
$jmsg['texte'] = $message->getText();
$jmsg['sendTime'] = $message->getSendDate();
$jmsg['sendTimestamp'] = strToTime($message->getSendDate());
$jmsg['rights'] = ($me)? $message->getSender()->getID() == $me->getID() || $me->isAdminLevelGreaterThan(5):FALSE;
array_push($jmsgs,$jmsg);
}
echo json_encode ( $jmsgs );
flush ();
exit;
case 'getPeopleList' :
//Action : get projest's secondary owners
//TODO precise output type (via $_GET)
$data = array ();
if(!isset($_GET ['p'])){
echo 'ERROR : NO PROJECT PROVIDED';
exit;
}
if($me?!$me->connect($_SESSION['session_mdp']):FALSE){
echo 'Votre empreinte r&eacute;tinale, digitale et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)';
exit;
}
$projet = new Projet($_GET ['p']);
if(!$projet->exists()){
echo 'Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!';
exit;
}
$owners = $projet->getSecondaryOwners();
$jmsgs = array();
foreach($owners as $owner){
$jmsg = array();
$jmsg['ID'] = $owner->getID();
$jmsg['pseudo'] = $owner->getPseudo();
array_push($jmsgs,$jmsg);
}
echo json_encode ( $jmsgs );
flush ();
exit;
case 'removePeople' :
//Action : remove secodary owner
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['peopleIDs']))
exiting('o');
if(!$me)
exiting('Veuillez vous identifier pour supprimer un secondary owner !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; supprimer un des propri&eacute;taires du projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$todIDs = explode(',',$_POST ['peopleIDs']);
$sowners = $projet->getSecondaryOwners();
$nsowners = array();;
foreach($sowners as $sowner)if(!in_array($sowner->getID(),$todIDs))$nsowners[] = $sowner;
$projet->setSecondaryOwners($nsowners);
exit;
case 'addPeople' :
//Action : add secodary owner
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['peopleName']))
exiting('o');
if(!$me)
exiting('Veuillez vous identifier pour ajouter un secondary owner !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; ajouter un propri&eacute;taires au projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$membre = Membre::getFromPseudo($_POST ['peopleName']);
if(count($membre) != 1)
exiting('Vous voulez ajouter QUI ?!!');
$projet->addSecondaryOwner($membre);
exit;
case 'setPublicy' :
//Action : set project publicy
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['publicy']))
exiting('o');
if(!$me)
exiting('Veuillez vous connecter pour changer la "publicit&eacute;"d\'un projet !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; ajouter un propri&eacute;taires au projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$projet->setPublicy($_POST ['publicy'] == 'true');
echo 'ok';
exit;
case 'nameOwner' :
//Action : name a new Owner
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['nOwnerID']))
exiting('o');
if(!$me)
exiting('Veuillez vous connecter pour changer le propri&eacute;taire d\'un projet !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; changer le propri&eacute;taires au projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$membre = new Membre($_POST ['nOwnerID']);
if(!$membre->exists())
exiting('Nous sommes hereux d\'acceuillir n&eacute;ant , le touveau propri&eacute;taire !!! Euh ...');
$projet->setOwner($membre);
$todIDs = $membre->getID();
$sowners = $projet->getSecondaryOwners();
$nsowners = array();
foreach($sowners as $sowner)if($sowner->getID() != $todIDs)$nsowners[] = $sowner;
$projet->setSecondaryOwners($nsowners);
$projet->addSecondaryOwner($me);
echo 'ok';
exit;
case 'delProject' :
//Action : delete this project
if(!isset($_GET ['p']))
exiting('c');
if(!$me)
exiting('Veuillez vous identifier pour supprimer un projet !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; supprimer le projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$projet->delete();
echo 'ok';
exit;
case 'getVersionList' :
//Action : get project's versions
//TODO precise output type (via $_GET)
$data = array ();
if(!isset($_GET ['p'])){
echo 'ERROR : NO PROJECT PROVIDED';
exit;
}
if($me?!$me->connect($_SESSION['session_mdp']):FALSE){
echo 'Votre empreinte r&eacute;tinale, digitale et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)';
exit;
}
$projet = new Projet($_GET ['p']);
if(!$projet->exists()){
echo 'Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!';
exit;
}
$versions = Version::getFromProject($projet);
$jmsgs = array();
foreach($versions as $version){
$jmsg = array();
$jmsg['id'] = $version->getID();
$jmsg['name'] = $version->getName();
$jmsg['versionAbs'] = $version->getVersionAbs();
array_push($jmsgs,$jmsg);
}
echo json_encode ( $jmsgs );
flush ();
exit;
case 'createVersion' :
//Action : add secodary owner
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['name']))
exiting('o');
if(!isset($_POST ['langage']))
exiting('q');
if(!isset($_POST ['tags']))
exiting('m');
if(!$me)
exiting('Veuillez vous identifier pour ajouter une version !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; ajouter une version au projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri&eacute;taire du projet');
//TODO make auto version_abs sorting according to $_POST ['insertIndex']
//TODO verify tags and langage
$projet->newVersion($_POST ['name'],Langage::getFromName($_POST ['langage']),$_POST ['tags'],Version::getHighestFromProject($projet)->getVersionAbs()+1);
//TODO do a REAL redirection (not to the highest)
echo 'www.bernard.890m.com/version.php?v=' . Version::getHighestFromProject($projet)->getID();
exit;
case 'editVersion' :
//Action : add secodary owner
if(!isset($_GET ['v']))
exiting('c');
if(!isset($_POST ['name']))
exiting('o');
if(!isset($_POST ['langage']))
exiting('q');
if(!isset($_POST ['tags']))
exiting('m');
if(!$me)
exiting('Veuillez vous identifier pour &eacute;diter une version !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$version = new Version($_GET['v']);
if(!$version->exists())
exiting('Je vais avoir du mal &agrave; &eacute;diter la version n&eacute;ant ...');
if(!($me->getID() == $version->getProject()->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri&eacute;taire du projet');
//TODO make auto version_abs sorting according to $_POST ['insertIndex']
//TODO verify tags and langage
$projet->editVersion($version,$_POST ['name'],Langage::getFromName($_POST ['langage']),$_POST ['tags'],Version::getHighestFromProject($projet)->getVersionAbs()+1);
//TODO do a REAL redirection (not to the highest)
echo 'www.bernard.890m.com/version.php?v=' . Version::getHighestFromProject($projet)->getID();
exit;
case 'delVersion' :
//Action : delete this version
if(!isset($_GET ['p']))
exiting('c');
if(!$me)
exiting('Veuillez vous identifier pour supprimer une version !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$version = new Version($_GET['p']);
if(!$version->exists())
exiting('Je vais avoir du mal &agrave; supprimer la version n&eacute;ant ...');
if(!($me->getID() == $version->getProject()->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri&eacute;taire du projet');
$version->delete();
echo 'ok';
exit;
}

View File

@ -1,6 +1,6 @@
<?php <?php
session_start(); session_start();
include_once 'includes/bdd.php'; include_once 'includes/inter.php';
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -9,7 +9,8 @@ include_once 'includes/bdd.php';
</head> </head>
<body> <body>
<?php include 'includes/header.php'; ?> <?php include 'includes/header.php'; ?>
<?php include 'includes/footer.php'; ?> <?php include 'includes/footer.php'; ?>
</body> </body>
</html> </html>

47
extras/downloadJar.php Normal file
View File

@ -0,0 +1,47 @@
<?php
session_start();
echo 'extensions:"'.ini_get('extensions').'"';
include_once "../includes/bdd.php";
include_once "../includes/inter.php";
include_once "megaapi.php";
$permissions = array (
FALSE,
FALSE,
FALSE,
FALSE
);
$connected = isConnected ();
$owner = FALSE;
$adminLevel = - 1;
$data = NULL;
if (isset ( $_GET ['id'] ) && isset ( $_GET ['v'] )) {
$data = getProjectVersionData( $_GET ['id'], $_GET ['v'] );
if ($data != NULL) {
$permissions = getPermissions( $data );
} else {
header('Location:../40A.php');
goto end;
}
} else {
header('Location:../40A.php');
goto end;
}
if (! $connected) {
header( 'Location:../401.php' );
goto end;
}
$owner = preg_match ( '#[^0-9]?' . $_SESSION ['session_id'] . '[^0-9]?#', $data ['owners'] );
$adminLevel = getAdminLevel ();
if (! $owner && $adminLevel < 12) {
header( 'Location:../403.php' );
goto end;
}
$megaapi = new MegaApiPHP("mA9D1IQQ", "PHP bernard.com");
$megaapi->login("bernard.lafayette63@gmail.com", "*******************");
$node = $megaapi->getNodeByPath('imageFinal.jpg', $megaapi->getRootNode());
$megaapi->startDownload($node, './');
end:

15
extras/dumpBDD.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
echo $1
if [ $1 = "start" ]
then mysql -uu890869027 -p -D u890869027_bcom < ./bdd.sql ; php -S localhost:8000
echo "\n"
mysqldump --routines -uu890869027 -p u890869027_bcom > ./bdd.sql
echo "Fin du programme";
elif [ "$1" = "stop" ]
then
mysqldump --routines -uu890869027 -p u890869027_bcom > ./bdd.sql
echo "Tadaaaaa !!!"
fi

34
extras/editVersion.php Normal file
View File

@ -0,0 +1,34 @@
<?php
session_start ();
include_once 'includes/inter.php';
?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<br />
<br />
<br />
<br />
<form action="editingVersion.php?id=<?php $_GET['id'];?>&amp;v=<?php $_GET['v'];?>" method="post">
<label for="newVersionName">Nom de la version :</label> <input
type="text" maxlength="100" id="newVersionName" name="name" /><br />
<br />
<select name="language">
<option value="Java">Java</option>
<option value="VBA">VBA</option>
</select>
<br />
<br />
<input type="submit" value="Modifier la version" />
</form>
<br />
<br />
<br />
<br />
<?php include 'includes/footer.php'; ?>
</body>
</html>

262
extras/inter.php Normal file
View File

@ -0,0 +1,262 @@
<?php
include_once 'includes/bdd.php';
function isConnected($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
if ($rep = $req->fetch ()) {
$connected = password_verify ( $mdp, $rep ['mdp'] );
} else {
$connected = FALSE;
}
$req->closeCursor ();
return $connected;
}
function getAdminLevel($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return - 1;
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
if ($result = $req->fetch ()) {
$adminLevel = $result ['administration'];
} else {
$adminLevel = - 1;
}
$req->closeCursor ();
return $adminLevel;
}
function getPseudo($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return "neant";
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function getPseudoOf($sid) {
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function tryToConnect($pseudo = NULL, $mdp = NULL) {
if (! isset ( $pseudo ) or ! isset ( $mdp )) {
$pseudo = $_POST ['pseudo'];
$mdp = $_POST ['mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' );
$req->execute ( array (
$pseudo
) );
$reponce = $req->fetch ();
if ($reponce != NULL) {
if (password_verify ( $mdp, $reponce ['mdp'] )) {
$req->closeCursor ();
return $reponce ['ID'];
} else {
$req->closeCursor ();
return 'errormdp';
}
} else {
$req->closeCursor ();
return 'errorpseudo';
}
}
function getProjectVersionData($project = NULL, $version = NULL) {
if (! isset ( $project ) or ! isset ( $version )) {
$project = $_GET ['id'];
$version = $_GET ['v'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS pID ,' . ' ' . 'v.versionAbs AS versionAbs , ' . ' ' . 'p.name AS name ,' . ' ' . 'v.version AS version ,' . ' ' . 'v.language AS language ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'INNER JOIN versions AS v' . ' ' . 'ON v.project_id = p.ID' . ' ' . 'WHERE v.project_id = ? AND v.versionAbs = ?' );
$req->execute ( array (
$project,
$version
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
}
function getProjectData($project = NULL) {
if (! isset ( $project )) {
$project = $_GET ['id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS ID ,' . ' ' . 'p.name AS name ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'WHERE p.ID = ?' );
$req->execute ( array (
$project
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
}
function getPermissions($data) {
$permissions = array (
FALSE,
FALSE,
FALSE,
FALSE
);
$permissions [0] = preg_match ( '#^1#', $data ['permissions'] );
$permissions [1] = preg_match ( '#^(0|1)1#', $data ['permissions'] );
$permissions [2] = preg_match ( '#^(0|1){2}1#', $data ['permissions'] );
$permissions [3] = preg_match ( '#^(0|1){3}1#', $data ['permissions'] );
return $permissions;
}
function getProjectsWithFirstPermission() {
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.permissions LIKE "1%" ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
$req->closeCursor ();
return $projects;
}
function getVersions($pid = NULL) {
if (! isset ( $pid )) {
$pid = $_GET ['id'];
}
$requete = 'SELECT * FROM versions WHERE project_id = ?';
$req = $GLOBALS ['bdd']->prepare ( $requete );
$req->execute ( array (
$pid
) );
// ADDPOINT langage
$versions = array (
array (),
array ()
);
while ( $rep = $req->fetch () ) {
$versions [$rep ['language']] [] = array (
'versionAbs' => $rep ['versionAbs'],
'versionName' => $rep ['version']
);
}
$req->closeCursor ();
return $versions;
}
function getOwnersisProjects($sid = NULL) {
if (! isset ( $sid )) {
$sid = $_SESSION ['session_id'];
}
$requete = 'SELECT p.ownersID AS ownersID , p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.ownersID REGEXP \'[^0-9]?' . $sid . '[^0-9]?\' ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
return $projects;
}
function registerPerson($pseudo, $mdp) {
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" );
$req->execute ( array (
$_POST ['pseudo']
) );
if ($req->fetch ()) {
return 'usedPseudo';
} else {
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$_POST ['pseudo'],
password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT )
) );
return 'ok';
}
}
function getMessages($discut = NULL) {
if (! isset ( $discut )) {
$discut = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE discussion_id=? ORDER BY sendTime DESC" );
$req->execute ( array (
$discut
) );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 0)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscuts() {
$req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions ORDER BY date_creation DESC" );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 1)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscutInfos($did = NULL) {
if(!isset($did)){
$did = $_GET['d'];
}
$req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions WHERE ID=?" );
return $req->fetch();
}
function sendMessage($discut = NULL, $text = NULL, $sender = NULL) {
if (! isset ( $discut ) || ! isset ( $text ) || ! isset ( $sender )) {
$discut = $_GET ['d'];
$text = $_POST ['msg'];
$sender = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
$req->execute ( array (
$discut,
htmlspecialchars ( $text ),
$sender
) );
return 'ok';
}
function createDiscut($name = NULL, $owner = NULL) {
if (! isset ( $name ) || ! isset ( $owner )) {
$name = $_POST ['name'];
$owner = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO discussions(name,creator_id,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$name,
$owner
) );
return 'ok';
}

57
extras/mandelbrot.html Normal file
View File

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<?php session_start();?>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<canvas id="mandelbrot" width="500" height="500">walou</canvas>
BIS
<script type="text/javascript">
window.onload = function() {
var canvas = document.getElementById('mandelbrot');
if (!canvas) {
alert("Impossible de récupérer le canvas");
return;
}
var context = canvas.getContext('2d');
if (!context) {
alert("Impossible de récupérer le context du canvas");
return;
}
context.fillStyle = "#ff0000";
var x1 = -2.1, x2 = 0.6, y1 = -1.2, y2 = 1.2, zoom = 100, iterations_max = 50, image_x = (x2 - x1)
* zoom, image_y = (y2 - y1) * zoom;
canvas.width = image_x;
canvas.heigth = image_y;
for (x = 0; x < image_x; x++) {
for (y = 0; y < image_y; y++) {
c_r = x / zoom + x1;
c_i = y / zoom + y1;
z_r = 0;
z_i = 0;
i = 0;
do {
var tmp = z_r;
z_r = z_r * z_r - z_i * z_i + c_r;
z_i = 2 * tmp * z_i + c_i;
i++;
} while (z_r * z_r + z_i * z_i < 4 && i < iterations_max);
if (i == iterations_max) {
context.fillStyle = "#FFFFFF";
context.fillRect(x, y, 1, 1);
}else{
context.fillStyle = "rgb(0, 0, "+255-(i*255/iterations_max)+")";
context.fillRect(x,y,1,1);
}
alert('done');
}
}
}
</script>

88
extras/megaProcess.php Normal file
View File

@ -0,0 +1,88 @@
<?php
session_start();
include_once 'clazz/Zincluder.php';
//GET : action="link|download(string)" v="versionabs(int)" t="jar|javadoc|vb(string)"
if(!isset($_GET['action'])){
header('Location:index.php');
echo "Vous devez definir l'attribut action via la methode GET";
echo 'NO';
exit;
}
switch($_GET['action']){
case 'link':
if(!isset($_GET['v'])){
header('Location:index.php');
echo "Vous devez definir l'attribut v (version) via la methode GET";
echo 'NO';
exit;
}
if(!isset($_GET['t'])){
header('Location:index.php');
echo "Vous devez definir l'attribut t (type) via la methode GET";
echo 'NO';
exit;
}
$version = new Version($_GET['v']);
if(!$version->exists()){
header('Location:404.php');
echo "v doit être l'ID d'une version existante !";
echo 'NO';
exit;
}
$go = FALSE;
$me = Membre::me();
if($me){
if($me->isAdminLevelHigherThan(12))
$go = TRUE;
$go = $go || $version->getProject()->haveRights($me);
}
switch($_GET['t']){
case 'jar':$go = $go || $version->isJarPublic();break;
case 'javadoc':$go = $go || $version->isJavadocPublic();break;
case 'java':$go = $go || $version->isJavaPublic();break;
case 'vb':$go = $go || $version->isVbPublic();break;
case 'xlsm':$go = $go || $version->isXlsmPublic();break;
default:exit;
}
if(!$go){
header('Location:403.php');
echo "VOUS N'AVEZ PAS LE DROIT !!!";
echo 'NO';
exit;
}
$path = '/Root/bernard.com/projets/'.$version->getProject()->getName().'/'.$version->getLanguage()->getName().'/'.$version->getName().'/';
$path .= $version->getProject()->getName().'-'.$version->getName();
switch($_GET['t']){
case 'jar':$path .= '.jar';break;
case 'javadoc':$path .= '-javadoc.tar.gz';break;
case 'java':$path .= '-src.tar.gz';break;
case 'vb':$path .= '.vb';break;
case 'xlsm':$path .= '.xlsm';break;
default:exit;
}
echo $path;
break;
}
//IF action=download
//Tester telechargement
//Génerer clé aleatoire de telechargement
//La stoquer
//Rediriger vers megabernard.alwaysdata.net
//IF action=link
//Tester si la personne peut acceder au fichier
//Generer chemin de fichier selon les arguments
//Renvoyer le tout

46
extras/newVersion.php Normal file
View File

@ -0,0 +1,46 @@
<?php
session_start ();
include_once 'includes/inter.php';
?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php include_once 'includes/inter.php';
$data = getProjectData();
if(!isConnected()){
header("Location:401.php");
goto end;
}else if(!preg_match('#[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?#',$data ['owners'])){
header("Location:403.php");
goto end;
}
?>
<br />
<br />
<br />
<br />
<form action="creatingVersion.php?id=<?php $_GET['id'];?>" method="post">
<label for="newVersionName">Nom de la version :</label> <input
type="text" maxlength="100" id="newVersionName" name="name" /><br />
<br />
<select name="language">
<option value="Java">Java</option>
<option value="VBA">VBA</option>
</select><br/>
<br />
<input type="submit" value="Cr&eacute;er une nouvelle version" />
</form>
<br />
<br />
<br />
<br />
<?php include 'includes/footer.php'; ?>
</body>
</html>
<?php
end:
?>

108
extras/sortBDD.php Normal file
View File

@ -0,0 +1,108 @@
<?php
session_start ();
include_once 'includes/inter.php';
if (! isConnected ()) {
header ( 'Location:401.php' );
goto end;
} else if (getAdminLevel () < 16) {
header ( 'Location:403.php' );
goto end;
} else {
try {
echo '[' . date ( 'H:i:s' ) . ']' . 'Start sorting bdd<br/>';
/*-------------------- USERS --------------------*/
$idAssos = array();
echo '[' . date ( 'H:i:s' ) . ']' . 'Table users<br/>';
$rep = $GLOBALS ['bdd']->query ( 'SELECT * FROM users ORDER BY ID' );
$users = array ();
while ( $user = $rep->fetch () ) {
echo '----' . $user ['ID'] . ':"' . $user ['pseudo'] . '";"' . $user ['mdp'] . '";' . $user ['date_creation'] . ';' . $user ['administration'] . '<br/>';
$users [] = $user;
}
$rep->closeCursor ();
$GLOBALS ['bdd']->exec ( 'TRUNCATE TABLE users' );
echo '[' . date ( 'H:i:s' ) . ']' . 'Table users effacée<br/>';
$currentID = 1;
foreach ( $users as $u ) {
$req = $GLOBALS['bdd']->prepare('INSERT INTO users(pseudo,mdp,date_creation,administration) VALUES (?,?,?,?)');
$req->execute(array($u ['pseudo'],$u ['mdp'], $u ['date_creation'], $u ['administration']));
$idAssos[$u['ID']] = $currentID;
$currentID +=1;
echo '----' . $u ['ID'] . '->' . $idAssos[$u['ID']] . '<br/>';
}
echo '[' . date ( 'H:i:s' ) . ']' . 'Pseudos réinsérés triés par ID<br/>';
/*-------------------- PROJETS --------------------*/
$pidAssos = array();
echo '[' . date ( 'H:i:s' ) . ']' . 'Table projets<br/>';
$rep = $GLOBALS ['bdd']->query ( 'SELECT * FROM projets ORDER BY ID' );
$projects = array ();
while ( $project = $rep->fetch () ) {
echo '----' . $project ['ID'] . ':"' . $project['name'] . '";"' . $project ['ownersID'] . '";' . $project ['permissions'] . '<br/>';
$projects[] = $project;
}
$rep->closeCursor();
$GLOBALS ['bdd']->exec ( 'TRUNCATE TABLE projets' );
echo '[' . date ( 'H:i:s' ) . ']' . 'Table projets effacée<br/>';
$currentID = 1;
foreach ( $projects as $p ) {
$ownersID = explode(';',$p['ownersID']);
$ownersNewID = array();
foreach($ownersID AS $o){
if(isset($idAssos[$o])){
$ownersNewID[] = $idAssos[$o];
}
}
$newOwnersID = implode(';',$ownersNewID);
if(count($ownersNewID)<=0){
echo '####################' . 'Le projet '.print_r($p,TRUE).' n\'a aucun poss&eacute;sseur<br/>';
}else{
echo '--------' . 'Owners :'.$p['ownersID'].' &agrave; '.$newOwnersID.'<br/>';
}
$req = $GLOBALS['bdd']->prepare('INSERT INTO projets(name,ownersID,permissions) VALUES (?,?,?)');
$req->execute(array($p ['name'],$newOwnersID,$p['permissions']));
$pidAssos[$p['ID']] = $currentID;
$currentID +=1;
echo '----' . $p ['ID'] . '->' . $pidAssos[$p['ID']] . '<br/>';
}
echo '[' . date ( 'H:i:s' ) . ']' . 'Projets réinsérés triés par ID<br/>';
/*-------------------- VERSIONS --------------------*/
$vidAssos=array();
echo '[' . date ( 'H:i:s' ) . ']' . 'Table versions<br/>';
$rep = $GLOBALS ['bdd']->query ( 'SELECT * FROM versions ORDER BY id' );
$versions = array ();
while ( $version = $rep->fetch () ) {
echo '----' . $version ['id'] . ':' . $version['project_id'] . ';"' . $version ['version'] . '";"' . $version ['versionAbs'].'";'.$version['language'] . '<br/>';
$versions[] = $version;
}
$rep->closeCursor();
$GLOBALS ['bdd']->exec ( 'TRUNCATE TABLE versions' );
echo '[' . date ( 'H:i:s' ) . ']' . 'Table versions effacée<br/>';
$currentID = 1;
foreach ( $versions as $v ) {
$newProjectId=$pidAssos[$v['project_id']];
$req = $GLOBALS['bdd']->prepare('INSERT INTO versions(project_id,version,versionAbs,language) VALUES (?,?,?,?)');
$req->execute(array($pidAssos,$v ['version'],$v['versionAbs'],$v ['language']));
$vidAssos[$v['id']] = $currentID;
$currentID +=1;
echo '----' . $v ['id'] . '->' . $vidAssos[$v['id']] . '<br/>';
}
echo '[' . date ( 'H:i:s' ) . ']' . 'Versions réinsérés triés par ID<br/>';
} catch ( Exception $e ) {
echo $GLOBALS['bdd']->error;
}
}
end:
?>

9
extras/test.php Normal file
View File

@ -0,0 +1,9 @@
<?php
include_once 'clazz/Zincluder.php';
$out = Membre::registerPerson ("moi","pwd");
var_dump($out);

View File

@ -1,8 +1,8 @@
<?php <?php
try{ try{
//$bdd = new PDO('mysql:host=localhost;dbname=bernard.com;charset=utf8', 'root', ''); $GLOBALS['bdd'] = new PDO('mysql:host=localhost;dbname=bcom', 'bcom', '*******************');
$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************'); //$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************');
}catch(Exception $e){ }catch(Exception $e){
die ('Erreur : ' . $e->getMessage()); die ('Erreur : ' . $e->getMessage() . "\n");
} }
?> ?>

100
includes/cards.html Normal file
View File

@ -0,0 +1,100 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html" charset="utf-8"/>
<title>Cartajou&eacute;</title>
</head>
<body>
<script>
/**
* Shuffles array in place.
* @param {Array} a items An array containing the items.
*/
function shuffle(a) {
var j, x, i;
for (i = a.length - 1; i > 0; i--) {
j = Math.floor(Math.random() * (i + 1));
x = a[i];
a[i] = a[j];
a[j] = x;
}
return a;
}
var cartes = {
1 : ["2_of_clubs","2♣",1],
2 : ["2_of_diamonds","2♦",1],
3 : ["2_of_hearts","2♥",1],
4 : ["2_of_spades","2♠",1],
5 : ["3_of_clubs","3♣",2],
6 : ["3_of_diamonds","3♦",2],
7 : ["3_of_hearts","3♥",2],
8 : ["3_of_spades","3♠",2],
9 : ["4_of_clubs","4♣",3],
10: ["4_of_diamonds","4♦",3],
11: ["4_of_hearts","4♥",3],
12: ["4_of_spades","4♠",3],
13: ["5_of_clubs","5♣",4],
14: ["5_of_diamonds","5♦",4],
15: ["5_of_hearts","5♥",4],
16: ["5_of_spades","5♠",4],
17: ["6_of_clubs","6♣",5],
18: ["6_of_diamonds","6♦",5],
19: ["6_of_hearts","6♥",5],
20: ["6_of_spades","6♠",5],
21: ["7_of_clubs","7♣",6],
22: ["7_of_diamonds","7♦",6],
23: ["7_of_hearts","7♥",6],
24: ["7_of_spades","7♠",6],
25: ["8_of_clubs","8♣",7],
26: ["8_of_diamonds","8♦",7],
27: ["8_of_hearts","8♥",7],
28: ["8_of_spades","8♠",7],
29: ["9_of_clubs","9♣",8],
30: ["9_of_diamonds","9♦",8],
31: ["9_of_hearts","9♥",8],
32: ["9_of_spades","9♠",8],
33: ["10_of_clubs","10♣",9],
34: ["10_of_diamonds","10♦",9],
35: ["10_of_hearts","10♥",9],
36: ["10_of_spades","10♠",9],
37: ["jack_of_clubs2","J♣",10],
38: ["jack_of_diamonds2","J♦",10],
39: ["jack_of_hearts2","J♥",10],
40: ["jack_of_spades2","J♠",10],
41: ["queen_of_clubs2","Q♣",11],
42: ["queen_of_diamonds2","Q♦",11],
43: ["queen_of_hearts2","Q♥",11],
44: ["queen_of_spades2","Q♠",11],
45: ["king_of_clubs2","K♣",12],
46: ["king_of_diamonds2","K♦",12],
47: ["king_of_hearts2","K♥",12],
48: ["king_of_spades2","K♠",12],
49: ["ace_of_clubs2","A♣",13],
50: ["ace_of_diamonds2","A♦",13],
51: ["ace_of_hearts2","A♥",13],
52: ["ace_of_spades2","A♠",13],
53: ["black_joker","☺b",42],
0: ["red_joker","☺r",42]
};
var Njoueurs = 2;
var shuffled = shuffle(cartes.slice());
var tazDeCarte = [];
for (var i = 0; i < Njoueurs; i++) {
tazDeCarte[][];
}
</script>
</body>
</html>

View File

@ -9,4 +9,22 @@
</div> </div>
<a href="" id="haut_de_page">Haut de page</a> <a href="" id="haut_de_page">Haut de page</a>
</footer> </footer>
<?php if(isset($_SESSION['current_error'])){ ?>
<div id="currentErrorPanel" class="fullscreen big-background-semi-opaque full-text">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered opaque">
<?php echo $_SESSION['current_error'];?>
</div>
</div>
</div>
<script type="text/javascript">
$('#currentErrorPanel').click(function(){
$('#currentErrorPanel').fadeOut(600);
});
</script>
<?php unset($_SESSION['current_error']);
} ?>

View File

@ -1,40 +1,57 @@
<?php include_once 'clazz/Zincluder.php'; ?>
<header> <header>
<?php include_once('includes/bdd.php');
$req = $bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?'); <!--
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){ 000000000000000800000000000000000000000000000000000000000000000000000
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp'])); 000000000000008000000000000000000000000000000000000000000000000000000
$rep = $req->fetch(); 000000000000080000000000000888000000000000000000000000000000000000000
}if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && isset($rep['pseudo']) ){ 000000000000800000000000088000880000000000000000000000000000000000000
000000000008008000000000000000080000000000000000000000000000000000000
000000000080008000000000000000800000000000000000000000000000000000000
000000000888888888000000000008000000000000000000000000000000000000000
000000000000008000000000000080000000000000000000000000000000000000000
000000000000008000000000000800000000000000000000000000000000000000000
000000000000008000000000088888880000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
-->
<?php
$me = Membre::headerInfos($_SESSION['session_id'] ?? -1,$_SESSION['session_mdp'] ?? '');
if($me['connected']){
?> ?>
<div id="bienvenue">Bienvenue &agrave; toi ,<?php echo $rep['pseudo']; ?> <div id="bienvenue">Bienvenue &agrave; toi, <?php echo $me['pseudo']; ?>
<form id="headDisconnectForm" method="post" action="disconnect.php"> <form id="headDisconnectForm" method="post" action="executor.php?action=disconnect">
<input type="submit" value="Se d&eacute;connecter" /> <input type="submit" value="Se d&eacute;connecter" />
</form> </form>
</div> </div>
<?php }else{ ?> <?php }else{ ?>
<form id="headLoginForm" method="post" action="logging.php"> <form id="headLoginForm" method="post" action="executor.php?action=login">
<label for="pseudo">Pseudo :</label> <label for="pseudo">Pseudo :</label>
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" required /> <input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" />
<label for="mdp">Mot de passe :</label> <label for="mdp">Mot de passe :</label>
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" required /> <input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" />
<input type="Submit" value="Se connecter" /> <input type="submit" value="Se connecter" />
</form> </form>
<form id="headLittleLoginForm" method="post" action="login.php">
<form id="headRegisterForm" method="post" action="register.php"> <input type="submit" value="Se connecter" />
<input type="submit" value="S'inscrire" /> </form>
<br/> <form id="headRegisterForm" method="post" action="register.php">
</form> <input type="submit" value="S'inscrire" />
</form>
<?php } ?> <?php } ?>
<img id="bande" src="pictures/bande.png" alt="Erreur d'affichage de l'image" /> <img id="bande" src="pictures/<?php if(rand(0,314159) < 110*42)echo "lucas_president.png";else echo "bande.png";?>" alt="Erreur d'affichage de l'image" width=1000 height="89" />
<nav id="navLinks"> <nav id="navLinks">
<a href="index.php">Acceuil</a><br class="navV"/> <a href="index.php">Accueil</a><br class="navV"/>
<a href="projets.php">Mes Projets</a><br class="nav2x2"/> <a href="projets.php">Mes Projets</a><br class="nav3x2 navV"/>
<a href="others.php">Tous les projets</a><br class="navV"/> <a href="others.php">Tous les projets</a><br class="navV"/>
<a href="discuts.php">Discussions</a><br class="navV"/>
<a href="profile.php">Mon profil</a><br class="navV"/> <a href="profile.php">Mon profil</a><br class="navV"/>
</nav> </nav>
</header> </header>

View File

@ -1,32 +1,127 @@
<?php <?php
include_once 'includes/bdd.php'; include_once 'includes/bdd.php';
function isConnected2S($username, $mdp) { function isConnected($sid = NULL, $mdp = NULL) {
$req = $bdd->prepare ( 'SELECT * FROM users WHERE ID=? AND mdp=?' ); if (! isset ( $sid ) or ! isset ( $mdp )) {
if(isset($_SESSION ['session_id']) and isset($_SESSION ['session_mdp'])){
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}else{
return FALSE;
}
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array ( $req->execute ( array (
$username, $sid
$mdp
) ); ) );
return ( bool ) $req->fetch (); if ($rep = $req->fetch ()) {
$connected = password_verify ( $mdp, $rep ['mdp'] );
} else {
$connected = FALSE;
}
$req->closeCursor ();
return $connected;
} }
function isConnected() { function getAdminLevel($sid = NULL, $mdp = NULL) {
return isConnected2S ( $_SESSION ['session_id'], $_SESSION ['session_mdp'] ); if (! isset ( $sid ) or ! isset ( $mdp )) {
} $sid = $_SESSION ['session_id'];
function getProjectVersionDataFromIDs($project, $version) { $mdp = $_SESSION ['session_mdp'];
$req = $bdd->prepare ( 'SELECT p.ID AS pID , ' . 'v.versionAbs AS versionAbs , ' . 'p.name AS name , ' . 'v.version AS version , ' . 'v.language AS language , ' . 'p.permissions AS permissions , ' . 'p.ownersID AS owners ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE v.project_id LIKE = ? AND v.versionAbs = ?' ); }
if (! isConnected ( $sid, $mdp ))
return - 1;
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array ( $req->execute ( array (
$_GET ['id'], $sid
$_GET ['v'] ) );
if ($result = $req->fetch ()) {
$adminLevel = $result ['administration'];
} else {
$adminLevel = - 1;
}
$req->closeCursor ();
return intval($adminLevel);
}
function getPseudo($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return "neant";
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function getPseudoOf($sid) {
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function tryToConnect($pseudo = NULL, $mdp = NULL) {
if (! isset ( $pseudo ) or ! isset ( $mdp )) {
$pseudo = $_POST ['pseudo'];
$mdp = $_POST ['mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' );
$req->execute ( array (
$pseudo
) );
$reponce = $req->fetch ();
if ($reponce != NULL) {
if (password_verify ( $mdp, $reponce ['mdp'] )) {
$req->closeCursor ();
return $reponce ['ID'];
} else {
$req->closeCursor ();
return 'errormdp';
}
} else {
$req->closeCursor ();
return 'errorpseudo';
}
}
function getProjectVersionData($project = NULL, $version = NULL) {
if (! isset ( $project ) or ! isset ( $version )) {
$project = $_GET ['id'];
$version = $_GET ['v'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS pID ,' . ' ' . 'v.versionAbs AS versionAbs , ' . ' ' . 'p.name AS name ,' . ' ' . 'v.version AS version ,' . ' ' . 'v.language AS language ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'INNER JOIN versions AS v' . ' ' . 'ON v.project_id = p.ID' . ' ' . 'WHERE v.project_id = ? AND v.versionAbs = ?' );
$req->execute ( array (
$project,
$version
) ); ) );
if (($data = $req->fetch ())) { if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data; return $data;
} else { } else {
$req->closeCursor ();
return NULL; return NULL;
} }
} }
function getProjectVersionData() { function getProjectData($project = NULL) {
return getProjectVersionDataFromIds ( $_GET ['id'], $_GET ['v'] ); if (! isset ( $project )) {
$project = $_GET ['id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS ID ,' . ' ' . 'p.name AS name ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'WHERE p.ID = ?' );
$req->execute ( array (
$project
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
} }
function getPermissionsFromData($data) { function getPermissions($data) {
$permissions = array ( $permissions = array (
FALSE, FALSE,
FALSE, FALSE,
@ -37,6 +132,196 @@ function getPermissionsFromData($data) {
$permissions [1] = preg_match ( '#^(0|1)1#', $data ['permissions'] ); $permissions [1] = preg_match ( '#^(0|1)1#', $data ['permissions'] );
$permissions [2] = preg_match ( '#^(0|1){2}1#', $data ['permissions'] ); $permissions [2] = preg_match ( '#^(0|1){2}1#', $data ['permissions'] );
$permissions [3] = preg_match ( '#^(0|1){3}1#', $data ['permissions'] ); $permissions [3] = preg_match ( '#^(0|1){3}1#', $data ['permissions'] );
return $permissions;
}
function getProjectsWithFirstPermission() {
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.permissions LIKE "1%" ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
$req->closeCursor ();
return $projects;
}
function getVersions($pid = NULL) {
if (! isset ( $pid )) {
$pid = $_GET ['id'];
}
$requete = 'SELECT * FROM versions WHERE project_id = ?';
$req = $GLOBALS ['bdd']->prepare ( $requete );
$req->execute ( array (
$pid
) );
// ADDPOINT langage
$versions = array (
array (),
array ()
);
while ( $rep = $req->fetch () ) {
$versions [$rep ['language']] [] = array (
'versionAbs' => $rep ['versionAbs'],
'versionName' => $rep ['version']
);
}
$req->closeCursor ();
return $versions;
}
function getOwnersisProjects($sid = NULL) {
if (! isset ( $sid )) {
$sid = $_SESSION ['session_id'];
}
$requete = 'SELECT p.ownersID AS ownersID , p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.ownersID REGEXP \'[^0-9]?' . $sid . '[^0-9]?\' ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
return $projects;
}
function registerPerson($pseudo, $mdp) {
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" );
$req->execute ( array (
$_POST ['pseudo']
) );
if ($req->fetch ()) {
return 'usedPseudo';
} else {
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$_POST ['pseudo'],
password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT )
) );
return 'ok';
}
}
function getMessages($discut = NULL) {
if (! isset ( $discut )) {
$discut = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE discussion_id=? ORDER BY sendTime DESC" );
$req->execute ( array (
$discut
) );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 0)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscuts() {
$req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions ORDER BY date_creation DESC" );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 1)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscutInfos($did = NULL) {
if (! isset ( $did )) {
$did = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM discussions WHERE ID=?" );
$req->execute ( array (
$did
) );
return $req->fetch ();
}
function sendMessage($discut = NULL, $text = NULL, $sender = NULL) {
if (! isset ( $discut ) || ! isset ( $text ) || ! isset ( $sender )) {
$discut = $_GET ['d'];
$text = $_POST ['msg'];
$sender = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
$req->execute ( array (
$discut,
htmlspecialchars ( $text ),
$sender
) );
return 'ok';
}
function createDiscut($name = NULL, $owner = NULL) {
if (! isset ( $name ) || ! isset ( $owner )) {
$name = $_POST ['name'];
$owner = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO discussions(name,creator_id,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$name,
$owner
) );
return 'ok';
}
function testInt($var, $errorLocation = NULL) {
if (preg_match ( '#^[0-9]+$#', $var )) {
return intval ( $var );
} else {
if (isset ( $errorLocation )) {
header ( 'Location:' + $errorLocation );
exit ();
}
return null;
}
}
function getMessage($m = NULL) {
if (! isset ( $m )) {
$m = $_GET ['m'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE ID=?" );
$req->execute ( array (
$m
) );
if ($rep = $req->fetch ())
return $rep;
return - 1;
}
function removeMessage($m = NULL) {
if (! isset ( $m )) {
$m = $_GET ['m'];
}
$req = $GLOBALS ['bdd']->prepare ( "DELETE FROM messages WHERE ID=?" );
$req->execute ( array (
$m
) );
}
function changePassword($oldPassword = NULL, $newPassword = NULL, $newPasswordBis = NULL) {
if (! isset ( $oldPassword ) || ! isset ( $newPassword ) || ! isset ( $newPasswordBis )) {
$oldPassword = $_POST ['rmdp'];
$newPassword = $_POST ['nmdp'];
$newPasswordBis = $_POST ['nmdp2'];
}
if(!isConnected($_SESSION['session_id'],$oldPassword))
return 'falsePassword';
if($newPassword != $newPasswordBis)
return 'passwordMissmatch';
$req = $GLOBALS['bdd']->prepare('UPDATE users SET mdp=? WHERE ID=?');
$req->execute(array(password_hash ( $newPassword, PASSWORD_DEFAULT ),$_SESSION['session_id']));
return true;
}
function discutExists($did = NULL) {
if (! isset ( $did )) {
$did = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM discussions WHERE ID=?" );
$req->execute ( array (
$did
) );
return $req->fetch();
} }
?>

View File

@ -1,11 +1,29 @@
<title>Le site de tous les bernards !</title> <title>Le site de tous les bernards !</title>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="keywords" lang="fr" content="cercloid officiel, zx project" /> <meta name="keywords" lang="fr" content="cercloid officiel, zeidhyx project" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/style.css" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<script type="text/x-mathjax-config"> MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]},
CommonHTML: { linebreaks: { automatic: true }, scale: ((window.innerWidth || document.body.clientWidth)<600)?70:100},
"HTML-CSS": { linebreaks: { automatic: true } },
SVG: { linebreaks: { automatic: true } }});
</script> </script>
<script type="text/javascript" async <script type="text/javascript">
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"> var headBloc = document.getElementsByTagName("head")[0];
</script> //Load css according to the browser
var link = document.createElement( "link" );
link.type = "text/css";
link.rel = "stylesheet";
link.media = "screen,print";
if(!!navigator.userAgent.match(/firefox/i)){
link.href = "css/firefoxStyle.css";
}else{
link.href = "css/noFirefoxStyle.css";
}
headBloc.appendChild( link );
</script>

124
index.php
View File

@ -2,124 +2,26 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<?php include 'includes/meta.php'; ?></head> <?php include 'includes/meta.php'; ?>
</head>
<body> <body>
<?php include 'includes/header.php'; ?> <?php include 'includes/header.php'; ?>
<h1>Bernard</h1> <h1>Bernard</h1>
<p><font size=4>J'ai le plaisir de vous souhaiter la bienvenue au sein de notre site: bernard.890m.com</font></p> <p><font size=4>J'ai le plaisir de vous souhaiter la bienvenue au sein de notre site: bernard.890m.com</font></p>
<?php foreach(Article::getNewest(10) as $article){ ?>
<article>
<!-- TODO put class on article node -->
<h2 class="articleTitle"><?php echo $article['title']; ?></h2>
<?php if($article['picPath'] != ''){?><a class="articlePic" href="<?php echo $article['picPath']; ?>"><img src="<?php echo $article['picPath'] ?>" width="128" /></a><?php }?>
<div class="articleText"><?php echo ($article['short'] == '')?$article['text']:$article['short']; ?></div>
</article>
<?php } ?>
<article>
<div>
<div style="float:left;">
<h2><u><strong>ZX Project</strong></u></h2>
<a href="tempPreMega/intoDonut.png"><img src="tempPreMega/intoDonut.png" width="128" /></a>
</div>
<p>
2016/21/09 19h - A090 : T&eacute;l&eacute;chargement du workspace Eclipse <a href="tempPreMega/workspace.zip">ici</a> !
<br/> Eclipse Neon download:
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-win64.exe"> Win64</a>,
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-win32.exe"> Win32</a>,
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-linux64.tar.gz"> Linux64</a>,
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-linus32.tar.gz"> Linux32</a>,
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-mac64.tar.gz"> Mac64</a>.
<br/> Nihil morati post haec militares avidi saepe turbarum adorti sunt Montium primum, qui divertebat in proximo, levi corpore senem
atque morbosum, et hirsutis resticulis cruribus eius innexis divaricaturn sine spiramento ullo ad usque praetorium traxere praefecti.Alii summum decus in
carruchis solito altioribus et ambitioso vestium cultu ponentes sudant sub ponderibus lacernarum, quas in collis insertas cingulis ipsis adnectunt nimia
subtegminum tenuitate perflabiles, expandentes eas crebris agitationibus maximeque sinistra, ut longiores fimbriae tunicaeque perspicue luceant varietate
liciorum effigiatae in species animalium multiformes.Haec dum oriens diu perferret, caeli reserato tepore Constantius consulatu suo septies et Caesaris
ter egressus Arelate Valentiam petit, in Gundomadum et Vadomarium fratres Alamannorum reges arma moturus, quorum crebris excursibus vastabantur confines
limitibus terrae Gallorum.Constituendi autem sunt qui sint in amicitia fines et quasi termini diligendi.De quibus tres video sententias ferri, quarum
nullam probo, unam, ut eodem modo erga amicum adfecti simus, quo erga nosmet ipsos, alteram, ut nostra in amicos benevolentia illorum erga nos
benevolentiae pariter aequaliterque respondeat, tertiam, ut, quanti quisque se ipse facit, tanti fiat ab amicis.Quid enim tam absurdum quam delectari
multis inanimis rebus, ut honore, ut gloria, ut aedificio, ut vestitu cultuque corporis, animante virtute praedito, eo qui vel amare vel, ut ita dicam,
redamare possit, non admodum delectari? Nihil est enim remuneratione benevolentiae, nihil vicissitudine studiorum officiorumque iucundius.
</p>
</div>
<hr><!--############### BlaBlaBla ###############-->
<div>
<div style="float:left;">
<h2><u><strong>Cerclo&iuml;de</strong></u></h2>
<a href="tempPreMega/cercloidCacahuete.png"><img src="tempPreMega/cercloidCacahuete.png" width="128" /></a>
</div>
$$C: \sum_{n=1}^N{\sqrt[p]{\sum_{g=1}^G{\left|F_{g,n}-A_n\right|^p}}}=R$$
<ul>
<li>\(p \in \mathbb{R}^*\) l'exposant qui d&eacute;termine la norme utilis&eacute;</li>
<li>\(N \in \mathbb{N}^*\) le nombre de dimension de l'espace</li>
<li>\(G \in \mathbb{N}^*\) le nombre de foyer</li>
<li>\(R \in \mathbb{R}_+\) le rayon</li>
<li>\(A \in \mathbb{R}^N\) le point consid&eacute;r&eacute;</li>
<li>\(F \in (\mathbb{R}^N)^G\) le tableau de foyer</li>
</ul>
</div>
<hr><!--############### Laissez en bloc ###############-->
<div>
<h2 style="float:left;"><u><strong>Lorem Ipsum</strong></u></h2>
Nihil morati post haec militares avidi saepe turbarum adorti sunt Montium primum, qui divertebat in proximo, levi corpore senem
atque morbosum, et hirsutis resticulis cruribus eius innexis divaricaturn sine spiramento ullo ad usque praetorium traxere praefecti.Alii summum decus in
carruchis solito altioribus et ambitioso vestium cultu ponentes sudant sub ponderibus lacernarum, quas in collis insertas cingulis ipsis adnectunt nimia
subtegminum tenuitate perflabiles, expandentes eas crebris agitationibus maximeque sinistra, ut longiores fimbriae tunicaeque perspicue luceant varietate
liciorum effigiatae in species animalium multiformes.Haec dum oriens diu perferret, caeli reserato tepore Constantius consulatu suo septies et Caesaris
ter egressus Arelate Valentiam petit, in Gundomadum et Vadomarium fratres Alamannorum reges arma moturus, quorum crebris excursibus vastabantur confines
limitibus terrae Gallorum.Constituendi autem sunt qui sint in amicitia fines et quasi termini diligendi.De quibus tres video sententias ferri, quarum
nullam probo, unam, ut eodem modo erga amicum adfecti simus, quo erga nosmet ipsos, alteram, ut nostra in amicos benevolentia illorum erga nos
benevolentiae pariter aequaliterque respondeat, tertiam, ut, quanti quisque se ipse facit, tanti fiat ab amicis.Quid enim tam absurdum quam delectari
multis inanimis rebus, ut honore, ut gloria, ut aedificio, ut vestitu cultuque corporis, animante virtute praedito, eo qui vel amare vel, ut ita dicam,
redamare possit, non admodum delectari? Nihil est enim remuneratione benevolentiae, nihil vicissitudine studiorum officiorumque iucundius.Accenderat
super his incitatum propositum ad nocendum aliqua mulier vilis, quae ad palatium ut poposcerat intromissa insidias ei latenter obtendi prodiderat a
militibus obscurissimis.quam Constantina exultans ut in tuto iam locata mariti salute muneratam vehiculoque inpositam per regiae ianuas emisit in
publicum, ut his inlecebris alios quoque ad indicanda proliceret paria vel maiora.Haec igitur Epicuri non probo, inquam.De cetero vellem equidem aut
ipse doctrinis fuisset instructior est enim, quod tibi ita videri necesse est, non satis politus iis artibus, quas qui tenent, eruditi appellantur aut ne
deterruisset alios a studiis.quamquam te quidem video minime esse deterritum.Cuius acerbitati uxor grave accesserat incentivum, germanitate Augusti
turgida supra modum, quam Hannibaliano regi fratris filio antehac Constantinus iunxerat pater, Megaera quaedam mortalis, inflammatrix saevientis adsidua,
humani cruoris avida nihil mitius quam maritus; qui paulatim eruditiores facti processu temporis ad nocendum per clandestinos versutosque rumigerulos
conpertis leviter addere quaedam male suetos falsa et placentia sibi discentes, adfectati regni vel artium nefandarum calumnias insontibus adfligebant.
Quibus ita sceleste patratis Paulus cruore perfusus reversusque ad principis castra multos coopertos paene catenis adduxit in squalorem deiectos atque
maestitiam, quorum adventu intendebantur eculei uncosque parabat carnifex et tormenta.et ex is proscripti sunt plures actique in exilium alii, non nullos
gladii consumpsere poenales.nec enim quisquam facile meminit sub Constantio, ubi susurro tenus haec movebantur, quemquam absolutum.Sed quid est quod in
hac causa maxime homines admirentur et reprehendant meum consilium, cum ego idem antea multa decreverim, que magis ad hominis dignitatem quam ad rei
publicae necessitatem pertinerent? Supplicationem quindecim dierum decrevi sententia mea.Rei publicae satis erat tot dierum quot C.Mario ; dis
immortalibus non erat exigua eadem gratulatio quae ex maximis bellis.Ergo ille cumulus dierum hominis est dignitati tributus.Sed maximum est in amicitia
parem esse inferiori.Saepe enim excellentiae quaedam sunt, qualis erat Scipionis in nostro, ut ita dicam, grege.Numquam se ille Philo, numquam Rupilio,
numquam Mummio anteposuit, numquam inferioris ordinis amicis, Q.vero Maximum fratrem, egregium virum omnino, sibi nequaquam parem, quod is anteibat aetate,
tamquam superiorem colebat suosque omnes per se posse esse ampliores volebat.Dum haec in oriente aguntur, Arelate hiemem agens Constantius post theatralis
ludos atque circenses ambitioso editos apparatu diem sextum idus Octobres, qui imperii eius annum tricensimum terminabat, insolentiae pondera gravius
librans, siquid dubium deferebatur aut falsum, pro liquido accipiens et conperto, inter alia excarnificatum Gerontium Magnentianae comitem partis exulari
maerore multavit.Haec et huius modi quaedam innumerabilia ultrix facinorum impiorum bonorumque praemiatrix aliquotiens operatur Adrastia atque utinam
semper quam vocabulo duplici etiam Nemesim appellamus: ius quoddam sublime numinis efficacis, humanarum mentium opinione lunari circulo superpositum,
el ut definiunt alii, substantialis tutela generali potentia partilibus praesidens fatis, quam theologi veteres fingentes Iustitiae filiam ex abdita
quadam aeternitate tradunt omnia despectare terrena.Adolescebat autem obstinatum propositum erga haec et similia multa scrutanda, stimulos admovente
regina, quae abrupte mariti fortunas trudebat in exitium praeceps, cum eum potius lenitate feminea ad veritatis humanitatisque viam reducere utilia
suadendo deberet, ut in Gordianorum actibus factitasse Maximini truculenti illius imperatoris rettulimus coniugem.Quam ob rem ut ii qui superiores
suntubmittere se debent in amicitia, sic quodam modo inferiores extollere.Sunt enim quidam qui molestas amicitias faciunt, cum ipsi se contemni putant;
quod non fere contingit nisi iis qui etiam contemnendos se arbitrantur; qui hac opinione non modo verbis sed etiam opere levandi sunt.Auxerunt haec vulgi
sordidioris audaciam, quod cum ingravesceret penuria commeatuum, famis et furoris inpulsu Eubuli cuiusdam inter suos clari domum ambitiosam ignibus
subditis inflammavit rectoremque ut sibi iudicio imperiali addictum calcibus incessens et pugnis conculcans seminecem laniatu miserando discerpsit.post
cuius lacrimosum interitum in unius exitio quisque imaginem periculi sui considerans documento recenti similia formidabat.Utque aegrum corpus quassari
etiam levibus solet offensis, ita animus eius angustus et tener, quicquid increpuisset, ad salutis suae dispendium existimans factum aut cogitatum,
insontium caedibus fecit victoriam luctuosam.Proinde concepta rabie saeviore, quam desperatio incendebat et fames, amplificatis viribus ardore incohibili
in excidium urbium matris Seleuciae efferebantur, quam comes tuebatur Castricius tresque legiones bellicis sudoribus induratae.Eius populus ab
incunabulis primis ad usque pueritiae tempus extremum, quod annis circumcluditur fere trecentis, circummurana pertulit bella, deinde aetatem ingressus
adultam post multiplices bellorum aerumnas Alpes transcendit et fretum, in iuvenem erectus et virum ex omni plaga quam orbis ambit inmensus, reportavit
laureas et triumphos, iamque vergens in senium et nomine solo aliquotiens vincens ad tranquilliora vitae discessit.Incenderat autem audaces usque ad
insaniam homines ad haec, quae nefariis egere conatibus, Luscus quidam curator urbis subito visus: eosque ut heiulans baiolorum praecentor ad expediendum
quod orsi sunt incitans vocibus crebris.qui haut longe postea ideo vivus exustus est.
</div>
</article>
<?php include 'includes/footer.php'; ?> <?php include 'includes/footer.php'; ?>
<?php
if(isset($_GET['i'])){
if($_GET['i'] == 0){
echo "<script>alert('Connexion effectuee avec succes !')</script>";
}
}
?>
</body> </body>
</html> </html>

View File

@ -1,26 +0,0 @@
<?php
session_start();
include_once 'includes/bdd.php';
$req=$bdd->prepare('SELECT * FROM users WHERE pseudo=?');
$req->execute(array($_POST['pseudo']));
$reponce=$req->fetch();
if($reponce != null){
if($reponce['mdp']===$_POST['mdp']){
$_SESSION['session_id'] = $reponce['ID'];
$_SESSION['session_mdp'] = $reponce['mdp'];
header('Location:index.php?i=0');
}else{
header('Location:login.php?i=2');
}
}else{
header('Location:login.php?i=1');
}
$req->closeCursor();
?>

View File

@ -9,17 +9,17 @@
<form id="loginForm" method="post" action="logging.php"> <form id="loginForm" method="post" action="executor.php?action=login">
<label for="pseudo">Pseudo :</label> <label for="pseudo">Pseudo :</label>
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" required/> <input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" />
<br/> <br/>
<label for="mdp">Mot de passe :</label> <label for="mdp">Mot de passe :</label>
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" required/> <input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" />
<br/> <br/>
<input type="Submit" value="Se connecter"> <input type="Submit" value="Se connecter">
</form> </form>
<?php include 'includes/foot.php' ?> <?php include 'includes/footer.php' ?>
<?php <?php
if(isset($_GET['i'])){ if(isset($_GET['i'])){
if($_GET['i'] == 1){ if($_GET['i'] == 1){
@ -30,4 +30,4 @@
} }
?> ?>
</body> </body>
</html> </html>

View File

@ -1,7 +1,22 @@
<?php session_start(); ?> <?php
session_start();
include_once 'clazz/Zincluder.php';
try{
$projects = Projet::getPublicProjectsForPresentation($_SESSION['session_id'] ?? NULL,$_SESSION['session_mdp'] ?? NULL);
}catch(SQLProcessingException $e){
var_dump($e);
echo $e->getHtmlMessage();
$_SESSION ['current_error'] = $e->getHtmlMessage();
header ( 'Location:' . $e->getPreferredRedirection() );
exit;
}
?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<?php include 'includes/meta.php'; ?> <?php include 'includes/meta.php'; ?>
</head> </head>
@ -12,29 +27,20 @@
<h1>Tous les projets</h1> <h1>Tous les projets</h1>
<?php <?php
include_once 'includes/bdd.php'; try{
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE p.permissions LIKE "1%" ';
$req = $bdd->query($requete)or die(print_r($bdd->errorInfo()));
$projects = array();
while($rep = $req->fetch()){
if(!isset($projects[$rep['projectID']])){
$projects[$rep['projectID']] = $rep;
}else if($projects[$rep['projectID']]['versionAbs'] < $rep['versionAbs']){
$projects[$rep['projectID']] = $rep;
}
}
foreach($projects as $project){ foreach($projects as $project){
echo ('<a href="projet.php?id='. $project['projectID'] .'&amp;v='. $project['versionAbs'] .'">Le projet ' . $project['projectName'] . ' en version ' . $project['versionName'] . '</a><br/>'); if($project['versionID'])
echo ('<a href="projet.php?p='. $project['projectID'] .'">Le projet ' . $project['projectName'] . '</a> <a href="version.php?v='. $project['versionID'] .'">en version ' . $project['versionName'] . '</a><br/>');
else
echo ('<a href="projet.php?p='. $project['projectID'] .'">Le projet ' . $project['projectName'] . ' sans version </a><br/>');
} }
?><br/> }catch(SQLProcessingException $e){
$_SESSION ['current_error'] = $e->getHtmlMessage();
}
?>
<br/>
<?php include 'includes/footer.php'; ?> <?php include 'includes/footer.php'; ?>
</body> </body>
</html> </html>

Binary file not shown.

Binary file not shown.

BIN
pictures/discours.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
pictures/discours.png Normal file

Binary file not shown.

BIN
pictures/discoursB2b2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
pictures/hexa_soucoupe.png Normal file

Binary file not shown.

BIN
pictures/into_donut.png Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,5 @@
<?php session_start(); ?> <?php session_start();
include_once 'clazz/Zincluder.php' ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -7,38 +8,30 @@
<body> <body>
<?php include 'includes/header.php'; ?> <?php include 'includes/header.php'; ?>
<?php <?php
include_once 'includes/bdd.php'; try{
Membre::checkIdLogin($_SESSION['session_id'],$_SESSION['session_mdp']);
$req=$bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?'); }catch(SQLProcessingException $e){
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){ header('Location:login.php');
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp'])); $_SESSION['current_error'] = 'Veuillez vous connectez ou vous inscrire pour acc&eacute;der &agrave; votre profil (&ccedil;a semble logique ...)';
} exit;
}
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && $req->fetch() ){ ?>
?> <form method="post" action="executor.php?action=changePassword" id="changePasswordForm">
<form method="post" action="change_password.php" id="changePasswordForm"> Changer le mot de passe :<br/><br/>
Changer le mot de passe :<br/> <label for="real_mdp_ask">Votre ancien mot de passe :</label>
<label for="real_mdp_ask">Votre ancien mot de passe :</label> <input type="password" id="real_mdp_ask" name="rmdp" />
<input type="password" id="real_mdp_ask" name="rmdp" required/> <br/>
<br/> <label for="new_mdp2_ask">Votre nouveau mot de passe :</label>
<label for="new_mdp2_ask">Votre nouveau mot de passe :</label> <input type="password" id="new_mdp_ask" name="nmdp" />
<input type="password" id="new_mdp_ask" name="nmdp" required/> <br/>
<br/> <label for="new_mdp2_ask">R&eacute;p&eacute;tez-le :</label>
<label for="new_mdp2_ask">R&eacute;p&eacute;tez-le :</label> <input type="password" id="new_mdp2_ask" name="nmdp2" />
<input type="password" id="new_mdp2_ask" name="nmdp2" required/> <br/>
<br/> <input type="submit" value="Changer le mot de passe">
<input type="submit" value="Changer le mot de passe"> </form>
</form>
<?php
}else{
header('Location:register.php');
}
?>
<?php include 'includes/footer.php'; ?> <?php include 'includes/footer.php'; ?>
</body> </body>
</html> </html>

View File

@ -1,156 +1,354 @@
<?php session_start(); ?> <?php
session_start();
include_once 'clazz/Zincluder.php';
try{
$projet = Projet::showProject($_SESSION['session_id'] ?? NULL,$_SESSION['session_mdp'] ?? NULL,$_GET['p'] ?? NULL);
}catch(SQLProcessingException $e){
error_log($e);
echo $e->getHtmlMessage();
$_SESSION ['current_error'] = $e->getHtmlMessage();
header ( 'Location:' . $e->getPreferredRedirection() ?? 'others.php' );
exit;
}
?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<head> <body>
<?php include 'includes/meta.php'; ?> <?php include 'includes/header.php'; ?>
</head>
<body> <h1>Mes projets</h1>
<?php include 'includes/header.php'; ?> <script>
<?php var projectPublic = <?php echo $projet['public']?'true':'false'; ?>;
include_once 'includes/inter.php'; </script>
<h1>Le projet <?php echo($projet['name']); ?></h1>
$permissions = array ( <br/>
FALSE,
FALSE,
FALSE,
FALSE
);
$connected = isConnected ();
$owner = FALSE;
$data = array ();
if (isset ( $_GET ['id'] ) && isset ( $_GET ['v'] )) {
$data = getProjectVersionData ();
if ($data == NULL) {
$permissions = getPermissionsWithData ( $data );
} else {
header ( 'Location:40A.php' );
goto end;
}
} else {
header ( 'Location:40A.php' );
goto end;
}
if ($connected)
$owner = preg_match ( '[^0-9]?' . $_SESSION ['session_id'] . '[^0-9]?', $data ['owners'] );
if ($permissions [0] || $owner) {
?>
<h1>Le projet <?php echo($data['name']) ?> en version <?php echo($data['version']) ?></h1> <?php
<br /> $ssu = $projet['ownerID'] == ($_POST['session_id'] ?? -1);
<?php if($rep['language'] == 0){?> $couple = Utility::getHierarchicCouple();
<a class="project_option" echo $couple[0] . ' : ' . $projet['ownerPseudo'] . '<br/>';
href=<?php if($permissions[1]){ echo( '"megaProcess/downloadJar.php?id='. $data[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>> $str = $couple[1] . ' : ';
<img foreach($projet['sowners'] as $sowner)
class="project_option_img<?php if(!$permissions[1]){echo(" disabeled");} ?>" $str .= $sowner['pseudo'] . ', ';//TODO add link to membre.php
alt="T&eacute;l&eacute;charger le jar" if(count($projet['sowners']) > 0)
title="T&eacute;l&eacute;charger le jar" echo '<span id="sOwnersText">'.substr($str,0,-2).'</span>';
src="pictures/download_jar.png" /> ?>
</a> <?php if($ssu){ ?>
<a class="project_option"
href=<?php if($permissions[2]){ echo( '"megaProcess/viewJavaSrc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>> <br/>
<img <br/><button id="managePeopleButton">G&eacute;rer les <?php echo $couple[1];?></button>
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>" <br/><button id="editProjectButton">Editer le projet</button>
alt="Voir la source" title="Voir la source" <br/><button id="newVersionButton">Nouvelle version</button>
src="pictures/view_code.png" />
<div class="fullscreen absent big-background-semi-opaque" id="managePeoplePanel">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered opaque big-background-opaque" id="managePeoplePan">
<ul class="gray-bordered fast-full-width gone-puce">
Mise a jour de la liste
</ul>
<form>
<input type="text"/>
<button>Ajouter un <?php echo $couple[1];?></button>
</form>
<button>Supprimer les <?php echo $couple[1];?> s&eacute;lectionn&eacute;s</button><br/>
<button>Termin&eacute; !</button>
<script>
$('#managePeoplePan form button').click(function(){
var peopleIDs = new Array();
$(this).prop('disabled',true);
$.post('executor.php?action=addPeople&p='+projectID,{peopleName : $('#managePeoplePan form input').val()},function(){$('#managePeoplePan form button').prop('disabled',false);askPeopleUpdate();});
});
$('#managePeoplePan form').bind('submit',function() {return false;});
$('#managePeoplePan > button:nth-of-type(1)').click(function(){
var peopleIDs = new Array();
$(this).prop('disabled',true);
$('#managePeoplePan ul li.selected').each(function(){peopleIDs.push($(this).data('membreID'));});
$.post('executor.php?action=removePeople&p='+projectID,{peopleIDs : peopleIDs.join(',')},function(){$('#managePeoplePan button:nth-of-type(1)').prop('disabled',false);askPeopleUpdate();});
});
$('#managePeoplePan > button:nth-of-type(2)').click(function(){
$('#managePeoplePanel').fadeOut(600);
});
var askPeopleUpdate = function(){
$.post('executor.php?action=getPeopleList&p='+projectID,{},answerPeopleList);
};
var answerPeopleList = function(newList){
var list = eval(newList);
$('#managePeoplePan ul').empty();
if(list.length < 1)$('#managePeoplePan ul').text("Ce projet n'a pas de <?php echo $couple[1];?>");
var pseudos = new Array();
list.forEach(function(item){
var element = $('<li></li>');
pseudos.push(item['pseudo']);
element.text(item['pseudo']);
element.data('membreID',item['ID']);
$('#managePeoplePan ul').append(element);
});
$('#managePeoplePan ul li').click(function(e){
$(e.target).toggleClass('selected');
});
$('#sOwnersText').text(pseudos.join(','));
};
</script>
</div>
</div>
</div>
</a>
<a class="project_option" <div class="fullscreen absent big-background-semi-opaque" id="editProjectPanel">
href=<?php if($permissions[2]){ echo( '"megaProcess/downloadJavaSrc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>> <div class="screen-vertical-centered">
<img <div class="screen-horizontal-centered" id="editProjectPan">
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>" <ul class="gray-bordered fast-full-width gone-puce">
alt="T&eacute;l&eacute;charger la source" Mise a jour de la liste
title="T&eacute;l&eacute;charger la source" </ul>
src="pictures/download_code.png" /> <button id="nOwnerButton">Nommer nouveau <?php echo $couple[0];?></button><br/>
<button id="projectPublicButton"></button><br/>
</a> <button id="delProjectButton">Supprimer le projet &lt;/!\ Tr&egrave;s dangereux&gt;</button><br/>
<a class="project_option" <button id="editProjectDone">Termin&eacute; !</button>
href=<?php if($permissions[3]){ echo( '"megaProcess/viewJavadoc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>> <script>
<img var askPeopleNOwnUpdate = function(){
class="project_option_img<?php if(!$permissions[3]){echo(" disabeled");} ?>" $.post('executor.php?action=getPeopleList&p='+projectID,{},answerPeopleNOwnList);
alt="Voir la doc" title="Voir la doc" src="pictures/view_javadoc.png" /> };
$('#editProjectPan #projectPublicButton').click(function(){
</a> $('#editProjectPan #projectPublicButton').prop('disabled',true);
<a class="project_option"
href=<?php if($permissions[3]){ echo( '"megaProcess/downloadJavadoc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>> $.post('executor.php?action=setPublicy&p='+projectID,{publicy : !projectPublic},function(data){
<img $('#editProjectPan #projectPublicButton').prop('disabled',false);
class="project_option_img<?php if(!$permissions[3]){echo(" disabeled");} ?>" if(data != 'ok')return;
alt="T&eacute;lecharger la doc" title="T&eacute;lecharger la doc" projectPublic = !projectPublic;
src="pictures/download_javadoc.png" /> nameProject();
});
</a> });
<br /> $('#editProjectPan #nOwnerButton').click(function(){
<?php }else if($rep['projectLanguage'] == 1){?> var idToName = $('#editProjectPan > ul > li.selected').data('membreID');
<a class="project_option" if(!idToName)return;
href=<?php if($permissions[1]){ echo( '"megaProcess/downloadXlsm.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>> $('#messagePan').addClass('redMessage').html('Voulez vous vraiment promouvoir ce ministre en président ? Vous serez r&eacute;trograd&eacute; en simple ministre t lenouveau pr&eacute;sident pourra a tout moment vous virez ! Ne nommez pas un pr&eacute;sident si vous n\'avez pas confiance en lui<br/><button>Par les pouvoir qui me sont conf&eacute;r&eacute;s, je nomme nouveau pr&eacute;sident ...</button><button>Je suis bien ici en fait !</button>');
<img $('#messagePan button:nth-of-type(1)').click(function(){
class="project_option_img<?php if(!$permissions[1]){echo(" disabeled");} ?>" $('#messagePanel').fadeOut(600);
alt="T&eacute;l&eacute;charger le xlsm" $('#editProjectPan #nOwnerButton').prop('disabled',true);
title="T&eacute;l&eacute;charger le xlsm" $.post('executor.php?action=nameOwner&p='+projectID,{nOwnerID : idToName},function(data){
src="pictures/download_xlsm.png" /> if(data == 'ok')window.location.reload();
$('#editProjectPan #nOwnerButton').prop('disabled',false);
</a> });
<a class="project_option" });
href=<?php if($permissions[2]){ echo( '"megaProcess/viewVbSrc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>> $('#messagePan button:nth-of-type(2)').click(function(){
<img $('#messagePanel').fadeOut(600);
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>" });
alt="Voir la source" title="Voir la source" src="pictures/voir_vb.png" /> $('#messagePanel').fadeIn(600);
});
</a>
<a class="project_option" $('#editProjectPan #delProjectButton').click(function(){
href=<?php if($permissions[2]){ echo( '"megaProcess/downloadVbSrc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>> $('#messagePan').addClass('redMessage').html('Voulez vous vraiment supprimer ce projet ? Les fichiers seront supprim&eacute;s automatiquement et seront irr&eacute;cup&eacute;rables, le nom de projet sera lib&eacute;s et toutes les informations additionelles seront aussi supprim&eacute;es et ce, d&eacute;finitivement !<br/><button>C\'est ainsi que projet nous quitte ...</button><button>NONNNNNNN !!!!! NE MEURS PAS PROJEEEEEEET !!!!</button>');
<img $('#messagePan button:nth-of-type(1)').click(function(){
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>" $('#messagePanel').fadeOut(600);
alt="T&eacute;l&eacute;charger la source" $('#editProjectPan #delProjectButton').prop('disabled',true);
title="T&eacute;l&eacute;charger la source" $.post('executor.php?action=delProject&p='+projectID,{},function(data){
src="pictures/download_vb.png" /> if(data == 'ok')window.location.replace('projets.php');
$('#editProjectPan #delProjectButton').prop('disabled',false);
</a> });
<?php } ?> });
$('#messagePan button:nth-of-type(2)').click(function(){
<br /> $('#messagePanel').fadeOut(600);
<br /> });
<h3>Toutes les versions :</h3> $('#messagePanel').fadeIn(600);
<br /> });
<table class="versionTable">
<tr>
<th>Version</th>
</tr>
<?php
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE v.project_id = ?';
$req = $bdd->prepare ( $requete );
$req->execute ( array (
$_GET ['id']
) );
while ( $rep = $req->fetch () ) {
?>
<tr>
<td><a
href=<?php echo( '"projet.php?id='. $rep[ 'projectID'] . '&v='. $rep[ 'versionAbs'] . '"'); ?>><?php echo($rep['versionName']);?></a>
</td>
</tr>
<?php } ?>
</table>
<?
} else {
header ( 'Location:403.php' );
goto end;
}
?>
<?php
end: var answerPeopleNOwnList = function(newList){
?> var list = eval(newList);
<?php include 'includes/footer.php'; ?> $('#editProjectPan ul').empty();
</body> if(list.length < 1)$('#editProjectPan ul').text("Ce projet n'a pas de <?php echo $couple[1];?>");
list.forEach(function(item){
var element = $('<li></li>');
element.text(item['pseudo']);
element.data('membreID',item['ID']);
$('#editProjectPan ul').append(element);
});
$('#editProjectPan ul li').click(function(e){
$('#editProjectPan ul li').removeClass('selected');
$(e.target).addClass('selected');
});
};
var nameProject = function(){
$('#editProjectPan #projectPublicButton').text(projectPublic?"Le projet est public":"Le projet n'est pas public");
}
</html> $('#editProjectPan > #editProjectDone').click(function(){
$('#editProjectPanel').fadeOut(600);
});
</script>
</div>
</div>
</div>
<div class="fullscreen absent big-background-semi-opaque" id="newVersionPanel">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered" id="newVersionPan">
<form id="nVersionForm">
<label for="nVersionName">Nom de la version</label>
<input type="text" id="nVersionName" /><br/>
<label for="languageSelect">Langage :</label>
<select id="languageSelect">
<option value="Java">Java</option>
<option value="VBA">VBA</option>
</select><br/>
<label for="nVAlphaCheck">Alpha : </label>
<input type="checkbox" id="nVAlphaCheck" value="alpha"/><br/>
<label for="nVBetaCheck">Beta : </label>
<input type="checkbox" id="nVBetaCheck" value="beta"/><br/>
<label for="nVReleaseCheck">Release : </label>
<input type="checkbox" id="nVReleaseCheck" value="release"/><br/>
<label for="nVBuggedCheck">Bogu&eacute; : </label>
<input type="checkbox" id="nVBuggedCheck" value="bugged"/><br/>
</form><br/>
<ul class="gray-bordered fast-full-width gone-puce">
Mise a jour de la liste
</ul>
<button id="createVersionDone">Cr&eacute;er la version</button><br/>
<button id="createVersionAbort">En fait ... non</button>
<script>
$('#nVersionName').on('input',updateVersionName);
$('#newVersionPan form').bind('submit',function() {return false;});
$('#createVersionDone').click(sendCreationRequest);
$('#createVersionAbort').click(function(){
$('#newVersionPanel').fadeOut(600);
});
var askVersionUpdate = function(){
$.post('executor.php?action=getVersionList&p='+projectID,{},answerVersionList);
};
var answerVersionList = function(newList){
var list = eval(newList);
$('#newVersionPan ul').empty();
$('#newVersionPan ul').append($('<li>&zwnj;</li>').attr('id',"versionAbsPotentialPos-1").addClass('potentialPos'));
list.forEach(function(item,index){
var element = $('<li></li>');
element.text(item['name']);
element.data('versionAbs',item['versionAbs']);
element.addClass('hoverable');
$('#newVersionPan ul').append(element);
$('#newVersionPan ul').append($('<li>&zwnj;</li>').attr('id',"versionAbsPotentialPos" + index).addClass('potentialPos').css('display','none'));
});
window.currentIndex = $('#newVersionPan ul > li.hoverable').length - 1;
window.savedCurrentIndex = currentIndex;
$('#newVersionPan ul li.hoverable').mousemove(function(e){
var itemIndex = $('#newVersionPan ul > li.hoverable').index(this);
var index = (currentIndex < itemIndex)?itemIndex:itemIndex-1;
if(currentIndex != index){
$("#versionAbsPotentialPos"+currentIndex).css('display','none');
currentIndex = index;
$("#versionAbsPotentialPos"+currentIndex).css('display','block');
}
});
$('#newVersionPan ul').click(function(){
savedCurrentIndex = currentIndex;
});
$('#newVersionPan ul').hover(null,function(){
$("#versionAbsPotentialPos"+currentIndex).css('display','none');
currentIndex = savedCurrentIndex;
$("#versionAbsPotentialPos"+currentIndex).css('display','block');
});
};
function updateVersionName(){
var name = $('#nVersionName').val();
var pp = $('#newVersionPan ul li.potentialPos');
(name.match(/^\s*$/))?pp.html('&zwnj;'):pp.text(name);
}
function sendCreationRequest(){
var name = $('#nVersionName').val();
var langage = $('#languageSelect').val();
var tags = new Array();
$("#nVersionForm input:checked").each(function(){
tags.push($( this ).val());
});
var insertIndex = savedCurrentIndex;
$.post('executor.php?action=createVersion&p='+projectID,{name:name,langage:langage,tags:tags.join(' '),insertIndex:insertIndex},answerCreationRequest);
}
function answerCreationRequest(data){
if(data != 'ok'){
console.log(data);//TODO la jolie boite de dialogue
}else
window.location.replace(data);
}
</script>
</div>
</div>
</div>
<div class="fullscreen absent big-background-semi-opaque" id="messagePanel">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered" id="messagePan">
<!-- Progamically filled -->
</div>
</div>
</div>
<script type="text/javascript">
$('#managePeopleButton').click(function(){
askPeopleUpdate();
$('#managePeoplePanel').fadeIn(600);
});
$('#editProjectButton').click(function(){
askPeopleNOwnUpdate();
nameProject();
$('#editProjectPanel').fadeIn(600);
});
$('#newVersionButton').click(function(){
askVersionUpdate();
$('#newVersionPanel').fadeIn(600);
});
</script>
<?php } ?>
<br/>
<br/>
<?php if(count($projet['versions']) > 0){ ?>
<?php $languages = array();
foreach($projet['versions'] AS $version)
array_push($languages,$version['language']);
$languages = array_unique($languages,SORT_REGULAR); ?>
<h3>Toutes les versions :</h3>
<br/>
<?php foreach($languages as $language){ ?>
<table class="versionTable">
<tr>
<th><?php echo Langage::getFromId($language)->getName(); ?></th>
</tr>
<?php foreach ($projet['versions'] as $writingVersion){if($writingVersion['language'] == $language){ ?>
<tr><td><a href = "version.php?v=<?php echo $writingVersion['ID'];?>"><?php echo $writingVersion['name']; ?></a></td></tr>
<?php }}?>
</table>
<?php } ?>
<?php }?>
<br/>
<br/>
<?php include 'includes/footer.php'; ?>
</body>
</html>

View File

@ -1,104 +0,0 @@
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php
include_once 'includes/bdd.php';
$req=$bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?');
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp']));
$connected = $req->fetch();
}
$req=$bdd->prepare('SELECT * FROM projets WHERE permissions LIKE "1___" AND ID=?');
$req->execute(array($_GET['id']));
$viewPerm = $req->fetch();
if(($connected && isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])) || $viewPerm){
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName , v.language AS projectLanguage , p.permissions AS permissions '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE v.project_id = ? AND v.versionAbs = ?';
$req = $bdd->prepare($requete);
$req->execute(array($_GET['id'],$_GET['v']));
$rep=$req->fetch();
if($rep){
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE v.project_id = ? AND v.versionAbs = ? AND (p.ownersID REGEXP \'[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?\' OR p.permissions LIKE "1%")';
$req = $bdd->prepare($requete);
$req->execute(array($_GET['id'],$_GET['v']));
$fsyuf = $req->fetch();
$req = $bdd->prepare('SELECT p.ID AS projectID FROM projets AS p INNER JOIN versions AS v ON v.project_id = p.ID WHERE v.project_id = ? AND v.versionAbs = ? AND p.ownersID REGEXP \'[^0-9]?' . (isset($_SESSION['session_id']))?$_SESSION['session_id']:'err' .'[^0-9]?\'');
$req->execute(array($_GET['id'],$_GET['v']));
if($req->fetch()){
$owner=TRUE;
}else{
$owner=FALSE;
}
echo($owner."###".$_SESSION['session_id']);
$exeAccess = preg_match('#^11(0|1)*#',$rep['permissions']) || $owner;
$docAccess = preg_match('#^111(0|1)*#',$rep['permissions']) || $owner;
$srcAccess = preg_match('#^1111(0|1)*#',$rep['permissions']) || $owner;
if($fsyuf){?>
<h1>Le projet <?php echo($rep['projectName']) ?> en version <?php echo($rep['versionName']) ?></h1>
<br/>
<?php if($rep['projectLanguage'] == 0){?>
<a class="project_option" href=<?php if($exeAccess){ echo( '"megaProcess/downloadJar.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$exeAccess){echo("disabeled");} ?>" alt="T&eacute;l&eacute;charger le jar" title="T&eacute;l&eacute;charger le jar" src="pictures/download_jar.png"></img></a>
<a class="project_option" href=<?php if($srcAccess){ echo( '"megaProcess/viewJavaSrc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/view_code.png"></img></a>
<a class="project_option" href=<?php if($srcAccess){ echo( '"megaProcess/downloadJavaSrc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_code.png"></img></a>
<a class="project_option" href=<?php if($docAccess){ echo( '"megaProcess/viewJavadoc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$docAccess){echo("disabeled");} ?>" alt="Voir la doc" title="Voir la doc" src="pictures/view_javadoc.png"></img></a>
<a class="project_option" href=<?php if($docAccess){ echo( '"megaProcess/downloadJavadoc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$docAccess){echo("disabeled");} ?>" alt="T&eacute;lecharger la doc" title="T&eacute;lecharger la doc" src="pictures/download_javadoc.png"></img></a>
<br/>
<?php }else if($rep['projectLanguage'] == 1){?>
<a class="project_option" href=<?php if($exeAccess){ echo( '"megaProcess/downloadXlsm.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$exeAccess){echo("disabeled");} ?>" alt="T&eacute;l&eacute;charger le xlsm" title="T&eacute;l&eacute;charger le xlsm" src="pictures/download_xlsm.png"></img></a>
<a class="project_option" href=<?php if($srcAccess){ echo( '"megaProcess/viewVbSrc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/voir_vb.png"></img></a>
<a class="project_option" href=<?php if($srcAccess){ echo( '"megaProcess/downloadVbSrc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_vb.png"></img></a>
<?php } ?>
<br/> <a href="#">##################################</a>
<br/>
<br/>
<h3>Toutes les versions :</h3>
<br/>
<table class="versionTable">
<tr>
<th>Version</th>
</tr>
<?php
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE v.project_id = ?';
$req = $bdd->prepare($requete);
$req->execute(array($_GET['id']));
while($rep = $req->fetch()){
?>
<tr>
<td> <a href=<?php echo( '"projet.php?id='. $rep[ 'projectID'] . '&v='. $rep[ 'versionAbs'] . '"'); ?>><?php echo($rep['versionName']);?></a> </td>
</tr>
<?php } ?>
</table>
<?php
}else{
header('Location:403.php');
}
}else{
header('Location:40A.php');
}
}else{
header('Location:401.php');
}
?>
<?php include 'includes/footer.php'; ?>
</body>
</html>

View File

@ -1,52 +1,51 @@
<?php session_start(); ?> <?php
<!DOCTYPE html> session_start();
<html> include_once 'clazz/Zincluder.php';
<head> if(!isset($_SESSION['session_id'])){
<?php include 'includes/meta.php'; ?> $_SESSION ['current_error'] = Utility::LOGIN_NEEDED_FOR_PROJECTS;
</head> header ( 'Location:login.php' );
exit;
}
try{
Membre::checkIdLogin($_SESSION['session_id'] ?? NULL,$_SESSION['session_mdp'] ?? NULL);
$projects = Projet::getAuthorizedProjectsForPresentation($_SESSION['session_id'],$_SESSION['session_mdp']);
}catch(SQLProcessingException $e){
var_dump($e);
echo $e->getHtmlMessage();
$_SESSION ['current_error'] = $e->getHtmlMessage();
header ( 'Location:' . $e->getPreferredRedirection() );
exit;
}
<body> ?>
<?php include 'includes/header.php'; ?> <!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<h1>Mes projets</h1> <body>
<?php include 'includes/header.php'; ?>
<?php <h1>Mes projets</h1>
include_once 'includes/bdd.php';
$req=$bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?'); <?php
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){ try{
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp'])); foreach($projects as $project){
} if($project['versionID'])
echo ('<a href="projet.php?p='. $project['projectID'] .'">Le projet ' . $project['projectName'] . '</a> <a href="version.php?v='. $project['versionID'] .'">en version ' . $project['versionName'] . '</a><br/>');
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && $req->fetch() ){ else
echo ('<a href="projet.php?p='. $project['projectID'] .'">Le projet ' . $project['projectName'] . ' sans version </a><br/>');
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE p.ownersID REGEXP \'[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?\' ';
$req = $bdd->query($requete)or die(print_r($bdd->errorInfo()));
//$req = $bdd->query('SELECT * FROM projets WHERE ownersID REGEXP \'[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?\'');
$projects = array();
while($rep = $req->fetch()){
if(!isset($projects[$rep['projectID']])){
$projects[$rep['projectID']] = $rep;
}else if($projects[$rep['projectID']]['versionAbs'] < $rep['versionAbs']){
$projects[$rep['projectID']] = $rep;
}
}
foreach($projects as $project){
echo ('<a href="projet.php?id='. $project['projectID'] .'&amp;v='. $project['versionAbs'] .'">Le projet ' . $project['projectName'] . ' en version ' . $project['versionName'] . '</a><br/>');
}
}else{
header('Location:401.php');
} }
}catch(SQLProcessingException $e){
$_SESSION ['current_error'] = $e->getHtmlMessage();
}
?> ?>
<br/> <br/>
<?php include 'includes/footer.php'; ?> <?php include 'includes/footer.php'; ?>
</body> </body>
</html>
</html>

View File

@ -9,33 +9,15 @@
<body> <body>
<?php include 'includes/header.php'; ?> <?php include 'includes/header.php'; ?>
<?php <form id="registerForm" method="post" action="executor.php?action=register">
if(isset($_GET['i'])){
if($_GET['i'] == 1){
echo "<script>alert('Vous n\\'avez pas rentré toutes les données !')</script>";
} elseif($_GET['i'] == 2){
echo "<script>alert('Les mots de passe ne correspondent pas')</script>";
} elseif($_GET['i'] == 3){
echo "<script>alert('Le pseudo n\\'est pas bien formé (Il ne peux contenir que des lettres (majuscules et minuscules), des nombres, le tiret(-) et l\\'underscore(_) ')</script>";
} elseif($_GET['i'] == 4){
echo "<script>alert('Le mot de passe n\\'est pas bien formé (Caractères autorisés : abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&é\"#\\'{}()[]|è\\ç^à@°+=\$¤£*µ!§:/;.,?²)')</script>";
} elseif($_GET['i'] == 5){
echo "<script>alert('Pseudo déjà utilisé')</script>";
} elseif($_GET['i'] == 6){
echo "<script>alert('Vous etes correctement inscrit sur bernard.com !!!')</script>";
}
}
?>
<form id="registerForm" method="post" action="registering.php">
<label for="pseudo">Pseudo :</label> <label for="pseudo">Pseudo :</label>
<input type="text" name="pseudo" id="pseudo" placeholder="Votre pseudo" required /> <input type="text" name="pseudo" id="pseudo" placeholder="Votre pseudo" />
<br/> <br/>
<label for="mdp">Mot de passe :</label> <label for="mdp">Mot de passe :</label>
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" required /> <input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" />
<br/> <br/>
<label for="mdp2">Mot de passe (bis) :</label> <label for="mdp2">Mot de passe (bis) :</label>
<input type="password" name="mdp2" id="mdp2" placeholder="Votre mot de passe" required /> <input type="password" name="mdp2" id="mdp2" placeholder="Votre mot de passe" />
<br/> <br/>
<input type="Submit" value="S'inscrire"> <input type="Submit" value="S'inscrire">
</form> </form>
@ -43,4 +25,4 @@
<?php include 'includes/footer.php' ?> <?php include 'includes/footer.php' ?>
</body> </body>
</html> </html>

View File

@ -1,31 +0,0 @@
<?php session_start();
include_once 'includes/bdd.php';
if(isset($_POST['pseudo']) && isset($_POST['mdp']) && isset($_POST['mdp2'])){
if($_POST['mdp'] === $_POST['mdp2']){
if(preg_match("#^[a-zA-Z0-9\\-_]+$#",$_POST['pseudo'])){
if(preg_match("#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&éèàùçµ\"\\#'{}()[\\]|\\^@°+=\$¤£*!§:/;.,?²]+$#",$_POST['mdp'])){
$req = $bdd->prepare("SELECT * FROM users WHERE pseudo=?");
$req->execute(array($_POST['pseudo']));
if($req->fetch()){
header('Location:register.php?i=5');
}else{
$req = $bdd->prepare('INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())');
$req->execute(array($_POST['pseudo'],$_POST['mdp']));
$_SESSION['session_id'] = $reponce['ID'];
$_SESSION['session_mdp'] = $reponce['mdp'];
header('Location:register.php?i=6');
}
}else{
header('Location:register.php?i=4');
}
}else{
header('Location:register.php?i=3');
}
}else{
header('Location:register.php?i=2');
}
}else{
header('Location:register.php?i=1');
}
?>

24
sql/GetDiscutInfo.sql Normal file
View File

@ -0,0 +1,24 @@
DROP PROCEDURE IF EXISTS GetDiscutInfo;
DELIMITER //
CREATE PROCEDURE GetDiscutInfo
(
IN p_sid TEXT,
IN p_password TEXT,
IN p_did INT,
OUT outputCode INT(11),
OUT o_connected INT(1)
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 OR outputCode=2005 THEN
SET o_connected = 1;
ELSE
SET o_connected = 0;
END IF;
SET outputCode :=( SELECT CASE WHEN (SELECT CheckInGroup(p_sid,authorizedGroupID)=42 OR p_sid=creatorID FROM discussions WHERE ID=p_did) THEN 42 ELSE 2019 END );
END//
DELIMITER ;

22
sql/GetDiscutMessages.sql Normal file
View File

@ -0,0 +1,22 @@
DROP PROCEDURE IF EXISTS GetDiscutMessages;
DELIMITER //
CREATE PROCEDURE GetDiscutMessages
(
IN p_sid INT,
IN p_password TEXT,
IN p_did INT,
OUT outputCode INT(11)
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 OR outputCode = 2005 THEN
SET outputCode :=( SELECT CASE WHEN (SELECT CheckInGroup(p_sid,authorizedGroupID)=42 OR p_sid=creatorID FROM discussions WHERE ID=p_did) THEN 42 ELSE 2019 END );
IF outputCode = 42 THEN
INSERT INTO smz SELECT m.ID AS ID,u.ID AS senderID,u.pseudo AS senderPseudo,m.texte AS texte,m.sendTime AS sendTime, p_sid = senderID AS rights FROM messages AS m INNER JOIN membres AS u ON u.ID = m.senderID WHERE m.discussionID = p_did;
END IF;
END IF;
END//
DELIMITER ;

20
sql/changePassword.sql Normal file
View File

@ -0,0 +1,20 @@
DROP PROCEDURE IF EXISTS ChangePassword;
DELIMITER //
CREATE PROCEDURE ChangePassword
(
IN p_sid INT,
IN p_password TEXT,
IN p_npassword TEXT,
OUT outputCode INT
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 THEN
UPDATE membres SET hashedPassword = MD5(p_npassword) WHERE ID = p_sid;
END IF;
END//
DELIMITER ;

39
sql/checkIdLogin.sql Normal file
View File

@ -0,0 +1,39 @@
DROP PROCEDURE IF EXISTS CheckIdLogin;
DELIMITER //
CREATE PROCEDURE CheckIdLogin
(
IN p_sid INT,
IN p_password TEXT,
OUT outputCode INT
)
READS SQL DATA
BEGIN
SET outputCode :=(
SELECT
(
CASE
WHEN (
SELECT
COUNT(*)
FROM
membres
WHERE
ID = p_sid
) != 1 THEN 2005
WHEN(
SELECT
COUNT(*)
FROM
membres
WHERE
ID = p_sid AND
hashedPassword = MD5(p_password)
) != 1 THEN 2006
ELSE 42
END
)
);
END//
DELIMITER ;

66
sql/checkInGroup.sql Normal file
View File

@ -0,0 +1,66 @@
DROP FUNCTION IF EXISTS CheckInGroup;
DELIMITER //
CREATE FUNCTION CheckInGroup
(
p_sid INT,
p_gid INT
)
RETURNS INT
READS SQL DATA
BEGIN
SET @outputCode :=(
SELECT
(
CASE
WHEN p_gid = 0 THEN 0
WHEN p_gid = 1 THEN 42
ELSE 100
END
)
);
IF @outputCode = 100 THEN
SET @outputCode :=(
SELECT
(
CASE
WHEN(
SELECT
COUNT(*)
FROM
groupes
WHERE
ID = p_gid
) = 1 THEN 42
ELSE 2012
END
)
);
IF @outputCode = 42 THEN
SET @outputCode :=(
SELECT
(
CASE
WHEN(
SELECT
COUNT(*)
FROM
appartenanceAUnGroupe
INNER JOIN groupes
ON groupes.ID = appartenanceAUnGroupe.groupID
WHERE
groupes.ID = p_gid AND appartenanceAUnGroupe.membreID = p_sid
) >= 1 THEN 42
ELSE 0
END
)
);
END IF;
END IF;
RETURN @outputCode;
END//
DELIMITER ;

49
sql/checkLogin.sql Normal file
View File

@ -0,0 +1,49 @@
DROP PROCEDURE IF EXISTS CheckLogin;
DELIMITER //
CREATE PROCEDURE CheckLogin
(
IN p_pseudo TEXT,
IN p_password TEXT,
OUT outputCode INT,
OUT accountID INT
)
READS SQL DATA
BEGIN
SET outputCode :=(
SELECT
(
CASE
WHEN (
SELECT
COUNT(*)
FROM
membres
WHERE
pseudo = p_pseudo
) != 1 THEN 2005
WHEN (
SELECT
COUNT(*)
FROM
membres
WHERE
pseudo = p_pseudo AND
hashedPassword = MD5(p_password)
) != 1 THEN 2006
ELSE 42
END
)
);
SET accountID :=(
SELECT
ID
FROM
membres
WHERE
pseudo = p_pseudo AND
hashedPassword = MD5(p_password)
);
END//
DELIMITER ;

43
sql/createDiscussion.sql Normal file
View File

@ -0,0 +1,43 @@
DROP PROCEDURE IF EXISTS CreateDiscusson;
DELIMITER //
CREATE PROCEDURE CreateDiscusson
(
IN p_sid INT,
IN p_password TEXT,
IN p_name TEXT,
OUT outputCode INT
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password,outputCode);
IF outputCode = 42 THEN
IF (SELECT COUNT(*) FROM membres WHERE ID = p_sid AND adminLevel >= 2) = 1 THEN
SET outputCode :=(
SELECT
(
CASE
WHEN LENGTH(p_name) > 255 THEN 2014
WHEN CAST(p_name AS BINARY) NOT REGEXP BINARY '^[-a-zA-Z0-9\_ ]+$' THEN 2015
WHEN(
SELECT
COUNT(*)
FROM
discussions
WHERE
name = p_name
) > 0 THEN 2016
ELSE 42
END
)
);
END IF;
ELSE
SET outputCode = 2013;
END IF;
IF outputCode = 42 THEN INSERT INTO discussions(name,creatorID,dateCreation,authorizedGroupId) VALUES (CAST(p_name AS CHAR(255)),p_sid,NOW(),0); END IF;
END//
DELIMITER ;

46
sql/deleteMessage.sql Normal file
View File

@ -0,0 +1,46 @@
DROP PROCEDURE IF EXISTS DeleteMessage;
DELIMITER //
CREATE PROCEDURE DeleteMessage
(
IN p_sid INT,
IN p_password TEXT,
IN p_mid INT,
OUT outputCode INT,
OUT did INT
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 THEN
SET outputCode :=(
SELECT
(
CASE
WHEN(
SELECT
COUNT(*)
FROM
messages
WHERE
ID = p_mid
) = 1 THEN 2010
ELSE 42
END
)
);
IF outputCode = 42 THEN
SET did :=(SELECT discussionID FROM messages WHERE ID = p_mid);
SET @authorizedGroupID :=(SELECT authorizedGroupID FROM discussions WHERE ID=did);
CALL `CheckInGroup`(p_sid, @authorizedGroupID, outputCode);
IF outputCode = 42 THEN
DELETE FROM messages WHERE ID = p_mid;
END IF;
END IF;
END IF;
END//
DELIMITER ;

View File

@ -0,0 +1,18 @@
DROP PROCEDURE IF EXISTS GetAuthorizedProjectsForPresentation;
DELIMITER //
CREATE PROCEDURE GetAuthorizedProjectsForPresentation
(
IN p_sid TEXT,
IN p_password TEXT,
OUT outputCode INT(11)
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 THEN
INSERT INTO projects SELECT p.ID AS projectID, p.name AS projectName, v.ID AS versionID , v.name AS versionName FROM projets AS p LEFT JOIN versions AS v ON p.ID = v.projectID WHERE (p.ownerID = p_sid OR CheckInGroup(p_sid,p.secondaryOwnersGroupID) = 42) AND (v.ID IS NULL OR v.versionAbs = (SELECT MAX(versionAbs) FROM versions WHERE projectID = p.ID));
END IF;
END//
DELIMITER ;

View File

@ -0,0 +1,19 @@
DROP PROCEDURE IF EXISTS GetPublicProjectsForPresentation;
DELIMITER //
CREATE PROCEDURE GetPublicProjectsForPresentation
(
IN p_sid TEXT,
IN p_password TEXT,
OUT outputCode INT(11)
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 OR outputCode = 2005 THEN
SET outputCode = 42;
INSERT INTO projects SELECT p.ID AS projectID, p.name AS projectName, v.ID AS versionID , v.name AS versionName FROM projets AS p LEFT JOIN versions AS v ON p.ID = v.projectID WHERE (p.ownerID = 1 OR CheckInGroup(1,p.secondaryOwnersGroupID) = 42 OR CheckInGroup(1,p.authorizedGroupID) = 42) AND (v.ID IS NULL OR v.versionAbs = (SELECT MAX(versionAbs) FROM versions WHERE projectID = p.ID));
END IF;
END//
DELIMITER ;

21
sql/getVisibleDiscuts.sql Normal file
View File

@ -0,0 +1,21 @@
DROP PROCEDURE IF EXISTS GetVisibleDiscuts;
DELIMITER //
CREATE PROCEDURE GetVisibleDiscuts
(
IN p_sid TEXT,
IN p_password TEXT,
OUT outputCode INT(11),
OUT canCreate INT(1)
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 OR outputCode = 2005 THEN
SET outputCode = 42;
SELECT adminLevel > 8 INTO canCreate FROM membres WHERE ID=p_sid;
INSERT INTO discuts SELECT d.ID AS ID, d.name AS Name, m.pseudo AS creatorPseudo FROM discussions AS d LEFT JOIN membres AS m ON d.creatorID = m.ID WHERE CheckInGroup(p_sid,authorizedGroupId) = 42;
END IF;
END//
DELIMITER ;

24
sql/headerInfos.sql Normal file
View File

@ -0,0 +1,24 @@
DROP PROCEDURE IF EXISTS HeaderInfos;
DELIMITER //
CREATE PROCEDURE HeaderInfos
(
IN p_sid TEXT,
IN p_password TEXT,
OUT outputCode INT(11),
OUT o_connected INT(1),
OUT o_pseudo VARCHAR(255)
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 THEN
SELECT pseudo INTO o_pseudo FROM membres WHERE ID = p_sid;
SET o_connected = 1;
ELSE
SET outputCode = 42;
SET o_connected = 0;
END IF;
END//
DELIMITER ;

46
sql/postMessage.sql Normal file
View File

@ -0,0 +1,46 @@
DROP PROCEDURE IF EXISTS PostMessage;
DELIMITER //
CREATE PROCEDURE PostMessage
(
IN p_sid INT,
IN p_password TEXT,
IN p_did INT,
IN p_text TEXT,
OUT outputCode INT,
OUT mid INT
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 THEN
SET outputCode :=(
SELECT
(
CASE
WHEN(
SELECT
COUNT(*)
FROM
discussions
WHERE
ID = p_did
) = 1 THEN 2010
ELSE 42
END
)
);
IF outputCode = 42 THEN
SET @authorizedGroupID :=(SELECT authorizedGroupID FROM discussions WHERE ID=p_did);
CALL `CheckInGroup`(p_sid, @authorizedGroupID, outputCode);
IF outputCode = 42 THEN
INSERT INTO messages(texte,senderID,sendTime,discussionID) VALUES (p_text,p_sid,NOW(),p_did);
SET mid :=(SELECT LAST_INSERT_ID());
END IF;
END IF;
END IF;
END//
DELIMITER ;

30
sql/presentProject.sql Normal file
View File

@ -0,0 +1,30 @@
DROP PROCEDURE IF EXISTS PresentProject;
DELIMITER //
CREATE PROCEDURE PresentProject
(
IN p_sid INT,
IN p_password TEXT,
IN p_pid INT,
OUT outputCode INT(11),
OUT o_public INT(1),
OUT o_name VARCHAR(255),
OUT o_ownerID INT,
OUT o_ownerPseudo VARCHAR(255)
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 OR outputCode = 2005 THEN
SET outputCode := (SELECT (CASE WHEN (SELECT CheckInGroup(p_sid,authorizedGroupId) = 42 OR CheckInGroup(p_sid,secondaryOwnersGroupId) = 42 OR p_sid = ownerID FROM projets WHERE ID = p_pid) THEN 42 ELSE 2017 END));
IF outputCode = 42 THEN
SELECT authorizedGroupId = 1 AS public, name INTO o_public, o_name FROM projets WHERE projets.ID = p_pid;
SELECT membres.pseudo, membres.ID INTO o_ownerPseudo, o_ownerID FROM membres INNER JOIN projets ON projets.ownerID = membres.ID WHERE projets.ID = p_pid;
INSERT INTO verzions SELECT languageID AS language, ID, name FROM versions WHERE projectID = p_pid;
INSERT INTO sowners SELECT pseudo FROM membres INNER JOIN projets ON projets.ownerID != membres.ID AND CheckInGroup(membres.ID,projets.secondaryOwnersGroupID) = 42 WHERE projets.ID = p_pid;
END IF;
END IF;
END//
DELIMITER ;

34
sql/presentVersion.sql Normal file
View File

@ -0,0 +1,34 @@
DROP PROCEDURE IF EXISTS PresentVersion;
DELIMITER //
CREATE PROCEDURE PresentVersion
(
IN p_sid INT,
IN p_password TEXT,
IN p_vid INT,
OUT outputCode INT(11),
OUT o_su INT(1),
OUT o_ssu INT(1),
OUT o_langageID INT,
OUT o_projectName VARCHAR(255),
OUT o_name VARCHAR(255),
OUT o_fileAccessibility INT,
OUT o_projectID INT,
OUT o_tags INT
)
MODIFIES SQL DATA
BEGIN
CALL `CheckIdLogin`(p_sid,p_password, outputCode);
IF outputCode = 42 OR outputCode = 2005 THEN
SET outputCode := (SELECT (CASE WHEN (SELECT CheckInGroup(p_sid,authorizedGroupId) = 42 OR CheckInGroup(p_sid,secondaryOwnersGroupId) = 42 OR p_sid = ownerID FROM projets INNER JOIN versions ON versions.projectID = projets.ID WHERE versions.ID = p_vid) THEN 42 ELSE 2018 END));
IF outputCode = 42 THEN
SELECT CheckInGroup(p_sid,projets.secondaryOwnersGroupId) = 42 OR projets.ownerID = p_sid, projets.ownerID = p_sid, versions.languageID, projets.name,versions.name,versions.fileAccessibility,projets.ID,versions.tags INTO o_su,o_ssu,o_langageID,o_projectName,o_name,o_fileAccessibility,o_projectID,o_tags FROM projets INNER JOIN versions ON versions.projectID = projets.ID WHERE versions.ID = p_vid;
INSERT INTO verzions SELECT languageID AS language, ID, name FROM versions WHERE projectID = o_projectID;
END IF;
END IF;
END//
DELIMITER ;

33
sql/registerPerson.sql Normal file
View File

@ -0,0 +1,33 @@
DROP PROCEDURE IF EXISTS RegisterPerson;
DELIMITER //
CREATE PROCEDURE RegisterPerson
(
IN p_pseudo TEXT,
IN p_password TEXT,
OUT outputCode INT
)
MODIFIES SQL DATA
BEGIN
SET outputCode :=(
SELECT
(
CASE
WHEN LENGTH(p_pseudo) > 255 THEN 2002
WHEN CAST(p_pseudo AS BINARY) NOT REGEXP BINARY '^[-a-zA-Z0-9\_]+$' THEN 2003
WHEN(
SELECT
COUNT(*)
FROM
membres
WHERE
pseudo = p_pseudo
) > 0 THEN 2004
ELSE 42
END
)
);
IF outputCode = 42 THEN INSERT INTO membres(pseudo,hashedPassword,dateCreation) VALUES (CAST(p_pseudo AS CHAR(255)),MD5(p_password),NOW()); END IF;
END//
DELIMITER ;

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