Exemple #1
0
 public static function generatePage(&$tpl, &$session, &$account, &$mj)
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE id=:persoId' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
     $prep->executePlus($db, __FILE__, __LINE__);
     $arr = $prep->fetch();
     $prep->closeCursor();
     $prep = NULL;
     if ($arr === false) {
         return fctErrorMSG('perso innexistant');
     }
     $perso = new Member_Perso($arr);
     //Lister l'inventaire
     $i = 0;
     $e = 0;
     $arrItem = array();
     while ($item = $perso->getInventaire($i++, true)) {
         if (isset($_POST['inv' . $item->getInvId()]) && is_numeric($_POST['inv' . $item->getInvId()]) && $_POST['inv' . $item->getInvId()] != $item->getQte()) {
             $item->setQte($_POST['inv' . $item->getInvId()]);
         }
     }
     //Retourner le template complété/rempli
     $tpl->set('PAGE', 'Perso_Inventaire&id=' . $_GET['id']);
     return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/redirect.htm', __FILE__, __LINE__);
 }
Exemple #2
0
 public static function generatePage(&$tpl, &$session, &$account, &$mj)
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     if (!isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id'])) {
         return fctErrorMSG('Données requises manquantes.');
     }
     //Trouver le nom technique de l'ID de lieu
     $query = 'SELECT nom_technique' . ' FROM ' . DB_PREFIX . 'lieu' . ' WHERE id=:lieuId' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $prep->bindValue(':lieuId', $_GET['id'], PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arr = $prep->fetch();
     $prep->closeCursor();
     $prep = NULL;
     if ($arr === false) {
         return fctErrorMSG('Ce lieu n\'existe pas.');
     }
     $lieuTech = $arr['nom_technique'];
     $tpl->set('LIEU_TECH', $lieuTech);
     $tpl->set('LIEU_ID', (int) $_GET['id']);
     $perso = new Member_Perso();
     $ARR_COMPS = array('ACRO', 'ARMB', 'ARMC', 'ARMF', 'ARML', 'ARMU', 'ARTI', 'ATHL', 'CHIM', 'CHRG', 'CROC', 'CRYP', 'CUIS', 'CYBR', 'DRSG', 'ELEC', 'ENSG', 'ESQV', 'EXPL', 'FORG', 'FRTV', 'GENE', 'HCKG', 'HRDW', 'LNCR', 'MECA', 'MRCH', 'PCKP', 'PLTG', 'PROG', 'PSYC', 'SCRS', 'TOXI');
     $COMPS = array();
     for ($i = 0; $i < count($ARR_COMPS); $i++) {
         $COMPS[$ARR_COMPS[$i]] = array('comp' => $ARR_COMPS[$i], 'compTxt' => $perso->getCompName($perso->convCompCodeToId($ARR_COMPS[$i])));
     }
     //Trouver toutes les compétences déjà enregistrées
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'lieu_etude' . ' WHERE lieuId=:lieuId;';
     $prep = $db->prepare($query);
     $prep->bindValue(':lieuId', $_GET['id'], PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $result = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     $ALREADY_SAVED = array();
     foreach ($result as $arr) {
         $COMPS[strtoupper($arr['comp'])]['cout_pa'] = $arr['cout_pa'];
         $COMPS[strtoupper($arr['comp'])]['cout_cash'] = $arr['cout_cash'];
         $COMPS[strtoupper($arr['comp'])]['qualite_lieu'] = $arr['qualite_lieu'];
         $COMPS[strtoupper($arr['comp'])]['chk'] = true;
     }
     $tpl->set('COMPS', $COMPS);
     //Retourner le template complété/rempli
     return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Lieu/Etude.htm', __FILE__, __LINE__);
 }
Exemple #3
0
 public static function generatePage(&$tpl, &$session, &$account)
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     if (!isset($_GET['id'])) {
         return fctErrorMSG('Données requises manquantes. (cheat)');
     }
     //Établir la liste de signes disponibles.
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'caract' . ' WHERE type="system"' . ' AND catid=0' . ' ORDER BY nom;';
     $prep = $db->prepare($query);
     $prep->execute($db, __FILE__, __LINE__);
     $arrCat = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     foreach ($arrCat as &$arr) {
         $arr['nom'] = stripslashes($arr['nom']);
         $arr['desc'] = stripslashes($arr['desc']);
     }
     $tpl->set('CAT', $arrCat);
     //Fetcher les caractéristiques du perso
     $query = 'SELECT c.*, p.desc as perso_desc' . ' FROM ' . DB_PREFIX . 'caract as c' . ' LEFT JOIN ' . DB_PREFIX . 'perso_caract as p ON (p.caractid=c.id AND p.persoid=:persoId)' . ' WHERE c.type="system"' . ' AND c.catid>0' . ' ORDER BY c.nom;';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arrCaract = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     $arrC = array();
     foreach ($arrCaract as &$arr) {
         $arr['nom'] = stripslashes($arr['nom']);
         $arr['desc'] = stripslashes($arr['desc']);
         $fn = 'caractDesc_' . $arr['id'];
         if (isset($_POST[$fn]) && !empty($_POST[$fn])) {
             $arrC[$arr['id']] = $_POST[$fn];
         } elseif ($arr['perso_desc'] !== null) {
             $arrC[$arr['id']] = stripslashes($arr['perso_desc']);
         }
     }
     $tpl->set('CARACT', $arrCaract);
     $tpl->set('PERSO_CARACT', $arrC);
     //Établir la liste des statistiques disponibles
     $query = 'SELECT s.*, IFNULL(p.xp, 0) as xp' . ' FROM ' . DB_PREFIX . 'stat as s' . ' LEFT JOIN ' . DB_PREFIX . 'perso_stat as p ON (p.statid = s.id AND p.persoid=:persoId);';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arrStat = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     foreach ($arrStat as &$arr) {
         if (isset($_POST['stat_' . $arr['id']])) {
             $arr['xp'] = $_POST['stat_' . $arr['id']];
         }
     }
     $tpl->set('STATS', $arrStat);
     //Établir la liste des compétences disponibles
     $query = 'SELECT c.*, IFNULL(p.xp, 0) as xp' . ' FROM ' . DB_PREFIX . 'competence as c' . ' LEFT JOIN ' . DB_PREFIX . 'perso_competence as p ON (p.compid = c.id AND p.persoid=:persoId)' . ' WHERE c.inscription="1";';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arrComp = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     foreach ($arrComp as &$arr) {
         if (isset($_POST['comp_' . $arr['id']])) {
             $arr['lvl'] = $_POST['comp_' . $arr['id']];
         } else {
             $arr['lvl'] = Member_Perso::convCompXpToLevel($arr['xp']);
         }
     }
     $tpl->set('COMPS', $arrComp);
     //Trouver les informations sur le perso
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE	id=:persoId' . ' AND userid=:userId' . ' AND inscription_valide IN ("0","mod")' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
     $prep->bindValue(':userId', $account->getId(), PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arrP = $prep->fetch();
     $prep->closeCursor();
     $prep = NULL;
     if ($arrP === false) {
         return fctErrorMSG('Ce personnage n\'existe pas, ne vous appartiend pas, ou n\'est pas en phase de refus. (cheat)');
     }
     //Formater correctement certaines données:
     $arrP['nom'] = stripslashes($arrP['nom']);
     $arrP['description'] = stripslashes($arrP['description']);
     $arrP['background'] = stripslashes($arrP['background']);
     $arrP['yeux'] = stripslashes($arrP['yeux']);
     $arrP['ethnie'] = stripslashes($arrP['ethnie']);
     $arrP['cheveux'] = stripslashes($arrP['cheveux']);
     $arrP['taillem'] = substr($arrP['taille'], 0, 1);
     $arrP['taillecm'] = substr($arrP['taille'], 2, 2);
     if (isset($_POST) && count($_POST) > 0) {
         $tpl->set('PERSO', $_POST);
     } else {
         $tpl->set('PERSO', $arrP);
     }
     //Trouver la raison du refus
     if ($arrP['inscription_valide'] == 'mod') {
         $perso = new Member_Perso($arrP);
         $he = new Member_He($account, $perso);
         $heMsg = $he->listMessages($perso, 0, $account->getMsgPerPage());
         $code = '';
         foreach ($heMsg as $msg) {
             if ($msg->getType() == 'inscription') {
                 $tpl->set('MSG', $msg);
                 $code .= $tpl->fetch($account->getSkinRemotePhysicalPath() . '/html/Member/he_item.htm');
             }
         }
         if ($code != '') {
             $tpl->set('PAGE_HE_MESSAGES', $code);
         }
     }
     $tpl->set('GAME_IS_CYBERCITY', GAME_IS_CYBERCITY);
     //Retourner le template complété/rempli
     $tpl->set('REDIRECT_TO', 'ModPerso2&id=' . $_GET['id']);
     $tpl->set('CHECK_URL', 'ModPersoCheck&id=' . $_GET['id']);
     return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/creerPerso2.htm', __FILE__, __LINE__);
 }
Exemple #4
0
 /**
  * Quel est le nombre de message maximum que peux contenir le HE d'une personne ?
  *
  * Favoriser Member_He::spacePerMembership() car la présente méthode requiert une requête
  * pour trouver le niveau d'abonnement d'un perso.
  */
 private static function calculateHeMaxSize($id)
 {
     return self::spacePerMembership(Member_Perso::memberLevel($id));
 }
Exemple #5
0
 /** Envoie un message radio
  * @param Member_Perso $perso Instance du perso qui envoi le message
  * @param string $message Message à envoyer
  */
 public function utiliser(&$perso, $message)
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     $errorUrl = '?popup=1&amp;m=Action_Radios';
     if (!$this->getCanTalk()) {
         return fctErrorMSG('Aucune fréquence n\'a été réglée vous ne pouvez pas parler.', $errorUrl);
     }
     $enteteDestinataire = "Vous entendez quelqu'un parler depuis la radio branchée sur la fréquence: " . $this->getFrequence();
     //Recup des talkies sur la même frequence que celui de l'utilisateur
     $query = 'SELECT DISTINCT *' . ' FROM ' . DB_PREFIX . 'item_inv' . ' LEFT JOIN ' . DB_PREFIX . 'item_db ON (db_id=inv_dbid) ' . ' LEFT JOIN ' . DB_PREFIX . 'perso ON (id=inv_persoid)' . ' WHERE inv_notel=:freq' . ' AND inv_id!=:id' . ' AND inv_persoid IS NOT NULL' . ' AND db_type="talkiewalkie";';
     $prep = $db->prepare($query);
     $prep->bindValue(':freq', $this->getFrequence(), PDO::PARAM_INT);
     $prep->bindValue(':id', $this->getInvId(), PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arrRadio = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     //Parcourir toutes les radios qui captent la fréquence de celle de l'envoyeur.
     $arrDestOreilletteClair = array();
     //Tableau des destinataire (ceux possédant une radio avec oreillette)
     $arrDestOreilletteCrypt = array();
     //Tableau des destinataire (ceux possédant une radio avec oreillette)
     $arrToClair = array();
     //Tableau concernant les perso dans les lieux
     $arrToCrypt = array();
     //Tableau concernant les perso dans les lieux
     foreach ($arrRadio as $arrRadioTo) {
         //Construire la liste de ceux qui recoivent la transmission (et qui ont un radio)
         //From, du point de vu de ceux qui vont recevoir le message
         //(To sera les gens qui entendent la radio de From qui la possède, $perso est l'émetteur réel)
         $persoFrom = new Member_Perso($arrRadioTo);
         $radio = new Member_ItemRadio($arrRadioTo);
         $lieuTech = $persoFrom->getLieu()->getNomTech();
         //Lieu Technique du perso ayant la radio réceptrice
         //S'il y a une oreillette, ajouter le perso dans une liste spéciale où il ne notifira pas les autres
         if ($radio->getSilenceCapable()) {
             //Si le message peut-être décrypté
             if ($radio->getClef() === $this->getClef()) {
                 $this->addWithoutDouble($arrDestOreilletteClair, $persoFrom->getId());
             } else {
                 $this->addWithoutDouble($arrDestOreilletteCrypt, $persoFrom->getId());
             }
             //$arrDestOreilletteCrypt[] = $persoFrom->getId();
             //S'il n'y a pas d'oreillette, ajouter tout les perso présent dans le lieu
         } else {
             //Si le message peut-être décrypté
             if ($radio->getClef() === $this->getClef()) {
                 //Ajouter le perso qui recoit le message
                 $this->addFromTo($arrToClair, $lieuTech, 'from', $persoFrom->getId());
                 $i = 0;
                 while ($persoTo = $persoFrom->getLieu()->getPerso($persoFrom, $i++)) {
                     if ($persoTo->getId() != $persoFrom->getId()) {
                         $this->addFromTo($arrToClair, $lieuTech, 'to', $persoTo->getId());
                     }
                 }
             } else {
                 //Ajouter le perso qui recoit le message
                 $this->addFromTo($arrToCrypt, $lieuTech, 'from', $persoFrom->getId());
                 $i = 0;
                 while ($persoTo = $persoFrom->getLieu()->getPerso($persoFrom, $i++)) {
                     if ($persoTo->getId() != $persoFrom->getId()) {
                         $this->addFromTo($arrToCrypt, $lieuTech, 'to', $persoTo->getId());
                     }
                 }
             }
         }
     }
     //### AJOUTER LES MESSAGES DANS LES HE
     //Message du personnage qui l'envoi
     $to = array();
     if (!$this->getSilenceCapable()) {
         $i = 0;
         $e = 0;
         while ($persoTo = $perso->getLieu()->getPerso($perso, $i++)) {
             $to[$e++] = $persoTo->getId();
         }
     }
     Member_He::add($perso->getId(), $to, 'radio', "Une transmission radio est envoyée:\n " . $message, HE_TOUS, HE_TOUS);
     //HE_AUCUN)
     //Seulement pour les perso avec une oreillette
     if (count($arrDestOreilletteClair) > 0) {
         Member_He::add('System', $arrDestOreilletteClair, 'radio', "Une transmission radio se fait entendre:\n " . $message, HE_AUCUN, HE_UNIQUEMENT_MOI);
     }
     if (count($arrDestOreilletteCrypt) > 0) {
         Member_He::add('System', $arrDestOreilletteCrypt, 'radio', "Une transmission radio se fait entendre:\n (charabia incompréhensible)", HE_AUCUN, HE_UNIQUEMENT_MOI);
     }
     //Pour chaque lieu
     if (count($arrToClair) > 0) {
         foreach ($arrToClair as $arr) {
             Member_He::add($arr['from'], $arr['to'], 'radio', "Une transmission radio se fait entendre:\n" . $message, HE_TOUS, HE_TOUS);
         }
     }
     if (count($arrToCrypt) > 0) {
         foreach ($arrToCrypt as $arr) {
             Member_He::add($arr['from'], $arr['to'], 'radio', "Une transmission radio se fait entendre:\n (charabia incompréhensible)", HE_TOUS, HE_TOUS);
         }
     }
 }
Exemple #6
0
 public static function generatePage(&$tpl, &$session, &$account)
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     //$errorUrl = défini plus bas
     if (!isset($_GET['id'])) {
         return fctErrorMSG('Données requises manquantes. (cheat)');
     }
     //Trouver les informations sur le perso / Valider s'il est authorisé à être modifié
     $query = 'SELECT id' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE	id=:id' . ' AND userid=:userId' . ' AND inscription_valide IN ("0", "mod")' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $prep->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
     $prep->bindValue(':userId', $account->getId(), PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arr = $prep->fetch();
     $prep->closeCursor();
     $prep = NULL;
     if ($arr === false) {
         return fctErrorMSG('Ce personnage n\'existe pas, ne vous appartiend pas, ou n\'est pas en phase de refus. (cheat)');
     }
     $persoId = $arr[0];
     $errorUrl = '?m=ModPerso&id=' . $persoId;
     //Si les magicQuote sont activer, les retirer.
     fctStripMagicQuote($_POST);
     //Validation du NOM
     if (!isset($_POST['nom']) || empty($_POST['nom'])) {
         return fctErrorMSG('Nom de personnage manquant.', $errorUrl, $_POST, false);
     }
     if (strlen($_POST['nom']) > 25 || strlen($_POST['nom']) < 4) {
         return fctErrorMSG('Le nom du personnage à une taille invalide.', $errorUrl, $_POST, false);
     }
     preg_match('/^[-\' çéèôêîA-Za-z]+$/', $_POST['nom'], $matches);
     if (count($matches) == 0) {
         return fctErrorMSG('Le nom du personnage comporte des caractères invalide (' . $_POST['nom'] . ').', $errorUrl, $_POST, false);
     }
     $query = 'SELECT id' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE	nom=:nom' . ' AND id!=:id' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $prep->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR);
     $prep->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arr = $prep->fetch();
     $prep->closeCursor();
     $prep = NULL;
     if ($arr !== false) {
         return fctErrorMSG('Ce nom est déjà utilisé par un autre personnage que le vôtre.', $errorUrl, $_POST, false);
     }
     //Validation de l'ETHNIE
     if (!isset($_POST['ethnie']) || empty($_POST['ethnie'])) {
         return fctErrorMSG('Ethnie du personnage manquant.', $errorUrl, $_POST, false);
     }
     //Validation de l'AGE
     if (!isset($_POST['age']) || empty($_POST['age'])) {
         return fctErrorMSG('Âge du personnage manquant.', $errorUrl, $_POST, false);
     }
     preg_match('/^[0-9]{1,2}$/', $_POST['age'], $matches);
     if (count($matches) == 0) {
         return fctErrorMSG('L\'âge du personnage comporte des caractères invalide.', $errorUrl, $_POST, false);
     }
     //Validation du POIDS
     if (!isset($_POST['poids']) || empty($_POST['poids'])) {
         return fctErrorMSG('Poids du personnage manquant.', $errorUrl, $_POST, false);
     }
     preg_match('/^[0-9]{1,3}$/', $_POST['poids'], $matches);
     if (count($matches) == 0) {
         return fctErrorMSG('Le poids du personnage comporte des caractères invalide.', $errorUrl, $_POST, false);
     }
     //Validation de la TAILLE
     if (!isset($_POST['taillem']) || empty($_POST['taillem'])) {
         return fctErrorMSG('Taille du personnage manquante (1).', $errorUrl, $_POST, false);
     }
     if (!isset($_POST['taillecm']) || empty($_POST['taillecm'])) {
         return fctErrorMSG('Taille du personnage manquante (2).', $errorUrl, $_POST, false);
     }
     $taille = $_POST['taillem'] . 'm' . $_POST['taillecm'];
     preg_match('/^[12][m][0-9][05]$/', $taille, $matches);
     if (count($matches) == 0) {
         return fctErrorMSG('La taille du personnage comporte des caractères invalide.', $errorUrl, $_POST, false);
     }
     //Validation des YEUX
     if (!isset($_POST['yeux']) || empty($_POST['yeux'])) {
         return fctErrorMSG('Description des yeux du personnage manquante.', $errorUrl, $_POST, false);
     }
     if (strlen($_POST['yeux']) > 100) {
         return fctErrorMSG('mod - Description des yeux du personnage à une taille invalide (' . strlen($_POST['yeux']) . ').', $errorUrl, $_POST, false);
     }
     //Validation des CHEVEUX
     if (!isset($_POST['cheveux']) || empty($_POST['cheveux'])) {
         return fctErrorMSG('mod - Description des cheveux du personnage manquante.', $errorUrl, $_POST, false);
     }
     if (strlen($_POST['cheveux']) > 100) {
         return fctErrorMSG('Description des cheveux du personnage à une taille invalide (' . strlen($_POST['cheveux']) . ').', $errorUrl, $_POST, false);
     }
     //Effectuer la liste de toutes les statistiques
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'stat;';
     $prep = $db->prepare($query);
     $prep->execute($db, __FILE__, __LINE__);
     $arrStat = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     //Validation des STATS
     $totalStat = 0;
     foreach ($arrStat as $stat) {
         $fieldName = 'stat_' . $stat['id'];
         if (!isset($_POST[$fieldName]) || !is_numeric($_POST[$fieldName]) || $_POST[$fieldName] < -75 || $_POST[$fieldName] > 75) {
             return fctErrorMSG('Données sur les statistiques invalides.', $errorUrl, $_POST, false);
         }
         $totalStat += $_POST[$fieldName];
     }
     if ($totalStat != 0) {
         return fctErrorMSG('Les statistiques doivent avoir une somme de zéro.', $errorUrl, $_POST, false);
     }
     //Effectuer la liste de toutes les compétences
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'competence' . ' WHERE inscription="1";';
     $prep = $db->prepare($query);
     $prep->execute($db, __FILE__, __LINE__);
     $arrComp = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     //Validation des COMPS
     $totalComp = 0;
     foreach ($arrComp as $comp) {
         $fieldName = 'comp_' . $comp['id'];
         if (!isset($_POST[$fieldName]) || !is_numeric($_POST[$fieldName]) || $_POST[$fieldName] < 0 || $_POST[$fieldName] > INSCRIPTION_MAX_COMP) {
             return fctErrorMSG('Données sur les compétences invalides.', $errorUrl, $_POST, false);
         }
         $totalComp += $_POST[$fieldName];
     }
     if ($totalComp != INSCRIPTION_NBR_COMP) {
         return fctErrorMSG('Les compétences doivent avoir une somme de ' . INSCRIPTION_NBR_COMP . '.', $errorUrl, $_POST, false);
     }
     //Validation SIGNES
     if (!isset($_POST['arrCaract'])) {
         return fctErrorMSG('Sélection des signes du personnage manquante.', $errorUrl, $_POST, false);
     }
     if (count($_POST['arrCaract']) < 5) {
         return fctErrorMSG('Données sur les signes invalides.', $errorUrl, $_POST, false);
     }
     //Validation Background + Description
     if (!isset($_POST['description']) || empty($_POST['description'])) {
         return fctErrorMSG('Description du personnage manquante.', $errorUrl, $_POST, false);
     }
     if (!isset($_POST['background']) || empty($_POST['background'])) {
         return fctErrorMSG('Historique du personnage manquante.', $errorUrl, $_POST, false);
     }
     // FIN DES VALIDATION, EFFECTUER LA MISE A JOUR.
     //Modifier le personnage
     $query = 'UPDATE ' . DB_PREFIX . 'perso' . ' SET' . ' `nom`				= :nom,' . ' `sexe`				= :sexe,' . ' `age`				= :age,' . ' `taille`			= :taille,' . ' `yeux`				= :yeux,' . ' `ethnie`			= :ethnie,' . ' `cheveux`			= :cheveux,' . ' `poids`				= :poids,' . ' `lng1_lvl`			= :lng1_lvl,' . ' `lng2`				= :lng2,' . ' `lng2_lvl`			= :lng2_lvl,' . ' `description`		= :description,' . ' `background`		= :background,' . ' `inscription_valide`= :saveType' . ' WHERE id=:persoId' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $saveType = $_POST['SaveType'] == 'go' ? '0' : 'mod';
     $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
     $prep->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR);
     $prep->bindValue(':sexe', $_POST['sexe'], PDO::PARAM_STR);
     $prep->bindValue(':age', $_POST['age'], PDO::PARAM_INT);
     $prep->bindValue(':taille', $taille, PDO::PARAM_STR);
     $prep->bindValue(':yeux', $_POST['yeux'], PDO::PARAM_STR);
     $prep->bindValue(':ethnie', $_POST['ethnie'], PDO::PARAM_STR);
     $prep->bindValue(':cheveux', $_POST['cheveux'], PDO::PARAM_STR);
     $prep->bindValue(':poids', $_POST['poids'], PDO::PARAM_INT);
     $prep->bindValue(':lng1_lvl', $_POST['lng1_lvl'], PDO::PARAM_STR);
     $prep->bindValue(':lng2', $_POST['lng2'], PDO::PARAM_STR);
     $prep->bindValue(':lng2_lvl', $_POST['lng2_lvl'], PDO::PARAM_STR);
     $prep->bindValue(':description', $_POST['description'], PDO::PARAM_STR);
     $prep->bindValue(':background', $_POST['background'], PDO::PARAM_STR);
     $prep->bindValue(':saveType', $saveType, PDO::PARAM_STR);
     $prep->execute($db, __FILE__, __LINE__);
     $prep->closeCursor();
     $prep = NULL;
     //Effacer les informations sur les statistiques
     $query = 'DELETE FROM ' . DB_PREFIX . 'perso_stat' . ' WHERE persoid=:persoId;';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $prep->closeCursor();
     $prep = NULL;
     //Insérer les stats
     $query = 'INSERT INTO ' . DB_PREFIX . 'perso_stat' . ' (`persoid`, `statid`, `xp`)' . ' VALUES' . ' (:persoId, :statId, :xp);';
     $prep = $db->prepare($query);
     foreach ($arrStat as $stat) {
         $statXp = $_POST['stat_' . $stat['id']];
         $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
         $prep->bindValue(':statId', $stat['id'], PDO::PARAM_INT);
         $prep->bindValue(':xp', $statXp, PDO::PARAM_INT);
         $prep->execute($db, __FILE__, __LINE__);
     }
     $prep->closeCursor();
     $prep = NULL;
     //Effacer les informations sur les compétences
     $query = 'DELETE FROM ' . DB_PREFIX . 'perso_competence' . ' WHERE persoid=:persoId;';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $prep->closeCursor();
     $prep = NULL;
     //Insérer les compétences
     $query = 'INSERT INTO ' . DB_PREFIX . 'perso_competence' . ' (`persoid`, `compid`, `xp`)' . ' VALUES' . ' (:persoId, :compId, :xp);';
     $prep = $db->prepare($query);
     foreach ($arrComp as $comp) {
         $fn = 'comp_' . $comp['id'];
         if (isset($_POST[$fn]) && is_numeric($_POST[$fn]) && $_POST[$fn] > 0) {
             $compXp = Member_Perso::convCompLevelToXp($_POST[$fn]);
             $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
             $prep->bindValue(':compId', $comp['id'], PDO::PARAM_INT);
             $prep->bindValue(':xp', $compXp, PDO::PARAM_INT);
             $prep->execute($db, __FILE__, __LINE__);
         }
     }
     $prep->closeCursor();
     $prep = NULL;
     //Effacer les informations sur les anciennes caractéristiques
     $query = 'DELETE FROM ' . DB_PREFIX . 'perso_caract' . ' WHERE persoid=:persoId;';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $prep->closeCursor();
     $prep = NULL;
     //Ajouter les informations sur les caractéristiques
     $query = 'INSERT INTO ' . DB_PREFIX . 'perso_caract' . ' ( `persoid` , `caractid` , `desc` )' . ' VALUES' . ' (:persoId, :caractId, :desc);';
     $prep = $db->prepare($query);
     foreach ($_POST['arrCaract'] as $caract) {
         $desc = fctScriptProtect($_POST['caractDesc_' . $caract]);
         $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
         $prep->bindValue(':caractId', $caract, PDO::PARAM_INT);
         $prep->bindValue(':desc', $desc, PDO::PARAM_STR);
         $prep->execute($db, __FILE__, __LINE__);
     }
     $prep->closeCursor();
     $prep = NULL;
     //Retourner le template complété/rempli
     $tpl->set('PAGE', 'News');
     //return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/redirect.htm',__FILE__,__LINE__);
 }
Exemple #7
0
 private static function remiseAccount($accountId)
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     if (DEBUG_MODE) {
         self::$debugInfo .= 'a' . $accountId;
     }
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE userId=:userId' . ' AND inscription_valide="1";';
     $prep = $db->prepare($query);
     $prep->bindValue(':userId', $accountId, PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arrPerso = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     //Passe tout les perso d'un compte
     foreach ($arrPerso as $arr) {
         //$perso->getLieu() peut lever une exception si le lieu n'existe pas
         // Dans ce cas, on zap la remise
         try {
             $perso = new Member_Perso($arr);
             if (!in_array($perso->getLieu()->getNomTech(), array(INNACTIVITE_VOLUNTARY_LOCATION, INNACTIVITE_TELEPORT_LOCATION))) {
                 self::remisePerso($perso);
             }
         } catch (exception $e) {
             //On fait rien --> on zap la remise du perso sans bloquer les autres remises
         }
     }
     //Détagguer le compte & définir la prochaine remise
     $query = 'UPDATE ' . DB_PREFIX . 'account' . ' SET remise=remise+86400' . ' WHERE id=:userId' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $prep->bindValue(':userId', $accountId, PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $prep->closeCursor();
     $prep = NULL;
     if (DEBUG_MODE) {
         self::$debugInfo .= 'a2';
     }
 }
Exemple #8
0
 public static function generatePage(&$tpl, &$session, &$account)
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     $errorUrl = '?m=CreerPerso2';
     //Si les magicQuote sont activer, les retirer.
     fctStripMagicQuote($_POST);
     //Déterminer la quantité de perso que ce compte à l'autorisation de créer
     $query = 'SELECT auth_creation_perso' . ' FROM ' . DB_PREFIX . 'account' . ' WHERE id=:id' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $prep->bindValue(':id', $account->getId(), PDO::PARAM_INT);
     $prep->execute($db, __FILE__, __LINE__);
     $arr = $prep->fetch();
     $prep->closeCursor();
     $prep = NULL;
     if ($arr['auth_creation_perso'] == 0) {
         return fctErrorMSG('Vous n\'avez pas l\'autorisation de créer un personnage. (cheat)', '?m=News', null, false);
     }
     //Validation du NOM
     if (!isset($_POST['nom']) || empty($_POST['nom'])) {
         return fctErrorMSG('Nom de personnage manquant.', $errorUrl, $_POST, false);
     }
     if (strlen($_POST['nom']) > 25 || strlen($_POST['nom']) < 4) {
         return fctErrorMSG('Le nom du personnage à une taille invalide.', $errorUrl, $_POST, false);
     }
     preg_match('/^[-\' çéèôêîA-Za-z]+$/', $_POST['nom'], $matches);
     if (count($matches) == 0) {
         return fctErrorMSG('Le nom du personnage comporte des caractères invalide.', $errorUrl, $_POST, false);
     }
     $query = 'SELECT id' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE nom=:nom' . ' LIMIT 1;';
     $prep = $db->prepare($query);
     $prep->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR);
     $prep->execute($db, __FILE__, __LINE__);
     $arr = $prep->fetch();
     $prep->closeCursor();
     $prep = NULL;
     if ($arr !== false) {
         return fctErrorMSG('Ce nom est déjà utilisé.', $errorUrl, $_POST, false);
     }
     //Validation de l'ETHNIE
     if (!isset($_POST['ethnie']) || empty($_POST['ethnie'])) {
         return fctErrorMSG('Ethnie du personnage manquant.', $errorUrl, $_POST, false);
     }
     //Validation de l'AGE
     if (!isset($_POST['age']) || empty($_POST['age'])) {
         return fctErrorMSG('Âge du personnage manquant.', $errorUrl, $_POST, false);
     }
     preg_match('/^[0-9]{1,2}$/', $_POST['age'], $matches);
     if (count($matches) == 0) {
         return fctErrorMSG('L\'âge du personnage comporte des caractères invalide.', $errorUrl, $_POST, false);
     }
     //Validation du POIDS
     if (!isset($_POST['poids']) || empty($_POST['poids'])) {
         return fctErrorMSG('Poids du personnage manquant.', $errorUrl, $_POST, false);
     }
     preg_match('/^[0-9]{1,3}$/', $_POST['poids'], $matches);
     if (count($matches) == 0) {
         return fctErrorMSG('Le poids du personnage comporte des caractères invalide.', $errorUrl, $_POST, false);
     }
     //Validation de la TAILLE
     if (!isset($_POST['taillem']) || empty($_POST['taillem'])) {
         return fctErrorMSG('Taille du personnage manquante (1).', $errorUrl, $_POST, false);
     }
     if (!isset($_POST['taillecm']) || empty($_POST['taillecm'])) {
         return fctErrorMSG('Taille du personnage manquante (2).', $errorUrl, $_POST, false);
     }
     $taille = $_POST['taillem'] . 'm' . $_POST['taillecm'];
     preg_match('/^[12][m][0-9][05]$/', $taille, $matches);
     if (count($matches) == 0) {
         return fctErrorMSG('La taille du personnage comporte des caractères invalide.', $errorUrl, $_POST, false);
     }
     //Validation des YEUX
     if (!isset($_POST['yeux']) || empty($_POST['yeux'])) {
         return fctErrorMSG('Description des yeux du personnage manquante.', $errorUrl, $_POST, false);
     }
     if (strlen($_POST['yeux']) > 100) {
         return fctErrorMSG('add - Description des yeux du personnage à une taille invalide (' . strlen($_POST['yeux']) . ').', $errorUrl, $_POST, false);
     }
     //Validation des CHEVEUX
     if (!isset($_POST['cheveux']) || empty($_POST['cheveux'])) {
         return fctErrorMSG('Description des cheveux du personnage manquante.', $errorUrl, $_POST, false);
     }
     if (strlen($_POST['cheveux']) > 100) {
         return fctErrorMSG('add - Description des cheveux du personnage à une taille invalide (' . strlen($_POST['cheveux']) . ').', $errorUrl, $_POST, false);
     }
     //Effectuer la liste de toutes les statistiques
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'stat;';
     $prep = $db->prepare($query);
     $prep->execute($db, __FILE__, __LINE__);
     $arrStat = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     //Validation des STATS
     $totalStat = 0;
     foreach ($arrStat as &$stat) {
         $fieldName = 'stat_' . $stat['id'];
         if (!isset($_POST[$fieldName]) || !is_numeric($_POST[$fieldName]) || $_POST[$fieldName] < -75 || $_POST[$fieldName] > 75) {
             return fctErrorMSG('Données sur les stats invalides.', $errorUrl, $_POST, false);
         }
         $totalStat += $_POST[$fieldName];
     }
     if ($totalStat != 0) {
         return fctErrorMSG('Les statistiques doivent avoir une somme de zéro.', $errorUrl, $_POST, false);
     }
     //Effectuer la liste de toutes les compétences
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'competence' . ' WHERE inscription="1";';
     $prep = $db->prepare($query);
     $prep->execute($db, __FILE__, __LINE__);
     $arrComp = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     //Validation des COMPS
     $totalComp = 0;
     foreach ($arrComp as &$comp) {
         $fieldName = 'comp_' . $comp['id'];
         if (!isset($_POST[$fieldName]) || !is_numeric($_POST[$fieldName]) || $_POST[$fieldName] < 0 || $_POST[$fieldName] > INSCRIPTION_MAX_COMP) {
             return fctErrorMSG('Données sur les compétences invalides.', $errorUrl, $_POST, false);
         }
         $totalComp += $_POST[$fieldName];
     }
     if ($totalComp != INSCRIPTION_NBR_COMP) {
         return fctErrorMSG('Les compétences doivent avoir une somme de ' . INSCRIPTION_NBR_COMP . '.', $errorUrl, $_POST, false);
     }
     //Validation SIGNES
     if (!isset($_POST['arrCaract'])) {
         return fctErrorMSG('Sélection des caractéristiques du personnage manquante.', $errorUrl, $_POST, false);
     }
     if (count($_POST['arrCaract']) < 5) {
         return fctErrorMSG('Vous n\'avez sélectionné que ' . count($_POST['arrCaract']) . ' caractéristique(s).', $errorUrl, $_POST, false);
     }
     //Validation Background + Description
     if (!isset($_POST['description']) || empty($_POST['description'])) {
         return fctErrorMSG('Description du personnage manquante.', $errorUrl, $_POST, false);
     }
     if (!isset($_POST['background']) || empty($_POST['background'])) {
         return fctErrorMSG('Historique du personnage manquante.', $errorUrl, $_POST, false);
     }
     //Protéger tout les champs de premier niveau
     foreach ($_POST as &$elem) {
         if (!is_array($elem)) {
             $elem = fctScriptProtect($elem);
         }
     }
     //Créer le personnage
     if (isset($_POST['go'])) {
         $Pstatus = '0';
     }
     if (isset($_POST['save'])) {
         $Pstatus = 'mod';
     }
     try {
         $db->beginTransaction();
         $query = 'INSERT INTO ' . DB_PREFIX . 'perso' . ' (' . ' `userId`, `nom`, `sexe`, `age`, `taille`, `yeux`,' . ' `ethnie`, `cheveux`, `poids`,' . ' `lng1`, `lng1_lvl`, `lng2`, `lng2_lvl`,' . ' `lieu`, `description`, `background`, `inscription_valide`' . ' )' . ' VALUES' . ' (' . ' :userId,  :nom,  :sexe,  :age,  :taille,  :yeux,' . ' :ethnie,  :cheveux,  :poids,' . ' "en",	:lng1_lvl,  :lng2,  :lng2_lvl,' . ' :lieu,  :description,  :background,  :saveType' . ' );';
         $prep = $db->prepare($query);
         $saveType = $_POST['SaveType'] == 'go' ? '0' : 'mod';
         $prep->bindValue(':userId', $account->getId(), PDO::PARAM_INT);
         $prep->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR);
         $prep->bindValue(':sexe', $_POST['sexe'], PDO::PARAM_STR);
         $prep->bindValue(':age', $_POST['age'], PDO::PARAM_INT);
         $prep->bindValue(':taille', $taille, PDO::PARAM_STR);
         $prep->bindValue(':yeux', $_POST['yeux'], PDO::PARAM_STR);
         $prep->bindValue(':ethnie', $_POST['ethnie'], PDO::PARAM_STR);
         $prep->bindValue(':cheveux', $_POST['cheveux'], PDO::PARAM_STR);
         $prep->bindValue(':poids', $_POST['poids'], PDO::PARAM_STR);
         $prep->bindValue(':lng1_lvl', $_POST['lng1_lvl'], PDO::PARAM_STR);
         $prep->bindValue(':lng2', $_POST['lng2'], PDO::PARAM_STR);
         $prep->bindValue(':lng2_lvl', $_POST['lng2_lvl'], PDO::PARAM_STR);
         $prep->bindValue(':lieu', INNACTIVITE_VOLUNTARY_LOCATION, PDO::PARAM_STR);
         $prep->bindValue(':description', $_POST['description'], PDO::PARAM_STR);
         $prep->bindValue(':background', $_POST['background'], PDO::PARAM_STR);
         $prep->bindValue(':saveType', $saveType, PDO::PARAM_STR);
         $prep->execute($db, __FILE__, __LINE__);
         $prep->closeCursor();
         $prep = NULL;
         $persoId = $db->lastInsertId();
         //Insérer les stats
         $query = 'INSERT INTO ' . DB_PREFIX . 'perso_stat' . ' (`persoid`, `statid`, `xp`)' . ' VALUES' . ' (:persoId,  :statId,  :xp);';
         $prep = $db->prepare($query);
         foreach ($arrStat as &$stat) {
             $statXp = $_POST['stat_' . $stat['id']];
             $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
             $prep->bindValue(':statId', $stat['id'], PDO::PARAM_INT);
             $prep->bindValue(':xp', $statXp, PDO::PARAM_INT);
             $prep->execute($db, __FILE__, __LINE__);
         }
         $prep->closeCursor();
         $prep = NULL;
         //Insérer les compétences
         $query = 'INSERT INTO ' . DB_PREFIX . 'perso_competence' . ' (`persoid`, `compid`, `xp`)' . ' VALUES' . ' (:persoId,  :compId,  :xp);';
         $prep = $db->prepare($query);
         foreach ($arrComp as &$comp) {
             $fn = 'comp_' . $comp['id'];
             if (isset($_POST[$fn]) && is_numeric($_POST[$fn]) && $_POST[$fn] > 0) {
                 $compXp = Member_Perso::convCompLevelToXp($_POST[$fn]);
                 $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
                 $prep->bindValue(':compId', $comp['id'], PDO::PARAM_INT);
                 $prep->bindValue(':xp', $compXp, PDO::PARAM_INT);
                 $prep->execute($db, __FILE__, __LINE__);
             }
         }
         $prep->closeCursor();
         $prep = NULL;
         //Ajouter les informations sur les Signes
         $query = 'INSERT INTO ' . DB_PREFIX . 'perso_caract' . ' (`persoid`, `caractid`, `desc`)' . ' VALUES' . ' (:persoId,  :caractId,  :desc);';
         $prep = $db->prepare($query);
         foreach ($_POST['arrCaract'] as &$caract) {
             $desc = $_POST['caractDesc_' . $caract];
             $prep->bindValue(':persoId', $persoId, PDO::PARAM_INT);
             $prep->bindValue(':caractId', $caract, PDO::PARAM_INT);
             $prep->bindValue(':desc', $desc, PDO::PARAM_STR);
             $prep->execute($db, __FILE__, __LINE__);
         }
         $prep->closeCursor();
         $prep = NULL;
         //Baisser le nombre de création de perso de 1
         $query = 'UPDATE ' . DB_PREFIX . 'account' . ' SET auth_creation_perso=auth_creation_perso-1' . ' WHERE id=:userId' . ' LIMIT 1;';
         $prep = $db->prepare($query);
         $prep->bindValue(':userId', $account->getId(), PDO::PARAM_INT);
         $prep->execute($db, __FILE__, __LINE__);
         $prep->closeCursor();
         $prep = NULL;
         //Sauvegarder la liste des personnages du compte
         $perso_list = array();
         $perso_list = $session->getVar('persoList');
         $perso_list[] = array('id' => $persoId, 'nom' => $_POST['nom']);
         $session->setVar('persoList', $perso_list);
         $db->commit();
     } catch (exception $e) {
         $db->rollback();
         var_dump($e);
         throw $e;
     }
     //Retourner le template complété/rempli
     $tpl->set('PAGE', 'News');
     return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/redirect.htm', __FILE__, __LINE__);
 }
Exemple #9
0
 public static function generatePage(&$tpl, &$session, &$account, &$perso)
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     //Générer la liste des compétances
     $arrComp = $perso->getComp();
     $comp = array();
     $i = 0;
     foreach ($arrComp as $compId) {
         $rawXp = $perso->getCompXp($compId);
         $rawLvl = $perso->getCompRawLevel($compId);
         $realLvl = $perso->getCompRealLevel($compId);
         $pCompXp = Member_Perso::convCompLevelToXp($rawLvl);
         $nCompXp = Member_Perso::convCompLevelToXp($rawLvl + 1);
         $comp[$i]['code'] = $perso->getCompCode($compId);
         $comp[$i]['nom'] = $perso->getCompName($compId);
         $comp[$i]['totalXp'] = $nCompXp - $pCompXp;
         $comp[$i]['currentXp'] = $rawXp - $pCompXp;
         $comp[$i]['lvl'] = $rawLvl;
         $comp[$i]['reallvl'] = $realLvl;
         $comp[$i]['xp'] = $rawXp;
         $i++;
     }
     $tpl->set('COMP', $comp);
     //Générer la liste des statistiques
     $arrStat = $perso->getStat();
     $stat = array();
     $i = 0;
     foreach ($arrStat as $statId) {
         $statCode = $perso->getStatCode($statId);
         $rawXp = $perso->getStatRawXp($statId);
         $rawLvl = $perso->getStatRawLevel($statId);
         $statName = $perso->getStatName($statId);
         $prevLvlMinXp = Member_Perso::convStatLevelToXp($rawLvl - 1);
         $prevLvlMaxXp = Member_Perso::convStatLevelToXp($rawLvl);
         $nextLvlMinXp = Member_Perso::convStatLevelToXp($rawLvl);
         $nextLvlMaxXp = Member_Perso::convStatLevelToXp($rawLvl + 1);
         //Si le niveau est négatif
         if ($rawLvl < 0) {
             $prevBarMax = abs($prevLvlMinXp) - abs($prevLvlMaxXp);
             $prevBarPosition = abs($rawXp) - abs($prevLvlMaxXp) + 1;
             if ($prevBarMax == 0) {
                 $nextBarMax = $prevBarPosition;
                 $nextBarPosition = 1;
             } else {
                 $nextBarMax = abs($prevLvlMinXp) - abs($prevLvlMaxXp);
                 $nextBarPosition = $prevBarMax - $prevBarPosition;
             }
         }
         //Si le niveau est positif
         if ($rawLvl > 0) {
             $nextBarMax = abs($nextLvlMaxXp) - abs($nextLvlMinXp);
             $nextBarPosition = abs($rawXp) - abs($nextLvlMinXp) + 1;
             if ($nextBarMax == 0) {
                 $prevarMax = $nextBarPosition;
                 $prevBarPosition = 1;
             } else {
                 $prevBarMax = abs($nextLvlMaxXp) - abs($nextLvlMinXp);
                 $prevBarPosition = $nextBarMax - $nextBarPosition;
             }
         }
         //Si le niveau est celui du centre
         if ($rawLvl == 0) {
             $prevBarMax = abs($prevLvlMinXp) + abs($nextLvlMaxXp);
             $nextBarMax = abs($prevLvlMinXp) + abs($nextLvlMaxXp);
             $prevBarPosition = $rawXp + abs($prevLvlMinXp);
             $nextBarPosition = $prevBarMax - $prevBarPosition;
         }
         $stat[$i]['code'] = $statCode;
         $stat[$i]['nom'] = $statName;
         $stat[$i]['lvl'] = $rawLvl;
         $stat[$i]['xp'] = $rawXp;
         $stat[$i]['prevBarMax'] = $prevBarMax;
         $stat[$i]['nextBarMax'] = $nextBarMax;
         $stat[$i]['prevBarPos'] = $prevBarPosition;
         $stat[$i]['nextBarPos'] = $nextBarPosition;
         $i++;
     }
     //die(nl2br(var_export($stat, true)));
     $tpl->set('STAT', $stat);
     //Trouver les caractéristiques du perso
     $query = 'SELECT p.*, c.nom, t.nom as cat' . ' FROM ' . DB_PREFIX . 'perso_caract as p' . ' LEFT JOIN ' . DB_PREFIX . 'caract as c ON (c.id = p.caractid)' . ' LEFT JOIN ' . DB_PREFIX . 'caract as t ON (t.id = c.catid)' . ' WHERE p.persoid=:persoId;';
     $prep = $db->prepare($query);
     $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
     $prep->executePlus($db, __FILE__, __LINE__);
     $arrAll = $prep->fetchAll();
     $prep->closeCursor();
     $prep = NULL;
     foreach ($arrAll as &$arr) {
         $arr['cat'] = stripslashes($arr['cat']);
         $arr['nom'] = stripslashes($arr['nom']);
         $arr['desc'] = stripslashes($arr['desc']);
     }
     $tpl->set('CARACT', $arrAll);
     //Retourner le template complété/rempli
     return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Perso/FichePerso.htm', __FILE__, __LINE__);
 }
Exemple #10
0
 private function genMemberPage($file)
 {
     //Si aucun perso est chargé ET qu'on ne veux pas en charger un
     if ($this->session->getVar('persoId') === NULL && !isset($_GET['perso'])) {
         //Page n'ayant besoin d'être en train de jouer un perso
         $canAccessWithoutPerso = false;
         $pages = explode(',', str_replace(' ', '', ENGINE_ACCESS_WITHOUT_PERSO));
         foreach ($pages as $page) {
             if ($page == $file) {
                 $canAccessWithoutPerso = true;
                 break;
             }
         }
         unset($pages, $page);
         if ($canAccessWithoutPerso) {
             return call_user_func_array(array('Member_' . $file, 'generatePage'), array(&$this->tpl, &$this->session, &$this->account));
         } else {
             return fctErrorMSG('Aucun personnage sélectionné.');
         }
         unset($canAccessWithoutPerso);
     } else {
         //S'il faudrait charger un perso mais que rien n'est demandé
         if ($this->session->getVar('persoId') === NULL && !isset($_GET['perso'])) {
             return fctErrorMSG('Vous devez sélectionner un personnage.');
         }
         //Si aucun perso n'est actuellement joué, procéder à son chargement
         if (isset($_GET['perso']) && $_GET['perso'] != $this->session->getVar('persoId')) {
             //Rechercher parmis notre liste de personnage si celui demandé y est.
             $persoFound = false;
             foreach ($this->session->getVar('persoList') as $arrPerso) {
                 if ($arrPerso['id'] == $_GET['perso']) {
                     $persoFound = true;
                     break;
                 }
             }
             if (!$persoFound) {
                 return fctErrorMSG('Tentative de jouer un perso qui ne vous appartiend pas. (cheat)');
             }
             $this->session->setVar('persoId', (int) $_GET['perso']);
         }
         try {
             $perso = Member_Perso::load($this->session->getVar('persoId'));
             $this->tpl->set('CURRENT_PERSO_ID', $perso->getId());
             if ($perso->getHeMsgCount() > 15000) {
                 fctBugReport('Un problème avec le HE à été détecté. Un rapport d\'erreur à été créé et votre compte sera vérifié sous peu.', $perso, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, true, true, true);
             }
             //$this->session->setVar('perso', $perso);
         } catch (Exception $e) {
             return fctErrorMSG($e->getMessage());
         }
         return call_user_func_array(array('Member_' . $file, 'generatePage'), array(&$this->tpl, &$this->session, &$this->account, &$perso));
     }
     //Fin du if: Si un personnage à été sélection ou est sauvegardé
 }
Exemple #11
0
    public static function generatePage(&$tpl, &$session, &$account, &$mj)
    {
        $dbMgr = DbManager::getInstance();
        //Instancier le gestionnaire
        $db = $dbMgr->getConn('game');
        //Demander la connexion existante
        if (isset($_POST['save'])) {
            //Fetcher toutes les informations concernant le perso
            $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE id=:persoId' . ' LIMIT 1;';
            $prepP = $db->prepare($query);
            $prepP->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
            $prepP->executePlus($db, __FILE__, __LINE__);
            $arr = $prepP->fetch();
            $perso = new Member_Perso($arr);
            //Vérifier tout ce qui a changé
            $msg = array();
            if ($perso->getUserId() != $_POST['userId']) {
                $msg[] = 'UserId: ' . $_POST['userId'];
            }
            if ($perso->getNom() != $_POST['nom']) {
                $msg[] = 'Nom: ' . $_POST['nom'];
            }
            if ($perso->getSexe() != $_POST['sexe']) {
                $msg[] = 'Sexe: ' . $_POST['sexe'];
            }
            if ($perso->getAge() != $_POST['age']) {
                $msg[] = 'Age: ' . $_POST['age'];
            }
            if ($perso->getTaille() != $_POST['taille']) {
                $msg[] = 'Taille: ' . $_POST['taille'];
            }
            if ($perso->getEthnie() != $_POST['ethnie']) {
                $msg[] = 'Ethnie: ' . $_POST['ethnie'];
            }
            if ($perso->getYeux() != $_POST['yeux']) {
                $msg[] = 'Yeux: ' . $_POST['yeux'];
            }
            if ($perso->getCheveux() != $_POST['cheveux']) {
                $msg[] = 'Cheveux: ' . $_POST['cheveux'];
            }
            if ($perso->getType() != $_POST['playertype']) {
                $msg[] = 'Type: ' . $_POST['playertype'];
            }
            if ($perso->getPrMax() != $_POST['prmax']) {
                $msg[] = 'Pr Max: ' . $_POST['prmax'];
            }
            if ($perso->getPa() != $_POST['pa']) {
                $msg[] = 'Pa: ' . $_POST['pa'];
            }
            if ($perso->getPaMax() != $_POST['pamax']) {
                $msg[] = 'Pa Max: ' . $_POST['pamax'];
            }
            if ($perso->getPv() != $_POST['pv']) {
                $msg[] = 'Pv: ' . $_POST['pv'];
            }
            if ($perso->getPvMax() != $_POST['pvmax']) {
                $msg[] = 'Pv Max: ' . $_POST['pvmax'];
            }
            if ($perso->getPn() != $_POST['pn']) {
                $msg[] = 'Pn: ' . $_POST['pn'];
            }
            if ($perso->getCash() != $_POST['cash']) {
                $msg[] = 'Argent: ' . $_POST['cash'];
            }
            try {
                if ($perso->getLieu()->getNomTech() != $_POST['lieu']) {
                    $msg[] = 'Lieu: ' . $_POST['lieu'];
                }
            } catch (Exception $e) {
                if (!isset($_POST['lieu'])) {
                    $msg[] = 'Lieu: non-sélectionné';
                } else {
                    $msg[] = 'Lieu: ' . $_POST['lieu'];
                }
            }
            if ($perso->getCurrentAction() != $_POST['current_action']) {
                $msg[] = "Action Courrante: \n" . $_POST['current_action'];
            }
            if ($perso->getDescription() != $_POST['description']) {
                $msg[] = "Description: \n" . $_POST['description'];
            }
            if ($perso->getBackground() != $_POST['background']) {
                $msg[] = "Background: \n" . $_POST['background'];
            }
            if ($perso->getNoteMj() != $_POST['note_mj']) {
                $msg[] = "Note MJ: \n" . $_POST['note_mj'];
            }
            if ($perso->isBloque() != $_POST['actif']) {
                $msg[] = 'Actif: ' . $_POST['actif'];
            }
            if ($perso->getVisaPerm() != $_POST['visavert']) {
                $msg[] = 'VisaVert: ' . $_POST['visavert'];
            }
            if ($perso->getPv() > 0 && $_POST['pv'] < 0) {
                $perso->logMort($mj->getNom(), 'Modifier Perso');
            }
            $menotte = $_POST['menotte'] == false ? NULL : $_POST['menotteId'];
            if ($perso->getMenotte() != $menotte) {
                $msg[] = 'Menotté : ' . ($menotte ? 'oui (' . $menotte . ').' : 'non.');
                //Gestion des menottes
                //Si menotté :
                //Vérifier si l'item a bien la capacité menottage
                //Vérifier si l'item n'est pas déjà utilisé
                //Equiper l'item
                //Si passage de monotté à menotté avec autre item => déséquiper ancien item
                //Si passage de menotté à non menotté => déséquiper l'item
                if ($menotte) {
                    try {
                        $newMenotte = Member_ItemFactory::createFromInvId($menotte);
                    } catch (Exception $e) {
                        return fctErrorMSG($e->getMessage());
                    }
                    $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'item_menu' . ' WHERE item_dbid = :dbid' . ' AND url="Menotter" LIMIT 1;';
                    $prep = $db->prepare($query);
                    $prep->bindValue(':dbid', $newMenotte->getDbId(), PDO::PARAM_INT);
                    $prep->executePlus($db, __FILE__, __LINE__);
                    $arrAll = $prep->fetchAll();
                    $prep->closeCursor();
                    $prep = NULL;
                    if (count($arrAll) == 0) {
                        return fctErrorMSG('L\'item choisi pour menotter n\'a pas la capacité menotter.');
                    }
                    if ($newMenotte->isEquip()) {
                        return fctErrorMSG('L\'item choisi pour menotter est déjà utilisé.');
                    }
                    //Équiper l'item
                    $query = 'UPDATE ' . DB_PREFIX . 'item_inv' . ' SET inv_equip="1"' . ' WHERE inv_id=:itemId' . ' LIMIT 1;';
                    $prep = $db->prepare($query);
                    $prep->bindValue(':itemId', $newMenotte->getInvId(), PDO::PARAM_INT);
                    $prep->executePlus($db, __FILE__, __LINE__);
                    $prep->closeCursor();
                    $prep = NULL;
                    if ($perso->getMenotte()) {
                        $query = 'UPDATE ' . DB_PREFIX . 'item_inv' . ' SET inv_equip="0"' . ' WHERE inv_id=:itemId' . ' LIMIT 1;';
                        $prep = $db->prepare($query);
                        $prep->bindValue(':itemId', $perso->getMenotte(), PDO::PARAM_INT);
                        $prep->executePlus($db, __FILE__, __LINE__);
                        $prep->closeCursor();
                        $prep = NULL;
                    }
                } else {
                    $query = 'UPDATE ' . DB_PREFIX . 'item_inv' . ' SET inv_equip="0"' . ' WHERE inv_id=:itemId' . ' LIMIT 1;';
                    $prep = $db->prepare($query);
                    $prep->bindValue(':itemId', $perso->getMenotte(), PDO::PARAM_INT);
                    $prep->executePlus($db, __FILE__, __LINE__);
                    $prep->closeCursor();
                    $prep = NULL;
                }
            }
            //modification
            $query = 'UPDATE ' . DB_PREFIX . 'perso' . ' SET' . ' userId=:userId,' . ' nom=:nom,' . ' sexe=:sexe,' . ' age=:age,' . ' taille=:taille,' . ' ethnie=:ethnie,' . ' yeux=:yeux,' . ' cheveux=:cheveux,' . ' playertype=:playerType,' . ' prmax=:prMax,' . ' pa=:pa,' . ' pamax=:paMax,' . ' pv=:pv,' . ' pvmax=:pvMax,' . ' pn=:pn,' . ' cash=:cash,' . ' lieu=:lieu,' . ' current_action=:currentAction,' . ' description=:description,' . ' background=:background,' . ' note_mj=:noteMj,' . ' bloque=:bloque,' . ' visa_perm=:visaPerm,' . ' menotte = :menotte' . ' WHERE id=:persoId;';
            $prep = $db->prepare($query);
            $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
            $prep->bindValue(':userId', $_POST['userId'], PDO::PARAM_INT);
            $prep->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR);
            $prep->bindValue(':sexe', $_POST['sexe'], PDO::PARAM_STR);
            $prep->bindValue(':age', $_POST['age'], PDO::PARAM_INT);
            $prep->bindValue(':taille', $_POST['taille'], PDO::PARAM_STR);
            $prep->bindValue(':ethnie', $_POST['ethnie'], PDO::PARAM_STR);
            $prep->bindValue(':yeux', $_POST['yeux'], PDO::PARAM_STR);
            $prep->bindValue(':cheveux', $_POST['cheveux'], PDO::PARAM_STR);
            $prep->bindValue(':playerType', $_POST['playertype'], PDO::PARAM_STR);
            $prep->bindValue(':prMax', $_POST['prmax'], PDO::PARAM_INT);
            $prep->bindValue(':pa', $_POST['pa'], PDO::PARAM_INT);
            $prep->bindValue(':paMax', $_POST['pamax'], PDO::PARAM_INT);
            $prep->bindValue(':pv', $_POST['pv'], PDO::PARAM_INT);
            $prep->bindValue(':pvMax', $_POST['pvmax'], PDO::PARAM_INT);
            $prep->bindValue(':pn', $_POST['pn'], PDO::PARAM_INT);
            $prep->bindValue(':cash', $_POST['cash'], PDO::PARAM_INT);
            $prep->bindValue(':lieu', isset($_POST['lieu']) ? $_POST['lieu'] : LIEU_DEPART, PDO::PARAM_STR);
            $prep->bindValue(':currentAction', $_POST['current_action'], PDO::PARAM_STR);
            $prep->bindValue(':description', $_POST['description'], PDO::PARAM_STR);
            $prep->bindValue(':background', $_POST['background'], PDO::PARAM_STR);
            $prep->bindValue(':noteMj', $_POST['note_mj'], PDO::PARAM_STR);
            $prep->bindValue(':bloque', $_POST['actif'], PDO::PARAM_STR);
            $prep->bindValue(':visaPerm', $_POST['visavert'], PDO::PARAM_STR);
            $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
            $prep->bindValue(':menotte', $menotte, PDO::PARAM_STR);
            $prep->executePlus($db, __FILE__, __LINE__);
            $prep->closeCursor();
            $prep = NULL;
            //Fetcher toutes les informations concernant le perso
            $prepP->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
            $prepP->executePlus($db, __FILE__, __LINE__);
            $arr = $prepP->fetch();
            $perso = new Member_Perso($arr);
            //Sauvegarder les stats
            $query = 'INSERT INTO ' . DB_PREFIX . 'perso_stat' . ' (persoid, statid, xp)' . ' VALUES' . ' (:persoId, :statId, :xp);';
            $prepIns = $db->prepare($query);
            $query = 'UPDATE ' . DB_PREFIX . 'perso_stat' . ' SET xp=:xp' . ' WHERE persoid=:persoId' . ' AND statid=:statId' . ' LIMIT 1;';
            $prepUpd = $db->prepare($query);
            foreach ($perso->getStat() as $id) {
                $statCode = $perso->getStatCode($id);
                $fieldName = 'stat_' . $statCode;
                if (isset($_POST[$fieldName]) && is_numeric($_POST[$fieldName]) && $perso->getStatRawXp($id) != $_POST[$fieldName]) {
                    //Construire le message d'information
                    $statDiff = (int) $_POST[$fieldName] - $perso->getStatRawXp($id);
                    if ($statDiff > 0) {
                        $statDiff = '+' . $statDiff;
                    }
                    $msg[] = 'Stat ' . strtoupper($statCode) . ': ' . $statDiff;
                    if ($perso->getStatRawXp($id) === NULL) {
                        $prepIns->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
                        $prepIns->bindValue(':statId', $id, PDO::PARAM_INT);
                        $prepIns->bindValue(':xp', $_POST[$fieldName], PDO::PARAM_INT);
                        $prepIns->executePlus($db, __FILE__, __LINE__);
                    } else {
                        $prepUpd->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
                        $prepUpd->bindValue(':statId', $id, PDO::PARAM_INT);
                        $prepUpd->bindValue(':xp', $_POST[$fieldName], PDO::PARAM_INT);
                        $prepUpd->executePlus($db, __FILE__, __LINE__);
                    }
                }
            }
            $prepIns->closeCursor();
            $prepIns = NULL;
            $prepUpd->closeCursor();
            $prepUpd = NULL;
            //Sauvegarder les comps
            $query = 'INSERT INTO ' . DB_PREFIX . 'perso_competence' . ' (`persoid`, `compid`, `xp`)' . 'VALUES' . '(:persoId, :compId, :xp);';
            $prepIns = $db->prepare($query);
            $query = 'UPDATE ' . DB_PREFIX . 'perso_competence' . ' SET xp=:xp' . ' WHERE persoid=:persoId' . ' AND compid=:compId' . ' LIMIT 1;';
            $prepUpd = $db->prepare($query);
            $query = 'DELETE FROM ' . DB_PREFIX . 'perso_competence' . ' WHERE persoid=:persoId' . ' AND compid=:compId' . ' LIMIT 1;';
            $prepDel = $db->prepare($query);
            foreach ($perso->getComp() as $id) {
                $compCode = $perso->getCompCode($id);
                $fieldName = 'comp_' . $compCode;
                //La comp doit être définie
                if (isset($_POST[$fieldName]) && !empty($_POST[$fieldName]) && is_numeric($_POST[$fieldName]) && $perso->getCompXp($id) != $_POST[$fieldName]) {
                    //Construire le message d'information
                    $compDiff = (int) $_POST[$fieldName] - $perso->getCompXp($id);
                    if ($compDiff > 0) {
                        $compDiff = '+' . $compDiff;
                    }
                    $msg[] = 'Comp ' . strtoupper($compCode) . ': ' . $compDiff;
                    //Créer la comp
                    if ($perso->getCompXp($id) === NULL) {
                        $prepIns->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
                        $prepIns->bindValue(':compId', $id, PDO::PARAM_INT);
                        $prepIns->bindValue(':xp', $_POST[$fieldName], PDO::PARAM_INT);
                        $prepIns->executePlus($db, __FILE__, __LINE__);
                    } else {
                        $prepUpd->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
                        $prepUpd->bindValue(':compId', $id, PDO::PARAM_INT);
                        $prepUpd->bindValue(':xp', $_POST[$fieldName], PDO::PARAM_INT);
                        $prepUpd->executePlus($db, __FILE__, __LINE__);
                    }
                }
                //La compétence doit être effacée
                if (isset($_POST[$fieldName]) && empty($_POST[$fieldName]) && $perso->getCompXp($id) !== NULL) {
                    $prepDel->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
                    $prepDel->bindValue(':compId', $id, PDO::PARAM_INT);
                    $prepDel->executePlus($db, __FILE__, __LINE__);
                    //Construire le message d'information
                    $msg[] = 'Comp ' . strtoupper($compCode) . ': 0';
                }
            }
            $prepIns->closeCursor();
            $prepIns = NULL;
            $prepUpd->closeCursor();
            $prepUpd = NULL;
            $prepDel->closeCursor();
            $prepDel = NULL;
            //Modifier / Supprimer une caract
            $query = 'SELECT p.*, c.nom' . ' FROM ' . DB_PREFIX . 'perso_caract as p' . ' LEFT JOIN ' . DB_PREFIX . 'caract as c' . ' ON (c.id = p.caractid)' . ' WHERE p.`persoid`=:persoId;';
            $prep = $db->prepare($query);
            $prep->bindValue(':persoId', $_GET['id']);
            $prep->executePlus($db, __FILE__, __LINE__);
            $arrAll = $prep->fetchAll();
            $prep->closeCursor();
            $prep = NULL;
            $query = 'UPDATE ' . DB_PREFIX . 'perso_caract' . ' SET `desc`=:description' . ' WHERE `id`=:id;';
            $prepUpd = $db->prepare($query);
            $query = 'DELETE FROM ' . DB_PREFIX . 'perso_caract' . ' WHERE `id`=:id' . ' LIMIT 1;';
            $prepDel = $db->prepare($query);
            foreach ($arrAll as &$row) {
                //Supprimer ?
                if (isset($_POST['del_caract_' . $row['id']])) {
                    $prepDel->bindValue(':id', $row['id'], PDO::PARAM_INT);
                    $prepDel->executePlus($db, __FILE__, __LINE__);
                    $msg[] = 'Suppression de la caract ' . stripslashes($row['nom']);
                } else {
                    $newDesc = fctScriptProtect($_POST['caract_' . $row['id']]);
                    if (stripslashes($row['desc']) != $newDesc) {
                        //Modifier
                        $prepUpd->bindValue(':description', $newDesc, PDO::PARAM_STR);
                        $prepUpd->bindValue(':id', $row['id'], PDO::PARAM_INT);
                        $prepUpd->executePlus($db, __FILE__, __LINE__);
                        $msg[] = 'Modification de la caract ' . stripslashes($row['nom']) . ":\n" . $newDesc;
                    }
                }
            }
            $prepUpd->closeCursor();
            $prepUpd = NULL;
            $prepDel->closeCursor();
            $prepDel = NULL;
            //Ajouter une caract
            if ($_POST['add_caract'] != 0) {
                $query = 'INSERT INTO ' . DB_PREFIX . 'perso_caract' . ' (`caractid`,`persoid`)' . ' VALUES' . ' (:caractId, :persoId);';
                $prep = $db->prepare($query);
                $prep->bindValue(':caractId', $_POST['add_caract'], PDO::PARAM_INT);
                $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
                $prep->executePlus($db, __FILE__, __LINE__);
                $prep->closeCursor();
                $prep = NULL;
                $msg[] = 'Ajout de la caract #' . $_POST['add_caract'] . ":\n";
            }
            //Recharger la liste des perso du compte actuel (compte du MJ)
            $query = 'SELECT id, nom
						FROM ' . DB_PREFIX . 'perso
						WHERE userId=:userId;';
            $prep = $db->prepare($query);
            $prep->bindValue(':userId', $session->getVar('userId'), PDO::PARAM_INT);
            $prep->executePlus($db, __FILE__, __LINE__);
            $arrAll = $prep->fetchAll();
            $prep->closeCursor();
            $prep = NULL;
            $session->setVar('persoList', $arrAll);
            //Afficher les messages et logger dans le HE MJ
            if (count($msg) > 0) {
                $msg = implode(",\n", $msg);
                $tpl->set('MODIFICATIONS', nl2br($msg));
                $mj->addHe("Modification du personnage: \n" . $msg, $perso->getNom(), 'perso');
            }
            $prepP->closeCursor();
            $prepP = NULL;
        }
        // End save
        //Fetcher toutes les informations concernant le perso
        $query = 'SELECT p.*, a.user as user' . ' FROM ' . DB_PREFIX . 'perso as p' . ' LEFT JOIN ' . DB_PREFIX . 'account as a' . ' ON (a.id=p.userId)' . ' WHERE p.id=:persoId' . ' LIMIT 1;';
        $prep = $db->prepare($query);
        $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT);
        $prep->executePlus($db, __FILE__, __LINE__);
        $arr = $prep->fetch();
        $prep->closeCursor();
        $prep = NULL;
        if ($arr === false) {
            return fctErrorMSG('Ce personnage n\'existe pas.');
        }
        try {
            $perso = new Member_Perso($arr);
        } catch (Exception $e) {
            return fctErrorMSG($e->getMessage());
        }
        try {
            $tpl->set('PERSO_LIEU', $perso->getLieu()->getNomTech());
        } catch (Exception $e) {
            $tpl->set('PERSO_LIEU', 'LIEU CORROMPU');
        }
        $tpl->set('PERSO', $perso);
        $tpl->set('ACCOUNT_USER', $arr['user']);
        $tpl->set('BACKGROUND', stripslashes($arr['background']));
        $tpl->set('NOTE_MJ', stripslashes($arr['note_mj']));
        //Trouver les drogues consommées
        $query = 'SELECT inv_id' . ' FROM ' . DB_PREFIX . 'item_inv' . ' WHERE inv_equip="1"' . ' AND inv_dbid="2"' . ' AND inv_persoid=:persoId' . ' ;';
        $prep = $db->prepare($query);
        $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
        $prep->executePlus($db, __FILE__, __LINE__);
        $arrAll = $prep->fetchAll();
        $prep->closeCursor();
        $prep = NULL;
        $drogues = array();
        foreach ($arrAll as &$arr) {
            $drogues[] = '<a href="?mj=Item_Inv_Mod&id=' . (int) $arr['inv_id'] . '&rpage=Perso_Mod&rid=' . (int) $perso->getId() . '">' . (int) $arr['inv_id'] . '</a>';
        }
        if (count($drogues) > 0) {
            $tpl->set('DROGUES', implode(', ', $drogues));
        }
        //Trouver les caractéristiques du perso
        $query = 'SELECT p.*, c.nom, t.nom as cat' . ' FROM ' . DB_PREFIX . 'perso_caract as p' . ' LEFT JOIN ' . DB_PREFIX . 'caract as c ON (c.id = p.caractid)' . ' LEFT JOIN ' . DB_PREFIX . 'caract as t ON (t.id = c.catid)' . ' WHERE p.persoid=:persoId;';
        $prep = $db->prepare($query);
        $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
        $prep->executePlus($db, __FILE__, __LINE__);
        $arrAll = $prep->fetchAll();
        $prep->closeCursor();
        $prep = NULL;
        foreach ($arrAll as &$arr) {
            $arr['cat'] = stripslashes($arr['cat']);
            $arr['nom'] = stripslashes($arr['nom']);
            $arr['desc'] = stripslashes($arr['desc']);
        }
        $tpl->set('CARACT', $arrAll);
        //Trouver toutes les caractéristiques
        $query = 'SELECT c.*, t.nom as cat' . ' FROM ' . DB_PREFIX . 'caract as c' . ' LEFT JOIN ' . DB_PREFIX . 'caract as t ON (t.id = c.catid)' . ' WHERE c.catid!=0' . ' ORDER BY t.nom, c.nom;';
        $prep = $db->prepare($query);
        $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
        $prep->executePlus($db, __FILE__, __LINE__);
        $arrAll = $prep->fetchAll();
        $prep->closeCursor();
        $prep = NULL;
        foreach ($arrAll as &$arr) {
            $arr['cat'] = stripslashes($arr['cat']);
            $arr['nom'] = stripslashes($arr['nom']);
        }
        $tpl->set('ALLCARACT', $arrAll);
        //trouver les modificateurs des compétences:
        $query = 'SELECT c.*, p.xp, s.statid, s.stat_multi' . ' FROM ' . DB_PREFIX . 'competence as c' . ' LEFT JOIN ' . DB_PREFIX . 'perso_competence as p ON (p.compid = c.id AND p.persoid=:persoId)' . ' LEFT JOIN ' . DB_PREFIX . 'competence_stat as s ON (s.compid = c.id)' . ' ORDER BY c.id;';
        $prep = $db->prepare($query);
        $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT);
        $prep->executePlus($db, __FILE__, __LINE__);
        $arrAll = $prep->fetchAll();
        $prep->closeCursor();
        $prep = NULL;
        $arrComp = array();
        foreach ($arrAll as &$arr) {
            if ($arr['statid'] === NULL) {
                $arrComp[$arr['id']] = NULL;
            } else {
                $arrComp[$arr['id']][$arr['statid']] = $arr['stat_multi'];
            }
        }
        foreach ($arrComp as &$arr) {
            if ($arr === NULL) {
                $arr['txt'] = '';
            } else {
                $txtBuilder = array();
                foreach ($arr as $statId => $multi) {
                    $txtBuilder[] = strtoupper($perso->getStatCode($statId)) . 'x' . $multi;
                }
                $arr['txt'] = implode(' + ', $txtBuilder);
            }
        }
        $tpl->set('COMP_MOD_TXT', $arrComp);
        return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Perso/Mod.htm');
    }
Exemple #12
0
 function testGetLieu()
 {
     $obj = Member_Perso::load($this->validPersoId);
     $this->assertTrue($obj->getLieu()->confirmPerso($obj, $obj->getId()));
 }