1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
<?php
set_include_path(".;..");
require_once('config/Database.conf.php');
require_once('classes/Membre.class.php');
require_once('classes/User.class.php');
require_once('classes/Clan.class.php');
require_once('classes/Race.class.php');
class Database {
private $id_connexion;
function connect(){
$this->id_connexion = mysql_connect(_SERVEUR,_LOGIN,_PASSWD);
$id_selectbase = mysql_select_db(_BASE , $this->id_connexion);
}
function disconnect(){
mysql_close($this->id_connexion);
$id_connexion=NULL;
}
function exist_login($login_test){
$sql = "select * from users where login = '$login_test'";
$resultat = mysql_query($sql , $this->id_connexion);
$nbenr = mysql_num_rows($resultat);
if ($nbenr==0) {return false;}
else {return true;}
}
function auth_login($login,$passwd){
$sql = "select * from users where login = '$login' and password = '$passwd'";
$resultat = mysql_query($sql , $this->id_connexion);
$nbenr = mysql_num_rows($resultat);
if ($nbenr==0) {return false;}
else {return true;}
}
function creer_user($login,$mdp){
$sql="insert into users(login,password) values"
."('".$login."','".$mdp."')";
$resultat= mysql_query($sql, $this->id_connexion);
}
function modifier_user($login,$mdp){
$sql="delete from users where login = '$login'";
$resultat= mysql_query($sql, $this->id_connexion);
$this->creer_user($login,$mdp);
}
function query($sql){
$resultat= mysql_query($sql, $this->id_connexion);
return $resultat;
}
function gestion_erreur($identifiant){
echo "Une erreur est survenue :<br>".mysql_errno()." : ".mysql_error();
mysql_close($identifiant);
exit;
}
function getMembreByLogin($login_usr){
$sql="select MB.ID, MB.NOM, RC.NOM_RACE, RC.BONUS_RACE, CL.NOM_CLAN, CL.CHEF_CLAN, CL.NBMAX_MEMBRES, MB.NIVEAU, MB.POINTS, ".
"MB.FORCE, MB.AGILITE, MB.RESISTANCE, MB.APPARENCE, MB.CHARISME, MB.REPUTATION, MB.PERCEPTION, MB.INTELLIGENCE, MB.SAVOIR ".
"from LYS_MEMBRES MB, LYS_AUTHS US, LYS_RACES RC, LYS_CLANS CL ".
"where MB.ID_USER = US.ID_USER and MB.RACE = RC.ID_RACE and CL.ID_CLAN = MB.CLAN and US.NOM_USER = '".$login_usr."'";
$resultat = mysql_query($sql);
$reponse = mysql_fetch_assoc($resultat);
$clan = new Clan();
$clan->setNom($reponse['NOM_CLAN']);
$clan->setChef($reponse['CHEF_CLAN']);
$clan->setSecond($reponse['SECOND_CLAN']);
$clan->setNbMaxMembres($reponse['NBMAX_MEMBRES']);
$race = new Race();
$race->setNom($reponse['NOM_RACE']);
$race->setBonus($reponse['BONUS_RACE']);
$membre = new Membre();
$membre->setNom($reponse['NOM']);
$membre->setRace($race);
$membre->setClan($clan);
$membre->setNiveau($reponse['NIVEAU']);
$membre->setPoints($reponse['POINTS']);
$membre->setForce($reponse['FORCE']);
$membre->setAgilite($reponse['AGILITE']);
$membre->setResistance($reponse['RESISTANCE']);
$membre->setApparence($reponse['APPARENCE']);
$membre->setCharisme($reponse['CHARISME']);
$membre->setReputation($reponse['REPUTATION']);
$membre->setPerception($reponse['PERCEPTION']);
$membre->setIntelligence($reponse['INTELLIGENCE']);
$membre->setSavoir($reponse['SAVOIR']);
return $membre;
}
}
?> |
Partager