Nouvelle classe Membre, différente. D'autres modifs....

This commit is contained in:
Mysaa 2021-06-06 12:54:42 +02:00
parent 38ec48c9fc
commit e59898b0bb
42 changed files with 2006 additions and 455 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "includes/MathJax"]
path = includes/MathJax
url = https://github.com/mathjax/MathJax.git

View File

@ -26,7 +26,7 @@ if ($me->isAdminLevelLowerThan ( 15 )) {
<div class="commanderCommandSelector">
Commande :
<select id="commandSelector">
<option value="get" selected="true">get</option>
<option value="get" selected="selected">get</option>
<option value="set">set</option>
<option value="remove">remove</option>
<option value="add">add</option>
@ -53,7 +53,7 @@ if ($me->isAdminLevelLowerThan ( 15 )) {
<div class="commander" id="addCommander" style="display: none;">
Sujet :
<select id="addClassSelector">
<option value="membre" selected="true">Membre</option>
<option value="membre" selected="selected">Membre</option>
<option value="discussion">Discussion</option>
<option value="message">Message</option>
<option value="projet">Projet</option>
@ -63,10 +63,10 @@ if ($me->isAdminLevelLowerThan ( 15 )) {
<div class="addDivAttribute" id="addDivAttributeMembre" style="display: block;">
<span>Pseudo :<input type="text" class="addCommanderAttribute pseudo" alt="Un pseudonyme valide" title="Un pseudonyme valide"/></span><br/>
<span>Mot de passe :<input type="text" class="addCommanderAttribute mdp" alt="Un mot de passe valide" title="Un mot de passe valide"/></span><br/>
<span>Email :<input type="text" class="addCommanderAttribute email" alt="Une adresse mail valide (outrepasse la vérification)" title="Une adresse mail valide (outrepasse la v&eacute;rification)"/></span><br/>
<span>Email :<input type="text" class="addCommanderAttribute email" alt="Une adresse mail valide (outrepasse la v<EFBFBD>rification)" title="Une adresse mail valide (outrepasse la v&eacute;rification)"/></span><br/>
<span class="facultatif">Date de cr&eacute;ation :<input type="text" class="addCommanderAttribute dateCreation" alt="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de r&eacute;ception de la requ&ecirc;te" title="Une date Mysql valide (AAAA-MM-JJ hh:mm:ss), si vide, la date de r&eacute;ception de la requ&ecirc;te"/></span><br/>
<span class="facultatif">Banni&egrave;re :<input type="text" class="addCommanderAttribute banniere" alt="Un chemin vers une image, si vide, alors utilise la banni&egrave;re de base" title="Un chemin vers une image, si vide, alors utilise la banni&egrave;re de base"/></span><br/>
<span class="facultatif">Message :<input type="text" class="addCommanderAttribute message" alt="Une chaine de caract&egrave;res, si vide, aucun message ne sera affiché" title="Une chaine de caract&egrave;res, si vide, aucun message ne sera affich&eacute;"/></span><br/>
<span class="facultatif">Message :<input type="text" class="addCommanderAttribute message" alt="Une chaine de caract&egrave;res, si vide, aucun message ne sera affich<EFBFBD>" title="Une chaine de caract&egrave;res, si vide, aucun message ne sera affich&eacute;"/></span><br/>
</div>
<div class="addDivAttribute" id="addDivAttributeDiscussion" style="display: none;">
@ -113,7 +113,7 @@ if ($me->isAdminLevelLowerThan ( 15 )) {
<div class="commander" id="bddCommander" style="display: none;">
Action :
<select id="bddActionSelector">
<option value="sort" selected="true">Sort</option>
<option value="sort" selected="selected">Sort</option>
<option value="save">Save</option>
<option value="retieve">Retieve</option>
</select><br/>

View File

@ -20,7 +20,7 @@
var pieceHeigth = 7;
var pieceLevitation = 1;
var speed = 5;
var pieceDelta = 1;
var pieceDelta = 20;
var getWidthFromSize = function(x){return 7*x+10;}
var entreDeux = 200;
document.getElementById('out').innerHTML="Géneration des déplacements";

View File

@ -23,7 +23,7 @@ class Article {
$this->text = $rep['text'];
$this->postDate = $rep['postDate'];
$this->lastNoticeableChangeDate = $rep['lastNoticeableChangeDate'];
$this->lastChange = $rep['lastChange'];
$this->lastChange = $rep['lastChangeDate'];
$this->picPath = $rep['picPath'];
}else{
$this->valid = FALSE;
@ -119,7 +119,6 @@ class Article {
$req = $GLOBALS['bdd']->prepare('SELECT * FROM articles ORDER BY lastNoticeableChangeDate DESC LIMIT '.intval($count));
$req->execute();
$reps = array();
$GLOBALS['bdd']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
while($rep = $req->fetch()){
$reps[] = new Article($rep['ID']);
}

View File

@ -49,7 +49,13 @@ class Langage{
if($language->getID() == $ID)
return $language;
}
//var_dump(Langage::$languages);
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){

47
clazz/MegaFile.class.php Normal file
View File

@ -0,0 +1,47 @@
<?php
class MegaFile{
protected $ID;
protected $where;
protected $args;
public function __construct($where,$args = array()){
$this->where = $where;
$this->args = $args;
}
public function is(){
$req = $GLOBALS['bdd']->prepare('SELECT COUNT(ID) AS count FROM megaFile WHERE ' . $where);//TODO changeto megaFileSSSSS
$req->execute($args);
return !!$req->fetch();
}
public static function addVersionFile($version,$fileType,$publicy){
try {
$path = '/Root/bernard.com/projets/' .
$version->getProject()->getName() . '/' .
$version->getLanguage()->getName() . '/' .
$version->getName().'/';
$pathFile = MegaFile::getFromPath($path);
if($pathFile->is())
return USED_PATH;
$pathFile = new MegaFile('fileType=? AND ');
if($pathFile->is())
return USED_PATH;
$req = $GLOBALS['bdd']->prepare('INSERT INTO megaFile (fileType,path,publicy) VALUES (?,?,?)');//TODO changeto megaFileSSSSS
$req->execute(array($fileType,$path,$publicy));
}catch(NoneObjectCallException $e){
return NONE_VERSION;
}
}
public static function getFromPath($path){
return new MegaFile('path=?',array($path));
}
public const NONE_VERSION = "sshfzrgh";
}

View File

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

View File

@ -297,7 +297,7 @@ class Membre {
$command = 'SELECT * FROM membres '.$wherePart;
$req = $GLOBALS['bdd']->prepare($command);
$req->execute($restrictionValues);
echo $command.'</br>';
//echo $command.'</br>';
if($req->errorInfo()[0] != 0)
echo 'Erreur SQL, veuillez verifier les selecteurs';
$out = array();

720
clazz/Membre2.class.php Normal file
View File

@ -0,0 +1,720 @@
<?php
class Membre {
const DEFAULT_BANNER = "pictures/bande.png";
protected $ID = NULL;
protected $IDLoaded = FALSE;
protected $pseudo = NULL;
protected $pseudoLoaded = FALSE;
protected $hashedPassword = NULL;
protected $hashedPasswordLoaded = FALSE;
protected $adminLevel = NULL;
protected $adminLevelLoaded = FALSE;
protected $dateCreation = NULL;
protected $dateCreationLoaded = FALSE;
protected $requiredBanner = NULL;
protected $requiredBannerLoaded = FALSE;
protected $personnalMessage;
protected $personnalMessageLoaded = FALSE;
protected $count = NULL;
protected $where;
protected $whereArgs;
protected const ATTRIBUTES = array('ID','pseudo','hashedPassword','dateCreation','adminLevel','data');
protected function __construct($where,$whereArgs = array()) {
$this->where = $where;
$this->whereArgs = $whereArgs;
}
public static function me(){
if(!isset($_SESSION['session_id']))
return NO_SESSION_ID;
return new Membre('WHERE ID=?');
}
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 with($conditions){//[ { 'adminLevel' , '>=' , 24 } , { requiredBanner , '/home/banner.png' } , { email } ]
$wheres = array();
$whereAttributes = array();
foreach($conditions as $condition){
//TODO support custom conditions (OR, NAND)
//TODO test !is_array()
switch(count($condition)){
case 0:
throw new MalformedConditionException($conditions,'Une condition ne peut pas être NULL , voyons ...'));
break;
case 1:
assert(in_array($condition[0],Membre::ATTRIBUTES),new MalformedConditionException($conditions,'$condition[0] n\'est pas un attribut de la classe membre !'));
$wheres[] = $condition[0] . ' NOT NULL';
break;
case 2:
assert(in_array($condition[0],Membre::ATTRIBUTES),new MalformedConditionException($conditions,'$condition[0] n\'est pas un attribut de la classe membre !'));
$wheres[] = $condition[0] . ' = ?';
$whereAttributes[] = $condition[1];
break;
case 3:
assert(in_array($condition[0],Membre::ATTRIBUTES),new MalformedConditionException($conditions,'$condition[0] n\'est pas un attribut de la classe membre !'));
$operator = Utility::getSqlOperator($condition[2]);
assert($operator !== NULL,new MalformedConditionException($conditions,'$condition[2] n\'est pas un opérateur valide !'));
$wheres[] = $condition[0] . ' ' . $operator . ' ?';
$whereAttributes[] = $condition[1];
break;
default:
throw new MalformedConditionException($conditions,'Cette version du site ne comprends pas encore les conditions avec plus de trois paramètres (' . json_encode($condition); . ')');
}
}
$where = implode(' AND ',$wheres);
return new Membre($where,$whereAttributes);
}
public static function withPseudo($pseudo){
return new Membre('WHERE pseudo=?',array($pseudo));
}
public static function withAdminLevel($level){
return new Membre('WHERE adminLevel=?',array($level));
}
public static function withAdminLevelGreaterThan($level){
return new Membre('WHERE adminLevel>?',array($level));
}
public static function withAdminLevelLowerThan($level){
return new Membre('WHERE adminLevel<?',array($level));
}
public static function withDateCreation($date){
return new Membre('WHERE dateCreation=?',array($pseudo));
}
public static function withDateCreationLaterThan($date){
return new Membre('WHERE dateCreation>?',array($pseudo));
}
public static function withDateCreationEarlierThan($date){
return new Membre('WHERE dateCreation<?',array($pseudo));
}
public function checkPassword($password) {
return password_verify ($password, $this->getHashedPassword() );
}
public function __toString(){
return 'Membre with "' . $where . '" args:{' . $whereArgs . '}';
}
/**
@returns
Si le Membre est unique et que le dernier paramètre est faux (valeur par défaut)
@return [ 'ID' => 12 , 'pseudo' => "Mysaa" ]
Si le Membre est plurier ou si le dernier paramètre est vrai
@return [ { 'ID' => 12 , 'pseudo' => "Mysaa" } , { 'ID' => 11 , 'pseudo' => "Zlopeg" } ]
**/
public function get(){
$objects = func_get_args();
assert(count($objects) < 1, new BadMethodCallException('La methode get requiert au moins un argument'));
$array = end($objects);
if(gettype($array) !== 'boolean')
$array=FALSE;
else
array_pop($objects);
assert(count($objectsCount) < 1, new BadMethodCallException('La methode get requiert au moins un nom de paramètre à retourner !'));
$toAsk = array();
$toGive = array();
foreach($objects as $object){
assert(!is_string($object), new InvalidArgumentException('"$object" n\'est pas une chaine de caractère ... ça devrait'))
assert(in_array($object,Membre::ATTRIBUTES),new InvalidArgumentException('$object n\'est pas un attribut de la classe membre !'));
if($this->{$object . 'Loaded'})
array_push($toGive,$object);
else
array_push($toAsk,$object);
}
$result = array();
if(count($toAsk)>0){
$req = $GLOBALS['bdd']->prepare('SELECT ' . implode(',',$toAsk) . 'FROM membres WHERE ' . $this->where);
$req->execute($this->whereArgs);
$sqlResult = $req->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP);
foreach($toAsk as $item){
if(!isset($this->count))$this->count = count($item);
$this->$item = $sqlResult[$item];
$this->{$item . 'Loaded'} = TRUE;
$result[$item] = $sqlResult[$item];
}
}
foreach($toGive as $item)
$result[$item] = $this->$item;
/* RETURN */
if(count($result) === 0)
return $array?array():NULL;
$return = array()
if(!$array AND $this->count === 1)
foreach($result as $item => $values)$return[$key] = $values[0];
else
foreach($result as $key=>$res)
for($i=0;$i<$this->count;$i++)
$return[$i][$key] = $res[$i]
return $return;
}
public function count(){
if($this->count)return $this->count;
$req = $GLOBALS['bdd']->prepare('SELECT COUNT(*) AS count FROM membres WHERE ' . $this->where);
$req->execute($this->whereArgs);
return $req->fetch()['count'];
}
public function __call($funcName,$params){
if(preg_match('^get',$funcName)){// TODO Support multi get ("getPseudoAndAdminLevel")
$attributeName = lcfirst(substr($funcName,3))
assert(in_array($attributeName,Membre::ATTRIBUTES), new BadMethodCallException('$attributeName n\'est pas un attribut de la classe membre !'));
$return = call_user_func_array(array($this,'get'),array($attributeName));
return (count($return)===1)?$return[0]:$return;
}
}
public function get(){
$objects = func_get_args();
assert(count($objects) < 2, new BadMethodCallException('La methode set requiert au moins deux argument'));
$objectsCount = count($objects);
assert($objectsCount % 2 === 0, new BadMethodCallException('La methode set requiert un nombre pair d\'arguments'));
foreach($objects as $object){
assert(!is_string($object), new InvalidArgumentException('"$object" n\'est pas une chaine de caractère ... ça devrait'))
assert(in_array($object,Membre::ATTRIBUTES),new InvalidArgumentException('$object n\'est pas un attribut de la classe membre !'));
if($this->{$object . 'Loaded'})//FIXME to complete get -> set
array_push($toGive,$object);
else
array_push($toAsk,$object);
}
$result = array();
if(count($toAsk)>0){
$req = $GLOBALS['bdd']->prepare('SELECT ' . implode(',',$toAsk) . 'FROM membres WHERE ' . $this->where);
$req->execute($this->whereArgs);
$sqlResult = $req->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP);
foreach($toAsk as $item){
if(!isset($this->count))$this->count = count($item);
$this->$item = $sqlResult[$item];
$this->{$item . 'Loaded'} = TRUE;
$result[$item] = $sqlResult[$item];
}
}
foreach($toGive as $item)
$result[$item] = $this->$item;
/* RETURN */
if(count($result) === 0)
return $array?array():NULL;
$return = array()
if(!$array AND $this->count === 1)
foreach($result as $item => $values)$return[$key] = $values[0];
else
foreach($result as $key=>$res)
for($i=0;$i<$this->count;$i++)
$return[$i][$key] = $res[$i]
return $return;
}
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]]));
}
//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
const NO_SESSION_ID = 0;
//changePassword
const PASSWORD_TOO_LONG = 'Le mot de passe est trop long ! (Max : 255 caract&egrave;res)';
const PASSWORD_CHANGED = 'Le mot de passe a bien &eacute;t&eacute; chang&eacute;';
//registerPerson
const USED_USERNAME = 'Le pseudonyme est d&eacute;j&agrave; utilis&eacute;';
const PERSON_REGISTERED = 'Le membre a bien &eacute;t&eacute; inscrit !';
}

View File

@ -0,0 +1,18 @@
<?php
class NoneObjectCallException extends Exception
{
public function __construct($message, $code = 0)
{
parent::__construct($message, $code);
}
public function __construct($functionName, $className, $code = 0)
{
parent::__construct('You tried to call the function ' . $functionName . ' on a ' . $className . 'pointing on nothing. Try catch me the next time !', $code);
}
public function __toString()
{
return $this->message;
}
}

View File

@ -20,7 +20,7 @@ class Projet{
$this->owner = new Membre($rep['ownerID']);
$this->dateCreation = $rep['dateCreation'];
$this->secondaryOwners = array();
foreach (explode(';',$rep['secondaryOwnersID']) AS $secondaryOwner)
foreach (($rep['secondaryOwnersID']!="")?explode(';',$rep['secondaryOwnersID']):[] AS $secondaryOwner)
$this->secondaryOwners[] = new Membre($secondaryOwner);
$this->publik = $rep['public'];
}else{
@ -40,6 +40,7 @@ class Projet{
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;
}
@ -65,7 +66,7 @@ class Projet{
}
public function isPublic(){
return $this->publik == 1;
return $this->publik;
}
@ -78,9 +79,21 @@ class Projet{
public function setSecondaryOwners($secondaryOwners){
$this->secondaryOwners = $secondaryOwners;
$secondaryOwnersID = array();
foreach($secondaryOwners AS $secondaryOwner)$secondaryOwnersID[] = $secondaryOwner->getID();
$req = $GLOBALS['bdd']->prepare('UPDATE projets SET secondaryOwners=? WHERE ID=?');
$req->execute(array(implode(';',$secondaryOwnersID),$this->ID));
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){
@ -159,7 +172,7 @@ class Projet{
}
public static function getWhichHeCanAccess($he){
//TODO Faire la selection directement grâce à une requette SQL
//TODO Faire la selection directement gràce à une reqete SQL
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
$req->execute(array());
$out = array();
@ -184,7 +197,7 @@ class Projet{
$out = array();
while ( $rep = $req->fetch()) {
$projet = new Projet($rep['ID']);
if ($he?$he->isAdminLevelGreaterThan(12):FALSE || $projet->isPublic())
if ($he?$he->isAdminLevelGreaterThan(12):FALSE || $projet->isPublic() == '1')
$out[] = $projet;
}
switch(count($out)){
@ -197,5 +210,42 @@ class Projet{
}
}
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";
}

View File

@ -48,6 +48,32 @@ NOT REGEXP
...la valeur de gauche ne correspond pas à l'expression régulière donnée
*/
public static function getSqlOperator($operator){
switch ($operator){
case '=':
return '=';
case '<':
return '<';
case '>':
return '>';
case '<=':
return '<=';
case '>=':
return '>=';
case '=<':
return '<=';
case '<>':
return '<>';
case '!=':
return '!=';
case '!<':
return '!<';
case '!>':
return '!>';
default:
return NULL;
}
}
public static function getIntegerSqlOperator($operator){
switch ($operator){
@ -116,8 +142,12 @@ NOT REGEXP
public static function arrayIfNot($var){
if(!is_array($var))
return array($var);
return $var!=NULL?array($var):NULL;
return $var;
}
public static function getHierarchicCouple(){
return array("Pr&eacute;sident","Ministres");
}
}

View File

@ -258,6 +258,18 @@ class Version{
}
}
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()));
@ -321,6 +333,13 @@ class Version{
return Version::versionGetterOutput($req);
}
public function delete(){
$req = $GLOBALS['bdd']->prepare('DELETE FROM versions WHERE ID=?');
$req->execute(array($this->getID()));
$this->valid = FALSE;
}

View File

@ -1,8 +1,8 @@
<?php
try{
//$GLOBALS['bdd'] = new PDO('mysql:host=127.0.0.1;dbname=u890869027_bcom;charset=utf8', 'u890869027', '*******************');
$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************');
$GLOBALS['bdd'] = new PDO('mysql:host=localhost;dbname=u890869027_bcom;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());
}

View File

@ -15,11 +15,18 @@
width:100%;
height:100%;
vertical-align:middle;
background-color: #222;
}
.big-background-semi-opaque{
background-color: rgba(34,34,34,0.75);
}
.big-background-opaque{
background-color: rgba(34,34,34,1);
}
.opaque{
opacity: 0.75;
opacity: 1;
}
.absent {
@ -31,9 +38,8 @@
margin-top: 50vh;
transform: translateY(-50%);
}
.screen-horizontal-centered{
display:inline;
opacity:1;
.full-text{
font-size:42px;
overflow-wrap: break-word;
word-wrap: break-word;
@ -49,6 +55,41 @@
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;
@ -132,6 +173,7 @@ footer {
padding-bottom: 0px;
margin-left: auto;
margin-right: auto;
padding-top: 5px;
}
#copyright {

View File

@ -35,6 +35,7 @@ include_once 'clazz/Zincluder.php'; ?>
</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){
@ -130,7 +131,15 @@ include_once 'clazz/Zincluder.php'; ?>
reloadEditListeners();
currentClock = setTimeout(askData,15000);
}
$(document).ready(askData);
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 -->

View File

@ -6,7 +6,7 @@ $me = Membre::me();
TODO add $_GET['p'] => should return on $_SESSION ['current_error'] (0) or via echo (1)
*/
function exiting($message,$location='register.php'){
function exiting($message,$location='index.php'){
header ( 'Location:' . $location );
$_SESSION ['current_error'] = $message;
exit;
@ -26,8 +26,8 @@ switch ($_GET ['action']) {
exiting('Tu auras du rentrer deux fois le m&ecirc;me mot de passe (tu permet aussi de rendre le champs "Recopier le mot de passe" utile)');
if (preg_match ( "#^[a-zA-Z0-9\\-_]+$#", $_POST ['pseudo'] ))
exiting('Le pseudo sera incorrect : Les seuls caract&egrave;res autoris&eacute;s sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_');
if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&éèàùçµ\"\\#'{}()[\\]|\\^@°+=\$¤£*!§:/;.,?²]+$#", $_POST ['mdp'] ))
exiting('Le mot de passe fut incorrect : Les seuls caract&egrave;res autoris&eacute;s sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&&eacute;&egrave;&agrave;&ugrave;&ccedil;&mu;"#\'{}()[]|^@°+=$¤£*!§:/;.,?²');
if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"\\#'{}()[\\]|\\^@<40>+=\$<EFBFBD><EFBFBD>*!<21>:/;.,?<3F>]+$#", $_POST ['mdp'] ))
exiting('Le mot de passe fut incorrect : Les seuls caract&egrave;res autoris&eacute;s sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&&eacute;&egrave;&agrave;&ugrave;&ccedil;&mu;"#\'{}()[]|^@<EFBFBD>+=$<24><>*!<21>:/;.,?<3F>');
$out = Membre::registerPerson ($_POST ['pseudo'],$_POST ['mdp']);
if($out ===Membre::USED_USERNAME)
@ -162,12 +162,253 @@ switch ($_GET ['action']) {
flush ();
exit;
case 'getPeopleList' :
//Action : get projest's secondary owners
//TODO precise output type (via $_GET)
$data = array ();
if(!isset($_GET ['p'])){
echo 'ERROR : NO PROJECT PROVIDED';
exit;
}
if($me?!$me->connect($_SESSION['session_mdp']):FALSE){
echo 'Votre empreinte r&eacute;tinale, digitale et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)';
exit;
}
$projet = new Projet($_GET ['p']);
if(!$projet->exists()){
echo 'Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!';
exit;
}
$owners = $projet->getSecondaryOwners();
$jmsgs = array();
foreach($owners as $owner){
$jmsg = array();
$jmsg['ID'] = $owner->getID();
$jmsg['pseudo'] = $owner->getPseudo();
array_push($jmsgs,$jmsg);
}
echo json_encode ( $jmsgs );
flush ();
exit;
case 'removePeople' :
//Action : remove secodary owner
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['peopleIDs']))
exiting('o');
if(!$me)
exiting('Veuillez vous identifier pour supprimer un secondary owner !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; supprimer un des propri&eacute;taires du projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$todIDs = explode(',',$_POST ['peopleIDs']);
$sowners = $projet->getSecondaryOwners();
$nsowners = array();;
foreach($sowners as $sowner)if(!in_array($sowner->getID(),$todIDs))$nsowners[] = $sowner;
$projet->setSecondaryOwners($nsowners);
exit;
case 'addPeople' :
//Action : add secodary owner
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['peopleName']))
exiting('o');
if(!$me)
exiting('Veuillez vous identifier pour ajouter un secondary owner !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; ajouter un propri&eacute;taires au projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$membre = Membre::getFromPseudo($_POST ['peopleName']);
if(count($membre) != 1)
exiting('Vous voulez ajouter QUI ?!!');
$projet->addSecondaryOwner($membre);
exit;
case 'setPublicy' :
//Action : set project publicy
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['publicy']))
exiting('o');
if(!$me)
exiting('Veuillez vous connecter pour changer la "publicit&eacute;"d\'un projet !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; ajouter un propri&eacute;taires au projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$projet->setPublicy($_POST ['publicy'] == 'true');
echo 'ok';
exit;
case 'nameOwner' :
//Action : name a new Owner
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['nOwnerID']))
exiting('o');
if(!$me)
exiting('Veuillez vous connecter pour changer le propri&eacute;taire d\'un projet !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; changer le propri&eacute;taires au projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$membre = new Membre($_POST ['nOwnerID']);
if(!$membre->exists())
exiting('Nous sommes hereux d\'acceuillir n&eacute;ant , le touveau propri&eacute;taire !!! Euh ...');
$projet->setOwner($membre);
$todIDs = $membre->getID();
$sowners = $projet->getSecondaryOwners();
$nsowners = array();
foreach($sowners as $sowner)if($sowner->getID() != $todIDs)$nsowners[] = $sowner;
$projet->setSecondaryOwners($nsowners);
$projet->addSecondaryOwner($me);
echo 'ok';
exit;
case 'delProject' :
//Action : delete this project
if(!isset($_GET ['p']))
exiting('c');
if(!$me)
exiting('Veuillez vous identifier pour supprimer un projet !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; supprimer le projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri<72>taire du projet');
$projet->delete();
echo 'ok';
exit;
case 'getVersionList' :
//Action : get project's versions
//TODO precise output type (via $_GET)
$data = array ();
if(!isset($_GET ['p'])){
echo 'ERROR : NO PROJECT PROVIDED';
exit;
}
if($me?!$me->connect($_SESSION['session_mdp']):FALSE){
echo 'Votre empreinte r&eacute;tinale, digitale et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)';
exit;
}
$projet = new Projet($_GET ['p']);
if(!$projet->exists()){
echo 'Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!';
exit;
}
$versions = Version::getFromProject($projet);
$jmsgs = array();
foreach($versions as $version){
$jmsg = array();
$jmsg['id'] = $version->getID();
$jmsg['name'] = $version->getName();
$jmsg['versionAbs'] = $version->getVersionAbs();
array_push($jmsgs,$jmsg);
}
echo json_encode ( $jmsgs );
flush ();
exit;
case 'createVersion' :
//Action : add secodary owner
if(!isset($_GET ['p']))
exiting('c');
if(!isset($_POST ['name']))
exiting('o');
if(!isset($_POST ['langage']))
exiting('q');
if(!isset($_POST ['tags']))
exiting('m');
if(!$me)
exiting('Veuillez vous identifier pour ajouter une version !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$projet = new Projet($_GET['p']);
if(!$projet->exists())
exiting('Je vais avoir du mal &agrave; ajouter une version au projet n&eacute;ant ...');
if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri&eacute;taire du projet');
//TODO make auto version_abs sorting according to $_POST ['insertIndex']
//TODO verify tags and langage
$projet->newVersion($_POST ['name'],Langage::getFromName($_POST ['langage']),$_POST ['tags'],Version::getHighestFromProject($projet)->getVersionAbs()+1);
//TODO do a REAL redirection (not to the highest)
echo 'www.bernard.890m.com/version.php?v=' . Version::getHighestFromProject($projet)->getID();
exit;
case 'editVersion' :
//Action : add secodary owner
if(!isset($_GET ['v']))
exiting('c');
if(!isset($_POST ['name']))
exiting('o');
if(!isset($_POST ['langage']))
exiting('q');
if(!isset($_POST ['tags']))
exiting('m');
if(!$me)
exiting('Veuillez vous identifier pour &eacute;diter une version !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$version = new Version($_GET['v']);
if(!$version->exists())
exiting('Je vais avoir du mal &agrave; &eacute;diter la version n&eacute;ant ...');
if(!($me->getID() == $version->getProject()->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri&eacute;taire du projet');
//TODO make auto version_abs sorting according to $_POST ['insertIndex']
//TODO verify tags and langage
$projet->editVersion($version,$_POST ['name'],Langage::getFromName($_POST ['langage']),$_POST ['tags'],Version::getHighestFromProject($projet)->getVersionAbs()+1);
//TODO do a REAL redirection (not to the highest)
echo 'www.bernard.890m.com/version.php?v=' . Version::getHighestFromProject($projet)->getID();
exit;
case 'delVersion' :
//Action : delete this version
if(!isset($_GET ['p']))
exiting('c');
if(!$me)
exiting('Veuillez vous identifier pour supprimer une version !!!');
if(!$me->connect($_SESSION['session_mdp']))
exiting('Votre empreinte r&eacute;tinale, digital et g&eacute;netique ne correspond pas &agrave; celles stoqu&eacute;es dans notre base de donn&eacute;es (Technologie &agrave; venir)');
$version = new Version($_GET['p']);
if(!$version->exists())
exiting('Je vais avoir du mal &agrave; supprimer la version n&eacute;ant ...');
if(!($me->getID() == $version->getProject()->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
exiting('Vous n\'&ecirc;tes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri&eacute;taire du projet');
$version->delete();
echo 'ok';
exit;

@ -1 +0,0 @@
Subproject commit be11806df1ae075508e33500c990497062ef3c5a

View File

@ -11,29 +11,21 @@
<a href="" id="haut_de_page">Haut de page</a>
</footer>
<?php
if(isset($_SESSION['current_error'])){
?>
<?php if(isset($_SESSION['current_error'])){ ?>
<div class="fullscreen opaque">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered">
<?php echo $_SESSION['current_error'];?>
</div>
</div>
</div>
<div id="currentErrorPanel" class="fullscreen absent 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 src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$('.fullscreen').on('click',function(){
$('.fullscreen').animate({opacity:0},1000,function(){
$('.fullscreen').css('display','none');
$('#currentErrorPanel').click(function(){
$('#currentErrorPanel').fadeOut(600);
});
});
</script>
<?php
unset($_SESSION['current_error']);
}
?>
</script>
<?php unset($_SESSION['current_error']);
} ?>

View File

@ -4,6 +4,8 @@
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="css/style.css" />
<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},
@ -23,21 +25,5 @@
link.href = "css/noFirefoxStyle.css";
}
headBloc.appendChild( link );
//Load server jQuery if not loaded
var jQuerySrc = 'https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML'
var mathJaxSrc = 'http://code.jquery.com/jquery-latest.min.js'
if(!navigator.onLine){
jQuerySrc = 'includes/jquery-latest.min.js';
mathJaxSrc = "includes/MathJax/MathJax.js?config=TeX-AMS_CHTML";
}
var script = document.createElement("script");
script.type = "text/javascript";
script.src = jQuerySrc;
headBloc.appendChild(script);
script = document.createElement("script");
script.type = "text/javascript";
script.src = mathJaxSrc;
headBloc.appendChild(script);
</script>

88
megaProcess.php Normal file
View File

@ -0,0 +1,88 @@
<?php
session_start();
include_once 'clazz/Zincluder.php';
//GET : action="link|download(string)" v="versionabs(int)" t="jar|javadoc|vb(string)"
if(!isset($_GET['action'])){
header('Location:index.php');
echo "Vous devez definir l'attribut action via la methode GET";
echo 'NO';
exit;
}
switch($_GET['action']){
case 'link':
if(!isset($_GET['v'])){
header('Location:index.php');
echo "Vous devez definir l'attribut v (version) via la methode GET";
echo 'NO';
exit;
}
if(!isset($_GET['t'])){
header('Location:index.php');
echo "Vous devez definir l'attribut t (type) via la methode GET";
echo 'NO';
exit;
}
$version = new Version($_GET['v']);
if(!$version->exists()){
header('Location:404.php');
echo "v doit &eacute;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

View File

@ -30,7 +30,7 @@ include_once 'includes/inter.php';
<select name="language">
<option value="Java">Java</option>
<option value="VBA">VBA</option>
</select><br />
</select><br/>
<br />
<input type="submit" value="Cr&eacute;er une nouvelle version" />
</form>
@ -43,4 +43,4 @@ include_once 'includes/inter.php';
</html>
<?php
end:
?>
?>

View File

@ -15,14 +15,15 @@ include_once 'clazz/Zincluder.php';?>
<?php
$me = Membre::me();
$projects = Projet::getOthers($me);
if($projects != NULL){
foreach(Utility::arrayIfNot($projects) as $project){
$version = Version::getHighestFromProject($project);
if($version)
echo ('<a href="projet.php?v='. $version->getID() .'">Le projet ' . $project->getName() . ' en version ' . $version->getName() . '</a><br/>');
echo ('<a href="projet.php?p='. $project->getID() .'">Le projet ' . $project->getName() . '</a> <a href="version.php?v='. $version->getID() .'">en version ' . $version->getName() . '</a><br/>');
else
echo ('<a href="404.php?p='. $project->getID() .'">Le projet ' . $project->getName() . ' sans version </a><br/>');
echo ('<a href="projet.php?p='. $project->getID() .'">Le projet ' . $project->getName() . ' sans version </a><br/>');
}
}
?>
<br/>

Binary file not shown.

Binary file not shown.

BIN
pictures/discours.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
pictures/discours.png Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 KiB

18
pieces.php Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<canvas id="pieces" width="500" height="500"></canvas>
<script type="text/javascript">
</script>
<?php include 'includes/footer.php'; ?>
</body>
</html>

View File

@ -5,6 +5,9 @@
<head>
<?php include 'includes/meta.php'; ?>
<script>
var projectID = <?php echo $_GET['p']; ?>;
</script>
</head>
<body>
@ -12,63 +15,327 @@
<?php
//TODO re la fonction exiting
$me = Membre::me();
if(!isset($_GET['v'])){
if(!isset($_GET['p'])){
header ( 'Location:projets.php');
$_SESSION ['current_error'] = 'Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!';
exit;
}
$version = new Version($_GET['v']);
if(!$version->exists()){
$projet = new Projet($_GET['p']);
if(!$projet->exists()){
header ( 'Location:projets.php');
$_SESSION ['current_error'] = 'Je vais avoir du mal &agrave; afficher les don&eacute;es de la version n&eacute;ant ...';
$_SESSION ['current_error'] = 'Je vais avoir du mal &agrave; afficher les don&eacute;es du projet n&eacute;ant ...';
exit;
}
if(count($version->getPublicFiles())<=0 && $me?$me->isAdminLevelLowerThan(12):FALSE && !$version->getProject()->haveRights()){
if(!($projet->isPublic() or $me?$me->isAdminLevelGreaterThan(12):FALSE or $me?$projet->haveRights($me):FALSE)){
header ( 'Location:projets.php');
$_SESSION ['current_error'] = 'Vous n\'avez pas le droit d\'&ecirc;tre ici ...<br/> DEGAGEZ !!!';
exit;
}
$su = $me?$version->getProject()->haveRights($me):FALSE OR $me?$me->isAdminLevelHigherThan(12):FALSE;
$su = $me?$projet->haveRights($me):FALSE OR $me?$me->isAdminLevelGreaterThan(12):FALSE;
$ssu = $me?$me->getID() == $projet->getOwner()->getID():FALSE OR $me?$me->isAdminLevelGreaterThan(13):FALSE;
?>
<h1>Le projet <?php echo($version->getProject()->getName()) ?> en version <?php echo($version->getName()) ?></h1>
<script>
var projectPublic = <?php echo $projet->isPublic()?'true':'false'; ?>;
</script>
<h1>Le projet <?php echo($projet->getName()); ?></h1>
<br/>
<?php if($version->getLanguage()->isJarAvalivable()){?>
<a class="project_option" href=<?php if($version->isJarPublic() OR $su){ echo( '"megaProcess/downloadJar.php?v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJarPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger le jar" title="T&eacute;l&eacute;charger le jar" src="pictures/download_jar.png"/>
</a>
<?php }if($version->getLanguage()->isJavaAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isJavaPublic() OR $su){ echo( '"megaProcess/viewJavaSrc.php?v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJavaPublic() OR $su)){echo(" disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/view_code.png"/>
</a>
<?php }if($version->getLanguage()->isJavaAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isJavaPublic() OR $su){ echo( '"megaProcess/downloadJavaSrc.php?v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJavaPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_code.png"/>
</a>
<?php }if($version->getLanguage()->isJavadocAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isJavadocPublic() OR $su){ echo( '"megaProcess/viewJavadoc.php?v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJavadocPublic() OR $su)){echo(" disabeled");} ?>" alt="Voir la doc" title="Voir la doc" src="pictures/view_javadoc.png"/>
</a>
<?php }if($version->getLanguage()->isJavadocAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isJavadocPublic() OR $su){ echo( '"megaProcess/downloadJavadoc.php?v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJavadocPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;lecharger la doc" title="T&eacute;lecharger la doc" src="pictures/download_javadoc.png"/>
</a>
<?php }if($version->getLanguage()->isXlsmAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isXlsmPublic() OR $su){ echo( '"megaProcess/downloadXlsm.php?v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isXlsmPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger le xlsm" title="T&eacute;l&eacute;charger le xlsm" src="pictures/download_xlsm.png"/>
</a>
<?php }if($version->getLanguage()->isVbAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isVbPublic() OR $su){ echo( '"megaProcess/viewVbSrc.php?v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isVbPublic() OR $su)){echo(" disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/voir_vb.png"/>
</a>
<?php }if($version->getLanguage()->isVbAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isVbPublic() OR $su){ echo( '"megaProcess/downloadVbSrc.php?v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isVbPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_vb.png"/>
</a>
<?php
$couple = Utility::getHierarchicCouple();
echo $couple[0] . ' : ' . $projet->getOwner()->getPseudo() . '<br/>';
$str = $couple[1] . ' : ';
foreach($projet->getSecondaryOwners() as $sowner)
$str .= $sowner->getPseudo() . ', ';//TODO add link to membre.php
if(count($projet->getSecondaryOwners()) > 0)
echo '<span id="sOwnersText">'.substr($str,0,-2).'</span>';
?>
<?php if($ssu){ ?>
<br/>
<br/><button id="managePeopleButton">G&eacute;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&eacute;lectionn&eacute;s</button><br/>
<button>Termin&eacute; !</button>
<script>
$('#managePeoplePan form button').click(function(){
var peopleIDs = new Array();
$(this).prop('disabled',true);
$.post('executor.php?action=addPeople&p='+projectID,{peopleName : $('#managePeoplePan form input').val()},function(){$('#managePeoplePan form button').prop('disabled',false);askPeopleUpdate();});
});
$('#managePeoplePan form').bind('submit',function() {return false;});
$('#managePeoplePan > button:nth-of-type(1)').click(function(){
var peopleIDs = new Array();
$(this).prop('disabled',true);
$('#managePeoplePan ul li.selected').each(function(){peopleIDs.push($(this).data('membreID'));});
$.post('executor.php?action=removePeople&p='+projectID,{peopleIDs : peopleIDs.join(',')},function(){$('#managePeoplePan button:nth-of-type(1)').prop('disabled',false);askPeopleUpdate();});
});
$('#managePeoplePan > button:nth-of-type(2)').click(function(){
$('#managePeoplePanel').fadeOut(600);
});
var askPeopleUpdate = function(){
$.post('executor.php?action=getPeopleList&p='+projectID,{},answerPeopleList);
};
var answerPeopleList = function(newList){
var list = eval(newList);
$('#managePeoplePan ul').empty();
if(list.length < 1)$('#managePeoplePan ul').text("Ce projet n'a pas de <?php echo $couple[1];?>");
var pseudos = new Array();
list.forEach(function(item){
var element = $('<li></li>');
pseudos.push(item['pseudo']);
element.text(item['pseudo']);
element.data('membreID',item['ID']);
$('#managePeoplePan ul').append(element);
});
$('#managePeoplePan ul li').click(function(e){
$(e.target).toggleClass('selected');
});
$('#sOwnersText').text(pseudos.join(','));
};
</script>
</div>
</div>
</div>
<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 &lt;/!\ Tr&egrave;s dangereux&gt;</button><br/>
<button id="editProjectDone">Termin&eacute; !</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&eacute;trograd&eacute; en simple ministre t lenouveau pr&eacute;sident pourra a tout moment vous virez ! Ne nommez pas un pr&eacute;sident si vous n\'avez pas confiance en lui<br/><button>Par les pouvoir qui me sont conf&eacute;r&eacute;s, je nomme nouveau pr&eacute;sident ...</button><button>Je suis bien ici en fait !</button>');
$('#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&eacute;s automatiquement et seront irr&eacute;cup&eacute;rables, le nom de projet sera lib&eacute;s et toutes les informations additionelles seront aussi supprim&eacute;es et ce, d&eacute;finitivement !<br/><button>C\'est ainsi que projet nous quitte ...</button><button>NONNNNNNN !!!!! NE MEURS PAS PROJEEEEEEET !!!!</button>');
$('#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);
});
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");
}
$('#editProjectPan > #editProjectDone').click(function(){
$('#editProjectPanel').fadeOut(600);
});
</script>
</div>
</div>
</div>
<div class="fullscreen absent big-background-semi-opaque" id="newVersionPanel">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered" id="newVersionPan">
<form id="nVersionForm">
<label for="nVersionName">Nom de la version</label>
<input type="text" id="nVersionName" /><br/>
<label for="languageSelect">Langage :</label>
<select id="languageSelect">
<option value="Java">Java</option>
<option value="VBA">VBA</option>
</select><br/>
<label for="nVAlphaCheck">Alpha : </label>
<input type="checkbox" id="nVAlphaCheck" value="alpha"/><br/>
<label for="nVBetaCheck">Beta : </label>
<input type="checkbox" id="nVBetaCheck" value="beta"/><br/>
<label for="nVReleaseCheck">Release : </label>
<input type="checkbox" id="nVReleaseCheck" value="release"/><br/>
<label for="nVBuggedCheck">Bogu&eacute; : </label>
<input type="checkbox" id="nVBuggedCheck" value="bugged"/><br/>
</form><br/>
<ul class="gray-bordered fast-full-width gone-puce">
Mise a jour de la liste
</ul>
<button id="createVersionDone">Cr&eacute;er la version</button><br/>
<button id="createVersionAbort">En fait ... non</button>
<script>
$('#nVersionName').on('input',updateVersionName);
$('#newVersionPan form').bind('submit',function() {return false;});
$('#createVersionDone').click(sendCreationRequest);
$('#createVersionAbort').click(function(){
$('#newVersionPanel').fadeOut(600);
});
var askVersionUpdate = function(){
$.post('executor.php?action=getVersionList&p='+projectID,{},answerVersionList);
};
var answerVersionList = function(newList){
var list = eval(newList);
$('#newVersionPan ul').empty();
$('#newVersionPan ul').append($('<li>&zwnj;</li>').attr('id',"versionAbsPotentialPos-1").addClass('potentialPos'));
list.forEach(function(item,index){
var element = $('<li></li>');
element.text(item['name']);
element.data('versionAbs',item['versionAbs']);
element.addClass('hoverable');
$('#newVersionPan ul').append(element);
$('#newVersionPan ul').append($('<li>&zwnj;</li>').attr('id',"versionAbsPotentialPos" + index).addClass('potentialPos').css('display','none'));
});
window.currentIndex = $('#newVersionPan ul > li.hoverable').length - 1;
window.savedCurrentIndex = currentIndex;
$('#newVersionPan ul li.hoverable').mousemove(function(e){
var itemIndex = $('#newVersionPan ul > li.hoverable').index(this);
var index = (currentIndex < itemIndex)?itemIndex:itemIndex-1;
if(currentIndex != index){
$("#versionAbsPotentialPos"+currentIndex).css('display','none');
currentIndex = index;
$("#versionAbsPotentialPos"+currentIndex).css('display','block');
}
});
$('#newVersionPan ul').click(function(){
savedCurrentIndex = currentIndex;
});
$('#newVersionPan ul').hover(null,function(){
$("#versionAbsPotentialPos"+currentIndex).css('display','none');
currentIndex = savedCurrentIndex;
$("#versionAbsPotentialPos"+currentIndex).css('display','block');
});
};
function updateVersionName(){
var name = $('#nVersionName').val();
var pp = $('#newVersionPan ul li.potentialPos');
(name.match(/^\s*$/))?pp.html('&zwnj;'):pp.text(name);
}
function sendCreationRequest(){
var name = $('#nVersionName').val();
var langage = $('#languageSelect').val();
var tags = new Array();
$("#nVersionForm input:checked").each(function(){
tags.push($( this ).val());
});
var insertIndex = savedCurrentIndex;
$.post('executor.php?action=createVersion&p='+projectID,{name:name,langage:langage,tags:tags.join(' '),insertIndex:insertIndex},answerCreationRequest);
}
function answerCreationRequest(data){
if(!data.startsWith('www.bernard.890m.com')){
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 $versions = Version::getFromProject($version->getProject()); ?>
<?php $versions = Version::getFromProject($projet); ?>
<?php if(is_array($versions)){/* = if count(versions>1) */ ?>
<?php $languages = Langage::getLanguagesFromVersions($versions); ?>
<h3>Toutes les versions :</h3>
@ -79,22 +346,13 @@
<th><?php echo $language->getName(); ?></th>
</tr>
<?php foreach (Utility::arrayIfNot($versions) as $writingVersion){if($writingVersion->getLanguage() == $language){ ?>
<tr><td><a href = "projet.php?v=<?php echo $writingVersion->getID();?>"><?php echo $writingVersion->getName(); ?></a></td></tr>
<tr><td><a href = "version.php?v=<?php echo $writingVersion->getID();?>"><?php echo $writingVersion->getName(); ?></a></td></tr>
<?php }}?>
</table>
<?php } ?>
<?php }?>
<br/>
<br/>
<?php if($me?$version->getProject()->haveRights($me):FALSE){ ?>
<a href="newVersion.php?id=<?php echo $_GET['id'];?>">Nouvelle version</a><br/>
<a href="editVersion.php?id=<?php echo $_GET['id'];?>&amp;v=<?php echo $_GET['v'];?>">Modifier la version</a><br/>
<a href="delVersion.php?id=<?php echo $_GET['id'];?>&amp;v=<?php echo $_GET['v'];?>">Supprimer la version</a><br/>
<a href="editProject.php?id=<?php echo $_GET['id'];?>">Modifier le projet</a><br/>
<a href="delProject.php?id=<?php echo $_GET['id'];?>">Supprimer le projet</a><br/>
<?php } ?>
<br/>

View File

@ -18,9 +18,9 @@ include_once 'clazz/Zincluder.php';?>
foreach(Utility::arrayIfNot($projects) as $project){
$version = Version::getHighestFromProject($project);
if($version)
echo ('<a href="projet.php?v='. $version->getID() .'">Le projet ' . $project->getName() . ' en version ' . $version->getName() . '</a><br/>');
echo ('<a href="projet.php?p='. $project->getID() .'">Le projet ' . $project->getName() . '</a> <a href="version.php?v='. $version->getID() .'">en version ' . $version->getName() . '</a><br/>');
else
echo ('<a href="404.php?p='. $project->getID() .'">Le projet ' . $project->getName() . ' sans version </a><br/>');
echo ('<a href="projet.php?p='. $project->getID() .'">Le projet ' . $project->getName() . ' sans version </a><br/>');
}
}else{

358
version.php Normal file
View File

@ -0,0 +1,358 @@
<?php session_start(); ?>
<?php include_once 'clazz/Zincluder.php';?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php
//TODO re la fonction exiting
$me = Membre::me();
if(!isset($_GET['v'])){
header ( 'Location:projets.php');
$_SESSION ['current_error'] = 'Quand on demande des donn&eacute;es, on donne des donn&eacute;es !!!';
exit;
}
$version = new Version($_GET['v']);
if(!$version->exists()){
header ( 'Location:projets.php');
$_SESSION ['current_error'] = 'Je vais avoir du mal &agrave; afficher les don&eacute;es de la version n&eacute;ant ...';
exit;
}
if(count($version->getPublicFiles())<=0 && $me?$me->isAdminLevelLowerThan(12):FALSE && !$version->getProject()->haveRights()){
header ( 'Location:projets.php');
$_SESSION ['current_error'] = 'Vous n\'avez pas le droit d\'&ecirc;tre ici ...<br/> DEGAGEZ !!!';
exit;
}
$su = $me?$version->getProject()->haveRights($me):FALSE OR $me?$me->isAdminLevelGreaterThan(12):FALSE;
$ssu = $me?$me->getID() == $version->getProject()->getOwner()->getID():FALSE OR $me?$me->isAdminLevelGreaterThan(13):FALSE;
?>
<h1>Le projet <?php echo($version->getProject()->getName()) ?> en version <?php echo($version->getName()) ?></h1>
<br/>
<?php if($version->getLanguage()->isJarAvalivable()){?>
<a class="project_option" href=<?php if($version->isJarPublic() OR $su){ echo( '"http://megabernard.alwaysdata.net/megaDownload.php?t=jar&amp;v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJarPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger le jar" title="T&eacute;l&eacute;charger le jar" src="pictures/download_jar.png"/>
</a>
<?php }if($version->getLanguage()->isJavaAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isJavaPublic() OR $su){ echo( '"http://megabernard.alwaysdata.net/megaDownload.php?t=java&amp;v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJavaPublic() OR $su)){echo(" disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/view_code.png"/>
</a>
<?php }if($version->getLanguage()->isJavaAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isJavaPublic() OR $su){ echo( '"http://megabernard.alwaysdata.net/megaDownload.php?t=java&amp;v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJavaPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_code.png"/>
</a>
<?php }if($version->getLanguage()->isJavadocAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isJavadocPublic() OR $su){ echo( '"http://megabernard.alwaysdata.net/megaDownload.php?t=javadoc&amp;v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJavadocPublic() OR $su)){echo(" disabeled");} ?>" alt="Voir la doc" title="Voir la doc" src="pictures/view_javadoc.png"/>
</a>
<?php }if($version->getLanguage()->isJavadocAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isJavadocPublic() OR $su){ echo( '"http://megabernard.alwaysdata.net/megaDownload.php?t=javadoc&amp;v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isJavadocPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;lecharger la doc" title="T&eacute;lecharger la doc" src="pictures/download_javadoc.png"/>
</a>
<?php }if($version->getLanguage()->isXlsmAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isXlsmPublic() OR $su){ echo( '"http://megabernard.alwaysdata.net/megaDownload.php?t=xlsm&amp;v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isXlsmPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger le xlsm" title="T&eacute;l&eacute;charger le xlsm" src="pictures/download_xlsm.png"/>
</a>
<?php }if($version->getLanguage()->isVbAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isVbPublic() OR $su){ echo( '"http://megabernard.alwaysdata.net/megaDownload.php?t=vb&amp;v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isVbPublic() OR $su)){echo(" disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/voir_vb.png"/>
</a>
<?php }if($version->getLanguage()->isVbAvalivable()){ ?>
<a class="project_option" href=<?php if($version->isVbPublic() OR $su){ echo( '"http://megabernard.alwaysdata.net/megaDownload.php?t=vb&amp;v='.$version->getID() . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!($version->isVbPublic() OR $su)){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_vb.png"/>
</a>
<?php } ?>
<script>
var projectID = <?php echo $version->getProject()->getID(); ?>;
var versionID = <?php echo $version->getID(); ?>;
</script>
<?php if($ssu){ ?>
<br/>
<br/><button id="editVersionButton">Editer la version</button>
<br/><button id="deleteVersionButton">Supprimer la version</button>
<div class="fullscreen absent big-background-semi-opaque" id="editVersionPanel">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered" id="editVersionPan">
<form id="eVersionForm">
<label for="nVersionName">Nom de la version</label>
<input type="text" id="nVersionName"><?php echo $version->getName(); ?></input><br/>
<label for="languageSelect">Langage :</label>
<select id="languageSelect">
<option value="Java" <?php if($version->getLanguage() == Langage::$java)echo 'selected=""'; ?>>Java</option>
<option value="VBA"<?php if($version->getLanguage() == Langage::$vba)echo 'selected=""'; ?>>VBA</option>
</select><br/>
<label for="VAlphaCheck">Alpha : </label>
<input type="checkbox" id="VAlphaCheck" value="alpha" <?php if($version->isAlpha())echo 'checked=""'; ?>/><br/>
<label for="VBetaCheck">Beta : </label>
<input type="checkbox" id="VBetaCheck" value="beta" <?php if($version->isBeta())echo 'checked=""'; ?>/><br/>
<label for="VReleaseCheck">Release : </label>
<input type="checkbox" id="VReleaseCheck" value="release" <?php if($version->isRelease())echo 'checked=""'; ?>/><br/>
<label for="VBuggedCheck">Bogu&eacute; : </label>
<input type="checkbox" id="VBuggedCheck" value="bugged" <?php if($version->isBugged())echo 'checked=""'; ?>/><br/>
</form><br/>
<ul class="gray-bordered fast-full-width gone-puce">
Mise a jour de la liste
</ul>
<button id="editVersionDone">Modifier la version</button><br/>
<button id="editVersionAbort">En fait ... non</button>
<script>
$('#nVersionName').on('input',updateVersionName);
$('#newVersionPan form').bind('submit',function() {return false;});
$('#editVersionDone').click(sendEditingRequest);
$('#editVersionAbort').click(function(){
$('#editVersionPanel').fadeOut(600);
});
var askVersionUpdate = function(){
$.post('executor.php?action=getVersionList&p='+projectID,{},answerVersionList);
};
var answerVersionList = function(newList){
var list = eval(newList);
$('#newVersionPan ul').empty();
$('#newVersionPan ul').append($('<li>&zwnj;</li>').attr('id',"versionAbsPotentialPos-1").addClass('potentialPos'));
list.forEach(function(item,index){
if(item['id'] != versionID){
var element = $('<li></li>');
element.text(item['name']);
element.data('versionAbs',item['versionAbs']);
element.addClass('hoverable');
$('#newVersionPan ul').append(element);
$('#newVersionPan ul').append($('<li>&zwnj;</li>').attr('id',"versionAbsPotentialPos" + index).addClass('potentialPos').css('display','none'));
}else{
window.currentIndex = $('#newVersionPan ul > li.hoverable').length - 1;
window.savedCurrentIndex = currentIndex;
}
});
$('#newVersionPan ul li.hoverable').mousemove(function(e){
var itemIndex = $('#newVersionPan ul > li.hoverable').index(this);
var index = (currentIndex < itemIndex)?itemIndex:itemIndex-1;
if(currentIndex != index){
$("#versionAbsPotentialPos"+currentIndex).css('display','none');
currentIndex = index;
$("#versionAbsPotentialPos"+currentIndex).css('display','block');
}
});
$('#newVersionPan ul').click(function(){
savedCurrentIndex = currentIndex;
});
$('#newVersionPan ul').hover(null,function(){
$("#versionAbsPotentialPos"+currentIndex).css('display','none');
currentIndex = savedCurrentIndex;
$("#versionAbsPotentialPos"+currentIndex).css('display','block');
});
};
function updateVersionName(){
var name = $('#nVersionName').val();
var pp = $('#newVersionPan ul li.potentialPos');
(name.match(/^\s*$/))?pp.html('&zwnj;'):pp.text(name);
}
function sendEditingRequest(){
var name = $('#nVersionName').val();
var langage = $('#languageSelect').val();
var tags = new Array();
$("#eVersionForm input:checked").each(function(){
tags.push($( this ).val());
});
var insertIndex = savedCurrentIndex;
$.post('executor.php?action=editVersion&v='+versionID,{name:name,langage:langage,tags:tags.join(' '),insertIndex:insertIndex},answerEditionRequest);
}
function answerEditionRequest(data){
if(data.startsWith('Error')){
console.log(data);//TODO la jolie boite de dialogue
}else
window.location.reload(true);
}
</script>
</div>
</div>
</div>
<script type="text/javascript">
$('#deleteVersionButton').click(function(){
$('#messagePan').addClass('redMessage').html('Voulez vous vraiment supprimer cette version ? Les fichiers seront supprim&eacute;s automatiquement et seront irr&eacute;cup&eacute;rables et toutes les informations additionelles seront aussi supprim&eacute;es et ce, d&eacute;finitivement !<br/><button>C\'est ainsi que version nous quitte ...</button><button>NONNNNNNN !!!!! NE MEURS PAS VERSIOOOOOOOON !!!!</button>');
$('#messagePan button:nth-of-type(1)').click(function(){
$.post('executor.php?action=delVersion&v='+versionID,{},function(data){
if(data == 'ok')window.location.replace('projet.php?p='+projectID);
});
});
$('#messagePan button:nth-of-type(2)').click(function(){
$('#messagePanel').fadeOut(600);
});
$('#messagePanel').fadeIn(600);
});
</script>
<script type="text/javascript">
$('#editVersionButton').click(function(){
askVersionUpdate();
updateVersionName();
$('#editVersionPanel').fadeIn(600);
});
</script>
<?php } if($su) { ?>
<br/><button id="manageFilesButton">G&eacute;rer les fichiers</button>
<div class="fullscreen absent big-background-semi-opaque" id="newVersionPanel">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered" id="newVersionPan">
<form id="nVersionForm">
<label for="nVersionName">Nom de la version</label>
<input type="text" id="nVersionName" /><br/>
<label for="languageSelect">Langage :</label>
<select id="languageSelect">
<option value="Java">Java</option>
<option value="VBA">VBA</option>
</select><br/>
<label for="nVAlphaCheck">Alpha : </label>
<input type="checkbox" id="nVAlphaCheck" value="alpha"/><br/>
<label for="nVBetaCheck">Beta : </label>
<input type="checkbox" id="nVBetaCheck" value="beta"/><br/>
<label for="nVReleaseCheck">Release : </label>
<input type="checkbox" id="nVReleaseCheck" value="release"/><br/>
<label for="nVBuggedCheck">Bogu&eacute; : </label>
<input type="checkbox" id="nVBuggedCheck" value="bugged"/><br/>
</form><br/>
<ul class="gray-bordered fast-full-width gone-puce">
Mise a jour de la liste
</ul>
<button id="createVersionDone">Cr&eacute;er la version</button><br/>
<button id="createVersionAbort">En fait ... non</button>
<script>
$('#nVersionName').on('input',updateVersionName);
$('#newVersionPan form').bind('submit',function() {return false;});
$('#createVersionDone').click(sendCreationRequest);
$('#createVersionAbort').click(function(){
$('#newVersionPanel').fadeOut(600);
});
var askVersionUpdate = function(){
$.post('executor.php?action=getVersionList&p='+projectID,{},answerVersionList);
};
var answerVersionList = function(newList){
var list = eval(newList);
$('#newVersionPan ul').empty();
$('#newVersionPan ul').append($('<li>&zwnj;</li>').attr('id',"versionAbsPotentialPos-1").addClass('potentialPos'));
list.forEach(function(item,index){
var element = $('<li></li>');
element.text(item['name']);
element.data('versionAbs',item['versionAbs']);
element.addClass('hoverable');
$('#newVersionPan ul').append(element);
$('#newVersionPan ul').append($('<li>&zwnj;</li>').attr('id',"versionAbsPotentialPos" + index).addClass('potentialPos').css('display','none'));
});
window.currentIndex = $('#newVersionPan ul > li.hoverable').length - 1;
window.savedCurrentIndex = currentIndex;
$('#newVersionPan ul li.hoverable').mousemove(function(e){
var itemIndex = $('#newVersionPan ul > li.hoverable').index(this);
var index = (currentIndex < itemIndex)?itemIndex:itemIndex-1;
if(currentIndex != index){
$("#versionAbsPotentialPos"+currentIndex).css('display','none');
currentIndex = index;
$("#versionAbsPotentialPos"+currentIndex).css('display','block');
}
});
$('#newVersionPan ul').click(function(){
savedCurrentIndex = currentIndex;
});
$('#newVersionPan ul').hover(null,function(){
$("#versionAbsPotentialPos"+currentIndex).css('display','none');
currentIndex = savedCurrentIndex;
$("#versionAbsPotentialPos"+currentIndex).css('display','block');
});
};
function updateVersionName(){
var name = $('#nVersionName').val();
var pp = $('#newVersionPan ul li.potentialPos');
(name.match(/^\s*$/))?pp.html('&zwnj;'):pp.text(name);
}
function sendCreationRequest(){
var name = $('#nVersionName').val();
var langage = $('#languageSelect').val();
var tags = new Array();
$("#nVersionForm input:checked").each(function(){
tags.push($( this ).val());
});
var insertIndex = savedCurrentIndex;
$.post('executor.php?action=createVersion&p='+projectID,{name:name,langage:langage,tags:tags.join(' '),insertIndex:insertIndex},answerCreationRequest);
}
function answerCreationRequest(data){
if(!data.startsWith('www.bernard.890m.com')){
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">
$('#newVersionButton').click(function(){
askVersionUpdate();
$('#newVersionPanel').fadeIn(600);
});
</script>
<?php } ?>
<br/>
<br/>
<?php $versions = Version::getFromProject($version->getProject()); ?>
<?php if(is_array($versions)){/* = if count(versions>1) */ ?>
<?php $languages = Langage::getLanguagesFromVersions($versions); ?>
<h3>Toutes les versions :</h3>
<br/>
<?php foreach($languages as $language){ ?>
<table class="versionTable">
<tr>
<th><?php echo $language->getName(); ?></th>
</tr>
<?php foreach (Utility::arrayIfNot($versions) as $writingVersion){if($writingVersion->getLanguage() == $language){ ?>
<tr><td><a href = "version.php?v=<?php echo $writingVersion->getID();?>"><?php echo $writingVersion->getName(); ?></a></td></tr>
<?php }}?>
</table>
<?php } ?>
<?php }?>
<br/>
<br/>
<br/>
<?php include 'includes/footer.php'; ?>
</body>
</html>