Exemplo n.º 1
0
 public static function generatePage(&$tpl, &$session, &$account, &$perso)
 {
     if ($account->getMemberLevel() === 0) {
         return fctErrorMSG('Cette option est accessible aux Membres Plus seulement.');
     }
     header("Content-Type: text/plain;");
     header("Content-Disposition: attachment; filename=he_export" . date("Y-m-d") . ".txt");
     for ($i = 0; $i < 12000; $i += 500) {
         $arrAll = Member_He::listMessages($perso, $i, 499, false);
         //Grouper adéquatement les envoyeurs & destinataires
         $arrHe = array();
         foreach ($arrAll as &$arrMsg) {
             $arrTmp = array();
             $arrTmp['msg'] = $arrMsg->getMsg();
             $arrTmp['date'] = $arrMsg->getDateTxt();
             //remplacer les tableaux From To par la version texte
             $arrFrom = array();
             $arrTo = array();
             foreach ($arrMsg->getFrom() as $tmp) {
                 $arrFrom[] = $tmp['nom'];
             }
             foreach ($arrMsg->getTo() as $tmp) {
                 $arrTo[] = $tmp['nom'];
             }
             $arrTmp['from'] = implode(', ', $arrFrom);
             $arrTmp['to'] = implode(', ', $arrTo);
             $arrHe[] = $arrTmp;
             unset($arrTmp);
         }
         unset($arrAll);
         $tpl->set('MESSAGES', $arrHe);
         unset($arrHe);
         //Retourner le template complété/rempli
         echo $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Mp/heExport2.htm', __FILE__, __LINE__);
         flush();
     }
     die;
 }
Exemplo n.º 2
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__);
 }
Exemplo n.º 3
0
 public static function generatePage(&$tpl, &$session, &$account, &$perso)
 {
     //Valider si le personnage a été validé
     if (!$perso->isInscriptionValide()) {
         return fctErrorMSG('Votre personnage ' . $perso->getNom() . ' n\'a pas encore été validé par un MJ.', '?m=News', null, false);
     }
     //Valider si le personnage est non-bloqué
     if ($perso->isBloque()) {
         return fctErrorMSG('Votre personnage ' . $perso->getNom() . ' a été bloqué.', '?m=News', null, false);
     }
     //Préparer le tableau d'information
     try {
         $tpl->set('id', $perso->getId());
         //Utile pour éviter de s'auto-renommer
         $tpl->set('nom', $perso->getNom());
         $tpl->set('pa', $perso->getPa());
         $tpl->set('paMax', $perso->getPaMax());
         $tpl->set('pn', $perso->getPn());
         $tpl->set('lieu', $perso->getLieu()->getNom());
         //Peut lancer une exception
         $tpl->set('pv', $perso->getPv());
         $tpl->set('pvMax', $perso->getPvMax());
         $tpl->set('argent', fctCreditFormat($perso->getCash()));
         $tpl->set('pr', $perso->getPr());
         $tpl->set('prmax', $perso->getPrMax());
         $tpl->set('membre', $account->getMemberLevelTxt() . '<br />reste: ' . $account->getMemberRestant() . " jour(s)");
         $tpl->set('MP_LVL', $account->getMemberLevel());
         $tpl->set('actionImmediate', $perso->getCurrentAction());
         if ($perso->isEnergetique()) {
             $tpl->set('PA_COLORCLASS', 'txtStyle_valeur');
         } elseif ($perso->isFaible()) {
             $tpl->set('PA_COLORCLASS', 'txtStyle_risque');
         } else {
             $tpl->set('PA_COLORCLASS', 'txtStyle_critique');
         }
         if ($perso->isAutonome()) {
             $tpl->set('PV_COLORCLASS', 'txtStyle_valeur');
         } elseif ($perso->isConscient()) {
             $tpl->set('PV_COLORCLASS', 'txtStyle_risque');
         } else {
             $tpl->set('PV_COLORCLASS', 'txtStyle_critique');
         }
         if ($perso->isRassasie()) {
             $tpl->set('PN_COLORCLASS', 'txtStyle_valeur');
         } elseif ($perso->isFaim()) {
             $tpl->set('PN_COLORCLASS', 'txtStyle_critique');
         } else {
             $tpl->set('PN_COLORCLASS', 'txtStyle_risque');
         }
         if ($perso->isLege()) {
             $tpl->set('PR_COLORCLASS', 'txtStyle_valeur');
         } else {
             $tpl->set('PR_COLORCLASS', 'txtStyle_risque');
         }
         $tpl->set('PERSO', $perso);
         if ($account->getMemberLevel() != 3) {
             $tpl->set('SHOW_PUB', true);
         }
     } catch (Exception $e) {
         //throw $e;
         return fctErrorMSG('Votre personnage ' . $perso->getNom() . ' est dans un lieu qui semble ne pas exister (' . $e->getMessage() . '). Contactez un MJ via le forum.', '?m=News', null, false);
     }
     //Préparer le menu d'action
     $tpl->set('MENU_ITEMS', $perso->generateActionMenu());
     $code = $tpl->fetch($account->getSkinRemotePhysicalPath() . '/html/Member/menu_actions.htm');
     $tpl->set('PAGE_MENU_ACTIONS', $code);
     //Préparer le he [Entête]
     //$he = new Member_He($account, $perso);
     $from = isset($_GET['hepage']) ? $_GET['hepage'] : 1;
     $tpl->set('HE_PAGE', $from);
     $tpl->set('HE_SIZE', $perso->getHeMsgCount());
     $tpl->set('HE_MAXSPACE', Member_He::spacePerMembership($account->getMemberLevel()));
     $tpl->set('MP', $account->getMemberLevel());
     $tpl->set('HE_MSGPERPAGE', $account->getMsgPerPage());
     $code = $tpl->fetch($account->getSkinRemotePhysicalPath() . '/html/Member/he_header.htm');
     $tpl->set('PAGE_HE_HEADER', $code);
     //Préparer le he [Liste des messages]
     $mpp = $account->getMsgPerPage();
     $heMsg = Member_He::listMessages($perso, ($from - 1) * $mpp, $mpp);
     $code = '';
     $i = $account->getMsgPerPage() + 1;
     foreach ($heMsg as $msg) {
         $tpl->set('MSG', $msg);
         $tpl->set('ITEM_NO_ON_PAGE', --$i);
         $code .= $tpl->fetch($account->getSkinRemotePhysicalPath() . '/html/Member/he_item.htm');
     }
     $tpl->set('PAGE_HE_MESSAGES', $code);
     //Changement de l'action immédiate
     if (isset($_POST['saveActionImmediate'])) {
         $perso->setCurrentAction($_POST['actionImmediate']);
         $tpl->set('actionImmediate', $_POST['actionImmediate']);
     }
     //Retourner le template complété/rempli
     return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/index.htm', __FILE__, __LINE__);
 }