Action :
diff --git a/allein/pieces.php b/allein/pieces.php
index e774963..f92e3f0 100644
--- a/allein/pieces.php
+++ b/allein/pieces.php
@@ -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";
diff --git a/clazz/Article.class.php b/clazz/Article.class.php
index 730f744..f7ef368 100644
--- a/clazz/Article.class.php
+++ b/clazz/Article.class.php
@@ -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']);
}
diff --git a/clazz/Langage.class.php b/clazz/Langage.class.php
index 986d61c..fcf53c1 100644
--- a/clazz/Langage.class.php
+++ b/clazz/Langage.class.php
@@ -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){
diff --git a/clazz/MegaFile.class.php b/clazz/MegaFile.class.php
new file mode 100644
index 0000000..3aa3d14
--- /dev/null
+++ b/clazz/MegaFile.class.php
@@ -0,0 +1,47 @@
+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";
+}
\ No newline at end of file
diff --git a/clazz/MegaStockage.class.php b/clazz/MegaStockage.class.php
deleted file mode 100644
index ff41408..0000000
--- a/clazz/MegaStockage.class.php
+++ /dev/null
@@ -1,327 +0,0 @@
-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.'';
- $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.'';
- if($req->errorInfo()[0] != 0)
- echo 'Erreur SQL, veuillez verifier les selecteurs';
- $out = array();
- while($rep = $req->fetch())
- $out[] = new Membre($rep['ID']);
-
- //Choose return value
- switch(count($out)){
- case 0:
- return NULL;
- case 1:
- return $out[0];
- default:
- return $out;
- }
- }
-
- public static function getFromPseudo($pseudo){
- return Membre::getFromAttributes(array(['pseudo','=',['"',$pseudo]]));
- }
-
- public static function getFromAdminLevel($level){
- return Membre::getFromAttributes(array(['adminLevel','=',['0',$level]]));
- }
-
- public static function getFromDateCreation($date){
- return Membre::getFromAttributes(array(['dateCreation','=',['0',$date]]));
- }
-
- public static function getCreatedLaterThan($date){
- return Membre::getFromAttributes(array(['dateCreation','>',['"',$date]]));
- }
-
- public static function getCreatedEarlierThan($date){
- return Membre::getFromAttributes(array(['dateCreation','<',['"',$date]]));
- }
-
- public static function getAdminGreaterThan($min){
- return Membre::getFromAttributes(array(['adminLevel','>',['0',$min]]));
- }
-
- public static function getAdminLowerThan($max){
- return Membre::getFromAttributes(array(['adminLevel','<',['0',$max]]));
- }
-
- public static function me(){
- if(!isset($_SESSION['session_id']))
- return NULL;
- $me = new Membre($_SESSION['session_id']);
- if(!$me->exists())
- return NULL;
- return $me;
- }
-
-
- //Membre creator
- public static function registerPerson($pseudo, $mdp) {
- if (Membre::getFromPseudo($pseudo))
- return Membre::USED_USERNAME;
- $req = $GLOBALS ['bdd']->prepare ('INSERT INTO membres(pseudo,mdp,date_creation) VALUES (?,?,NOW())');
- $req->execute (array($pseudo,password_hash( $mdp, PASSWORD_DEFAULT)));
- return Membre::PERSON_REGISTERED;
- }
-
- //Operateurs
- public function __is_identical($copain){
- return $this->getID() == $copain->getID();
- }
-
-
- //Outputs texts
-
- //changePassword
- const PASSWORD_TOO_LONG = 'Le mot de passe est trop long ! (Max : 255 caractères)';
- const PASSWORD_CHANGED = 'Le mot de passe a bien été changé';
-
- //registerPerson
- const USED_USERNAME = 'Le pseudonyme est déjà utilisé';
- const PERSON_REGISTERED = 'Le membre a bien été inscrit !';
-}
-
-
-
-
-
diff --git a/clazz/Membre.class.php b/clazz/Membre.class.php
index ef5a295..5f7ae02 100644
--- a/clazz/Membre.class.php
+++ b/clazz/Membre.class.php
@@ -297,7 +297,7 @@ class Membre {
$command = 'SELECT * FROM membres '.$wherePart;
$req = $GLOBALS['bdd']->prepare($command);
$req->execute($restrictionValues);
- echo $command.'';
+ //echo $command.'';
if($req->errorInfo()[0] != 0)
echo 'Erreur SQL, veuillez verifier les selecteurs';
$out = array();
diff --git a/clazz/Membre2.class.php b/clazz/Membre2.class.php
new file mode 100644
index 0000000..f43c5b6
--- /dev/null
+++ b/clazz/Membre2.class.php
@@ -0,0 +1,720 @@
+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.'';
+ 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.'';
+ $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.'';
+ 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ères)';
+ const PASSWORD_CHANGED = 'Le mot de passe a bien été changé';
+
+ //registerPerson
+ const USED_USERNAME = 'Le pseudonyme est déjà utilisé';
+ const PERSON_REGISTERED = 'Le membre a bien été inscrit !';
+}
+
+
+
+
+
diff --git a/clazz/NoneObjectCallException.class.php b/clazz/NoneObjectCallException.class.php
new file mode 100644
index 0000000..21a70e6
--- /dev/null
+++ b/clazz/NoneObjectCallException.class.php
@@ -0,0 +1,18 @@
+message;
+ }
+}
\ No newline at end of file
diff --git a/clazz/Projet.class.php b/clazz/Projet.class.php
index a387a0d..02fc6f4 100644
--- a/clazz/Projet.class.php
+++ b/clazz/Projet.class.php
@@ -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";
}
diff --git a/clazz/Utility.class.php b/clazz/Utility.class.php
index 87c1285..9bf214e 100644
--- a/clazz/Utility.class.php
+++ b/clazz/Utility.class.php
@@ -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ésident","Ministres");
+ }
}
diff --git a/clazz/Version.class.php b/clazz/Version.class.php
index d9aab73..8423071 100644
--- a/clazz/Version.class.php
+++ b/clazz/Version.class.php
@@ -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;
+ }
+
+
diff --git a/clazz/Zincluder.php b/clazz/Zincluder.php
index 9f164b8..580f1a3 100644
--- a/clazz/Zincluder.php
+++ b/clazz/Zincluder.php
@@ -1,8 +1,8 @@
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());
}
diff --git a/css/style.css b/css/style.css
index 9000383..cd0da47 100644
--- a/css/style.css
+++ b/css/style.css
@@ -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 {
diff --git a/discut.php b/discut.php
index d323708..c41e26e 100644
--- a/discut.php
+++ b/discut.php
@@ -35,6 +35,7 @@ include_once 'clazz/Zincluder.php'; ?>
diff --git a/executor.php b/executor.php
index a3ea4e0..0f9472d 100644
--- a/executor.php
+++ b/executor.php
@@ -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ême mot de passe (tu permet aussi de rendre le champs "Recopier le mot de passe" utile)');
if (preg_match ( "#^[a-zA-Z0-9\\-_]+$#", $_POST ['pseudo'] ))
exiting('Le pseudo sera incorrect : Les seuls caractères autorisés sont :
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_');
- if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&éèàùçµ\"\\#'{}()[\\]|\\^@°+=\$¤£*!§:/;.,?²]+$#", $_POST ['mdp'] ))
- exiting('Le mot de passe fut incorrect : Les seuls caractères autorisés sont :
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&éèàùçμ"#\'{}()[]|^@°+=$¤£*!§:/;.,?²');
+ if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&�����\"\\#'{}()[\\]|\\^@�+=\$��*!�:/;.,?�]+$#", $_POST ['mdp'] ))
+ exiting('Le mot de passe fut incorrect : Les seuls caractères autorisés sont :
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&éèàùçμ"#\'{}()[]|^@�+=$��*!�:/;.,?�');
$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étinale, digitale et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)';
+ exit;
+ }
+ $projet = new Projet($_GET ['p']);
+ if(!$projet->exists()){
+ echo 'Quand on demande des données, on donne des données !!!';
+ exit;
+ }
+ $owners = $projet->getSecondaryOwners();
+ $jmsgs = array();
+ foreach($owners as $owner){
+ $jmsg = array();
+ $jmsg['ID'] = $owner->getID();
+ $jmsg['pseudo'] = $owner->getPseudo();
+ array_push($jmsgs,$jmsg);
+ }
+ echo json_encode ( $jmsgs );
+ flush ();
+ exit;
+
+ case 'removePeople' :
+ //Action : remove secodary owner
+ if(!isset($_GET ['p']))
+ exiting('c');
+ if(!isset($_POST ['peopleIDs']))
+ exiting('o');
+ if(!$me)
+ exiting('Veuillez vous identifier pour supprimer un secondary owner !!!');
+ if(!$me->connect($_SESSION['session_mdp']))
+ exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
+ $projet = new Projet($_GET['p']);
+ if(!$projet->exists())
+ exiting('Je vais avoir du mal à supprimer un des propriétaires du projet néant ...');
+ if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
+ exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri�taire du projet');
+ $todIDs = explode(',',$_POST ['peopleIDs']);
+ $sowners = $projet->getSecondaryOwners();
+ $nsowners = array();;
+ foreach($sowners as $sowner)if(!in_array($sowner->getID(),$todIDs))$nsowners[] = $sowner;
+ $projet->setSecondaryOwners($nsowners);
+ exit;
+ case 'addPeople' :
+ //Action : add secodary owner
+ if(!isset($_GET ['p']))
+ exiting('c');
+ if(!isset($_POST ['peopleName']))
+ exiting('o');
+ if(!$me)
+ exiting('Veuillez vous identifier pour ajouter un secondary owner !!!');
+ if(!$me->connect($_SESSION['session_mdp']))
+ exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
+ $projet = new Projet($_GET['p']);
+ if(!$projet->exists())
+ exiting('Je vais avoir du mal à ajouter un propriétaires au projet néant ...');
+ if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
+ exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri�taire du projet');
+ $membre = Membre::getFromPseudo($_POST ['peopleName']);
+ if(count($membre) != 1)
+ exiting('Vous voulez ajouter QUI ?!!');
+ $projet->addSecondaryOwner($membre);
+ exit;
+ case 'setPublicy' :
+ //Action : set project publicy
+ if(!isset($_GET ['p']))
+ exiting('c');
+ if(!isset($_POST ['publicy']))
+ exiting('o');
+ if(!$me)
+ exiting('Veuillez vous connecter pour changer la "publicité"d\'un projet !!!');
+ if(!$me->connect($_SESSION['session_mdp']))
+ exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
+ $projet = new Projet($_GET['p']);
+
+ if(!$projet->exists())
+ exiting('Je vais avoir du mal à ajouter un propriétaires au projet néant ...');
+ if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
+ exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri�taire du projet');
+ $projet->setPublicy($_POST ['publicy'] == 'true');
+ echo 'ok';
+ exit;
+ case 'nameOwner' :
+ //Action : name a new Owner
+ if(!isset($_GET ['p']))
+ exiting('c');
+ if(!isset($_POST ['nOwnerID']))
+ exiting('o');
+ if(!$me)
+ exiting('Veuillez vous connecter pour changer le propriétaire d\'un projet !!!');
+ if(!$me->connect($_SESSION['session_mdp']))
+ exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
+ $projet = new Projet($_GET['p']);
+ if(!$projet->exists())
+ exiting('Je vais avoir du mal à changer le propriétaires au projet néant ...');
+ if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
+ exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri�taire du projet');
+ $membre = new Membre($_POST ['nOwnerID']);
+ if(!$membre->exists())
+ exiting('Nous sommes hereux d\'acceuillir néant , le touveau propriétaire !!! Euh ...');
+ $projet->setOwner($membre);
+ $todIDs = $membre->getID();
+ $sowners = $projet->getSecondaryOwners();
+ $nsowners = array();
+ foreach($sowners as $sowner)if($sowner->getID() != $todIDs)$nsowners[] = $sowner;
+ $projet->setSecondaryOwners($nsowners);
+ $projet->addSecondaryOwner($me);
+
+ echo 'ok';
+ exit;
+ case 'delProject' :
+ //Action : delete this project
+ if(!isset($_GET ['p']))
+ exiting('c');
+ if(!$me)
+ exiting('Veuillez vous identifier pour supprimer un projet !!!');
+ if(!$me->connect($_SESSION['session_mdp']))
+ exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
+ $projet = new Projet($_GET['p']);
+ if(!$projet->exists())
+ exiting('Je vais avoir du mal à supprimer le projet néant ...');
+ if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
+ exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propri�taire du projet');
+ $projet->delete();
+ echo 'ok';
+ exit;
+ case 'getVersionList' :
+ //Action : get project's versions
+ //TODO precise output type (via $_GET)
+ $data = array ();
+ if(!isset($_GET ['p'])){
+ echo 'ERROR : NO PROJECT PROVIDED';
+ exit;
+ }
+ if($me?!$me->connect($_SESSION['session_mdp']):FALSE){
+ echo 'Votre empreinte rétinale, digitale et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)';
+ exit;
+ }
+ $projet = new Projet($_GET ['p']);
+ if(!$projet->exists()){
+ echo 'Quand on demande des données, on donne des données !!!';
+ exit;
+ }
+ $versions = Version::getFromProject($projet);
+ $jmsgs = array();
+ foreach($versions as $version){
+ $jmsg = array();
+ $jmsg['id'] = $version->getID();
+ $jmsg['name'] = $version->getName();
+ $jmsg['versionAbs'] = $version->getVersionAbs();
+ array_push($jmsgs,$jmsg);
+ }
+
+ echo json_encode ( $jmsgs );
+ flush ();
+ exit;
+
+ case 'createVersion' :
+ //Action : add secodary owner
+ if(!isset($_GET ['p']))
+ exiting('c');
+ if(!isset($_POST ['name']))
+ exiting('o');
+ if(!isset($_POST ['langage']))
+ exiting('q');
+ if(!isset($_POST ['tags']))
+ exiting('m');
+ if(!$me)
+ exiting('Veuillez vous identifier pour ajouter une version !!!');
+ if(!$me->connect($_SESSION['session_mdp']))
+ exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
+ $projet = new Projet($_GET['p']);
+ if(!$projet->exists())
+ exiting('Je vais avoir du mal à ajouter une version au projet néant ...');
+ if(!($me->getID() == $projet->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
+ exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propriétaire du projet');
+
+ //TODO make auto version_abs sorting according to $_POST ['insertIndex']
+ //TODO verify tags and langage
+
+ $projet->newVersion($_POST ['name'],Langage::getFromName($_POST ['langage']),$_POST ['tags'],Version::getHighestFromProject($projet)->getVersionAbs()+1);
+
+ //TODO do a REAL redirection (not to the highest)
+ echo 'www.bernard.890m.com/version.php?v=' . Version::getHighestFromProject($projet)->getID();
+ exit;
+
+
+ case 'editVersion' :
+ //Action : add secodary owner
+ if(!isset($_GET ['v']))
+ exiting('c');
+ if(!isset($_POST ['name']))
+ exiting('o');
+ if(!isset($_POST ['langage']))
+ exiting('q');
+ if(!isset($_POST ['tags']))
+ exiting('m');
+ if(!$me)
+ exiting('Veuillez vous identifier pour éditer une version !!!');
+ if(!$me->connect($_SESSION['session_mdp']))
+ exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
+ $version = new Version($_GET['v']);
+ if(!$version->exists())
+ exiting('Je vais avoir du mal à éditer la version néant ...');
+ if(!($me->getID() == $version->getProject()->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
+ exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propriétaire du projet');
+
+ //TODO make auto version_abs sorting according to $_POST ['insertIndex']
+ //TODO verify tags and langage
+
+ $projet->editVersion($version,$_POST ['name'],Langage::getFromName($_POST ['langage']),$_POST ['tags'],Version::getHighestFromProject($projet)->getVersionAbs()+1);
+
+ //TODO do a REAL redirection (not to the highest)
+ echo 'www.bernard.890m.com/version.php?v=' . Version::getHighestFromProject($projet)->getID();
+ exit;
+
+ case 'delVersion' :
+ //Action : delete this version
+ if(!isset($_GET ['p']))
+ exiting('c');
+ if(!$me)
+ exiting('Veuillez vous identifier pour supprimer une version !!!');
+ if(!$me->connect($_SESSION['session_mdp']))
+ exiting('Votre empreinte rétinale, digital et génetique ne correspond pas à celles stoquées dans notre base de données (Technologie à venir)');
+ $version = new Version($_GET['p']);
+ if(!$version->exists())
+ exiting('Je vais avoir du mal à supprimer la version néant ...');
+ if(!($me->getID() == $version->getProject()->getOwner()->getID() OR $me->isAdminLevelGreaterThan(13)))
+ exiting('Vous n\'êtes pas assez PUISSANT !!!!!!!!!! (Faut un adminLevel de 13 ou plus OU etre propriétaire du projet');
+ $version->delete();
+ echo 'ok';
+ exit;
+
+
diff --git a/includes/MathJax b/includes/MathJax
deleted file mode 160000
index be11806..0000000
--- a/includes/MathJax
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit be11806df1ae075508e33500c990497062ef3c5a
diff --git a/includes/footer.php b/includes/footer.php
index 7510427..6f48e17 100644
--- a/includes/footer.php
+++ b/includes/footer.php
@@ -11,29 +11,21 @@
Haut de page
-
+
-
+
-
-
+
+
+
diff --git a/includes/meta.php b/includes/meta.php
index 7d05cc0..6f38909 100644
--- a/includes/meta.php
+++ b/includes/meta.php
@@ -4,6 +4,8 @@
+
+
diff --git a/megaProcess.php b/megaProcess.php
new file mode 100644
index 0000000..255c3ec
--- /dev/null
+++ b/megaProcess.php
@@ -0,0 +1,88 @@
+exists()){
+ header('Location:404.php');
+ echo "v doit étre l'ID d'une version existante !";
+ echo 'NO';
+ exit;
+ }
+ $go = FALSE;
+ $me = Membre::me();
+ if($me){
+ if($me->isAdminLevelHigherThan(12))
+ $go = TRUE;
+ $go = $go || $version->getProject()->haveRights($me);
+ }
+
+ switch($_GET['t']){
+ case 'jar':$go = $go || $version->isJarPublic();break;
+ case 'javadoc':$go = $go || $version->isJavadocPublic();break;
+ case 'java':$go = $go || $version->isJavaPublic();break;
+ case 'vb':$go = $go || $version->isVbPublic();break;
+ case 'xlsm':$go = $go || $version->isXlsmPublic();break;
+ default:exit;
+ }
+ if(!$go){
+ header('Location:403.php');
+ echo "VOUS N'AVEZ PAS LE DROIT !!!";
+ echo 'NO';
+ exit;
+ }
+
+ $path = '/Root/bernard.com/projets/'.$version->getProject()->getName().'/'.$version->getLanguage()->getName().'/'.$version->getName().'/';
+ $path .= $version->getProject()->getName().'-'.$version->getName();
+ switch($_GET['t']){
+ case 'jar':$path .= '.jar';break;
+ case 'javadoc':$path .= '-javadoc.tar.gz';break;
+ case 'java':$path .= '-src.tar.gz';break;
+ case 'vb':$path .= '.vb';break;
+ case 'xlsm':$path .= '.xlsm';break;
+ default:exit;
+ }
+ echo $path;
+ break;
+
+}
+
+//IF action=download
+//Tester telechargement
+
+//Génerer clé aleatoire de telechargement
+//La stoquer
+
+//Rediriger vers megabernard.alwaysdata.net
+
+
+
+//IF action=link
+
+//Tester si la personne peut acceder au fichier
+
+//Generer chemin de fichier selon les arguments
+
+//Renvoyer le tout
diff --git a/newVersion.php b/newVersion.php
index 59e5f43..76e6f55 100644
--- a/newVersion.php
+++ b/newVersion.php
@@ -30,7 +30,7 @@ include_once 'includes/inter.php';
+
@@ -43,4 +43,4 @@ include_once 'includes/inter.php';