Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.62 KB | None | 0 0
  1. <?php
  2.     abstract class Members {
  3.         protected   $Nickname;
  4.         protected   $Password;
  5.         protected   $Rank;
  6.         protected   $Mail;
  7.         protected   $FConnTimestamp;
  8.         protected   $FConnDate;
  9.         protected   $LConnTimestamp;
  10.         protected   $LConnDate;
  11.         protected   $InscriptionTimestamp;
  12.         protected   $IncriptionDate;
  13.         protected   $AvatarsName;
  14.         protected   $Quote;
  15.         protected   $Signature;
  16.         protected   $WMailPM;
  17.         protected   $WMailATM;
  18.         protected   $WMailATA;
  19.         protected   $WMailATF;
  20.         protected   $RFproperty;
  21.         protected   $Property;
  22.         protected   $mysql;
  23.         protected   $CanBeUsed = FALSE;
  24.         protected   $WasAlreadyStored = FALSE;
  25.  
  26.         public function __construct ( ) {
  27.             $this->RFproperty = new ReflexionClass ( 'Members' );
  28.             $ArgsNumber = func_num_args ( );
  29.             if ( $ArgsNumber == 1 ) {
  30.                 $id = func_get_arg ( 0 );
  31.                 if ( is_numeric ( $id ) AND $id > 0 ) {
  32.                     $this->mysql = mysql_connect ( HOSTNAME, USERNAME, PASSWORD );
  33.                     if ( $this->mysql ) {
  34.                         $db = mysql_select_db ( DBNAME );
  35.                         if ( $db == FALSE ) {
  36.                             $Arg = func_get_arg ( 0 );
  37.                             if ( is_numeric ( $Arg ) ) {
  38.                                 if ( $member_ressource = mysql_query ( 'SELECT * FROM members WHERE id = '.$id, $this->mysql ) ) {
  39.                                     if ( $member = mysql_fetch_row ( $member_ressource ) ) {
  40.                                         /* Ici, affectation des valeurs de la BDD aux properties de la classe */
  41.                                         $this->CanBeUsed = TRUE;
  42.                                         $this->WasAlreadyStored = TRUE;
  43.                                     } else {
  44.                                         throw new Exception ( 'Aucune ligne n\est disponible dans la ressource de selection du membre.' );
  45.                                     }
  46.                                 } else {
  47.                                     throw new Exception ( 'La requete pour aller chercher les informations concernant le membre n\'a pas pu avoir lieu.' );
  48.                                 }
  49.                             } else {
  50.                                 throw new Exception ( 'L\'id passé au constructeur n\'est pas un nombre.' );
  51.                             }
  52.                         } else {
  53.                             throw new Exception ( 'Impossible de selectionner la base de données.' );
  54.                         }
  55.                     } else {
  56.                         throw new Exception ( 'Impossible de se connecter à MySQL avec les identifiants actuels.' );
  57.                     }
  58.                 } else {
  59.                     throw new Exception ( 'L\'id passé au constructeur n\'est pas un nombre.' );
  60.                 }
  61.             } elseif ( $ArgsNumber == 11 ) {
  62.                 $Nickname = func_get_arg ( 0 );
  63.                 $Password = func_get_arg ( 1 );
  64.                 $Rank = func_get_arg ( 2 );
  65.                 $Mail = func_get_arg ( 3 );
  66.                 $FirstConnection = func_get_arg ( 4 );
  67.                 $LastConnection = func_get_arg ( 5 );
  68.                 $Inscription = func_get_arg ( 6 );
  69.                 $AvatarsName = func_get_arg ( 7 );
  70.                 $Quote = func_get_arg ( 8 );
  71.                 $Signature = func_get_arg ( 9 )
  72.                 $WMail = func_get_arg ( 10 );
  73.                
  74.                 if ( is_string ( $Nickname ) ) {
  75.                     $this->Nickname = $Nickname;
  76.                     if ( is_string ( $Password ) ) {
  77.                         $this->Password = $Password;
  78.                         if ( is_numeric ( $Rank ) ) {
  79.                             $this->Rank = $Rank;
  80.                             if ( is_string ( $Mail ) ) {
  81.                                 if ( self::isMailValid ( $Mail ) ) {
  82.                                     $this->Mail = $Mail;
  83.                                     if ( is_numeric ( $FirstConnection ) AND $FirstConnection > 0 ) {
  84.                                         $this->FConnTimestamp = $FirstConnection;
  85.                                         $this->FConnDate = date ( 'H:i:s d/m/Y', $FirstConnection );
  86.                                         if ( is_numeric ( $LastConnection ) AND $LastConnection > 0 ) {
  87.                                             $this->LConnTimestamp = $LastConnection;
  88.                                             $this->LConnDate = date ( 'H:i:s d/m/Y', $LastConnection );
  89.                                             if ( is_numeric ( $Inscription ) AND $Inscription > 0 ) {
  90.                                                 $this->InscriptionTimestamp = $Inscription;
  91.                                                 $this->InscriptionDate = date ( 'H:i:s d/m/Y', $Inscription );
  92.                                                 if ( is_string ( $AvatarsName ) ) {
  93.                                                     $this->AvatarsName = $AvatarsName;
  94.                                                     if ( is_string ( $Quote ) ) {
  95.                                                         $this->Quote = $Quote;
  96.                                                         if ( is_string ( $Signature ) ) {
  97.                                                             $this->Signature = $Signature;
  98.                                                             if ( is_numeric ( $WMail ) ) {
  99.                                                                 $this->WMailPM = $WMail & 1;
  100.                                                                 $this->WMailATM = $WMail & 2;
  101.                                                                 $this->WMailATA = $WMail & 4;
  102.                                                                 $this->WMailATF = $WMail & 8;
  103.                                                                 $this->CanBeUsed = TRUE;
  104.                                                             } else {
  105.                                                                 throw new Exception ( 'Une erreur est survenue lors de la determination des conditions d\'envoi de mails.' );
  106.                                                             }
  107.                                                         } else {
  108.                                                             throw new Exception ( 'La Signature passée au constructeur n\'est pas une chaine de caractères.' );
  109.                                                         }
  110.                                                     } else {
  111.                                                         throw new Exception ( 'La citation passée au constructeur n\'est pas une chaine de caractères.' );
  112.                                                     }
  113.                                                 } else {
  114.                                                     throw new Exception ( 'Le nom de l\'avatar passé au constructeur n\'est pas une chaine de caractères.' );
  115.                                                 }
  116.                                             } else {
  117.                                                 throw new Exception ( 'Le timestamp indiquant la date d\'inscription du membre est invalide.' );
  118.                                             }
  119.                                         } else {
  120.                                             throw new Exception ( 'Le timestamp indiquant la date de dernière connexion du membre est invalide.' );
  121.                                         }
  122.                                     } else {
  123.                                         throw new Exception ( 'Le timestamp indiquant la date de la première connexion du membre est invalide.' );
  124.                                     }
  125.                                 } else {
  126.                                     throw new Exception ( 'Le mail passé au constructeur n\'est pas un mail valide.' );
  127.                                 }
  128.                             } else {
  129.                                 throw new Exception ( 'Le mail passé au constructeur n\'est pas une chaine de caractères.' );
  130.                             }
  131.                         } else {
  132.                             throw new Exception ( 'Le rang passé au constructeur n\'est pas un nombre.' );
  133.                         }
  134.                     } else {
  135.                         throw new Exception ( 'Le mot de passe passé au constructeur n\'est pas une chaine de caractères.' );
  136.                     }
  137.                 } else {
  138.                     throw new Exception ( 'Le pseudonyme passé au constructeur n\'est pas une chaine de caractères.' );
  139.                 }
  140.             } else {
  141.                 throw new Exception ( 'Les arguments que vous avez passé au constructeur sont invalides.' );
  142.             }
  143.         }
  144.        
  145.         final protected function isMailValid ( $Mail ) {
  146.            
  147.         }
  148.  
  149.         /*public function get ( $AttributName ) {
  150.             $this->Property = $this->RFproperty->getProperty ( $AttributName );
  151.             $this->Property->setAccessible ( TRUE );
  152.  
  153.             return $this->Property->getValue ( $this );
  154.         }*/
  155.  
  156.         final public function update ( ) {
  157.             if ( $this->CanBeUsed ) {
  158.                 if ( $this->WasAlreadyStored ) {
  159.                     $result = mysql_query ( /* Requête pour mettre à jour les informations sur le membre */, $this->mysql );
  160.                 } else {
  161.                     $result = mysql_query ( /* Requête pour insérer le membre et ses informations dans la BDD */, $this->mysql );
  162.                 }
  163.                 if ( $result == FALSE ) {
  164.                     throw new Exception ( 'Une erreur est survenue lors de l\'upload concernant les informations du membre.' );
  165.                 }
  166.             }
  167.         }
  168.        
  169.         public function __destruct ( ) {
  170.             if ( $this->CanBeUsed ) {
  171.                 mysql_close ( $this->mysql );
  172.             }
  173.         }
  174.     }
  175.  
  176.     final class Member extends Members {
  177.         public function __construct ( ) {
  178.             $ArgsNumber = func_num_args ( );
  179.             if ( $ArgsNumber == 1 ) {
  180.                 $id = func_get_arg ( 0 );
  181.                 parent::__construct ( $id );
  182.             } elseif ( $ArgsNumber == 10 ) {
  183.                 $Nickname = func_get_arg ( 0 );
  184.                 $Password = func_get_arg ( 1 );
  185.                 $Mail = func_get_arg ( 2 );
  186.                 $FirstConnection = func_get_arg ( 3 );
  187.                 $LastConnection = func_get_arg ( 4 );
  188.                 $Inscription = func_get_arg ( 5 );
  189.                 $AvatarsName = func_get_arg ( 6 );
  190.                 $Quote = func_get_arg ( 7 );
  191.                 $Signature = func_get_arg ( 8 )
  192.                 $WMail = func_get_arg ( 9 );
  193.                 parent::__construct ( $Nickname, $Password, 1, $Mail, $FirstConnection, $LastConnection, $Inscription, $AvatarsName, $Quote, $Signature, $WMail );
  194.             } else {
  195.                 throw new Exception ( 'Les arguments que vous avez passé au constructeur sont invalides.' );
  196.             }
  197.         }
  198.        
  199.         public function __destruct ( ) {
  200.             parent::__destruct ( );
  201.         }
  202.     }
  203.  
  204.     final class Moderator extends Members {
  205.         public function __construct ( ) {
  206.             $ArgsNumber = func_num_args ( );
  207.             if ( $ArgsNumber == 1 ) {
  208.                 $id = func_get_arg ( 0 );
  209.                 parent::__construct ( $id );
  210.             } elseif ( $ArgsNumber == 10 ) {
  211.                 $Nickname = func_get_arg ( 0 );
  212.                 $Password = func_get_arg ( 1 );
  213.                 $Mail = func_get_arg ( 2 );
  214.                 $FirstConnection = func_get_arg ( 3 );
  215.                 $LastConnection = func_get_arg ( 4 );
  216.                 $Inscription = func_get_arg ( 5 );
  217.                 $AvatarsName = func_get_arg ( 6 );
  218.                 $Quote = func_get_arg ( 7 );
  219.                 $Signature = func_get_arg ( 8 )
  220.                 $WMail = func_get_arg ( 9 );
  221.                 parent::__construct ( $Nickname, $Password, 2, $Mail, $FirstConnection, $LastConnection, $Inscription, $AvatarsName, $Quote, $Signature, $WMail );
  222.             } else {
  223.                 throw new Exception ( 'Les arguments que vous avez passé au constructeur sont invalides.' );
  224.             }
  225.         }
  226.        
  227.         public function __destruct ( ) {
  228.             parent::__destruct ( );
  229.         }
  230.     }
  231.  
  232.     final class Administrator extends Members {
  233.         public function __construct ( ) {
  234.             $ArgsNumber = func_num_args ( );
  235.             if ( $ArgsNumber == 1 ) {
  236.                 $id = func_get_arg ( 0 );
  237.                 parent::__construct ( $id );
  238.             } elseif ( $ArgsNumber == 10 ) {
  239.                 $Nickname = func_get_arg ( 0 );
  240.                 $Password = func_get_arg ( 1 );
  241.                 $Mail = func_get_arg ( 2 );
  242.                 $FirstConnection = func_get_arg ( 3 );
  243.                 $LastConnection = func_get_arg ( 4 );
  244.                 $Inscription = func_get_arg ( 5 );
  245.                 $AvatarsName = func_get_arg ( 6 );
  246.                 $Quote = func_get_arg ( 7 );
  247.                 $Signature = func_get_arg ( 8 )
  248.                 $WMail = func_get_arg ( 9 );
  249.                 parent::__construct ( $Nickname, $Password, 3, $Mail, $FirstConnection, $LastConnection, $Inscription, $AvatarsName, $Quote, $Signature, $WMail );
  250.             } else {
  251.                 throw new Exception ( 'Les arguments que vous avez passé au constructeur sont invalides.' );
  252.             }
  253.         }
  254.        
  255.         public function __destruct ( ) {
  256.             parent::__destruct ( );
  257.         }
  258.     }
  259. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement