Nouvelle classe Membre, différente. D'autres modifs....
This commit is contained in:
+244
-3
@@ -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 :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_');
|
||||
if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&éèàùçµ\"\\#'{}()[\\]|\\^@°+=\$¤£*!§:/;.,?²]+$#", $_POST ['mdp'] ))
|
||||
exiting('Le mot de passe fut incorrect : Les seuls caractères autorisés sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&éèàùçμ"#\'{}()[]|^@°+=$¤£*!§:/;.,?²');
|
||||
if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&�����\"\\#'{}()[\\]|\\^@�+=\$��*!�:/;.,?�]+$#", $_POST ['mdp'] ))
|
||||
exiting('Le mot de passe fut incorrect : Les seuls caractères autorisés sont :<br/>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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user