Compare commits
10 Commits
20a9f135e7
...
66ac4b8973
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66ac4b8973 | ||
|
|
3488323439 | ||
|
|
e59898b0bb | ||
|
|
38ec48c9fc | ||
|
|
228f54d140 | ||
|
|
fba5123944 | ||
|
|
c9589d2cf6 | ||
|
|
6c9434e092 | ||
|
|
b3975e3cd1 | ||
|
|
2ea296cd61 |
49
404.php
49
404.php
@ -2,42 +2,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<base href="http://www.bernard.890m.com/"/>
|
||||
<?php include 'includes/meta.php'; ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php include 'includes/header.php'; ?>
|
||||
|
||||
<h1>404 Not Found</h1>
|
||||
<p>La page demandée demeure introuvable.<br/>
|
||||
Cette derniè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écédente" /></a><br/>
|
||||
|
||||
Si vous le voulez , vous pouvez essayer de trouver le code html de votre page web là dedans:<br/>
|
||||
|
||||
<div id="universe_text">
|
||||
|
||||
</div>
|
||||
<div id="add_universe">Plus</div>
|
||||
<script>
|
||||
var charsMaxPerPlus = 1000;
|
||||
var n = 1;
|
||||
var clics = 0;
|
||||
var plus = document.getElementById('add_universe');
|
||||
function addUniverseText(){
|
||||
var textToAdd = '';
|
||||
clics+=1;
|
||||
while(textToAdd.length < charsMaxPerPlus*clics){
|
||||
textToAdd+=n*n;
|
||||
n+=1;
|
||||
}
|
||||
var div = document.getElementById("universe_text");
|
||||
div.innerHTML+=textToAdd;
|
||||
<p>
|
||||
La page demandée demeure introuvable.<br/>
|
||||
Cette dernière n'existe plus ou pas encore.<br/>
|
||||
Bah au pire c'est pareil xD
|
||||
</p>
|
||||
|
||||
<button onclick="window.history.go(-1);" >Page précédente</button><br/>
|
||||
|
||||
<?php
|
||||
switch(rand(0,1)){
|
||||
case 1:
|
||||
include 'allein/pieces.php';
|
||||
break;
|
||||
default:
|
||||
include 'allein/univers.php';
|
||||
|
||||
}
|
||||
plus.onclick = addUniverseText;
|
||||
addUniverseText();
|
||||
</script>
|
||||
|
||||
?>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
306
admin.php
Normal file
306
admin.php
Normal 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érification)"/></span><br/>
|
||||
<span class="facultatif">Date de création :<input type="text" class="addCommanderAttribute dateCreation" alt="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de réception de la requête" title="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de réception de la requête"/></span><br/>
|
||||
<span class="facultatif">Bannière :<input type="text" class="addCommanderAttribute banniere" alt="Un chemin vers une image, si vide, alors utilise la bannière de base" title="Un chemin vers une image, si vide, alors utilise la bannière de base"/></span><br/>
|
||||
<span class="facultatif">Message :<input type="text" class="addCommanderAttribute message" alt="Une chaine de caractères, si vide, aucun message ne sera affiché" title="Une chaine de caractères, si vide, aucun message ne sera affiché"/></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éateur :<input type="text" class="addCommanderAttribute createur" alt="Un sélécteur de membre ou un nombre (ID du membre)" title="Un sélécteur de membre ou un nombre (ID du membre)"/></span><br/>
|
||||
<span class="facultatif">Date de création :<input type="text" class="addCommanderAttribute dateCreation" alt="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de réception de la requête" title="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de réception de la requête"/></span><br/>
|
||||
<span class="facultatif">Autorisations :<input type="text" class="addCommanderAttribute autorisations" alt="Une chaine de la forme permission : a10 -> niveau d'administration ≥ 10 p -> pas de restrictions x13,35,87 -> autorise les membres à l'ID égal à 13, 35 ou 87 Si vide, publique" title="Une chaine de la forme permission : a10 -> niveau d'administration ≥ 10 p -> pas de restrictions x13,35,87 -> autorise les membres à l'ID égal à 13, 35 ou 87 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élécteur de membre ou un nombre (ID du membre)" title="Un sélé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éception de la requête" title="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de réception de la requê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élécteur de membre ou un nombre (ID du membre)" title="Un sélé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 0->Java 1->VBA Si vide, 0 sélectionné (Java)" title="Un nombre correspondant au langage de programmation 0->Java 1->VBA Si vide, 0 sélectionné (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élécteur de membre ou un nombre (ID du membre)" title="Un sélé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 :«<span id="currentCommand">...</span>»
|
||||
<button id="send">Envoyer la requê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
283
admindialog.php
Normal 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
156
allein/pieces.html
Normal 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
60
allein/univers.php
Normal file
@ -0,0 +1,60 @@
|
||||
Si vous le voulez , vous pouvez essayer de trouver le code html de votre page web là 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','?',',',';','.','/',':','!','&','"','<','>','#','{','(','[','-','|','\\','_','@',')',']','=','}','+',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '];
|
||||
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>
|
||||
|
||||
@ -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 à bien été changé !</div>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
</body>
|
||||
</html>
|
||||
27
clazz/2/Article.class.php
Normal file
27
clazz/2/Article.class.php
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
88
clazz/2/Discussion.class.php
Normal file
88
clazz/2/Discussion.class.php
Normal 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éation doit être de la forme "AAAA:MM:JJ hh:mm:ss"';
|
||||
const DATE_CREATION_CHANGED = 'La date de création a bien été changée';
|
||||
}
|
||||
88
clazz/2/Langage.class.php
Normal file
88
clazz/2/Langage.class.php
Normal 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");
|
||||
327
clazz/2/MegaStockage.class.php
Normal file
327
clazz/2/MegaStockage.class.php
Normal 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ères)';
|
||||
const PASSWORD_CHANGED = 'Le mot de passe a bien été changé';
|
||||
|
||||
//registerPerson
|
||||
const USED_USERNAME = 'Le pseudonyme est déjà utilisé';
|
||||
const PERSON_REGISTERED = 'Le membre a bien été inscrit !';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
75
clazz/2/Membre.class.php
Normal file
75
clazz/2/Membre.class.php
Normal 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
32
clazz/2/Message.class.php
Normal 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
96
clazz/2/Projet.class.php
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
30
clazz/2/SQLProcessingException.class.php
Normal file
30
clazz/2/SQLProcessingException.class.php
Normal 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
153
clazz/2/Utility.class.php
Normal 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é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éjà été correctement inscrit sur bernard.com';
|
||||
const SUCESSFULLY_LOGGED_IN = 'Vous êtes bien connecté (vous l\'avez été et le serez également)!';
|
||||
const SUCESSFULLY_CHANGED_PASSWORD = 'Vos dispositifs d\'identification ont été correctement changés';
|
||||
const SUCESSFULLY_CREATED_DISCUSSION = 'C\'est fait !!! (la création de ta discussion bien sûr)';
|
||||
|
||||
const LOGIN_NEEDED_FOR_PROJECTS = 'Je veut bien être un site web parfait, mais j\'aimerai bien qut tu te connècte pour que je puisse te montrer tes projets';
|
||||
|
||||
}
|
||||
58
clazz/2/Version.class.php
Normal file
58
clazz/2/Version.class.php
Normal 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
20
clazz/2/Zincluder.php
Normal 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
145
clazz/Article.class.php
Normal 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
234
clazz/Discussion.class.php
Normal 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 éèàμ_\\-\'()\\[\\]\\\\/,;:.§!ù%£$¤=+\\-*\\#~"|ç@';
|
||||
$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éjà utilisé';
|
||||
const ILLEGAL_NAME = 'Le nom de la discussion est incorrect : les caractères autorisés sont :'.
|
||||
'<br/> abcdefghijklmnopqrstuvwxyz<wbr/>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<wbr/>'.
|
||||
'éèàμ_-\'()[\\]\\\\/<wbr/>,;:.§!ù%£$¤=+-*\\#~"|ç@';
|
||||
const TOO_LONG_NAME = 'Le nom est trop long : maximum 256 caractères';
|
||||
const NAME_CHANGED = 'Le nom a bien été changé !';
|
||||
|
||||
//changeAccessibility()
|
||||
const MALFORMED_ACCESSIBILITY = 'L\'accessibilité doit être de la forme : "p" ou "x31;41;59;26;53" ou "a42"';
|
||||
const ACCESSIBILITY_CHANGED = 'L\'accessibilité a bien été changée !';
|
||||
|
||||
//setDateCreation()
|
||||
const MALFORMED_DATE = 'La date de création doit être de la forme "AAAA:MM:JJ hh:mm:ss"';
|
||||
const DATE_CREATION_CHANGED = 'La date de création a bien été changée';
|
||||
}
|
||||
71
clazz/Langage.class.php
Normal file
71
clazz/Langage.class.php
Normal 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");
|
||||
327
clazz/MegaStockage.class.php
Normal file
327
clazz/MegaStockage.class.php
Normal 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ères)';
|
||||
const PASSWORD_CHANGED = 'Le mot de passe a bien été changé';
|
||||
|
||||
//registerPerson
|
||||
const USED_USERNAME = 'Le pseudonyme est déjà utilisé';
|
||||
const PERSON_REGISTERED = 'Le membre a bien été inscrit !';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
385
clazz/Membre.class.php
Normal file
385
clazz/Membre.class.php
Normal 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ères)';
|
||||
const PASSWORD_CHANGED = 'Le mot de passe a bien été changé';
|
||||
|
||||
//registerPerson
|
||||
const USED_USERNAME = 'Le pseudonyme est déjà utilisé';
|
||||
const PERSON_REGISTERED = 'Le membre a bien été inscrit !';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
143
clazz/Message.class.php
Normal file
143
clazz/Message.class.php
Normal 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
251
clazz/Projet.class.php
Normal 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
139
clazz/Utility.class.php
Normal 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ê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ères autorisés sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
|
||||
public static const InvalidPassword = 'Le mot de passe fut incorrect : Les seuls caractères autorisés sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&éèàùçμ"#\'{}()[]|^@<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ésident","Ministres");
|
||||
}
|
||||
|
||||
}
|
||||
346
clazz/Version.class.php
Normal file
346
clazz/Version.class.php
Normal 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
21
clazz/Zincluder.php
Normal 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
19
clazz/Zincluder_old.php
Normal 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
29
css/adminStyle.css
Normal 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
4
css/firefoxStyle.css
Normal file
@ -0,0 +1,4 @@
|
||||
*::-moz-selection {
|
||||
background-color: rgb(100, 200, 40);
|
||||
color: #222;
|
||||
}
|
||||
4
css/noFirefoxStyle.css
Normal file
4
css/noFirefoxStyle.css
Normal file
@ -0,0 +1,4 @@
|
||||
*::selection {
|
||||
background-color: rgb(100, 200, 40);
|
||||
color: #222;
|
||||
}
|
||||
404
css/style.css
404
css/style.css
@ -1,224 +1,370 @@
|
||||
/* 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 {
|
||||
background-color: #222;
|
||||
color: rgb(100, 200, 40);
|
||||
text-align: center;
|
||||
color: rgb(100, 200, 40);
|
||||
}
|
||||
|
||||
body{
|
||||
body {
|
||||
background-color: #222;
|
||||
color: rgb(100, 200, 40);
|
||||
text-align: center;
|
||||
color: rgb(100, 200, 40);
|
||||
text-align : center;
|
||||
}
|
||||
|
||||
body::selection, br::selection {
|
||||
background-color: rgb(100, 200, 40);
|
||||
color: #222;
|
||||
article{
|
||||
margin: 20px;
|
||||
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 {
|
||||
margin: 20px;
|
||||
padding: 5px;
|
||||
border: 3px #999 outset;
|
||||
h1 {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: #222;
|
||||
color: rgb(100, 200, 40);
|
||||
margin: 0px;
|
||||
padding: 10px;
|
||||
border-bottom: 3px rgb(100, 200, 40) solid;
|
||||
text-align: center;
|
||||
color: rgb(100, 200, 40);
|
||||
margin: 0px;
|
||||
padding: 10px;
|
||||
border-bottom: 3px rgb(100, 200, 40) solid;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
header a {
|
||||
color: rgb(100, 200, 40);
|
||||
}
|
||||
|
||||
nav {
|
||||
text-align: center;
|
||||
color: rgb(100, 200, 40);
|
||||
}
|
||||
|
||||
#navLinks a {
|
||||
color: rgb(100, 200, 40);
|
||||
padding-left: 70px;
|
||||
padding-right: 70px;
|
||||
background-color: #222;
|
||||
font-size: 4ex;
|
||||
border: 3px rgb(100, 200, 40) outset;
|
||||
border-collapse: collapse;
|
||||
text-decoration: none;
|
||||
color: rgb(100, 200, 40);
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
font-size: 4ex;
|
||||
border: 3px rgb(100, 200, 40) outset;
|
||||
border-collapse: collapse;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
footer {
|
||||
border-top: 10px rgb(100, 200, 40) double;
|
||||
background-color: #222;
|
||||
text-align: center;
|
||||
height: 250px
|
||||
border-top: 10px rgb(100, 200, 40) double;
|
||||
text-align: center;
|
||||
height: 250px
|
||||
}
|
||||
|
||||
#bienvenue {
|
||||
border-bottom: 3px rgb(100, 200, 40) solid;
|
||||
font-size: 20px;
|
||||
border-bottom: 3px rgb(100, 200, 40) solid;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
#bande {
|
||||
display: block;
|
||||
padding-bottom: 5px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: block;
|
||||
padding-bottom: 0px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
#copyright {
|
||||
float: left;
|
||||
color: rgb(100, 200, 40);
|
||||
float: left;
|
||||
color: rgb(100, 200, 40);
|
||||
}
|
||||
|
||||
#me_contacter {
|
||||
float: right;
|
||||
color: rgb(100, 200, 40);
|
||||
#nous_contacter {
|
||||
float: right;
|
||||
color: rgb(100, 200, 40);
|
||||
}
|
||||
|
||||
a #haut_de_page {
|
||||
background-color: rgb(100, 200, 40);
|
||||
color: #222;
|
||||
position: relative;
|
||||
top: 10px;
|
||||
padding: 10px;
|
||||
background-color: rgb(100, 200, 40);
|
||||
color: #222;
|
||||
position: relative;
|
||||
top: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
/* 404 */
|
||||
#universe_text{
|
||||
#universe_text {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
#add_universe{
|
||||
|
||||
#add_universe {
|
||||
text-align: center;
|
||||
margin : 50px auto;
|
||||
margin: 15px auto;
|
||||
border: 5px solid rgb(100, 200, 40);
|
||||
background-color: #222;
|
||||
}
|
||||
|
||||
|
||||
/* Login & Register */
|
||||
|
||||
|
||||
#loginForm {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 100px;
|
||||
margin-top: 100px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 100px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
#headDisconnectForm {
|
||||
display: inline;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#disconnectText, #passwordChangedText {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 100px;
|
||||
margin-top: 20px;
|
||||
font-size: 30px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 100px;
|
||||
margin-top: 20px;
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
#headLoginForm {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 0px;
|
||||
margin-top: 0px;
|
||||
display: inline;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 0px;
|
||||
margin-top: 0px;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#headLittleLoginForm {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 0px;
|
||||
margin-top: 0px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#headRegisterForm {
|
||||
display: inline;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#registerForm, #changePasswordForm{
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 100px;
|
||||
margin-top: 20px;
|
||||
#registerForm, #changePasswordForm {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 100px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
|
||||
/* Projet/Versions */
|
||||
|
||||
|
||||
.project_option_img {
|
||||
display: inline;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.disabeled{
|
||||
opacity : 0.2;
|
||||
.disabeled {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.project_option {
|
||||
|
||||
color:#222;
|
||||
}
|
||||
|
||||
.versionTable {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-bottom: 50px;
|
||||
margin-top: 0px;
|
||||
border-collapse: collapse;
|
||||
display: inline;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td, th {
|
||||
background-color: #222;
|
||||
color: rgb(100, 200, 40);
|
||||
text-align: center;
|
||||
border: 1px solid black;
|
||||
color: rgb(100, 200, 40);
|
||||
text-align: center;
|
||||
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 */
|
||||
|
||||
|
||||
.nav2x2{
|
||||
display:none;
|
||||
/* HEADER STYLE */
|
||||
.nav3x2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.navV{
|
||||
display:none;
|
||||
#navLinks a {
|
||||
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 */
|
||||
#bande{
|
||||
display:none;
|
||||
.navV {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1050px) { /* Cacher bandeau */
|
||||
#bande {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 705px){ /* Cacher login/register */
|
||||
#headLoginForm , #headRegisterForm{
|
||||
display:none;
|
||||
@media screen and (max-width: 705px) { /* Cacher login/register */
|
||||
#headLoginForm {
|
||||
display: none;
|
||||
}
|
||||
#headLittleLoginForm {
|
||||
display: inline
|
||||
}
|
||||
#headLittleLoginForm {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1180px){ /* Afficher nav2x2 */
|
||||
.nav2x2{
|
||||
display:inline;
|
||||
@media screen and (max-width: 1180px) { /* Afficher nav3x2 */
|
||||
.nav2x3 {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 400px) { /* Afficher navV */
|
||||
.navV {
|
||||
display: inline;
|
||||
}
|
||||
#navLinks a {
|
||||
display: inline-block;
|
||||
width : 250px;
|
||||
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;
|
||||
width: 200px;
|
||||
font-size: 2ex;
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
158
discut.php
Normal 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&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
59
discuts.php
Normal 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é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
415
executor.php
Normal 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éconnexion se sera correctement passée!';
|
||||
|
||||
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
423
extras/Nexecutor.php
Normal 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ées, on donne des données !!!');
|
||||
if ($_POST ['mdp'] === $_POST ['mdp2'])
|
||||
exiting('Tu auras du rentrer deux fois le mê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ères autorisé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ères autorisés sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&éèàùçμ"#\'{}()[]|^@<40>+=$<24><>*!<21>:/;.,?<3F>');
|
||||
|
||||
$out = Membre::registerPerson ($_POST ['pseudo'],$_POST ['mdp']);
|
||||
if($out ===Membre::USED_USERNAME)
|
||||
exiting('Le pseudonyme est déjà utilisé (par une entité differente de vous)');
|
||||
exiting('Vous avez déjà été correctement inscrit sur bernard.com','login.php');
|
||||
|
||||
case 'login' :
|
||||
//Action : login
|
||||
if (!( isset ( $_POST ['pseudo'] ) && isset ( $_POST ['mdp'] ) ))
|
||||
exiting('Quand on demande des données, on donne des données !!!');
|
||||
$me = Membre::getFromPseudo($_POST['pseudo']);
|
||||
if(!$me)
|
||||
exiting('Kikètvou ? Pseudo inconnu ...');
|
||||
if(!$me->connect($_POST ['mdp']))
|
||||
exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$_SESSION['session_id'] = $me->getID();
|
||||
$_SESSION['session_mdp'] = $_POST['mdp'];
|
||||
exiting('Vous êtes bien connecté (vous l\'avez été et le serez également)!');
|
||||
|
||||
case 'changePassword' :
|
||||
//Action : change password
|
||||
if(!(isset($_POST['rmdp']) && isset($_POST['nmdp']) && isset($_POST['nmdp2'])))
|
||||
exiting('Quand on demande des données, on donne des donné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étinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
if($_POST['nmdp'] !== $_POST['nmdp2'])
|
||||
exiting('Tu auras du rentrer deux fois le mê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 ≠ roman (255 caractères maximum)');
|
||||
exiting('Vos dispositifs d\'identification ont été correctement changés');
|
||||
|
||||
case 'createDiscussion' :
|
||||
//Action : create discussion
|
||||
if(!isset($_POST['name']))
|
||||
exiting('Quand on demande des données, on donne des données !!!');
|
||||
if(!$me)
|
||||
exiting('Veuillez vous identifier pour acceder à cette section !!!');
|
||||
if(!$me->connect($_SESSION['session_mdp']))
|
||||
exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
if($me->isAdminLevelLowerThan(2))
|
||||
exiting('Vous n\'ê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éjà utilisé l\'é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é à ta discussion ...<br/>Je n\'accepte que les caractères abcdefghijklmnopqrstuvwxyz<wbr/>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<wbr/>éèàμ_-\'()[\\]\\\\/<wbr/>,;:.§!ù%£$¤=+-*\\#~"|ç@');
|
||||
if($out === Discussion::TOO_LONG_NAME)
|
||||
exiting('Nom de discussion ≠ roman (255 caractères maximum)');
|
||||
exiting('C\'est fait !!! (la création de ta discussion bien sûr)');
|
||||
|
||||
case 'postMessage' :
|
||||
//Action : post message
|
||||
if(!$me)
|
||||
exiting('Veuillez vous identifier pour acceder à cette section !!!');
|
||||
if(!$me->connect($_SESSION['session_mdp']))
|
||||
exiting($me.'Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$discussion = new Discussion($_GET ['d']);
|
||||
if(!$discussion->exists())
|
||||
exiting('Pour des raisons d\'intégrité du site, nous avons décidé 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 écrire des messages dans une discussion à laquelle tu n\'as pas accès !!! Tu te crois où ?');
|
||||
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étinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$message = new Message($_GET['m']);
|
||||
if(!$message->exists())
|
||||
exiting('Je vais avoir du mal à supprimer le message n&ecute;ant ...');
|
||||
if($me->isAdminLevelLowerThan(6) && $me->getID() !== $message->getSender()->getID())
|
||||
exiting('Vous n\'ê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ées, on donne des données !!!');
|
||||
if(!$me)
|
||||
exiting('Veuillez vous identifier pour éditer une version !!!');
|
||||
if(!$me->connect($_SESSION['session_mdp']))
|
||||
exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$version = new Version($_GET['v']);
|
||||
if(!$version->exists())
|
||||
exiting('Je vais avoir du mal à éditer la version n&ecute;ant ...');
|
||||
if($me->isAdminLevelLowerThan(13) && $version->getProject()->haveRights($me))
|
||||
exiting('Vous n\'ê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étinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)';
|
||||
exit;
|
||||
}
|
||||
$discut = new Discussion($_GET ['d']);
|
||||
if(!$discut->exists()){
|
||||
echo 'Quand on demande des données, on donne des donné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étinale, digitale et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)';
|
||||
exit;
|
||||
}
|
||||
$projet = new Projet($_GET ['p']);
|
||||
if(!$projet->exists()){
|
||||
echo 'Quand on demande des données, on donne des donné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étinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$projet = new Projet($_GET['p']);
|
||||
if(!$projet->exists())
|
||||
exiting('Je vais avoir du mal à supprimer un des propriétaires du projet néant ...');
|
||||
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
|
||||
exiting('Vous n\'ê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étinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$projet = new Projet($_GET['p']);
|
||||
if(!$projet->exists())
|
||||
exiting('Je vais avoir du mal à ajouter un propriétaires au projet néant ...');
|
||||
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
|
||||
exiting('Vous n\'ê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é"d\'un projet !!!');
|
||||
if(!$me->connect($_SESSION['session_mdp']))
|
||||
exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$projet = new Projet($_GET['p']);
|
||||
|
||||
if(!$projet->exists())
|
||||
exiting('Je vais avoir du mal à ajouter un propriétaires au projet néant ...');
|
||||
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
|
||||
exiting('Vous n\'ê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étaire d\'un projet !!!');
|
||||
if(!$me->connect($_SESSION['session_mdp']))
|
||||
exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$projet = new Projet($_GET['p']);
|
||||
if(!$projet->exists())
|
||||
exiting('Je vais avoir du mal à changer le propriétaires au projet néant ...');
|
||||
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
|
||||
exiting('Vous n\'ê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éant , le touveau proprié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étinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$projet = new Projet($_GET['p']);
|
||||
if(!$projet->exists())
|
||||
exiting('Je vais avoir du mal à supprimer le projet néant ...');
|
||||
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
|
||||
exiting('Vous n\'ê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étinale, digitale et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)';
|
||||
exit;
|
||||
}
|
||||
$projet = new Projet($_GET ['p']);
|
||||
if(!$projet->exists()){
|
||||
echo 'Quand on demande des données, on donne des donné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étinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$projet = new Projet($_GET['p']);
|
||||
if(!$projet->exists())
|
||||
exiting('Je vais avoir du mal à ajouter une version au projet néant ...');
|
||||
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
|
||||
exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre proprié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 éditer une version !!!');
|
||||
if(!$me->connect($_SESSION['session_mdp']))
|
||||
exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$version = new Version($_GET['v']);
|
||||
if(!$version->exists())
|
||||
exiting('Je vais avoir du mal à éditer la version néant ...');
|
||||
if(!($me->getID() == $version->getProject()->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
|
||||
exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre proprié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étinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
|
||||
$version = new Version($_GET['p']);
|
||||
if(!$version->exists())
|
||||
exiting('Je vais avoir du mal à supprimer la version néant ...');
|
||||
if(!($me->getID() == $version->getProject()->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
|
||||
exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propriétaire du projet');
|
||||
$version->delete();
|
||||
echo 'ok';
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once 'includes/bdd.php';
|
||||
include_once 'includes/inter.php';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@ -9,7 +9,8 @@ include_once 'includes/bdd.php';
|
||||
</head>
|
||||
<body>
|
||||
<?php include 'includes/header.php'; ?>
|
||||
|
||||
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
</body>
|
||||
</html>
|
||||
47
extras/downloadJar.php
Normal file
47
extras/downloadJar.php
Normal 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
15
extras/dumpBDD.sh
Normal 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
34
extras/editVersion.php
Normal 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'];?>&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
262
extras/inter.php
Normal 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
57
extras/mandelbrot.html
Normal 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
88
extras/megaProcess.php
Normal 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
46
extras/newVersion.php
Normal 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éer une nouvelle version" />
|
||||
</form>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
end:
|
||||
?>
|
||||
108
extras/sortBDD.php
Normal file
108
extras/sortBDD.php
Normal 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ésseur<br/>';
|
||||
}else{
|
||||
echo '--------' . 'Owners :'.$p['ownersID'].' à '.$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
9
extras/test.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
include_once 'clazz/Zincluder.php';
|
||||
|
||||
$out = Membre::registerPerson ("moi","pwd");
|
||||
|
||||
var_dump($out);
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
try{
|
||||
//$bdd = new PDO('mysql:host=localhost;dbname=bernard.com;charset=utf8', 'root', '');
|
||||
$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************');
|
||||
$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', '*******************');
|
||||
}catch(Exception $e){
|
||||
die ('Erreur : ' . $e->getMessage());
|
||||
die ('Erreur : ' . $e->getMessage() . "\n");
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
100
includes/cards.html
Normal file
100
includes/cards.html
Normal file
@ -0,0 +1,100 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html" charset="utf-8"/>
|
||||
<title>Cartajoué</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>
|
||||
@ -9,4 +9,22 @@
|
||||
</div>
|
||||
|
||||
<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']);
|
||||
} ?>
|
||||
|
||||
@ -1,40 +1,57 @@
|
||||
<?php include_once 'clazz/Zincluder.php'; ?>
|
||||
<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'])){
|
||||
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp']));
|
||||
$rep = $req->fetch();
|
||||
}if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && isset($rep['pseudo']) ){
|
||||
|
||||
<!--
|
||||
000000000000000800000000000000000000000000000000000000000000000000000
|
||||
000000000000008000000000000000000000000000000000000000000000000000000
|
||||
000000000000080000000000000888000000000000000000000000000000000000000
|
||||
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 à toi ,<?php echo $rep['pseudo']; ?>
|
||||
<form id="headDisconnectForm" method="post" action="disconnect.php">
|
||||
<input type="submit" value="Se déconnecter" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="bienvenue">Bienvenue à toi, <?php echo $me['pseudo']; ?>
|
||||
<form id="headDisconnectForm" method="post" action="executor.php?action=disconnect">
|
||||
<input type="submit" value="Se déconnecter" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php }else{ ?>
|
||||
|
||||
<form id="headLoginForm" method="post" action="logging.php">
|
||||
<label for="pseudo">Pseudo :</label>
|
||||
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" required />
|
||||
<label for="mdp">Mot de passe :</label>
|
||||
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" required />
|
||||
<input type="Submit" value="Se connecter" />
|
||||
</form>
|
||||
|
||||
<form id="headRegisterForm" method="post" action="register.php">
|
||||
<input type="submit" value="S'inscrire" />
|
||||
<br/>
|
||||
</form>
|
||||
<form id="headLoginForm" method="post" action="executor.php?action=login">
|
||||
<label for="pseudo">Pseudo :</label>
|
||||
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" />
|
||||
<label for="mdp">Mot de passe :</label>
|
||||
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" />
|
||||
<input type="submit" value="Se connecter" />
|
||||
</form>
|
||||
<form id="headLittleLoginForm" method="post" action="login.php">
|
||||
<input type="submit" value="Se connecter" />
|
||||
</form>
|
||||
<form id="headRegisterForm" method="post" action="register.php">
|
||||
<input type="submit" value="S'inscrire" />
|
||||
</form>
|
||||
|
||||
<?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">
|
||||
<a href="index.php">Acceuil</a><br class="navV"/>
|
||||
<a href="projets.php">Mes Projets</a><br class="nav2x2"/>
|
||||
<a href="index.php">Accueil</a><br class="navV"/>
|
||||
<a href="projets.php">Mes Projets</a><br class="nav3x2 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"/>
|
||||
</nav>
|
||||
</header>
|
||||
</header>
|
||||
|
||||
@ -1,32 +1,127 @@
|
||||
<?php
|
||||
include_once 'includes/bdd.php';
|
||||
function isConnected2S($username, $mdp) {
|
||||
$req = $bdd->prepare ( 'SELECT * FROM users WHERE ID=? AND mdp=?' );
|
||||
function isConnected($sid = NULL, $mdp = NULL) {
|
||||
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 (
|
||||
$username,
|
||||
$mdp
|
||||
$sid
|
||||
) );
|
||||
return ( bool ) $req->fetch ();
|
||||
if ($rep = $req->fetch ()) {
|
||||
$connected = password_verify ( $mdp, $rep ['mdp'] );
|
||||
} else {
|
||||
$connected = FALSE;
|
||||
}
|
||||
$req->closeCursor ();
|
||||
return $connected;
|
||||
}
|
||||
function isConnected() {
|
||||
return isConnected2S ( $_SESSION ['session_id'], $_SESSION ['session_mdp'] );
|
||||
}
|
||||
function getProjectVersionDataFromIDs($project, $version) {
|
||||
$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 = ?' );
|
||||
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 (
|
||||
$_GET ['id'],
|
||||
$_GET ['v']
|
||||
$sid
|
||||
) );
|
||||
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 ())) {
|
||||
$req->closeCursor ();
|
||||
return $data;
|
||||
} else {
|
||||
$req->closeCursor ();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
function getProjectVersionData() {
|
||||
return getProjectVersionDataFromIds ( $_GET ['id'], $_GET ['v'] );
|
||||
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 getPermissionsFromData($data) {
|
||||
function getPermissions($data) {
|
||||
$permissions = array (
|
||||
FALSE,
|
||||
FALSE,
|
||||
@ -37,6 +132,196 @@ function getPermissionsFromData($data) {
|
||||
$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']->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();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@ -1,11 +1,29 @@
|
||||
<title>Le site de tous les bernards !</title>
|
||||
<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" />
|
||||
<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 type="text/javascript" async
|
||||
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var headBloc = document.getElementsByTagName("head")[0];
|
||||
//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
124
index.php
@ -2,124 +2,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php include 'includes/meta.php'; ?></head>
|
||||
<?php include 'includes/meta.php'; ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php include 'includes/header.php'; ?>
|
||||
|
||||
<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>
|
||||
|
||||
<?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élé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ï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étermine la norme utilisé</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éré</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
|
||||
if(isset($_GET['i'])){
|
||||
if($_GET['i'] == 0){
|
||||
echo "<script>alert('Connexion effectuee avec succes !')</script>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
26
logging.php
26
logging.php
@ -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();
|
||||
?>
|
||||
10
login.php
10
login.php
@ -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>
|
||||
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" required/>
|
||||
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" />
|
||||
<br/>
|
||||
<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/>
|
||||
<input type="Submit" value="Se connecter">
|
||||
</form>
|
||||
|
||||
<?php include 'includes/foot.php' ?>
|
||||
<?php include 'includes/footer.php' ?>
|
||||
<?php
|
||||
if(isset($_GET['i'])){
|
||||
if($_GET['i'] == 1){
|
||||
@ -30,4 +30,4 @@
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
52
others.php
52
others.php
@ -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>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php include 'includes/meta.php'; ?>
|
||||
</head>
|
||||
@ -12,29 +27,20 @@
|
||||
<h1>Tous les projets</h1>
|
||||
|
||||
<?php
|
||||
include_once 'includes/bdd.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 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;
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
foreach($projects as $project){
|
||||
echo ('<a href="projet.php?id='. $project['projectID'] .'&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'; ?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Binary file not shown.
BIN
pictures/cercloid_cacahuete.png
Normal file
BIN
pictures/cercloid_cacahuete.png
Normal file
Binary file not shown.
BIN
pictures/discours.jpg
Normal file
BIN
pictures/discours.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
pictures/discours.png
Normal file
BIN
pictures/discours.png
Normal file
Binary file not shown.
BIN
pictures/discoursB2b2.jpg
Normal file
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.
BIN
pictures/gebra_bezier_a_12.png
Normal file
BIN
pictures/gebra_bezier_a_12.png
Normal file
Binary file not shown.
BIN
pictures/hexa_soucoupe.png
Normal file
BIN
pictures/hexa_soucoupe.png
Normal file
Binary file not shown.
BIN
pictures/into_donut.png
Normal file
BIN
pictures/into_donut.png
Normal file
Binary file not shown.
BIN
pictures/lucas_president.png
Normal file
BIN
pictures/lucas_president.png
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
61
profile.php
61
profile.php
@ -1,4 +1,5 @@
|
||||
<?php session_start(); ?>
|
||||
<?php session_start();
|
||||
include_once 'clazz/Zincluder.php' ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -7,38 +8,30 @@
|
||||
<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']));
|
||||
}
|
||||
|
||||
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && $req->fetch() ){
|
||||
|
||||
?>
|
||||
<form method="post" action="change_password.php" id="changePasswordForm">
|
||||
Changer le mot de passe :<br/>
|
||||
<label for="real_mdp_ask">Votre ancien mot de passe :</label>
|
||||
<input type="password" id="real_mdp_ask" name="rmdp" required/>
|
||||
<br/>
|
||||
<label for="new_mdp2_ask">Votre nouveau mot de passe :</label>
|
||||
<input type="password" id="new_mdp_ask" name="nmdp" required/>
|
||||
<br/>
|
||||
<label for="new_mdp2_ask">Répétez-le :</label>
|
||||
<input type="password" id="new_mdp2_ask" name="nmdp2" required/>
|
||||
<br/>
|
||||
<input type="submit" value="Changer le mot de passe">
|
||||
</form>
|
||||
<?php
|
||||
|
||||
}else{
|
||||
header('Location:register.php');
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<?php
|
||||
try{
|
||||
Membre::checkIdLogin($_SESSION['session_id'],$_SESSION['session_mdp']);
|
||||
}catch(SQLProcessingException $e){
|
||||
header('Location:login.php');
|
||||
$_SESSION['current_error'] = 'Veuillez vous connectez ou vous inscrire pour accéder à votre profil (ça semble logique ...)';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<form method="post" action="executor.php?action=changePassword" id="changePasswordForm">
|
||||
Changer le mot de passe :<br/><br/>
|
||||
<label for="real_mdp_ask">Votre ancien mot de passe :</label>
|
||||
<input type="password" id="real_mdp_ask" name="rmdp" />
|
||||
<br/>
|
||||
<label for="new_mdp2_ask">Votre nouveau mot de passe :</label>
|
||||
<input type="password" id="new_mdp_ask" name="nmdp" />
|
||||
<br/>
|
||||
<label for="new_mdp2_ask">Répétez-le :</label>
|
||||
<input type="password" id="new_mdp2_ask" name="nmdp2" />
|
||||
<br/>
|
||||
<input type="submit" value="Changer le mot de passe">
|
||||
</form>
|
||||
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
490
projet.php
490
projet.php
@ -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>
|
||||
<html>
|
||||
<head>
|
||||
<?php include 'includes/meta.php'; ?>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<?php include 'includes/meta.php'; ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php include 'includes/header.php'; ?>
|
||||
|
||||
<body>
|
||||
<?php include 'includes/header.php'; ?>
|
||||
<?php
|
||||
include_once 'includes/inter.php';
|
||||
|
||||
$permissions = array (
|
||||
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>Mes projets</h1>
|
||||
<script>
|
||||
var projectPublic = <?php echo $projet['public']?'true':'false'; ?>;
|
||||
</script>
|
||||
<h1>Le projet <?php echo($projet['name']); ?></h1>
|
||||
<br/>
|
||||
|
||||
<h1>Le projet <?php echo($data['name']) ?> en version <?php echo($data['version']) ?></h1>
|
||||
<br />
|
||||
<?php if($rep['language'] == 0){?>
|
||||
<a class="project_option"
|
||||
href=<?php if($permissions[1]){ echo( '"megaProcess/downloadJar.php?id='. $data[ 'pID'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
|
||||
<img
|
||||
class="project_option_img<?php if(!$permissions[1]){echo(" disabeled");} ?>"
|
||||
alt="Télécharger le jar"
|
||||
title="Télécharger le jar"
|
||||
src="pictures/download_jar.png" />
|
||||
<?php
|
||||
$ssu = $projet['ownerID'] == ($_POST['session_id'] ?? -1);
|
||||
$couple = Utility::getHierarchicCouple();
|
||||
echo $couple[0] . ' : ' . $projet['ownerPseudo'] . '<br/>';
|
||||
$str = $couple[1] . ' : ';
|
||||
foreach($projet['sowners'] as $sowner)
|
||||
$str .= $sowner['pseudo'] . ', ';//TODO add link to membre.php
|
||||
if(count($projet['sowners']) > 0)
|
||||
echo '<span id="sOwnersText">'.substr($str,0,-2).'</span>';
|
||||
?>
|
||||
|
||||
</a>
|
||||
<a class="project_option"
|
||||
href=<?php if($permissions[2]){ echo( '"megaProcess/viewJavaSrc.php?id='. $rep[ 'pID'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
|
||||
<img
|
||||
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>"
|
||||
alt="Voir la source" title="Voir la source"
|
||||
src="pictures/view_code.png" />
|
||||
<?php if($ssu){ ?>
|
||||
|
||||
<br/>
|
||||
<br/><button id="managePeopleButton">Gérer les <?php echo $couple[1];?></button>
|
||||
<br/><button id="editProjectButton">Editer le projet</button>
|
||||
<br/><button id="newVersionButton">Nouvelle version</button>
|
||||
|
||||
<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électionnés</button><br/>
|
||||
<button>Terminé !</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"
|
||||
href=<?php if($permissions[2]){ echo( '"megaProcess/downloadJavaSrc.php?id='. $rep[ 'pID'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
|
||||
<img
|
||||
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>"
|
||||
alt="Télécharger la source"
|
||||
title="Télécharger la source"
|
||||
src="pictures/download_code.png" />
|
||||
|
||||
</a>
|
||||
<a class="project_option"
|
||||
href=<?php if($permissions[3]){ echo( '"megaProcess/viewJavadoc.php?id='. $rep[ 'pID'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
|
||||
<img
|
||||
class="project_option_img<?php if(!$permissions[3]){echo(" disabeled");} ?>"
|
||||
alt="Voir la doc" title="Voir la doc" src="pictures/view_javadoc.png" />
|
||||
|
||||
</a>
|
||||
<a class="project_option"
|
||||
href=<?php if($permissions[3]){ echo( '"megaProcess/downloadJavadoc.php?id='. $rep[ 'pID'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
|
||||
<img
|
||||
class="project_option_img<?php if(!$permissions[3]){echo(" disabeled");} ?>"
|
||||
alt="Télecharger la doc" title="Télecharger la doc"
|
||||
src="pictures/download_javadoc.png" />
|
||||
|
||||
</a>
|
||||
|
||||
<br />
|
||||
<?php }else if($rep['projectLanguage'] == 1){?>
|
||||
<a class="project_option"
|
||||
href=<?php if($permissions[1]){ echo( '"megaProcess/downloadXlsm.php?id='. $rep[ 'pID'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
|
||||
<img
|
||||
class="project_option_img<?php if(!$permissions[1]){echo(" disabeled");} ?>"
|
||||
alt="Télécharger le xlsm"
|
||||
title="Télécharger le xlsm"
|
||||
src="pictures/download_xlsm.png" />
|
||||
|
||||
</a>
|
||||
<a class="project_option"
|
||||
href=<?php if($permissions[2]){ echo( '"megaProcess/viewVbSrc.php?id='. $rep[ 'pID'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
|
||||
<img
|
||||
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>"
|
||||
alt="Voir la source" title="Voir la source" src="pictures/voir_vb.png" />
|
||||
|
||||
</a>
|
||||
<a class="project_option"
|
||||
href=<?php if($permissions[2]){ echo( '"megaProcess/downloadVbSrc.php?id='. $rep[ 'pID'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
|
||||
<img
|
||||
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>"
|
||||
alt="Télécharger la source"
|
||||
title="Télécharger la source"
|
||||
src="pictures/download_vb.png" />
|
||||
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
<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>
|
||||
|
||||
<?
|
||||
|
||||
} else {
|
||||
header ( 'Location:403.php' );
|
||||
goto end;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="fullscreen absent big-background-semi-opaque" id="editProjectPanel">
|
||||
<div class="screen-vertical-centered">
|
||||
<div class="screen-horizontal-centered" id="editProjectPan">
|
||||
<ul class="gray-bordered fast-full-width gone-puce">
|
||||
Mise a jour de la liste
|
||||
</ul>
|
||||
<button id="nOwnerButton">Nommer nouveau <?php echo $couple[0];?></button><br/>
|
||||
<button id="projectPublicButton"></button><br/>
|
||||
<button id="delProjectButton">Supprimer le projet </!\ Très dangereux></button><br/>
|
||||
<button id="editProjectDone">Terminé !</button>
|
||||
<script>
|
||||
var askPeopleNOwnUpdate = function(){
|
||||
$.post('executor.php?action=getPeopleList&p='+projectID,{},answerPeopleNOwnList);
|
||||
};
|
||||
$('#editProjectPan #projectPublicButton').click(function(){
|
||||
$('#editProjectPan #projectPublicButton').prop('disabled',true);
|
||||
|
||||
$.post('executor.php?action=setPublicy&p='+projectID,{publicy : !projectPublic},function(data){
|
||||
$('#editProjectPan #projectPublicButton').prop('disabled',false);
|
||||
if(data != 'ok')return;
|
||||
projectPublic = !projectPublic;
|
||||
nameProject();
|
||||
});
|
||||
});
|
||||
|
||||
$('#editProjectPan #nOwnerButton').click(function(){
|
||||
var idToName = $('#editProjectPan > ul > li.selected').data('membreID');
|
||||
if(!idToName)return;
|
||||
$('#messagePan').addClass('redMessage').html('Voulez vous vraiment promouvoir ce ministre en président ? Vous serez rétrogradé en simple ministre t lenouveau président pourra a tout moment vous virez ! Ne nommez pas un président si vous n\'avez pas confiance en lui<br/><button>Par les pouvoir qui me sont conférés, je nomme nouveau président ...</button><button>Je suis bien ici en fait !</button>');
|
||||
$('#messagePan button:nth-of-type(1)').click(function(){
|
||||
$('#messagePanel').fadeOut(600);
|
||||
$('#editProjectPan #nOwnerButton').prop('disabled',true);
|
||||
$.post('executor.php?action=nameOwner&p='+projectID,{nOwnerID : idToName},function(data){
|
||||
if(data == 'ok')window.location.reload();
|
||||
$('#editProjectPan #nOwnerButton').prop('disabled',false);
|
||||
});
|
||||
});
|
||||
$('#messagePan button:nth-of-type(2)').click(function(){
|
||||
$('#messagePanel').fadeOut(600);
|
||||
});
|
||||
$('#messagePanel').fadeIn(600);
|
||||
});
|
||||
|
||||
$('#editProjectPan #delProjectButton').click(function(){
|
||||
$('#messagePan').addClass('redMessage').html('Voulez vous vraiment supprimer ce projet ? Les fichiers seront supprimés automatiquement et seront irrécupérables, le nom de projet sera libés et toutes les informations additionelles seront aussi supprimées et ce, définitivement !<br/><button>C\'est ainsi que projet nous quitte ...</button><button>NONNNNNNN !!!!! NE MEURS PAS PROJEEEEEEET !!!!</button>');
|
||||
$('#messagePan button:nth-of-type(1)').click(function(){
|
||||
$('#messagePanel').fadeOut(600);
|
||||
$('#editProjectPan #delProjectButton').prop('disabled',true);
|
||||
$.post('executor.php?action=delProject&p='+projectID,{},function(data){
|
||||
if(data == 'ok')window.location.replace('projets.php');
|
||||
$('#editProjectPan #delProjectButton').prop('disabled',false);
|
||||
});
|
||||
});
|
||||
$('#messagePan button:nth-of-type(2)').click(function(){
|
||||
$('#messagePanel').fadeOut(600);
|
||||
});
|
||||
$('#messagePanel').fadeIn(600);
|
||||
});
|
||||
|
||||
|
||||
<?php
|
||||
end:
|
||||
?>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
</body>
|
||||
|
||||
var answerPeopleNOwnList = function(newList){
|
||||
var list = eval(newList);
|
||||
$('#editProjectPan ul').empty();
|
||||
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é : </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é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>‌</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>‌</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('‌'):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>
|
||||
|
||||
104
projetV1.php
104
projetV1.php
@ -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'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$exeAccess){echo("disabeled");} ?>" alt="Télécharger le jar" title="Télé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'] . '&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'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="Télécharger la source" title="Télé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'] . '&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'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$docAccess){echo("disabeled");} ?>" alt="Télecharger la doc" title="Té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'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$exeAccess){echo("disabeled");} ?>" alt="Télécharger le xlsm" title="Télé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'] . '&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'] . '&v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="Télécharger la source" title="Télé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>
|
||||
89
projets.php
89
projets.php
@ -1,52 +1,51 @@
|
||||
<?php session_start(); ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<?php
|
||||
session_start();
|
||||
include_once 'clazz/Zincluder.php';
|
||||
|
||||
<head>
|
||||
<?php include 'includes/meta.php'; ?>
|
||||
</head>
|
||||
if(!isset($_SESSION['session_id'])){
|
||||
$_SESSION ['current_error'] = Utility::LOGIN_NEEDED_FOR_PROJECTS;
|
||||
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
|
||||
include_once 'includes/bdd.php';
|
||||
<h1>Mes projets</h1>
|
||||
|
||||
$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']));
|
||||
}
|
||||
|
||||
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && $req->fetch() ){
|
||||
|
||||
$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'] .'&v='. $project['versionAbs'] .'">Le projet ' . $project['projectName'] . ' en version ' . $project['versionName'] . '</a><br/>');
|
||||
}
|
||||
|
||||
}else{
|
||||
header('Location:401.php');
|
||||
<?php
|
||||
try{
|
||||
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/>');
|
||||
else
|
||||
echo ('<a href="projet.php?p='. $project['projectID'] .'">Le projet ' . $project['projectName'] . ' sans version </a><br/>');
|
||||
}
|
||||
}catch(SQLProcessingException $e){
|
||||
$_SESSION ['current_error'] = $e->getHtmlMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
<br/>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<br/>
|
||||
<?php include 'includes/footer.php'; ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
28
register.php
28
register.php
@ -9,33 +9,15 @@
|
||||
<body>
|
||||
<?php include 'includes/header.php'; ?>
|
||||
|
||||
<?php
|
||||
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">
|
||||
<form id="registerForm" method="post" action="executor.php?action=register">
|
||||
<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/>
|
||||
<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/>
|
||||
<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/>
|
||||
<input type="Submit" value="S'inscrire">
|
||||
</form>
|
||||
@ -43,4 +25,4 @@
|
||||
<?php include 'includes/footer.php' ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@ -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
24
sql/GetDiscutInfo.sql
Normal 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
22
sql/GetDiscutMessages.sql
Normal 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
20
sql/changePassword.sql
Normal 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
39
sql/checkIdLogin.sql
Normal 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
66
sql/checkInGroup.sql
Normal 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
49
sql/checkLogin.sql
Normal 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
43
sql/createDiscussion.sql
Normal 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
46
sql/deleteMessage.sql
Normal 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 ;
|
||||
|
||||
18
sql/getAuthorizedProjectsForPresentation.sql
Normal file
18
sql/getAuthorizedProjectsForPresentation.sql
Normal 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 ;
|
||||
19
sql/getPublicProjectsForPresentation.sql
Normal file
19
sql/getPublicProjectsForPresentation.sql
Normal 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
21
sql/getVisibleDiscuts.sql
Normal 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
24
sql/headerInfos.sql
Normal 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
46
sql/postMessage.sql
Normal 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
30
sql/presentProject.sql
Normal 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
34
sql/presentVersion.sql
Normal 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
33
sql/registerPerson.sql
Normal 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
Loading…
x
Reference in New Issue
Block a user