diff --git a/admin.php b/admin.php index b3d9bbc..0b8346f 100644 --- a/admin.php +++ b/admin.php @@ -1 +1,176 @@ connect ( $_SESSION ['session_mdp'] ); +if ($me->isAdminLevelLowerThan ( 15 )) { + header ( 'Location:401.php' ); + exit (); +} +?> + + + + + +La console d'admin + + + + + + +
+ +
+ Objet

+ +
+ +
+ Valeur
+ +
+ +
+ +
+ + Hello !!!
+
+ + + + +
+
+
+ + + + + +
Nom du champ
+ + + +
+ +
+
+
+ + + + + \ No newline at end of file diff --git a/admindialog.php b/admindialog.php index e427a0b..f7a2ba9 100644 --- a/admindialog.php +++ b/admindialog.php @@ -1,52 +1,241 @@ 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+4); + $tPos = $pos; + while ($tPos<$maxPos) { + //echo $reading; + $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'; +print_r($nommes); +echo ''; -default : - echo 'Unknown action : '+$_GET['action']; +function exception($reason){ + echo 'An exception occurred : '.$reason; exit; +} + +function getObjects($selector){ -} \ No newline at end of file +} + +if($nommes[0][0] == 'a'){ + //Command + $fonction = strtoupper($nommes[0][1]); + switch ($fonction){ + case 'SET': + /* + SET selector attributeName value + */ + if(count($nommes) !== 4) + exception('La fonction n\'a pas recu le bon nombre d\'arguments (4)'); + 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': + break; + case 'Version': + break; + case 'Discussion': + break; + case 'Message': + break; + default: + exception('Unknown selector class : '.$nommes[1][1][0]); + } + if($objectsToSet === NULL) + exception('Not any object match the specified selector'); + echo '
';
+			print_r($objectsToSet);
+			echo '
'; + + break; + case 'DELETE': + + break; + default: + exception('Unknown function '.$fonction); + + } + +} + + diff --git a/clazz/Langage.class.php b/clazz/Langage.class.php index ed882e8..08aaf9c 100644 --- a/clazz/Langage.class.php +++ b/clazz/Langage.class.php @@ -1,8 +1,9 @@ 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 = 'WHERE '.implode(' AND ',$whereCommands); + + + $req = $GLOBALS['bdd']->prepare('SELECT * FROM membres '.$wherePart); + $req->execute($restrictionValues); + if($req->errorInfo()[0] == 0) + echo 'A SQL exception occured ...'; $out = array(); while($rep = $req->fetch()) $out[] = new Membre($rep['ID']); - switch(count($out)){ - case 0: - return NULL; - case 1: - return $out[0]; - default: - return $out; - } + + //Choose return value + switch(count($out)){ + case 0: + return NULL; + case 1: + return $out[0]; + default: + return $out; + } } public static function getFromPseudo($pseudo){ - $req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE pseudo=?'); - $req->execute(array($pseudo)); - return membreGetterOutput($req); + return getFromAttributes(array(['pseudo','=',$pseudo])); } public static function getFromAdminLevel($level){ - $req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE adminLevel=?'); - $req->execute(array($level)); - return membreGetterOutput($req); + return getFromAttributes(array(['adminLevel','=',$level])); } public static function getFromDateCreation($date){ - $req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE dateCreation=?'); - $req->execute(array($date)); - return membreGetterOutput($req); + return getFromAttributes(array(['dateCreation','=',$date])); } public static function getCreatedLaterThan($date){ - $req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE dateCreation>?'); - $req->execute(array($date)); - return membreGetterOutput($req); + return getFromAttributes(array(['dateCreation','>',$date])); } public static function getCreatedEarlierThan($date){ - $req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE dateCreationexecute(array($date)); - return membreGetterOutput($req); + return getFromAttributes(array(['dateCreation','<',$date])); } public static function getAdminGreaterThan($min){ - $req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE adminLevel>?'); - $req->execute(array($min)); - return membreGetterOutput($req); + return getFromAttributes(array(['adminLevel','>',$min])); } public static function getAdminLowerThan($max){ - $req = $GLOBALS['bdd']->prepare('SELECT * FROM membres WHERE adminLevelexecute(array($max)); - return membreGetterOutput($req); + return getFromAttributes(array(['adminLevel','<',$max])); } @@ -191,7 +247,7 @@ class Membre { 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::USERNAME_CHANGED; + return Membre::PERSON_REGISTERED; } diff --git a/clazz/Projet.class.php b/clazz/Projet.class.php index b00d17c..eb7e2d0 100644 --- a/clazz/Projet.class.php +++ b/clazz/Projet.class.php @@ -1,5 +1,6 @@ ou != + +...les deux valeurs ne sont pas égales +< + +...la valeur de gauche est strictement inférieure à celle de droite +> + +...la valeur de gauche est strictement supérieure à celle de droite +<= + +...la valeur de gauche est strictement inférieure ou égale à celle de droite +>= + +...la valeur de gauche est strictement supérieure ou égale à celle de droite +BETWEEN..AND + +...la valeur testée est située entre deux valeurs données +IN + +...la valeur testée se situe dans une liste valeurs données +NOT IN + +...la valeur testée ne se situe pas dans une liste de valeurs données +LIKE + +...la valeur de gauche correspond à celle de droite (celle de droite peux utiliser le caractère % pour simuler n'importe quel nombre de caractère, et _ pour un seul caractère +NOT LIKE + +...les deux valeurs ne correspondent pas +REGEXP ou RLIKE + +...la valeur de gauche correspond à l'expression régulière donnée +NOT REGEXP + +...la valeur de gauche ne correspond pas à l'expression régulière donnée + */ + + public static function getIntegerSqlOperator($operator){ + switch ($operator){ + case '=': + return '='; + case '<': + return '<'; + case '>': + return '>'; + case '<=': + return '<='; + case '>=': + return '>='; + case '=<': + return '<='; + case '<>': + return '<>'; + case '!=': + return '!='; + case '!<': + return '!<'; + case '!>': + return '!>'; + default: + throw new InvalidOperatorException('integer',$operator); + } + } + + public static function getStringSqlOperator($operator){ + switch ($operator){ + case '=': + return '='; + case '&like;': + return 'LIKE'; + default: + throw new InvalidOperatorException('string',$operator); + } + } + + public static function getDateSqlOperator($operator){ + switch ($operator){ + case '=': + return '='; + case '<': + return '<'; + case '>': + return '>'; + case '<=': + return '<='; + case '>=': + return '>='; + case '=<': + return '<='; + case '<>': + return '<>'; + case '!=': + return '!='; + case '!<': + return '!<'; + case '!>': + return '!>'; + default: + throw new InvalidOperatorException('date',$operator); + } + } + +} \ No newline at end of file diff --git a/clazz/Zincluder.php b/clazz/Zincluder.php index 71918e8..45004e2 100644 --- a/clazz/Zincluder.php +++ b/clazz/Zincluder.php @@ -7,10 +7,11 @@ try{ } //TODO in the classes , do more test of exists in setters +include_once 'clazz/Utility.class.php'; include_once 'clazz/Langage.class.php'; include_once 'clazz/Membre.class.php'; include_once 'clazz/Discussion.class.php'; include_once 'clazz/Message.class.php'; include_once 'clazz/Projet.class.php'; -//Use class's consts for file names +//TODO Use class's consts for file names include_once 'clazz/Version.class.php'; diff --git a/css/adminStyle.css b/css/adminStyle.css new file mode 100644 index 0000000..b4e9bf4 --- /dev/null +++ b/css/adminStyle.css @@ -0,0 +1,62 @@ +#adminDialogAnswer{ + display:block; + background-color:black; + color:white; + height: 150px; + overflow:scroll; +} +#setFormObject , #setChampsForm{ + display:inline-block; + text-align: center; + height: inherit; +} + +#setFormObject{ + width:25%; +} + +#setChampsForm{ + width:75%; +} + +#setDiv{ + border:5px double grey; +} + +#send{ + width:100%; +} + +.fullscreen{ + position:fixed; + top:0; + right:0; + width:100%; + height:100%; + vertical-align:middle; + background-color: #222; + opacity:0.97; +} + +.screen-vertical-centered{ + text-align:center; + margin-top: 50vh; + transform: translateY(-50%); +} +.screen-horizontal-centered{ + display:inline; + opacity:1; + font-size:42px; + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + /* This is the dangerous one in WebKit, as it breaks things wherever */ + word-break: break-all; + /* Instead use this non-standard one: */ + word-break: break-word; + /* Adds a hyphen where the word breaks, if supported (No Blink) */ + -ms-hyphens: auto; + -moz-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} \ No newline at end of file diff --git a/form.php b/form.php new file mode 100644 index 0000000..85f39ec --- /dev/null +++ b/form.php @@ -0,0 +1,9 @@ + + + + + +
+
+ + \ No newline at end of file diff --git a/includes/inter.php b/includes/inter.php index f0f0e36..4c8d6cb 100644 --- a/includes/inter.php +++ b/includes/inter.php @@ -155,7 +155,6 @@ function getVersions($pid = NULL) { $req->execute ( array ( $pid ) ); - // ADDPOINT langage $versions = array ( array (), array () @@ -217,6 +216,7 @@ function getMessages($discut = NULL) { $req->closeCursor (); return array_slice ( $rep, 0, - 1, TRUE ); } + function getDiscuts() { $req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions ORDER BY date_creation DESC" ); $rep = array (); diff --git a/inter.php b/inter.php deleted file mode 100644 index 60487ea..0000000 --- a/inter.php +++ /dev/null @@ -1,262 +0,0 @@ -prepare ( 'SELECT * FROM users WHERE ID=?' ); - $req->execute ( array ( - $sid - ) ); - if ($rep = $req->fetch ()) { - $connected = password_verify ( $mdp, $rep ['mdp'] ); - } else { - $connected = FALSE; - } - $req->closeCursor (); - return $connected; -} -function getAdminLevel($sid = NULL, $mdp = NULL) { - if (! isset ( $sid ) or ! isset ( $mdp )) { - $sid = $_SESSION ['session_id']; - $mdp = $_SESSION ['session_mdp']; - } - if (! isConnected ( $sid, $mdp )) - return - 1; - $req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' ); - $req->execute ( array ( - $sid - ) ); - if ($result = $req->fetch ()) { - $adminLevel = $result ['administration']; - } else { - $adminLevel = - 1; - } - $req->closeCursor (); - return $adminLevel; -} -function getPseudo($sid = NULL, $mdp = NULL) { - if (! isset ( $sid ) or ! isset ( $mdp )) { - $sid = $_SESSION ['session_id']; - $mdp = $_SESSION ['session_mdp']; - } - if (! isConnected ( $sid, $mdp )) - return "neant"; - $req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' ); - $req->execute ( array ( - $sid - ) ); - $pseudo = $req->fetch () ['pseudo']; - $req->closeCursor (); - return $pseudo; -} -function getPseudoOf($sid) { - $req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' ); - $req->execute ( array ( - $sid - ) ); - $pseudo = $req->fetch () ['pseudo']; - $req->closeCursor (); - return $pseudo; -} -function tryToConnect($pseudo = NULL, $mdp = NULL) { - if (! isset ( $pseudo ) or ! isset ( $mdp )) { - $pseudo = $_POST ['pseudo']; - $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'; - } -} -function getProjectVersionData($project = NULL, $version = NULL) { - if (! isset ( $project ) or ! isset ( $version )) { - $project = $_GET ['id']; - $version = $_GET ['v']; - } - $req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS pID ,' . ' ' . 'v.versionAbs AS versionAbs , ' . ' ' . 'p.name AS name ,' . ' ' . 'v.version AS version ,' . ' ' . 'v.language AS language ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'INNER JOIN versions AS v' . ' ' . 'ON v.project_id = p.ID' . ' ' . 'WHERE v.project_id = ? AND v.versionAbs = ?' ); - $req->execute ( array ( - $project, - $version - ) ); - if (($data = $req->fetch ())) { - $req->closeCursor (); - return $data; - } else { - $req->closeCursor (); - return NULL; - } -} -function getProjectData($project = NULL) { - if (! isset ( $project )) { - $project = $_GET ['id']; - } - $req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS ID ,' . ' ' . 'p.name AS name ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'WHERE p.ID = ?' ); - $req->execute ( array ( - $project - ) ); - if (($data = $req->fetch ())) { - $req->closeCursor (); - return $data; - } else { - $req->closeCursor (); - return NULL; - } -} -function getPermissions($data) { - $permissions = array ( - FALSE, - FALSE, - FALSE, - FALSE - ); - $permissions [0] = preg_match ( '#^1#', $data ['permissions'] ); - $permissions [1] = preg_match ( '#^(0|1)1#', $data ['permissions'] ); - $permissions [2] = preg_match ( '#^(0|1){2}1#', $data ['permissions'] ); - $permissions [3] = preg_match ( '#^(0|1){3}1#', $data ['permissions'] ); - return $permissions; -} -function getProjectsWithFirstPermission() { - $requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.permissions LIKE "1%" '; - $req = $GLOBALS ['bdd']->query ( $requete ); - $projects = array (); - - while ( $rep = $req->fetch () ) { - if (! isset ( $projects [$rep ['projectID']] )) { - $projects [$rep ['projectID']] = $rep; - } else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) { - $projects [$rep ['projectID']] = $rep; - } - } - $req->closeCursor (); - return $projects; -} -function getVersions($pid = NULL) { - if (! isset ( $pid )) { - $pid = $_GET ['id']; - } - - $requete = 'SELECT * FROM versions WHERE project_id = ?'; - $req = $GLOBALS ['bdd']->prepare ( $requete ); - $req->execute ( array ( - $pid - ) ); - // ADDPOINT langage - $versions = array ( - array (), - array () - ); - while ( $rep = $req->fetch () ) { - $versions [$rep ['language']] [] = array ( - 'versionAbs' => $rep ['versionAbs'], - 'versionName' => $rep ['version'] - ); - } - $req->closeCursor (); - return $versions; -} -function getOwnersisProjects($sid = NULL) { - if (! isset ( $sid )) { - $sid = $_SESSION ['session_id']; - } - $requete = 'SELECT p.ownersID AS ownersID , p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.ownersID REGEXP \'[^0-9]?' . $sid . '[^0-9]?\' '; - $req = $GLOBALS ['bdd']->query ( $requete ); - $projects = array (); - while ( $rep = $req->fetch () ) { - if (! isset ( $projects [$rep ['projectID']] )) { - $projects [$rep ['projectID']] = $rep; - } else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) { - $projects [$rep ['projectID']] = $rep; - } - } - return $projects; -} -function registerPerson($pseudo, $mdp) { - $req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" ); - $req->execute ( array ( - $_POST ['pseudo'] - ) ); - if ($req->fetch ()) { - return 'usedPseudo'; - } else { - $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'; - } -} -function getMessages($discut = NULL) { - if (! isset ( $discut )) { - $discut = $_GET ['d']; - } - $req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE discussion_id=? ORDER BY sendTime DESC" ); - $req->execute ( array ( - $discut - ) ); - $rep = array (); - while ( $rep [] = $req->fetch () ) - ; - if (count ( $rep ) <= 0) - $rep = NULL; - $req->closeCursor (); - return array_slice ( $rep, 0, - 1, TRUE ); -} -function getDiscuts() { - $req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions ORDER BY date_creation DESC" ); - $rep = array (); - while ( $rep [] = $req->fetch () ) - ; - if (count ( $rep ) <= 1) - $rep = NULL; - $req->closeCursor (); - return array_slice ( $rep, 0, - 1, TRUE ); -} -function getDiscutInfos($did = NULL) { - if(!isset($did)){ - $did = $_GET['d']; - } - $req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions WHERE ID=?" ); - return $req->fetch(); -} -function sendMessage($discut = NULL, $text = NULL, $sender = NULL) { - if (! isset ( $discut ) || ! isset ( $text ) || ! isset ( $sender )) { - $discut = $_GET ['d']; - $text = $_POST ['msg']; - $sender = $_SESSION ['session_id']; - } - $req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' ); - $req->execute ( array ( - $discut, - htmlspecialchars ( $text ), - $sender - ) ); - return 'ok'; -} -function createDiscut($name = NULL, $owner = NULL) { - if (! isset ( $name ) || ! isset ( $owner )) { - $name = $_POST ['name']; - $owner = $_SESSION ['session_id']; - } - $req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO discussions(name,creator_id,date_creation) VALUES (?,?,NOW())' ); - $req->execute ( array ( - $name, - $owner - ) ); - return 'ok'; -} diff --git a/nombre univers.cpp b/nombre univers.cpp new file mode 100644 index 0000000..fc91cef --- /dev/null +++ b/nombre univers.cpp @@ -0,0 +1,11 @@ +#include +using namespace std; +int main(){ +long long int a=1; +cout << "0."; +while(1){ +cout << a; +a++; +} +return 0; +} \ No newline at end of file