Ajout de plus de classe, on va y arriver

This commit is contained in:
Mysaa 2021-06-05 20:24:16 +02:00
parent 2ea296cd61
commit b3975e3cd1
6 changed files with 453 additions and 291 deletions

175
admin.php
View File

@ -1 +1,176 @@
<?php
include_once 'clazz/Zincluder.php;';
session_start ();
$me = new Membre ( $_SESSION ['session_id'] );
$me->connect ( $_SESSION ['session_mdp'] );
if ($me->isAdminLevelLowerThan ( 15 )) {
header ( 'Location:401.php' );
exit ();
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/adminStyle.css" />
<meta charset="utf-8" />
<title>La console d'admin</title>
</head>
<body>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<select id="commandSelector">
<option value="get" selected="true">get</option>
<option value="set">set</option>
<option value="remove">remove</option>
<option value="add">add</option>
<option value="BDD">BDD</option>
</select>
<div id="setDiv">
<form id="setFormObject">
Objet<br /> <select class="classSelector" id="setClassSelector">
<!-- Rempli en JS -->
</select><br />
<button id="selectFromObject">S&eacute;l&eacute;ctionner</button>
</form>
<!--
Pour enlever les vilains whitespace
-->
<form id="setChampsForm">
Valeur<br /> <select id="setChamps">
<!-- Rempli en JS -->
</select> <select id="arrayOperation">
<option value="add" selected="selected">add</option>
<option value="set">set</option>
<option value="remove">remove</option>
</select> <input type="text" id="primitiveValueField" />
<button id="selectComplexValue">S&eacute;l&eacute;ctionner</button>
</form>
</div>
<button id="send">Envoyer la requ&ecirc;te</button>
<br />
<samp id="adminDialogAnswer">
Hello !!!<br />
</samp>
<div class="fullscreen opaque">
<div class="screen-vertical-centered">
<form class="screen-horizontal-centered selectorForm">
<!-- ID set en JS (bonjour la galère) -->
<!-- Attributs remplis en JS -->
<span>
<input type="checkbox" />
<h5>Nom du champ</h5>
<select>
<option value="ee">=</option>
<option value="lt">&lt;</option>
<option value="gt">&gt;</option>
<option value="ge">&ge;</option>
<option value="le">&le;</option>
<option value="ne">&ne;</option>
</select>
<input type="text" />
<button id="nomDuChampSelector">Selecteur</button>
</span>
</form>
</div>
</div>
<script type="text/javascript">
function done(){
var objet = $(this).parent().data('object');//SetObjectSelector-projectSelector
var selector = new Array();
/*
$(this).parent().children('div').each(function() {
if($(this).children('input[type="checkbox"]').is(':selected')){
var varName = $(this).parent().children('h5').text();
var operator = $(this).parent().children('h5').text();
}
});
*/
$(this).parent().children('div').children('input[type="checkbox"]:selected').each(function() {
var varName = $(this).parent().children('h5').text();
var operator = $(this).parent().children('select').find(':selected').attr('value');
var value;
if($(this).parent().children('input[type="text"]').length)
value = $(this).parent().children('input[type="text"]').val();
else
value = $(this).parent().children('button').data('selector');
selector[varName] = operator+value;
}
});
$('#'+objet).data('selector',JSON.stringify(selector));
}
function selector(object,clazz) {
var newForm = $('<form></form>');
newForm.data('object',object);
switch(clazz){
case 'membre':
newForm.append(selectorNode('pseudo',true,false,false));
newForm.append(selectorNode('password',true,false,false));
newForm.append(selectorNode('adminLevel',true,false,true));
newForm.append(selectorNode('dateCreation',true,false,true));
newForm.append(selectorNode('requiredBanner',true,false,false));
newForm.append(selectorNode('personnalMessage',true,false,false));
break;
case 'projet':
newForm.append(selectorNode('name',true,false,false));
newForm.append(selectorNode('dateCreation',true,false,true));
newForm.append(selectorNode('owner',false,false,false));
newForm.append(selectorNode('secondaryOwner',false,true,false));
break;
case 'version':
newForm.append(selectorNode('name',true,false,false));
newForm.append(selectorNode('sendDate',true,false,true));
newForm.append(selectorNode('publicFiles',true,true,false));
newForm.append(selectorNode('tags',true,true,false));
newForm.append(selectorNode('project',false,false,false));
newForm.append(selectorNode('language',true,false,false));
break;
}
newForm.append('<br/>');
newForm.append('<button id="selectorAbort">Annuler</button>')
newForm.append('<button id="selectorDone">Termin&eacute;</button>');
$('form.selectorForm').replaceWith(newForm);
}
function selectorNode(name,primitive,array,number){
var span = $('<span></span>');
span.append('<input type="checkbox" />')
span.append('<h5>'+name+'</h5>')
if(number)
span.append('<select><option value="ee">=</option><option value="lt">&lt;</option><option value="gt">&gt;</option><option value="ge">&ge;</option><option value="le">&le;</option><option value="ne">&ne;</option></select>')
else if(array)
span.append('<select><option value="in">&isin;</option><option value="nn">&notin;</option></select>')
else
span.append('<select><option value="ee">=</option><option value="ne">&ne;</option></select>')
if(primitive)
span.append('<input type="text" />')
else
span.append('<button id="'+name+'Selector">Selecteur</button>')
}
function genClassesSelectors{
$('select.classSelector')
.append('<option value="membre">Membre</option>')
.append('<option value="projet">Projet</option>')
.append('<option value="version">Version</option>')
.append('<option value="discussion">Discussion</option>')
.append('<option value="message">Message</option>');
}
$(window).load(genClassesSelectors);
</script>
</body>
</html>

View File

@ -1,52 +1,224 @@
<?php
include_once 'clazz/Membre.class.php';
include_once 'includes/bdd.php';
/*
include_once 'clazz/Zincluder.php';
$me = new Membre();
$me->connect();
if($me->getAdminLevel()<15){
if($me->isAdminLevelLowerThan(15)){
echo 'Your admin level is too low (15 or more required)';
exit;
}elseif(!isset($_GET['action'])){
echo 'Please set an action in the URL (GET method ,name:"action")';
}elseif(!isset($_POST['command'])){
echo 'Please set an command in the URL (POST method ,name:"command")';
exit;
}
*/
function isAlphaNumeric($char){
return isAlphabetic($char) or isNumeric($char);
}
function isAlphabetic($char){
return preg_match('#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]$#',$char) === 1;
}
function isNumeric($char){
return preg_match('#^[0123456789]$#',$char) === 1;
}
function error($pos,$reason){
echo 'Error at char '.$pos.' : '.$reason;
exit;
}
switch ($_GET['action']){
case 'set_discutionVisibility' :
if(!isset($_POST['discutionVisibility'])){
echo 'You must give a discution visibility (POST method,name:"discutionVisibility")';
exit;
function readAlphabetic($command){
global $pos;
$out = "";
while (isAlphaNumeric($command[$pos])) {
$out .= $command[$pos];
$pos+=1;
}
if(!isset($_POST['discutionID'])){
echo 'You must give a discution ID (POST method,name:"discutionID")';
exit;
return $out;
}
function readNumeric($command){
//TODO Add non-integer support (virgule , puissance , autres bases ...)
global $pos;
$out = "";
while (isNumeric($command[$pos])) {
$out .= $command[$pos];
$pos+=1;
}
$discutionVisibility = $_POST['discutionVisibility'];
$discutionID = $_POST['discutionID'];
if ($discutionVisibility !== 'p' and preg_match ( "#^a[0-9]+$#",$discutionVisibility ) != 1 and preg_match ( '#^x([0-9]+;)*([0-9]+)?$#', $discutionVisibility ) != 1 ){
echo 'Your discution visibility is not well-formed : it should have been formed like ("p" or "x31;41;59;26;53" or "a42")';
exit;
return intval($out);
}
function readString($command,$startChar='\"'){
global $pos;
$out = "";
$startChar = $command[$pos];
$pos+=1;
while (TRUE) {
$char = $command[$pos];
if($char === $startChar)
break;
if($char === '\\'){
$pos+=1;
switch ($command[$pos]){
case '\\':
$char = '\\';
break;
case $startChar:
$char = $startChar;
break;
default:
error($pos,'Unexpected "'.$command['pos'].'" after "\\"');
}
}
$out .= $char;
$pos+=1;
}
$req = $GLOBALS['bdd']->prepare('UPDATE discussions SET autorized=? WHERE ID=?');
$req->execute(array($discutionVisibility,$discution));
exit;
$pos +=1;
return $out;
}
$operators = array('=','!=','>','<','>=','=>','<=','=<','&has;','&nhas;');
$operatorsChars = array('=','!','<','>','&');
function readOperator($command,$endChar = 'abcdefghijklmnopqrstuvwxytABCDEFGHIJKLMNOPQRSTUVWZYZ0123456789"\''){
global $pos,$operators;
if($command[$pos] === '&'){
$pos+=1;
$inOperator = readAlphabetic($command);
if($command[$pos] !== ';'){
error($pos, 'Unexepted character at the end of the operator ' . $inOperator);
}
return '&'.$inOperator.';';
}
$reading = '';
$lastOperator = '';
$maxPos=min(strlen($command),$pos+5);
$tPos = $pos;
while ($tPos<$maxPos) {
$reading .= $command[$pos];
$tPos+=1;
if(in_array($reading,$operators,TRUE))
$lastOperator=$reading;
}
$pos += strLen($lastOperator);
if(!in_array($lastOperator,$operators))
error($pos, 'Unknown operator : '.$out);
return $lastOperator;
}
function readSelector($command){
global $pos,$operatorsChars;
$out = array();
$pos += 1;//@
if(!isAlphabetic($command[$pos]))
error($pos,'Unexepted non-alphabetic char "'.$command[$pos].'" after @');
$className = readAlphabetic($command,'[');
$pos += 1;//[ +1
$attributes = array();
while($command[$pos] !== ']'){
if($command[$pos] === ',')
$pos+=1;
$attributeName = readAlphabetic($command,implode($operatorsChars));
$operator = readOperator($command);
$data = null;
$type = $command[$pos];
if(isAlphabetic($type)){
$data = array('a',readAlphabetic($command));
}elseif (isNumeric($type)){
$data = array('0',readNumeric($command));
}elseif ($type === '"' or $type === '\''){
$data = array('\"',readString($command));
}elseif ($type === "@"){
$data = array('@',readSelector($command));
}
$attribute = array();
$attribute[0] = $attributeName;
$attribute[1] = $operator;
$attribute[2] = $data;
$attributes[] = $attribute;
}
$pos+=1;//after "["
if($command[$pos] == ':'){
$pos+=1;//letter after ":"
$selectedAttribute = readAlphabetic($command);
return array($className,$attributes,$selectedAttribute);
}
return array($className,$attributes);
}
$command=$_POST['command'].' ';
$nommes=array();
$pos=0;
while ($pos<strlen($command)) {
echo $pos;
$nomme = array();
$type=$command[$pos];
if(isAlphabetic($type)){
$nomme[0] = 'a';
$nomme[1] = readAlphabetic($command);
}elseif (isNumeric($type)){
$nomme[0] = '0';
$nomme[1] = readNumeric($command);
}elseif ($type === '"' or $type === '\''){
$nomme[0] = '"';
$nomme[1] = readString($command);
}elseif (in_array($type,$operatorsChars,TRUE)){
$nomme[0] = "=";
$nomme[1] = readOperator($command);
}elseif ($type === "@"){
$nomme[0] = "@";
$nomme[1] = readSelector($command);
}
elseif ($type === ' ')break;
else error($pos, 'Unexpected char "'.$command[$pos].'" , cannot get the term type');
$nommes[] = $nomme;
$pos+=1;
}
echo '<pre>';
print_r($nommes);
echo '</pre>';
default :
echo 'Unknown action : '+$_GET['action'];
function exception($reason){
echo 'An exception occurred : '.$reason;
exit;
}
if($nommes[0][0] == 'a'){
//Command
$fonction = strtoupper($nommes[0][1]);
switch ($fonction){
case 'SET':
if(count($nommes) !== 42)
exception('La fonction n\'a pas recu le bon nombre d\'arguments (42)');
if($nommes[1][0] !== '@')
exception('Le deuxième argument doit etre un selecteur');
switch ($nommes[1][0][0]){
case 'Membre':
break;
case 'Projet':
break;
case 'Membre':
break;
case 'Projet':
break;
case 'Membre':
break;
default:
exception('Unknown selector class :'.$nommes[1][0][0]);
}
case 'DELETE':
default:
exception('Unknown function '.$fonction);
}
}
}

View File

@ -1,151 +0,0 @@
<?php
class Discussion{
protected $ID;
protected $name;
protected $creatorID;
protected $dateCreation;
protected $accessibility;
protected $valid;
public function __construct($ID){
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->name = $rep['name'];
$this->creatorID = $rep['creatorID'];
$this->dateCreation = $rep['dateCreation'];
$this->accessibility = $rep['accessibility'];
}else{
$this->valid = FALSE;
}
}
public function exists(){
return $this->valid;
}
public function __toString(){
$out = 'Discussion\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tName:' . $this->name . '\n';
$out .= '\tCreator\'s ID:' . $this->creatorID . '\n';
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
$out .= '\tAccessibility:' . $this->accessibility . '\n';
return out;
}
//Getters
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getCreatorID(){
return $creatorID;
}
public function getDateCreation(){
return $this->dateCreation;
}
public function getAccessibility(){
return $this->accessibility;
}
//Useful Getters
public function canAccess($membre){
$out = $this->accessibility === 'p';
if(preg_match ( "#^a[0-9]+$#", $this->accessibility ) == 1)
$out = $out or intval ( substr ( $this->accessibility, 1 ) ) <= $membre->getAdminLevel();
$out = $out or preg_match ( '#^x([0-9]+;)*' . $membre->getID() . '(;[0-9]+)*$#', $disc ['autorized'] ) == 1;
$out = $out or $membre->getAdminLevel() >= 14;
return $out;
}
//Setters
const NAME_ALREADY_USED = 'Nom d&eacute;j&agrave; utilis&eacute;';
const ILLEGAL_NAME = 'Le nom de la discussion est incorrect : les caract&egrave;res autoris&eacutes sont :'.
'<br/> abcdefghijklmnopqrstuvwxyz<wbr/>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<wbr/>'.
'&eacute;&egrave;&agrave;&mu;_-\'()[\\]\\\\/<wbr/>,;:.&sect;!&ugrave;%&pound;$&curren;=+-*\\#~"|&ccedil;@';
const TOO_LONG_NAME = 'Le nom est trop long : maximum 256 caract&egrave;res';
public function rename($newName){
if(!exists())
return NULL;
if(getFromName($newName))
return NAME_ALREADY_USED;
$regex = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.
'éèàµ_\\-\'()\\[\\]\\\\/,;:.§!ù%£$¤=+\\-*\\#~"|ç@';
$regex = '#^['.$regex.']+$#';
if(preg_match($regex,$newName) != 1)
return ILLEGAL_NAME;
}
//Discussions getters
private static function discussionGetterOutput($req){
$out = array();
while($rep = $req->fetch())
$out[] = new Discussion($rep['ID']);
if($out)
return $out;
else
return NULL;
}
public static function getFromName($name){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE name=?');
$req->execute(array($name));
return discussionGetterOutput($req);
}
public static function getFromCreator($ID){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
$req->execute(array($ID));
return discussionGetterOutput($req);
}
public static function getFromDateCreation($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation=?');
$req->execute(array($date));
return discussionGetterOutput($req);
}
public static function getFromAccessibility($accessibility){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
$req->execute(array($accessibility));
return discussionGetterOutput($req);
}
public static function getCreatedLaterThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation>?');
$req->execute(array($date));
return discussionGetterOutput($req);
}
public static function getCreatedEarlierThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation<?');
$req->execute(array($date));
return discussionGetterOutput($req);
}
public static function getWhichHeCanAccess($he){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions');
$req->execute(array());
$out = array();
while ( $rep = $req->fetch()) {
$disc = new Discussion($rep['ID']);
if ($disc->canAccess($membre))
$out[] = $disc;
}
if($out)
return $out;
else
return NULL;
}
}

View File

@ -1,107 +1 @@
<?php
class Membre {
const DEFAULT_BANNER = "pictures/bande.png";
protected $id;
protected $password;
protected $pseudo;
protected $adminLevel;
protected $dateCreation;
protected $requiredBanner;
protected $personnalMessage;
protected $connected;
public function __construct($id = NULL, $pass = NULL) {
$this->id = $id ?? $_SESSION ['session_id'];
$this->password = $pass ?? $_SESSION ['session_mdp'];
$connected = FALSE;
}
public function connect() {
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$this->id
) );
if ($rep = $req->fetch ()) {
$connected = password_verify ( $this->pass, $rep ['mdp'] );
$this->adminLevel = $connected ? $result ['administration'] : - 1;
$this->pseudo = $connected ? $result ['pseudo'] : NULL;
if ($connected)
decodeData ( $rep ['data'] );
return $this->connected = $connected;
} else {
$req->closeCursor ();
return $this->connected = FALSE;
}
}
public function hasPersonnalMessage() {
return isset ( $this->personnalMessage );
}
public function showPersonnalMessage() {
$msg = $this->personnalMessage;
$this->personnalMessage = NULL;
return $msg;
}
private function decodeData($data) {
$jsonData = json_decode ( $data );
// 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;
}
private function encodeData() {
$jsonArray = array ();
// Set requiredBanner only if it is different from DEFAULT_BANNER
$jsonArray ['requiredBanner'] = $this->requiredBanner !== self::DEFAULT_BANNER ? $this->requiredBanner : NULL;
$jsonArray ['personnalMessage'] = $this->personnalMessage ?? NULL;
return json_encode ( $jsonArray );
}
public function getID(){
return $this->id;
}
public function getAdminLevel() {
return $this->adminLevel;
}
public function getBanner() {
return $this->requiredBanner;
}
public function isConnected() {
return $connected;
}
public static function tryToConnect($pseudo = NULL, $mdp = NULL) {
$pseudo = $pseudo ?? $_POST ['pseudo'];
$mdp = $mdp ?? $_POST ['mdp'];
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' );
$req->execute ( array (
$pseudo
) );
$reponce = $req->fetch ();
if ($reponce != NULL) {
if (password_verify ( $mdp, $reponce ['mdp'] )) {
$req->closeCursor ();
return $reponce ['ID'];
} else {
$req->closeCursor ();
return 'errormdp';
}
} else {
$req->closeCursor ();
return 'errorpseudo';
}
}
public static function registerPerson($pseudo, $mdp) {
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" );
$req->execute ( array (
$_POST ['pseudo']
) );
if ($req->fetch ())
return 'usedPseudo';
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$_POST ['pseudo'],
password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT )
) );
return 'ok';
}
}
<?phpclass Membre{ const DEFAULT_BANNER = "pictures/bande.png"; protected $id; protected $password; protected $pseudo; protected $adminLevel; protected $dateCreation; protected $requiredBanner; protected $personnalMessage; protected $connected; public function __construct($id = NULL,$pass = NULL){ $this->id = $id ?? $_SESSION['session_id']; $this->password = $pass ?? $_SESSION['session_mdp']; $connected = FALSE; } public function connect(){ $req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' ); $req->execute (array($this->id)); if ($rep = $req->fetch ()){ $connected = password_verify ( $this->pass, $rep ['mdp'] ); $this->adminLevel = $connected?$result ['administration']:-1; $this->pseudo = $connected?$result['pseudo']:NULL; if($connected)decodeData($rep['data']); return $this->connected = $connected; }else{ $req->closeCursor (); return $this->connected = FALSE; } } public function hasPersonnalMessage(){ return isset($this->personnalMessage); } public function showPersonnalMessage(){ $msg = $this->personnalMessage; $this->personnalMessage = NULL; return $msg; } private function decodeData($data) { $jsonData = json_decode($data); //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; } private function encodeData(){ $jsonArray = array(); //Set requiredBanner only if it is different from DEFAULT_BANNER $jsonArray['requiredBanner'] = $this->requiredBanner !== self::DEFAULT_BANNER ? $this->requiredBanner : NULL; $jsonArray['personnalMessage'] = $this->personnalMessage ?? NULL; return json_encode($jsonArray); } public function getAdminLevel(){ return $this->adminLevel; } public function getBanner() { return $this->requiredBanner; } public function isConnected(){ return $connected; } public static function tryToConnect($pseudo = NULL,$mdp = NULL){ $pseudo = $pseudo ?? $_POST ['pseudo']; $mdp = $mdp ?? $_POST ['mdp']; $req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' ); $req->execute ( array ( $pseudo ) ); $reponce = $req->fetch (); if ($reponce != NULL) { if (password_verify ( $mdp, $reponce ['mdp'] )) { $req->closeCursor (); return $reponce ['ID']; } else { $req->closeCursor (); return 'errormdp'; } } else { $req->closeCursor (); return 'errorpseudo'; } } public static function registerPerson($pseudo, $mdp) { $req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" ); $req->execute (array($_POST ['pseudo'])); if ($req->fetch ()) return 'usedPseudo'; $req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' ); $req->execute(array($_POST ['pseudo'],password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT))); return 'ok'; }}

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

@ -0,0 +1,64 @@
<?php
class Projet{
protected $ID;
protected $name;
protected $dateCreation;
protected $owner;
protected $secondaryOwners;
protected $valid;
public function __construct($ID){
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->name = $rep['name'];
$this->owner = new Membre($rep['ownerID']);
$this->dateCreation = $rep['dateCreation'];
$this->secondaryOwners = array();
foreach (explode(';',$rep['secondaryOwners']) AS $secondaryOwner)
$this->secondaryOwners[] = new Membre($secondaryOwner);
}else{
$this->valid = FALSE;
}
}
public function exists(){
return $this->valid;
}
public function __toString(){
$out = 'Projet\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tName:' . $this->name . '\n';
$out .= '\tOwner:{' . substr(str_replace('\n\t',';',$this->owner->__toString()),0,-1) . '}\n';
foreach($this->secondaryOwners AS $secondaryOwner)
$out .= '\tSecondary owner:{' . substr(str_replace('\n\t',';',$secondaryOwner->__toString()),0,-1) . '}\n';
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
return out;
}
//Getters
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getOwner(){
return $this->owner;
}
public function getSecondaryOwners(){
return $this->secondaryOwners;
}
public function getDateCreation(){
return $this->dateCreation;
}
}

8
form.php Normal file
View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="admindialog.php" method="post"><input name="command" type="text"/><input type="submit"/></form>
</body>
</html>