Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- abstract class Members {
- protected $Nickname;
- protected $Password;
- protected $Rank;
- protected $Mail;
- protected $FConnTimestamp;
- protected $FConnDate;
- protected $LConnTimestamp;
- protected $LConnDate;
- protected $InscriptionTimestamp;
- protected $IncriptionDate;
- protected $AvatarsName;
- protected $Quote;
- protected $Signature;
- protected $WMailPM;
- protected $WMailATM;
- protected $WMailATA;
- protected $WMailATF;
- protected $RFproperty;
- protected $Property;
- protected $mysql;
- protected $CanBeUsed = FALSE;
- protected $WasAlreadyStored = FALSE;
- public function __construct ( ) {
- $this->RFproperty = new ReflexionClass ( 'Members' );
- $ArgsNumber = func_num_args ( );
- if ( $ArgsNumber == 1 ) {
- $id = func_get_arg ( 0 );
- if ( is_numeric ( $id ) AND $id > 0 ) {
- $this->mysql = mysql_connect ( HOSTNAME, USERNAME, PASSWORD );
- if ( $this->mysql ) {
- $db = mysql_select_db ( DBNAME );
- if ( $db == FALSE ) {
- $Arg = func_get_arg ( 0 );
- if ( is_numeric ( $Arg ) ) {
- if ( $member_ressource = mysql_query ( 'SELECT * FROM members WHERE id = '.$id, $this->mysql ) ) {
- if ( $member = mysql_fetch_row ( $member_ressource ) ) {
- /* Ici, affectation des valeurs de la BDD aux properties de la classe */
- $this->CanBeUsed = TRUE;
- $this->WasAlreadyStored = TRUE;
- } else {
- throw new Exception ( 'Aucune ligne n\est disponible dans la ressource de selection du membre.' );
- }
- } else {
- throw new Exception ( 'La requete pour aller chercher les informations concernant le membre n\'a pas pu avoir lieu.' );
- }
- } else {
- throw new Exception ( 'L\'id passé au constructeur n\'est pas un nombre.' );
- }
- } else {
- throw new Exception ( 'Impossible de selectionner la base de données.' );
- }
- } else {
- throw new Exception ( 'Impossible de se connecter à MySQL avec les identifiants actuels.' );
- }
- } else {
- throw new Exception ( 'L\'id passé au constructeur n\'est pas un nombre.' );
- }
- } elseif ( $ArgsNumber == 11 ) {
- $Nickname = func_get_arg ( 0 );
- $Password = func_get_arg ( 1 );
- $Rank = func_get_arg ( 2 );
- $Mail = func_get_arg ( 3 );
- $FirstConnection = func_get_arg ( 4 );
- $LastConnection = func_get_arg ( 5 );
- $Inscription = func_get_arg ( 6 );
- $AvatarsName = func_get_arg ( 7 );
- $Quote = func_get_arg ( 8 );
- $Signature = func_get_arg ( 9 )
- $WMail = func_get_arg ( 10 );
- if ( is_string ( $Nickname ) ) {
- $this->Nickname = $Nickname;
- if ( is_string ( $Password ) ) {
- $this->Password = $Password;
- if ( is_numeric ( $Rank ) ) {
- $this->Rank = $Rank;
- if ( is_string ( $Mail ) ) {
- if ( self::isMailValid ( $Mail ) ) {
- $this->Mail = $Mail;
- if ( is_numeric ( $FirstConnection ) AND $FirstConnection > 0 ) {
- $this->FConnTimestamp = $FirstConnection;
- $this->FConnDate = date ( 'H:i:s d/m/Y', $FirstConnection );
- if ( is_numeric ( $LastConnection ) AND $LastConnection > 0 ) {
- $this->LConnTimestamp = $LastConnection;
- $this->LConnDate = date ( 'H:i:s d/m/Y', $LastConnection );
- if ( is_numeric ( $Inscription ) AND $Inscription > 0 ) {
- $this->InscriptionTimestamp = $Inscription;
- $this->InscriptionDate = date ( 'H:i:s d/m/Y', $Inscription );
- if ( is_string ( $AvatarsName ) ) {
- $this->AvatarsName = $AvatarsName;
- if ( is_string ( $Quote ) ) {
- $this->Quote = $Quote;
- if ( is_string ( $Signature ) ) {
- $this->Signature = $Signature;
- if ( is_numeric ( $WMail ) ) {
- $this->WMailPM = $WMail & 1;
- $this->WMailATM = $WMail & 2;
- $this->WMailATA = $WMail & 4;
- $this->WMailATF = $WMail & 8;
- $this->CanBeUsed = TRUE;
- } else {
- throw new Exception ( 'Une erreur est survenue lors de la determination des conditions d\'envoi de mails.' );
- }
- } else {
- throw new Exception ( 'La Signature passée au constructeur n\'est pas une chaine de caractères.' );
- }
- } else {
- throw new Exception ( 'La citation passée au constructeur n\'est pas une chaine de caractères.' );
- }
- } else {
- throw new Exception ( 'Le nom de l\'avatar passé au constructeur n\'est pas une chaine de caractères.' );
- }
- } else {
- throw new Exception ( 'Le timestamp indiquant la date d\'inscription du membre est invalide.' );
- }
- } else {
- throw new Exception ( 'Le timestamp indiquant la date de dernière connexion du membre est invalide.' );
- }
- } else {
- throw new Exception ( 'Le timestamp indiquant la date de la première connexion du membre est invalide.' );
- }
- } else {
- throw new Exception ( 'Le mail passé au constructeur n\'est pas un mail valide.' );
- }
- } else {
- throw new Exception ( 'Le mail passé au constructeur n\'est pas une chaine de caractères.' );
- }
- } else {
- throw new Exception ( 'Le rang passé au constructeur n\'est pas un nombre.' );
- }
- } else {
- throw new Exception ( 'Le mot de passe passé au constructeur n\'est pas une chaine de caractères.' );
- }
- } else {
- throw new Exception ( 'Le pseudonyme passé au constructeur n\'est pas une chaine de caractères.' );
- }
- } else {
- throw new Exception ( 'Les arguments que vous avez passé au constructeur sont invalides.' );
- }
- }
- final protected function isMailValid ( $Mail ) {
- }
- /*public function get ( $AttributName ) {
- $this->Property = $this->RFproperty->getProperty ( $AttributName );
- $this->Property->setAccessible ( TRUE );
- return $this->Property->getValue ( $this );
- }*/
- final public function update ( ) {
- if ( $this->CanBeUsed ) {
- if ( $this->WasAlreadyStored ) {
- $result = mysql_query ( /* Requête pour mettre à jour les informations sur le membre */, $this->mysql );
- } else {
- $result = mysql_query ( /* Requête pour insérer le membre et ses informations dans la BDD */, $this->mysql );
- }
- if ( $result == FALSE ) {
- throw new Exception ( 'Une erreur est survenue lors de l\'upload concernant les informations du membre.' );
- }
- }
- }
- public function __destruct ( ) {
- if ( $this->CanBeUsed ) {
- mysql_close ( $this->mysql );
- }
- }
- }
- final class Member extends Members {
- public function __construct ( ) {
- $ArgsNumber = func_num_args ( );
- if ( $ArgsNumber == 1 ) {
- $id = func_get_arg ( 0 );
- parent::__construct ( $id );
- } elseif ( $ArgsNumber == 10 ) {
- $Nickname = func_get_arg ( 0 );
- $Password = func_get_arg ( 1 );
- $Mail = func_get_arg ( 2 );
- $FirstConnection = func_get_arg ( 3 );
- $LastConnection = func_get_arg ( 4 );
- $Inscription = func_get_arg ( 5 );
- $AvatarsName = func_get_arg ( 6 );
- $Quote = func_get_arg ( 7 );
- $Signature = func_get_arg ( 8 )
- $WMail = func_get_arg ( 9 );
- parent::__construct ( $Nickname, $Password, 1, $Mail, $FirstConnection, $LastConnection, $Inscription, $AvatarsName, $Quote, $Signature, $WMail );
- } else {
- throw new Exception ( 'Les arguments que vous avez passé au constructeur sont invalides.' );
- }
- }
- public function __destruct ( ) {
- parent::__destruct ( );
- }
- }
- final class Moderator extends Members {
- public function __construct ( ) {
- $ArgsNumber = func_num_args ( );
- if ( $ArgsNumber == 1 ) {
- $id = func_get_arg ( 0 );
- parent::__construct ( $id );
- } elseif ( $ArgsNumber == 10 ) {
- $Nickname = func_get_arg ( 0 );
- $Password = func_get_arg ( 1 );
- $Mail = func_get_arg ( 2 );
- $FirstConnection = func_get_arg ( 3 );
- $LastConnection = func_get_arg ( 4 );
- $Inscription = func_get_arg ( 5 );
- $AvatarsName = func_get_arg ( 6 );
- $Quote = func_get_arg ( 7 );
- $Signature = func_get_arg ( 8 )
- $WMail = func_get_arg ( 9 );
- parent::__construct ( $Nickname, $Password, 2, $Mail, $FirstConnection, $LastConnection, $Inscription, $AvatarsName, $Quote, $Signature, $WMail );
- } else {
- throw new Exception ( 'Les arguments que vous avez passé au constructeur sont invalides.' );
- }
- }
- public function __destruct ( ) {
- parent::__destruct ( );
- }
- }
- final class Administrator extends Members {
- public function __construct ( ) {
- $ArgsNumber = func_num_args ( );
- if ( $ArgsNumber == 1 ) {
- $id = func_get_arg ( 0 );
- parent::__construct ( $id );
- } elseif ( $ArgsNumber == 10 ) {
- $Nickname = func_get_arg ( 0 );
- $Password = func_get_arg ( 1 );
- $Mail = func_get_arg ( 2 );
- $FirstConnection = func_get_arg ( 3 );
- $LastConnection = func_get_arg ( 4 );
- $Inscription = func_get_arg ( 5 );
- $AvatarsName = func_get_arg ( 6 );
- $Quote = func_get_arg ( 7 );
- $Signature = func_get_arg ( 8 )
- $WMail = func_get_arg ( 9 );
- parent::__construct ( $Nickname, $Password, 3, $Mail, $FirstConnection, $LastConnection, $Inscription, $AvatarsName, $Quote, $Signature, $WMail );
- } else {
- throw new Exception ( 'Les arguments que vous avez passé au constructeur sont invalides.' );
- }
- }
- public function __destruct ( ) {
- parent::__destruct ( );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement