2008-09-20 10:00:00 +00:00
< ? php
/***************************************************************************
* class . user . php
* ----------------
* begin : Dimanche 7 septembre 2008
* update : Dimanche 7 septembre 2008
* email : nemunaire @ gmail . com
*
*
***************************************************************************/
2008-11-08 11:00:00 +00:00
class User extends File {
2008-09-20 10:00:00 +00:00
var $id_user ,
$pseudo ,
$auth_level ,
$race ,
$id_alliance ,
$id_grade_alliance ,
2008-11-08 11:00:00 +00:00
$mv ,
2008-09-20 10:00:00 +00:00
$mail ,
$envoyerMail ,
2008-11-08 11:00:00 +00:00
$last_visite ,
$points ,
$place_points ,
2008-09-20 10:00:00 +00:00
$technologies = array (),
2008-11-08 11:00:00 +00:00
$credits ,
$politique ,
$politique_lastchange ,
2008-09-20 10:00:00 +00:00
$destinationsFavoris ,
2008-11-08 11:00:00 +00:00
$amis = array (),
2008-09-20 10:00:00 +00:00
$combatAT_tactique ,
$combatDE_tactique ,
2008-11-08 11:00:00 +00:00
$modifUser = array ( " credits " );
2008-09-20 10:00:00 +00:00
/**
* Constructeur
* @ param int $id id de la planète à importer
*
* @ return void
* @ access public
*/
function User ( $id = 0 ){
if ( ! empty ( $id )) {
global $var___db , $config , $table_user ;
2008-11-08 11:00:00 +00:00
global $technologiesVAR ;
2008-09-20 10:00:00 +00:00
$bdd = new bdd ();
$bdd -> connexion ();
$bdd -> escape ( $id );
$user = $bdd -> unique_query ( " SELECT * FROM $table_user WHERE id = $id ; " );
$bdd -> deconnexion ();
if ( ! empty ( $user )) {
$this -> id_user = $user [ " id " ];
$this -> pseudo = $user [ " pseudo " ];
$this -> auth_level = $user [ " auth_level " ];
$this -> race = $user [ " race " ];
2008-11-08 11:00:00 +00:00
$this -> mv = $user [ " mv " ];
2008-09-20 10:00:00 +00:00
$this -> id_alliance = $user [ " id_alliance " ];
$this -> id_grade_alliance = $user [ " id_grade_alliance " ];
$this -> mail = $user [ " mail " ];
$this -> envoyerMail = $user [ " envoyerMail " ];
2008-11-08 11:00:00 +00:00
$this -> last_visite = $user [ " last_visite " ];
$this -> points = $user [ " points " ];
$this -> place_points = $user [ " place_points " ];
$this -> credits = $user [ " credits " ];
$this -> politique = $user [ " politique " ];
$this -> politique_lastchange = $user [ " politique_lastchange " ];
if ( ! empty ( $user [ " amis " ])) $this -> amis = unserialize ( $user [ " amis " ]);
else $this -> amis = array ();
if ( ! empty ( $user [ " destinationsFavoris " ])) $this -> destinationsFavoris = unserialize ( $user [ " destinationsFavoris " ]);
else $this -> destinationsFavoris = array ();
2008-09-20 10:00:00 +00:00
$this -> combatAT_tactique = $user [ " combatAT_tactique " ];
$this -> combatDE_tactique = $user [ " combatDE_tactique " ];
2008-11-08 11:00:00 +00:00
foreach ( $technologiesVAR as $tech ){
2008-09-20 10:00:00 +00:00
$this -> technologies [] = $user [ $tech ];
}
}
2008-11-08 11:00:00 +00:00
else die ( 'Erreur #01 : Utilisateur recherché introuvable dans la base de données. Contactez le support technique (' . $config [ 'mail_support' ] . ') au plus vite en précisant le code d\'erreur.' );
2008-09-20 10:00:00 +00:00
}
}
/**
* Destructeur
*
* @ return void
* @ access public
*/
function __destruct (){
global $var___db , $config , $table_user ;
$out = array ();
$bdd = new bdd ();
$bdd -> connexion ();
2009-11-01 11:00:00 +00:00
foreach ( $this -> modifUser as $key => $modif )
{
if ( ! is_array ( $this -> { $modif }))
{
$bdd -> escape ( $this -> { $modif });
if ( is_int ( $this -> { $modif }) || is_float ( $this -> { $modif })) $out [] .= $modif . " = " . $this -> { $modif };
else $out [] .= $modif . " = ' " . $this -> { $modif } . " ' " ;
}
else
{
if ( ereg ( 'file' , $modif ))
{
$prep = implode ( ';' , $this -> { $modif });
$bdd -> escape ( $prep );
$out [] .= $modif . " = ' $prep ' " ;
}
else
{
if ( $modif == " batiments " )
$calc = " batiment " ;
elseif ( $modif == " technologies " )
$calc = " technologies " ;
elseif ( $modif == " casernes " )
$calc = " casernen " ;
elseif ( $modif == " terrestres " )
$calc = " nomterrn " ;
elseif ( $modif == " vaisseaux " )
$calc = " nomvaisn " ;
2008-09-20 10:00:00 +00:00
2009-11-01 11:00:00 +00:00
if ( ! isset ( $ { $calc . 'VAR' }))
global $ { $calc . 'VAR' };
2008-09-20 10:00:00 +00:00
2009-11-01 11:00:00 +00:00
$nombr = count ( $ { $calc . 'VAR' });
for ( $j = 0 ; $j < $nombr ; $j ++ ){
$bdd -> escape ( $this -> { $modif }[ $j ]);
$out [] .= $ { $calc . 'VAR' }[ $j ] . " = " . $this -> { $modif }[ $j ];
}
}
2008-09-20 10:00:00 +00:00
}
}
2009-11-01 11:00:00 +00:00
if ( ! empty ( $out ))
$plan = $bdd -> query ( " UPDATE $table_user SET " . implode ( ', ' , $out ) . " WHERE id = " . $this -> id_user . " ; " );
2008-09-20 10:00:00 +00:00
$bdd -> deconnexion ();
}
}
?>