Fin du dossier megaprocess, encore de nouvelles classesx
This commit is contained in:
+59
-14
@@ -1,18 +1,19 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
include_once 'clazz/Zincluder.php';
|
||||
/*
|
||||
$me = new Membre();
|
||||
$me->connect();
|
||||
|
||||
if($me->isAdminLevelLowerThan(15)){
|
||||
$me = new Membre($_SESSION ['session_id']);
|
||||
$me->connect($_SESSION ['session_mdp']);
|
||||
if(!$me->isConnected()){
|
||||
echo 'Your must being connected to have access to this page';
|
||||
exit;
|
||||
}elseif($me->isAdminLevelLowerThan(15)){
|
||||
echo 'Your admin level is too low (15 or more required)';
|
||||
exit;
|
||||
}elseif(!isset($_POST['command'])){
|
||||
echo 'Please set an command in the URL (POST method ,name:"command")';
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
function isAlphaNumeric($char){
|
||||
return isAlphabetic($char) or isNumeric($char);
|
||||
}
|
||||
@@ -97,7 +98,7 @@ function readOperator($command,$endChar = 'abcdefghijklmnopqrstuvwxytABCDEFGHIJK
|
||||
$tPos = $pos;
|
||||
while ($tPos<$maxPos) {
|
||||
//echo $reading;
|
||||
$reading .= $command[$pos];
|
||||
$reading .= $command[$tPos];
|
||||
$tPos+=1;
|
||||
if(in_array($reading,$operators,TRUE))
|
||||
$lastOperator=$reading;
|
||||
@@ -153,7 +154,7 @@ $command=$_POST['command'].' ';
|
||||
$nommes=array();
|
||||
$pos=0;
|
||||
while ($pos<strlen($command)) {
|
||||
echo $pos;
|
||||
|
||||
$nomme = array();
|
||||
$type=$command[$pos];
|
||||
if(isAlphabetic($type)){
|
||||
@@ -171,6 +172,7 @@ while ($pos<strlen($command)) {
|
||||
}elseif ($type === "@"){
|
||||
$nomme[0] = "@";
|
||||
$nomme[1] = readSelector($command);
|
||||
//TODO Add @Selector[]:var type ':' support
|
||||
}
|
||||
elseif ($type === ' ')break;
|
||||
else error($pos, 'Unexpected char "'.$command[$pos].'" , cannot get the term type');
|
||||
@@ -179,10 +181,12 @@ while ($pos<strlen($command)) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//DEBUG
|
||||
/*
|
||||
echo '<pre>';
|
||||
print_r($nommes);
|
||||
echo '</pre>';
|
||||
*/
|
||||
|
||||
function exception($reason){
|
||||
echo 'An exception occurred : '.$reason;
|
||||
@@ -209,8 +213,12 @@ if($nommes[0][0] == 'a'){
|
||||
switch ($nommes[1][1][0]){
|
||||
case 'Membre':
|
||||
$objectsToSet = Membre::getFromAttributes($nommes[1][1][1]);
|
||||
echo '<br/><pre>';
|
||||
print_r($objectsToSet);
|
||||
echo '</pre>';
|
||||
break;
|
||||
case 'Projet':
|
||||
//TODO add others class support
|
||||
break;
|
||||
case 'Version':
|
||||
break;
|
||||
@@ -219,13 +227,50 @@ if($nommes[0][0] == 'a'){
|
||||
case 'Message':
|
||||
break;
|
||||
default:
|
||||
exception('Unknown selector class : '.$nommes[1][1][0]);
|
||||
exception('Unknown selector class :'.$nommes[1][1][0]);
|
||||
}
|
||||
if($objectsToSet === NULL)
|
||||
exception('Not any object match the specified selector');
|
||||
echo '<pre>';
|
||||
if($nommes[2][0] !== 'a')
|
||||
exception('Le troisième paramètre doit etre une chaine de commande (chaine de caractères alphanumériques commensant par une lettre sans guillemets');
|
||||
if($nommes[3][0] !== '"' and $nommes[3][0] !== '0' and $nommes[3][0] !== ':')
|
||||
exception('Le quatrième paramètre doit etre une variable (chaine de caractères entre guillemets, nombre ou variable de selecteur');
|
||||
$attributeToSetName = $nommes[2][1];
|
||||
$varToSet = $nommes[3];
|
||||
//TODO add @Selector[]:var support
|
||||
foreach($objectsToSet as $objectToSet){
|
||||
|
||||
$objectToSet->setAttribute($attributeToSetName,$varToSet[1],$varToSet[0]);
|
||||
}
|
||||
echo 'SET the value '.$varToSet[1].' at attribute '.$attributeToSetName.' of '.count($objectsToSet).' objects';
|
||||
break;
|
||||
case 'GET':
|
||||
/*
|
||||
GET selector
|
||||
*/
|
||||
if(count($nommes) !== 2)
|
||||
exception('La fonction n\'a pas recu le bon nombre d\'arguments (2)');
|
||||
if($nommes[1][0] !== '@')
|
||||
exception('Le deuxième argument doit etre un selecteur');
|
||||
$objectsToSet=NULL;
|
||||
switch ($nommes[1][1][0]){
|
||||
case 'Membre':
|
||||
$objectsToSet = Membre::getFromAttributes($nommes[1][1][1]);
|
||||
break;
|
||||
case 'Projet':
|
||||
//TODO add others class support
|
||||
break;
|
||||
case 'Version':
|
||||
break;
|
||||
case 'Discussion':
|
||||
break;
|
||||
case 'Message':
|
||||
break;
|
||||
default:
|
||||
exception('Unknown selector class :'.$nommes[1][1][0]);
|
||||
}
|
||||
echo '<br/><pre>';
|
||||
print_r($objectsToSet);
|
||||
echo '</pre>';
|
||||
echo '</pre>';+
|
||||
|
||||
|
||||
break;
|
||||
case 'DELETE':
|
||||
|
||||
Reference in New Issue
Block a user