Maintenant, tout dans le executor.php. Fin de tempPreMega.
Ajout d'un super simulateur de tours de Monoï dans la page 404.
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
class Article {
|
||||
|
||||
protected $ID;
|
||||
protected $title;
|
||||
protected $short;
|
||||
protected $text;
|
||||
protected $postDate;
|
||||
protected $lastNoticeableChangeDate;
|
||||
protected $lastChange;
|
||||
protected $picPath;
|
||||
|
||||
protected $valid;
|
||||
|
||||
public function __construct($ID) {
|
||||
$this->ID = $ID;
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM articles WHERE ID=?');
|
||||
$req->execute(array($ID));
|
||||
if($rep = $req->fetch()){
|
||||
$this->valid = TRUE;
|
||||
$this->title = $rep['title'];
|
||||
$this->short = $rep['short'];
|
||||
$this->text = $rep['text'];
|
||||
$this->postDate = $rep['postDate'];
|
||||
$this->lastNoticeableChangeDate = $rep['lastNoticeableChangeDate'];
|
||||
$this->lastChange = $rep['lastChange'];
|
||||
$this->picPath = $rep['picPath'];
|
||||
}else{
|
||||
$this->valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
$out = 'MegaStockage\n';
|
||||
$out .= '\tID:' . $this->ID . '\n';
|
||||
$out .= '\tTitle:' . $this->title . '\n';
|
||||
$out .= '\tShort description' . $this->short . '\n';
|
||||
$out .= '\tText:' . $this->text . '\n';
|
||||
$out .= '\tPost article date:' . $this->postDate . '\n';
|
||||
$out .= '\tLast noticeable change date:' . $this->lastNoticeableChangeDate . '\n';
|
||||
$out .= '\tLast change date:' . $this->lastChangeDate . '\n';
|
||||
$out .= '\tPic(ture) path:' . $this->picPath . '\n';
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function exists(){
|
||||
return $this->valid;
|
||||
}
|
||||
|
||||
//Getters
|
||||
|
||||
public function getID(){
|
||||
return $this->ID;
|
||||
}
|
||||
|
||||
public function setID($ID){
|
||||
$this->ID = $ID;
|
||||
}
|
||||
|
||||
public function getTitle(){
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title){
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function getShort(){
|
||||
return $this->short;
|
||||
}
|
||||
|
||||
public function setShort($short){
|
||||
$this->short = $short;
|
||||
}
|
||||
|
||||
public function getText(){
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function setText($text){
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
public function getPostDate(){
|
||||
return $this->postDate;
|
||||
}
|
||||
|
||||
public function setPostDate($postDate){
|
||||
$this->postDate = $postDate;
|
||||
}
|
||||
|
||||
public function getLastNoticeableChangeDate(){
|
||||
return $this->lastNoticeableChangeDate;
|
||||
}
|
||||
|
||||
public function setLastNoticeableChangeDate($lastNoticeableChangeDate){
|
||||
$this->lastNoticeableChangeDate = $lastNoticeableChangeDate;
|
||||
}
|
||||
|
||||
public function getLastChange(){
|
||||
return $this->lastChange;
|
||||
}
|
||||
|
||||
public function setLastChange($lastChange){
|
||||
$this->lastChange = $lastChange;
|
||||
}
|
||||
|
||||
public function getPicPath(){
|
||||
return $this->picPath;
|
||||
}
|
||||
|
||||
public function setPicPath($picPath){
|
||||
$this->picPath = $picPath;
|
||||
}
|
||||
//Useful getters
|
||||
|
||||
//Gross getters
|
||||
public static function getNewest($count){
|
||||
$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']);
|
||||
}
|
||||
return $reps;
|
||||
|
||||
}
|
||||
|
||||
//Setters
|
||||
|
||||
//
|
||||
|
||||
//Operateurs
|
||||
|
||||
|
||||
|
||||
//Outputs texts
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+52
-17
@@ -16,7 +16,7 @@ class Discussion{
|
||||
if($rep = $req->fetch()){
|
||||
$this->valid = TRUE;
|
||||
$this->name = $rep['name'];
|
||||
$this->creatorID = new Membre($rep['creatorID']);
|
||||
$this->creator = new Membre($rep['creatorID']);
|
||||
$this->dateCreation = $rep['dateCreation'];
|
||||
$this->accessibility = $rep['accessibility'];
|
||||
}else{
|
||||
@@ -35,7 +35,7 @@ class Discussion{
|
||||
$out .= '\tCreator:{' . substr(str_replace('\n\t',';',$this->creator->__toString()),0,-1) . '}\n';
|
||||
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
|
||||
$out .= '\tAccessibility:' . $this->accessibility . '\n';
|
||||
return out;
|
||||
return $out;
|
||||
}
|
||||
|
||||
//Getters
|
||||
@@ -48,7 +48,7 @@ class Discussion{
|
||||
}
|
||||
|
||||
public function getCreator(){
|
||||
return $creator;
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
public function getDateCreation(){
|
||||
@@ -62,13 +62,24 @@ class Discussion{
|
||||
|
||||
//Useful Getters
|
||||
public function canAccess($membre){
|
||||
$out = $this->accessibility === 'p';
|
||||
$out = $out or $membre->getID() === $this->creator->getID();
|
||||
if($this->accessibility === 'p')
|
||||
return TRUE;
|
||||
if($membre->getID() === $this->creator->getID())
|
||||
return TRUE;
|
||||
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;
|
||||
if(intval ( substr ( $this->accessibility, 1 ) ) <= $membre->getAdminLevel())
|
||||
return TRUE;
|
||||
if(preg_match ( '#^x([0-9]+,)*' . $membre->getID() . '(,[0-9]+)*$#', $this->accessibility ))
|
||||
return TRUE;
|
||||
if($membre->getAdminLevel() >= 14)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function isPublic(){
|
||||
if($this->accessibility === 'p')
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,37 +141,43 @@ class Discussion{
|
||||
public static function getFromName($name){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE name=?');
|
||||
$req->execute(array($name));
|
||||
return discussionGetterOutput($req);
|
||||
return Discussion::discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromCreator($creator){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
|
||||
$req->execute(array($creator->getID()));
|
||||
return discussionGetterOutput($req);
|
||||
return Discussion::discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromDateCreation($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation=?');
|
||||
$req->execute(array($date));
|
||||
return discussionGetterOutput($req);
|
||||
return Discussion::discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromAccessibility($accessibility){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
|
||||
$req->execute(array($accessibility));
|
||||
return discussionGetterOutput($req);
|
||||
return Discussion::discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation>?');
|
||||
$req->execute(array($date));
|
||||
return discussionGetterOutput($req);
|
||||
return Discussion::discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation<?');
|
||||
$req->execute(array($date));
|
||||
return discussionGetterOutput($req);
|
||||
return Discussion::discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getPublics(){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE accessibility LIKE "p%"');
|
||||
$req->execute();
|
||||
return Discussion::discussionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getWhichHeCanAccess($he){
|
||||
@@ -170,7 +187,7 @@ class Discussion{
|
||||
$out = array();
|
||||
while ( $rep = $req->fetch()) {
|
||||
$disc = new Discussion($rep['ID']);
|
||||
if ($disc->canAccess($membre))
|
||||
if ($disc->canAccess($he))
|
||||
$out[] = $disc;
|
||||
}
|
||||
if($out)
|
||||
@@ -178,6 +195,24 @@ class Discussion{
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
//Discussion creator
|
||||
public static function createDiscussion($name, $owner) {
|
||||
if(Discussion::getFromName($name))
|
||||
return Discussion::NAME_ALREADY_USED;
|
||||
if(strlen($name)>255)
|
||||
return Discussion::TOO_LONG_NAME;
|
||||
$regex = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 éèàμ_\\-\'()\\[\\]\\\\/,;:.§!ù%£$¤=+\\-*\\#~"|ç@';
|
||||
$regex = '#^['.$regex.']+$#';
|
||||
if(preg_match($regex,$name) != 1)
|
||||
return Discussion::ILLEGAL_NAME;
|
||||
$req = $GLOBALS ['bdd']->prepare ("INSERT INTO `discussions`(`ID`, `name`, `creatorID`, `dateCreation`, `accessibility`) VALUES (NULL,?,?,NOW(),'p')" );
|
||||
$req->execute ( array (
|
||||
$name,
|
||||
$owner
|
||||
) );
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
|
||||
// Exceptions texts
|
||||
|
||||
@@ -196,4 +231,4 @@ class Discussion{
|
||||
//setDateCreation()
|
||||
const MALFORMED_DATE = 'La date de création doit être de la forme "AAAA:MM:JJ hh:mm:ss"';
|
||||
const DATE_CREATION_CHANGED = 'La date de création a bien été changée';
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -5,7 +5,7 @@ class Langage{
|
||||
public static $java;
|
||||
public static $vba;
|
||||
|
||||
protected static $languages = array();
|
||||
public static $languages = array();
|
||||
|
||||
protected $ID;
|
||||
protected $name;
|
||||
@@ -16,7 +16,7 @@ class Langage{
|
||||
$this->ID = $ID;
|
||||
$this->name = $name;
|
||||
$this->avalivableFiles = explode(" ",$avalivableFiles);
|
||||
$languages[] = $this;
|
||||
Langage::$languages[] = $this;
|
||||
}
|
||||
|
||||
public function getID(){
|
||||
@@ -45,12 +45,20 @@ class Langage{
|
||||
}
|
||||
|
||||
public static function getFromID($ID){
|
||||
foreach(self::$languages AS $language){
|
||||
foreach(Langage::$languages AS $language){
|
||||
if($language->getID() == $ID)
|
||||
return $language;
|
||||
}
|
||||
//var_dump(Langage::$languages);
|
||||
return NULL;
|
||||
}
|
||||
public static function getLanguagesFromVersions($versions){
|
||||
$languages = array();
|
||||
foreach($versions AS $version)
|
||||
array_push($languages,$version->getLanguage());
|
||||
$languages = array_unique($languages,SORT_REGULAR);
|
||||
return $languages;
|
||||
}
|
||||
|
||||
}
|
||||
Langage::$java = new Langage(0, "Java", "jar java javadoc");
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
<?php
|
||||
class Membre {
|
||||
|
||||
protected $ID;
|
||||
protected $accountID;
|
||||
protected $accountPassword;
|
||||
protected $owner;
|
||||
protected $liberties;// [ [ read , read ],[ write , write ] ]
|
||||
protected $path;
|
||||
protected $size;
|
||||
|
||||
protected $valid;
|
||||
|
||||
public function __construct($ID) {
|
||||
$this->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.'</br>';
|
||||
$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.'</br>';
|
||||
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 !';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+25
-11
@@ -44,7 +44,7 @@ class Membre {
|
||||
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
|
||||
$out .= '\tRequired banner:' . $this->requiredBanner . '\n';
|
||||
$out .= '\tPersonnal message:' . $this->personnalMessage . '\n';
|
||||
return out;
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function isConnected(){
|
||||
@@ -95,7 +95,7 @@ class Membre {
|
||||
}
|
||||
|
||||
public function isAdminLevelGreaterThan($min){
|
||||
return $this->adminLevel>$max;
|
||||
return $this->adminLevel>$min;
|
||||
}
|
||||
|
||||
public function isAdminLevelLowerOrEqualThan($max){
|
||||
@@ -120,7 +120,7 @@ class Membre {
|
||||
public function changePassword($newPassword){
|
||||
if(strlen($newPassword)>255)
|
||||
return Membre::PASSWORD_TOO_LONG;
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE membres SET mdp=? WHERE ID=?');
|
||||
$req = $GLOBALS['bdd']->prepare('UPDATE membres SET hashedPassword=? WHERE ID=?');
|
||||
$req->execute(array(password_hash ( $newPassword, PASSWORD_DEFAULT ),$this->ID));
|
||||
return Membre::PASSWORD_CHANGED;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ class Membre {
|
||||
$operator = Utility::getIntegerSqlOperator($restriction[1]);
|
||||
break;
|
||||
case 'dateCreation':
|
||||
if($restriction[2][0] !== '"'){
|
||||
if($restriction[2][0] !== '"'){//TODO add type date
|
||||
echo 'Error : the type "'.$restriction[2][0].'" is not allowed for the attribute '.$attribute;
|
||||
exit;
|
||||
}
|
||||
@@ -316,31 +316,40 @@ class Membre {
|
||||
}
|
||||
|
||||
public static function getFromPseudo($pseudo){
|
||||
return getFromAttributes(array(['pseudo','=',$pseudo]));
|
||||
return Membre::getFromAttributes(array(['pseudo','=',['"',$pseudo]]));
|
||||
}
|
||||
|
||||
public static function getFromAdminLevel($level){
|
||||
return getFromAttributes(array(['adminLevel','=',$level]));
|
||||
return Membre::getFromAttributes(array(['adminLevel','=',['0',$level]]));
|
||||
}
|
||||
|
||||
public static function getFromDateCreation($date){
|
||||
return getFromAttributes(array(['dateCreation','=',$date]));
|
||||
return Membre::getFromAttributes(array(['dateCreation','=',['0',$date]]));
|
||||
}
|
||||
|
||||
public static function getCreatedLaterThan($date){
|
||||
return getFromAttributes(array(['dateCreation','>',$date]));
|
||||
return Membre::getFromAttributes(array(['dateCreation','>',['"',$date]]));
|
||||
}
|
||||
|
||||
public static function getCreatedEarlierThan($date){
|
||||
return getFromAttributes(array(['dateCreation','<',$date]));
|
||||
return Membre::getFromAttributes(array(['dateCreation','<',['"',$date]]));
|
||||
}
|
||||
|
||||
public static function getAdminGreaterThan($min){
|
||||
return getFromAttributes(array(['adminLevel','>',$min]));
|
||||
return Membre::getFromAttributes(array(['adminLevel','>',['0',$min]]));
|
||||
}
|
||||
|
||||
public static function getAdminLowerThan($max){
|
||||
return getFromAttributes(array(['adminLevel','<',$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;
|
||||
}
|
||||
|
||||
|
||||
@@ -352,6 +361,11 @@ class Membre {
|
||||
$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
|
||||
|
||||
+18
-11
@@ -16,8 +16,8 @@ class Message{
|
||||
if($rep = $req->fetch()){
|
||||
$this->valid = TRUE;
|
||||
$this->sender = new Membre($rep['senderID']);
|
||||
$this->sendDate = $rep['sendDate'];
|
||||
$this->text = $rep['text'];
|
||||
$this->sendDate = $rep['sendTime'];
|
||||
$this->text = $rep['texte'];
|
||||
$this->discussion = new Discussion($rep['discussionID']);
|
||||
}else{
|
||||
$this->valid = FALSE;
|
||||
@@ -78,7 +78,7 @@ class Message{
|
||||
private static function messagesGetterOutput($req){
|
||||
$out = array();
|
||||
while($rep = $req->fetch())
|
||||
$out[] = new Discussion($rep['ID']);
|
||||
$out[] = new Message($rep['ID']);
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
@@ -92,45 +92,52 @@ class Message{
|
||||
public static function getFromSender($param) {
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE senderID=?');
|
||||
$req->execute(array($sender->getID()));
|
||||
return messagesGetterOutput($req);
|
||||
return Message::messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
|
||||
public static function getFromSendDate($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate=?');
|
||||
$req->execute(array($date));
|
||||
return messagesGetterOutput($req);
|
||||
return Message::messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getSendedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate>?');
|
||||
$req->execute(array($date));
|
||||
return messagesGetterOutput($req);
|
||||
return Message::messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getSendedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE sendDate<?');
|
||||
$req->execute(array($date));
|
||||
return messagesGetterOutput($req);
|
||||
return Message::messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromText($text) {
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE text=?');
|
||||
$req->execute(array($text));
|
||||
return messagesGetterOutput($req);
|
||||
return Message::messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromDiscussion($discut){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM messages WHERE discussionID=?');
|
||||
$req->execute(array($discut->getID()));
|
||||
return messagesGetterOutput($req);
|
||||
return Message::messagesGetterOutput($req);
|
||||
}
|
||||
|
||||
|
||||
//Message creator
|
||||
public static function sendMessage($sender,$discussion,$text){
|
||||
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
|
||||
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussionID,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
|
||||
$req->execute (array($discussion->getID(),htmlspecialchars ($text),$sender->getID()));
|
||||
}
|
||||
|
||||
}
|
||||
public function removeMessage(){
|
||||
$req = $GLOBALS ['bdd']->prepare ( 'DELETE FROM messages WHERE ID=?' );
|
||||
$req->execute (array($this->getID()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+37
-13
@@ -6,6 +6,7 @@ class Projet{
|
||||
protected $dateCreation;
|
||||
protected $owner;
|
||||
protected $secondaryOwners;
|
||||
protected $publik;
|
||||
|
||||
protected $valid;
|
||||
|
||||
@@ -19,8 +20,9 @@ class Projet{
|
||||
$this->owner = new Membre($rep['ownerID']);
|
||||
$this->dateCreation = $rep['dateCreation'];
|
||||
$this->secondaryOwners = array();
|
||||
foreach (explode(';',$rep['secondaryOwners']) AS $secondaryOwner)
|
||||
foreach (explode(';',$rep['secondaryOwnersID']) AS $secondaryOwner)
|
||||
$this->secondaryOwners[] = new Membre($secondaryOwner);
|
||||
$this->publik = $rep['public'];
|
||||
}else{
|
||||
$this->valid = FALSE;
|
||||
}
|
||||
@@ -38,7 +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';
|
||||
return out;
|
||||
return $out;
|
||||
}
|
||||
|
||||
//Getters
|
||||
@@ -62,10 +64,14 @@ class Projet{
|
||||
return $this->dateCreation;
|
||||
}
|
||||
|
||||
public function isPublic(){
|
||||
return $this->publik == 1;
|
||||
}
|
||||
|
||||
|
||||
//Useful getters
|
||||
public function haveRights($member){
|
||||
return $member->getID() == $owner->getID() or in_array($member,$this->secondaryOwners);
|
||||
return $member->getID() == $this->owner->getID() or in_array($member,$this->secondaryOwners);
|
||||
}
|
||||
|
||||
//Setters
|
||||
@@ -92,7 +98,7 @@ class Projet{
|
||||
private static function projectGetterOutput($req){
|
||||
$out = array();
|
||||
while($rep = $req->fetch())
|
||||
$out[] = new Project($rep['ID']);
|
||||
$out[] = new Projet($rep['ID']);
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
@@ -104,19 +110,19 @@ class Projet{
|
||||
}
|
||||
|
||||
public static function getFromName($name){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE name=?');
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE name=?');
|
||||
$req->execute(array($name));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromOwner($owner){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE owner=?');
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE owner=?');
|
||||
$req->execute(array($owner->getID()));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromSecondaryOwner($secondaryOwner){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project');
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
|
||||
$req->execute();
|
||||
$out = array();
|
||||
while ($rep = $req->fetch()) {
|
||||
@@ -141,25 +147,44 @@ class Projet{
|
||||
}
|
||||
|
||||
public static function getCreatedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation>?');
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE dateCreation>?');
|
||||
$req->execute(array($date));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getCreatedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project WHERE dateCreation<?');
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets WHERE dateCreation<?');
|
||||
$req->execute(array($date));
|
||||
return projectGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getWhichHeCanAccess($he){
|
||||
//TODO Faire la selection directement grâce à une requette SQL
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM project');
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
|
||||
$req->execute(array());
|
||||
$out = array();
|
||||
while ( $rep = $req->fetch()) {
|
||||
$projet = new Projet($rep['ID']);
|
||||
if ($projet->haveRights($membre))
|
||||
if ($projet->haveRights($he))
|
||||
$out[] = $projet;
|
||||
}
|
||||
switch(count($out)){
|
||||
case 0:
|
||||
return NULL;
|
||||
case 1:
|
||||
return $out[0];
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getOthers($he){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM projets');
|
||||
$req->execute(array());
|
||||
$out = array();
|
||||
while ( $rep = $req->fetch()) {
|
||||
$projet = new Projet($rep['ID']);
|
||||
if ($he?$he->isAdminLevelGreaterThan(12):FALSE || $projet->isPublic())
|
||||
$out[] = $projet;
|
||||
}
|
||||
switch(count($out)){
|
||||
@@ -173,5 +198,4 @@ class Projet{
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -114,4 +114,10 @@ NOT REGEXP
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static function arrayIfNot($var){
|
||||
if(!is_array($var))
|
||||
return array($var);
|
||||
return $var;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+38
-23
@@ -8,6 +8,7 @@ class Version{
|
||||
protected $tags;//String "beta bugged" in bdd , stored as a string array
|
||||
protected $project;
|
||||
protected $language;
|
||||
protected $versionAbs;
|
||||
|
||||
public function __construct($ID){
|
||||
$this->ID = $ID;
|
||||
@@ -15,12 +16,13 @@ class Version{
|
||||
$req->execute(array($ID));
|
||||
if($rep = $req->fetch()){
|
||||
$this->valid = TRUE;
|
||||
$this->name = $rem['name'];
|
||||
$this->name = $rep['name'];
|
||||
$this->sendDate = $rep['sendDate'];
|
||||
$this->publicFiles = explode(" ",$rep['publicFiles']);
|
||||
$this->tags = explode(" ",$rep['tags']);
|
||||
$this->project = new Project($rep['projectID']);
|
||||
$this->language = Langage::getFromID($rep['languageID']);
|
||||
$this->project = new Projet($rep['projectID']);
|
||||
$this->language = Langage::getFromID(intval($rep['languageID']));
|
||||
$this->versionAbs = $rep['versionAbs'];
|
||||
}else{
|
||||
$this->valid = FALSE;
|
||||
}
|
||||
@@ -31,15 +33,21 @@ class Version{
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
$out = 'Version\n';
|
||||
$out .= '\tID:' . $this->ID . '\n';
|
||||
$out .= '\tName:{' . $this->name . '}\n';
|
||||
$out .= '\tSend date:' . $this->sendDate . '\n';
|
||||
$out .= '\tPublic files:"' . implode(' ',$this->publicFiles) . '"}\n';
|
||||
$out .= '\tTags:"' . implode(' ',$this->tags) . '"}\n';
|
||||
$out .= '\tProject:' . substr(str_replace('\n\t',';',$this->project->__toString()),0,-1) . '\n';
|
||||
$out .= '\tLanguage:' . $this->language->getName() . '\n';
|
||||
return out;
|
||||
try{
|
||||
$out = 'Version\n';
|
||||
$out .= '\tID:' . $this->ID . '\n';
|
||||
$out .= '\tName:{' . $this->name . '}\n';
|
||||
$out .= '\tSend date:' . $this->sendDate . '\n';
|
||||
$out .= '\tPublic files:"' . implode(' ',$this->publicFiles) . '"}\n';
|
||||
$out .= '\tTags:"' . implode(' ',$this->tags) . '"}\n';
|
||||
$out .= '\tProject:' . substr(str_replace('\n\t',';',$this->project->__toString()),0,-1) . '\n';
|
||||
$out .= '\tLanguage:' . $this->language->getName() . '\n';
|
||||
$out .= '\tVersion absolue:' . $this->versionAbs . '\n';
|
||||
return $out;
|
||||
}catch(Error $e){
|
||||
echo '#' . $this->language . "#";
|
||||
return $e->__toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +82,10 @@ class Version{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
public function getVersionAbs(){
|
||||
return $this->versionAbs;
|
||||
}
|
||||
|
||||
//Useful Getters
|
||||
//TODO make all of the following 'is' functions using haveTag
|
||||
public function haveTag($tag){
|
||||
@@ -249,19 +261,25 @@ class Version{
|
||||
public static function getFromLanguage($language){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE languageID=?');
|
||||
$req->execute(array($language->getID()));
|
||||
return versionGetterOutput($req);
|
||||
return Version::versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromProject($project){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE projectID=?');
|
||||
$req->execute(array($project->getID()));
|
||||
return versionGetterOutput($req);
|
||||
return Version::versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getHighestFromProject($project){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE projectID=? and versionAbs=(SELECT MAX(versionAbs) FROM versions WHERE projectID=?)');
|
||||
$req->execute(array($project->getID(),$project->getID()));
|
||||
return Version::versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromName($name){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE name=?');
|
||||
$req->execute(array($name));
|
||||
return versionGetterOutput($req);
|
||||
return Version::versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromTag($tag){
|
||||
@@ -282,31 +300,28 @@ class Version{
|
||||
return $out;
|
||||
}
|
||||
|
||||
return projectGetterOutput($req);
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE languageID=?');
|
||||
$req->execute(array($language->getID()));
|
||||
return versionGetterOutput($req);
|
||||
return Version::versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getFromSendDate($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate=?');
|
||||
$req->execute(array($date));
|
||||
return versionsGetterOutput($req);
|
||||
return Version::versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getSendedLaterThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate>?');
|
||||
$req->execute(array($date));
|
||||
return versionsGetterOutput($req);
|
||||
return Version::versionGetterOutput($req);
|
||||
}
|
||||
|
||||
public static function getSendedEarlierThan($date){
|
||||
$req = $GLOBALS['bdd']->prepare('SELECT * FROM versions WHERE sendDate<?');
|
||||
$req->execute(array($date));
|
||||
return versionsGetterOutput($req);
|
||||
return Version::versionGetterOutput($req);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
try{
|
||||
//$GLOBALS['bdd'] = new PDO('mysql:host=127.0.0.1;dbname=u890869027_bcom;charset=utf8', 'u890869027', '*******************');
|
||||
$GLOBALS['bdd'] = new PDO('mysql:host=mysql.hostinger.fr;dbname=u890869027_bcom;charset=utf8', 'u890869027_bcom', '*******************');
|
||||
}catch(Exception $e){
|
||||
die ('Erreur : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
//TODO all exceptions in functions must be returns (make handle too)
|
||||
//TODO in the classes , do more test of exists in setters
|
||||
include_once 'clazz/Utility.class.php';
|
||||
include_once 'clazz/Langage.class.php';
|
||||
@@ -14,5 +14,6 @@ include_once 'clazz/Membre.class.php';
|
||||
include_once 'clazz/Discussion.class.php';
|
||||
include_once 'clazz/Message.class.php';
|
||||
include_once 'clazz/Projet.class.php';
|
||||
include_once 'clazz/Article.class.php';
|
||||
//TODO Use class's consts for file names
|
||||
include_once 'clazz/Version.class.php';
|
||||
|
||||
Reference in New Issue
Block a user