public static function getAllMessage($mediaType, $canalId) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $titreEmission = Member_MediaFactory::getAllEmissionName($mediaType, $canalId); $result = array(); $query = 'SELECT *' . ' FROM `' . DB_PREFIX . 'media`' . ' WHERE `mediaType` = :mediaType' . ' AND `canalId` = :canalId' . ' AND `titre` = :titre' . ' ORDER BY `date` DESC;'; $prep = $db->prepare($query); $prep->bindValue(':mediaType', $mediaType, PDO::PARAM_STR); $prep->bindValue(':canalId', $canalId, PDO::PARAM_INT); foreach ($titreEmission as $titre) { $prep->bindValue(':titre', $titre['titre'], PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); foreach ($arrAll as $arr) { $arr['date'] = fctToGameTime($arr['date']); $arr['message'] = BBCodes($arr['message'], false, true, true); $result[] = $arr; } } $prep->closeCursor(); $prep = NULL; return $result; }
public static function generatePage(&$tpl, &$session, &$account) { $timeNow = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")); $timeNowAff = fctToGameTime($timeNow); $timeFutur = strtotime("+1 month", $timeNow); $timeFuturAff = fctToGameTime($timeFutur); $tpl->set('TIMENOW', $timeNow); $tpl->set('TIMENOWAFF', $timeNowAff); $tpl->set('TIMEFUTUR', $timeFutur); $tpl->set('TIMEFUTURAFF', $timeFuturAff); $transactionArr = array('transaction_id' => 10, 'transaction_compte_from' => '1111-1111', 'transaction_compte_to' => '2222-2222', 'transaction_valeur' => 250, 'transaction_description' => 'description test', 'transaction_date' => $timeNow); $transaction = new Member_BanqueTransactionAuto($transactionArr); $tpl->set('TRANSACTIONARRAY', $transactionArr); $tpl->set('TRANSACTION', $transaction); $transaction2 = new Member_BanqueTransactionAuto($transactionArr); $transaction2->changeCompteIdTo(94); $tpl->set('TRANSACTION2', $transaction2); $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso_fouille'; $prep = $db->prepare($query); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; if (!empty($arr)) { $arr['expiration'] = fctToGameTime($arr['expiration']); } $tpl->set('FOUILLE', $arr); //Retourner le template complété/rempli return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Visitor/test.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //Trouver les PPA associé au MJ $query = 'SELECT m.*, p.nom as perso' . ' FROM ' . DB_PREFIX . 'ppa as m' . ' LEFT JOIN ' . DB_PREFIX . 'perso as p ON (p.id = m.persoid)' . ' WHERE m.mjid=:mjId' . ' AND m.statut="ferme"' . ' ORDER BY m.`date` DESC;'; $prep = $db->prepare($query); $prep->bindValue(':mjId', $mj->getId(), PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $CLOSED_PPA_MJ = array(); if (count($arrAll) > 0) { foreach ($arrAll as &$arr) { $arr['date'] = fctToGameTime($arr['date']); $CLOSED_PPA_MJ[] = $arr; } } $tpl->set('CLOSED_PPA_MJ', $CLOSED_PPA_MJ); echo $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/tabClosedPPA.htm'); die; }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //Lister les sujets $query = 'SELECT p.*, mj.nom as mjnom' . ' FROM ' . DB_PREFIX . 'ppa as p' . ' LEFT JOIN ' . DB_PREFIX . 'mj as mj ON (mj.id = mjid)' . ' WHERE p.persoid=:persoId' . ' ORDER BY p.`statut` ASC, p.`date` DESC' . ' LIMIT 17;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrM = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $query = 'SELECT `date`' . ' FROM ' . DB_PREFIX . 'ppa_reponses' . ' WHERE sujetid=:sujetId' . ' AND mjid!=0' . ' ORDER BY `date` DESC' . ' LIMIT 1;'; $prep = $db->prepare($query); $i = 0; $arrPpa = array(); $ouvertCount = 0; if (count($arrM) != 0) { foreach ($arrM as &$arr) { $arrPpa[$i] = $arr; $arrPpa[$i]['titre'] = stripslashes($arr['titre']); $arrPpa[$i]['date'] = fctToGameTime($arr['date']); if ($arr['mjid'] == 0) { $arrPpa[$i]['mjnom'] = 'aucun'; } else { $arrPpa[$i]['mjnom'] = $arr['mjnom']; } if ($arr['statut'] == 'ouvert') { $ouvertCount++; } //Vérifier la dernière réponse $prep->bindValue(':sujetId', $arr['id'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrRep = $prep->fetch(); $arrPpa[$i]['replyDate'] = $arrRep === false ? 'En attente' : fctToGameTime($arrRep['date']); $i++; } } if (count($arrPpa) > 0) { $tpl->set('PPA', $arrPpa); } if ($ouvertCount < PPA_MAX) { $tpl->set('CAN_POST', true); } return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/contactMj.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $query = 'SELECT compte_banque, compte_compte' . ' FROM ' . DB_PREFIX . 'banque_comptes' . ' WHERE compte_id=:compteId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':compteId', $_GET['id'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; $compte_no = $arr['compte_banque'] . '-' . $arr['compte_compte']; $tpl->set('COMPTE', $compte_no); //Lister toutes les transaction $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'banque_historique' . ' WHERE compte=:compteNo' . ' ORDER BY date ASC;'; $prep = $db->prepare($query); $prep->bindValue(':compteNo', $compte_no, PDO::PARAM_STR); $prep->executePlus($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; if ($arr !== false) { $i = 0; $HISTORIQUE = array(); while ($arr = mysql_fetch_assoc($result)) { $HISTORIQUE[$i]['id'] = $arr['id']; $HISTORIQUE[$i]['date'] = fctToGameTime($arr['date']); //A quelle heure à été envoyé le message ? $HISTORIQUE[$i]['code'] = $arr['code']; $HISTORIQUE[$i]['depot'] = $arr['depot'] == 0 ? '' : fctCreditFormat($arr['depot']); $HISTORIQUE[$i]['retrait'] = $arr['retrait'] == 0 ? '' : fctCreditFormat($arr['retrait']); $HISTORIQUE[$i]['solde'] = fctCreditFormat($arr['solde']); $HISTORIQUE[$i]['vers'] = $arr['compte2']; $i++; } $tpl->set('HISTORIQUE', $HISTORIQUE); } //Retourner le template complété/rempli return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Lieu/BanqueCompteHistorique.htm', __FILE__, __LINE__); }
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'])) { return fctErrorMSG('Données requises manquantes.'); } //Lister les sujets $query = 'SELECT p.*, mj.nom as mjnom' . ' FROM ' . DB_PREFIX . 'ppa as p' . ' LEFT JOIN ' . DB_PREFIX . 'mj as mj ON (mj.id = mjid)' . ' WHERE p.persoid=:persoId' . ' ORDER BY p.`statut` DESC, p.`date` DESC;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $i = 0; $arrPpa = array(); $ouvertCount = 0; if (count($arrAll) > 0) { foreach ($arrAll as &$arr) { $arrPpa[$i] = $arr; $arrPpa[$i]['date'] = fctToGameTime($arr['date']); if ($arr['mjid'] == 0) { $arrPpa[$i]['mjnom'] = 'aucun'; } else { $arrPpa[$i]['mjnom'] = $arr['mjnom']; } if ($arr['statut'] == 'ouvert') { $ouvertCount++; } $i++; } } if (count($arrPpa) > 0) { $tpl->set('PPA', $arrPpa); } return $tpl->fetch($account->getSkinRemotePhysicalPath() . '/html/Mj/Perso/Listppa.htm'); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //BUT: Démarrer un template propre à cette page //Vérifier les paramêtres requis if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } //Valider le # du compte (TODO: REGEX !!!!) if (strlen($_POST['compte']) != 19) { return fctErrorMSG('Ce compte est invalide (no invalide).'); } //Séparer le # de banque $banque_no = substr($_POST['compte'], 0, 4); $compte_no = substr($_POST['compte'], 5, 14); //Passer le # de compte au template $tpl->set('COMPTE', $_POST['compte']); //Rechercher le compte afin d'y faire des opérations. $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'banque_comptes' . ' WHERE compte_banque=:banque' . ' AND compte_compte=:compte' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':compte', $compte_no, PDO::PARAM_STR); $prep->bindValue(':banque', $banque_no, PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; //Valider si le compte existe if ($arr === false) { return fctErrorMSG('Ce compte n\'existe pas (' . $_POST['compte'] . ')'); } //Instancier le compte $compte = new Member_BanqueCompte($arr); //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } //Lister toutes les transaction $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'banque_historique' . ' WHERE compte=:compte' . ' ORDER BY date ASC;'; $prep = $db->prepare($query); $prep->bindValue(':compte', $_POST['compte'], PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); $arrTrs = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; if (count($arrTrs) == 0) { $HISTORIQUE = array(); $i = 0; foreach ($arrTrs as &$arr) { $HISTORIQUE[$i]['id'] = $arr['id']; $HISTORIQUE[$i]['date'] = fctToGameTime($arr['date']); //A quelle heure à été envoyé le message ? $HISTORIQUE[$i]['code'] = $arr['code']; $HISTORIQUE[$i]['depot'] = $arr['depot'] == 0 ? '' : fctCreditFormat($arr['depot']); $HISTORIQUE[$i]['retrait'] = $arr['retrait'] == 0 ? '' : fctCreditFormat($arr['retrait']); $HISTORIQUE[$i]['solde'] = fctCreditFormat($arr['solde']); $i++; } $tpl->set('HISTORIQUE', $HISTORIQUE); } return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique.htm', __FILE__, __LINE__); }
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'])) { return fctErrorMSG('Données requises manquantes.'); } //Trouver les PPA associé au MJ $query = 'SELECT m.*, p.nom as perso' . ' FROM ' . DB_PREFIX . 'ppa as m' . ' LEFT JOIN ' . DB_PREFIX . 'perso as p ON (p.id = m.persoid) ' . ' WHERE m.id=:id' . ' LIMIT 1'; $prep = $db->prepare($query); $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('PPA innexistant ou attribué à un autre MJ.'); } $PPA = array(); $i = 0; //Afficher le message de base (Le PPA) $PPA[$i] = $arr; $PPA[$i]['msg'] = BBCodes(stripslashes($PPA[$i]['msg'])); $PPA[$i]['notemj'] = stripslashes($PPA[$i]['notemj']); $PPA[$i]['datetxt'] = fctToGameTime($arr['date']); $i++; // (( Non-Attribué, ou soi-même ) && Ouvert(non-fermé)) $CanReply = ($PPA[0]['mjid'] == 0 || $PPA[0]['mjid'] == $mj->getId()) && $PPA[0]['statut'] == 'ouvert'; //Sauvegarder le commentaire de base du Ppa if (isset($_POST['save_comment'])) { $query = 'UPDATE ' . DB_PREFIX . 'ppa' . ' SET notemj=:noteMj' . ' WHERE id =:id;'; $prep = $db->prepare($query); $prep->bindValue(':noteMj', htmlspecialchars($_POST['notemjbase']), PDO::PARAM_STR); $prep->bindValue(':id', $_GET['id'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; echo "<script type=\"text/javascript\">location.href='?mj=Perso_Ppa&id=" . $_GET['id'] . "';</script>"; die; } //Sauvegarder l'attribution du PPA if (isset($_POST['save_saisi'])) { $query = 'UPDATE ' . DB_PREFIX . 'ppa' . ' SET mjid=:mjId' . ' WHERE id =:id;'; $prep = $db->prepare($query); $prep->bindValue(':mjId', $_POST['mj'], PDO::PARAM_INT); $prep->bindValue(':id', $_GET['id'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; echo "<script type=\"text/javascript\">location.href='?mj=Perso_Ppa&id=" . $_GET['id'] . "';</script>"; die; } //Ajout d'une réponse ? if (isset($_POST['reply']) && $CanReply) { $query = 'INSERT INTO ' . DB_PREFIX . 'ppa_reponses' . ' (`sujetid`, `mjid`, `date`, `msg`, `notemj`)' . ' VALUES' . ' (:sujetId, :mjId, UNIX_TIMESTAMP(), :msg, :noteMj);'; $prep = $db->prepare($query); $prep->bindValue(':sujetId', $_GET['id'], PDO::PARAM_INT); $prep->bindValue(':mjId', $mj->getId(), PDO::PARAM_INT); $prep->bindValue(':msg', htmlspecialchars($_POST['msg']), PDO::PARAM_STR); $prep->bindValue(':noteMj', htmlspecialchars($_POST['notemj']), PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; Member_He::add($mj->getNom(), $PPA[0]['persoid'], 'ppa', $_POST['msg']); } //Afficher les réponses $query = 'SELECT p.*, mj.nom as mjnom' . ' FROM ' . DB_PREFIX . 'ppa_reponses as p' . ' LEFT JOIN ' . DB_PREFIX . 'mj as mj ON (mj.id = p.mjid)' . ' WHERE p.sujetid=:id' . ' ORDER BY p.`date` ASC;'; $prep = $db->prepare($query); $prep->bindValue(':id', $_GET['id'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; if (count($arrAll) > 0) { foreach ($arrAll as &$arr) { $PPA[$i] = $arr; $PPA[$i]['msg'] = BBCodes(stripslashes($PPA[$i]['msg'])); if (empty($PPA[$i]['notemj'])) { $PPA[$i]['notemj'] = "<i>- aucune note -</i>"; } else { $PPA[$i]['notemj'] = BBCodes(stripslashes($PPA[$i]['notemj'])); } $PPA[$i]['datetxt'] = fctToGameTime($arr['date']); if (empty($arr['mjnom'])) { if ($arr['mjid'] == 0) { $PPA[$i]['mjnom'] = $PPA[0]['perso']; } else { $PPA[$i]['mjnom'] = 'MJ Inconnu'; } } else { $PPA[$i]['mjnom'] = stripslashes($arr['mjnom']); } $i++; } } //Si PPA attribué, vérifier s'il traine (en attente) depuis plus de 3 jours //if($CanReply) //{ $canClose = false; if ($CanReply && $PPA[$i - 1]['date'] <= mktime(0, 0, 0, date('m'), date('d') - 3, date('Y'))) { //$canReply = true; $canClose = true; } //Fermer le PPA si le MJ est autorisé à y répondre if ($canClose && isset($_POST['close'])) { $query = 'UPDATE ' . DB_PREFIX . 'ppa' . ' SET statut="ferme"' . ' WHERE id=:sujetId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':sujetId', $_GET['id'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; header('location:?mj=Perso_Ppa&id=' . (int) $_GET['id']); die; } //} $query = 'SELECT id, nom' . ' FROM ' . DB_PREFIX . 'mj;'; $prep = $db->prepare($query); $prep->execute($db, __FILE__, __LINE__); $MJ = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $tpl->set("MJID", $mj->getId()); $tpl->set("MJ", $MJ); $tpl->set("PPA", $PPA); $tpl->set("CAN_REPLY", $CanReply); $tpl->set("CAN_CLOSE", $canClose); return $tpl->fetch($account->getSkinRemotePhysicalPath() . '/html/Mj/Perso/ppa.htm'); }
public function getDateTxt() { return fctToGameTime($this->date, true); }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //Trouver les PPA associé au MJ $query = 'SELECT m.*, p.nom as perso, r.`date` as rep_date, r.mjid as rep_mj' . ' FROM ' . DB_PREFIX . 'ppa as m' . ' LEFT JOIN ' . DB_PREFIX . 'perso as p ON (p.id = m.persoid)' . ' LEFT JOIN (' . ' SELECT rep.*' . ' FROM (' . ' SELECT *' . ' FROM cc_ppa_reponses' . ' ORDER BY `date` DESC' . ' ) AS rep' . ' GROUP BY rep.sujetid' . ' ) as r ON (r.sujetid=m.id)' . ' WHERE m.mjid=:mjId' . ' AND m.statut="ouvert"' . ' ORDER BY m.`date` DESC;'; $prep = $db->prepare($query); $prep->bindValue(':mjId', $mj->getId(), PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $PPA_MJ = array(); if (count($arrAll) != 0) { $i = 0; foreach ($arrAll as &$arr) { $PPA_MJ[$i] = $arr; $PPA_MJ[$i]['date'] = fctToGameTime($arr['date']); //NULL = pas de réponse //0 = réponse de joueur //>0 = id du MJ de la dernière réponse if ($arr['rep_mj'] != NULL && $arr['rep_mj'] > 0) { //Une réponse du joueur est attendu $PPA_MJ[$i]['replyDate'] = 'Att. du joueur'; } else { //Date de la réponse du joueur $PPA_MJ[$i]['replyDate'] = fctToGameTime($arr['rep_date']); } $i++; } } $tpl->set('PPA_MJ', $PPA_MJ); if ($mj->accessPpa()) { //Trouver les PPA en traitement rapide || traité trop lentement par un MJ $query = 'SELECT m.*, p.nom as perso, r.`date` as rep_date, r.mjid as rep_mj' . ' FROM ' . DB_PREFIX . 'ppa as m' . ' LEFT JOIN ' . DB_PREFIX . 'perso as p ON (p.id = m.persoid)' . ' LEFT JOIN (' . ' SELECT rep.*' . ' FROM (' . ' SELECT *' . ' FROM cc_ppa_reponses' . ' ORDER BY `date` DESC' . ' ) AS rep' . ' GROUP BY rep.sujetid' . ' ) as r ON (r.sujetid=m.id)' . ' WHERE' . ' (' . ' m.mjid=0' . ' OR (' . ' r.`date` <= :time' . ' AND r.mjid = 0' . ' )' . ' )' . ' AND m.statut="ouvert"' . ' ORDER BY m.`date` DESC;'; $prep = $db->prepare($query); $prep->bindValue(':time', time() - mktime(0, 0, 0, 0, 3), PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $PPA = array(); if (count($arrAll) != 0) { $i = 0; foreach ($arrAll as &$arr) { $PPA[$i] = $arr; $PPA[$i]['date'] = fctToGameTime($arr['date']); if ($arr['mjid'] == 0) { //Le PPA n'est pas attribué $PPA[$i]['replyDate'] = 'Non-Attribué...'; } elseif (!empty($arr['rep_date'])) { //La réponse du joueur date de $PPA[$i]['replyDate'] = fctToGameTime($arr['rep_date']); } else { //Aucune réponse encore $PPA[$i]['replyDate'] = 'En Attente...'; } $i++; } } $tpl->set('PPA', $PPA); } echo $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/tabPPA.htm'); die; }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //Vérifier l'état du perso if (!$perso->isAutonome()) { return fctErrorMSG('Votre n\'êtes pas en état d\'effectuer cette action.'); } //Vérifier les paramêtres requis if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } if (!isset($_POST['trsid'])) { return fctErrorMSG('Cette transaction est invalide (aucune transaction).'); } //Valider le # du compte (TODO: REGEX !!!!) if (strlen($_POST['compte']) != 19) { return fctErrorMSG('Ce compte est invalide (no invalide).'); } $banque_no = substr($_POST['compte'], 0, 4); $compte_no = substr($_POST['compte'], 5, 14); $tpl->set('COMPTE', $_POST['compte']); //Chercher le compte afin d'y faire des opérations. $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'banque_comptes' . ' WHERE compte_banque=:banque' . ' AND compte_compte=:compte' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':compte', $compte_no, PDO::PARAM_STR); $prep->bindValue(':banque', $banque_no, PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; //Valider si le compte existe if ($arr === false) { return fctErrorMSG('Ce compte n\'existe pas.'); } //Instancier le compte $compte = new Member_BanqueCompte($arr); //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } //Charger l'historique des transactions $fullCompte = $compte->getNoBanque() . '-' . $compte->getNoCompte(); $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'banque_historique' . ' WHERE compte=:fullCompte' . ' AND id=:id' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':fullCompte', $fullCompte, PDO::PARAM_STR); $prep->bindValue(':id', $_POST['trsid'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; //Valider si la transaction existe if ($arr === false) { return fctErrorMSG('Cette transaction est invalide (transaction innexistante).'); } //Formater les variables $arr['date'] = fctToGameTime($arr['date'], true); $arr['solde'] = fctCreditFormat($arr['solde'], true); //Afficher le template approprié selon le type de transaction switch ($arr['code']) { case 'RETR': $arr['montant'] = fctCreditFormat($arr['retrait']); $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailsdirect.htm', __FILE__, __LINE__); break; case 'DPOT': $arr['montant'] = fctCreditFormat($arr['depot']); $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailsdirect.htm', __FILE__, __LINE__); break; case 'RTRF': $arr['montant'] = fctCreditFormat($arr['depot']); $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailstransfert.htm', __FILE__, __LINE__); break; case 'STRF': $arr['montant'] = fctCreditFormat($arr['retrait']); $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailstransfert.htm', __FILE__, __LINE__); break; default: $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailsnodetails.htm', __FILE__, __LINE__); break; } }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { return fctErrorMSG('Données requises manquantes.'); } //Ajouter un message au PPA if (isset($_POST['form_action']) && ($_POST['form_action'] == 'reply' || $_POST['form_action'] == 'del' && !empty($_POST['msg']))) { $query = 'INSERT INTO ' . DB_PREFIX . 'ppa_reponses' . ' (`sujetid`, `mjid`, `date`, `msg`)' . ' VALUES' . ' (:sujetId, 0, UNIX_TIMESTAMP(), :msg);'; $prep = $db->prepare($query); $prep->bindValue(':sujetId', $_GET['id'], PDO::PARAM_INT); $prep->bindValue(':msg', fctScriptProtect($_POST['msg']), PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); //Copier le message dans les HE Member_He::add($perso->getId(), 'MJ', 'ppa', $_POST['msg']); } //Fermer le PPA if (isset($_POST['form_action']) && $_POST['form_action'] == 'del') { $query = 'UPDATE ' . DB_PREFIX . 'ppa' . ' SET statut="ferme"' . ' WHERE id=:sujetId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':sujetId', $_GET['id'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $tpl->set('PAGE', '?popup=1&m=ContactMj'); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/action_redirect.htm', __FILE__, __LINE__); } //Trouver les PPA demandé $query = 'SELECT m.id, m.msg, m.`date`, m.statut, mj.nom as mjnom' . ' FROM ' . DB_PREFIX . 'ppa as m' . ' LEFT JOIN ' . DB_PREFIX . 'mj as mj ON (mj.id = m.mjid) ' . ' WHERE m.id=:sujetId' . ' AND persoid=:persoId' . ' LIMIT 1'; $prep = $db->prepare($query); $prep->bindValue(':sujetId', $_GET['id'], PDO::PARAM_INT); $prep->bindValue(':persoId', $perso->getId(), PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); if ($arr === false) { return fctErrorMSG('Ppa innexistant.'); } $PPA = array(); $i = 0; //Afficher le message de base (Le PPA) $PPA[$i] = $arr; $PPA[$i]['msg'] = BBCodes(stripslashes($PPA[$i]['msg'])); $PPA[$i]['date'] = fctToGameTime($arr['date']); $PPA[$i]['de'] = $perso->getNom(); $i++; //Afficher les réponses $query = 'SELECT p.*, mj.nom as mjnom' . ' FROM ' . DB_PREFIX . 'ppa_reponses as p' . ' LEFT JOIN ' . DB_PREFIX . 'mj as mj ON (mj.id = p.mjid)' . ' WHERE p.sujetid=:sujetId' . ' ORDER BY p.`date` ASC;'; $prep = $db->prepare($query); $prep->bindValue(':sujetId', $_GET['id'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arrM = $prep->fetchAll(); if (count($arrM) != 0) { foreach ($arrM as $arr) { $PPA[$i] = $arr; $PPA[$i]['msg'] = BBCodes(stripslashes($PPA[$i]['msg'])); $PPA[$i]['date'] = fctToGameTime($arr['date']); if (empty($arr['mjnom'])) { $PPA[$i]['de'] = $perso->getNom(); } else { $PPA[$i]['de'] = stripslashes($arr['mjnom']); } $i++; } } $tpl->set('PPA', $PPA); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/contactMjMod.htm', __FILE__, __LINE__); }
function __construct() { //Établir la connexion MySQL (Temps: 0.002 sec) try { $dbMan = DbManager::getInstance(); $this->db = $dbMan->newConn('game', DB_HOST, DB_USER, DB_PASS, DB_BASE); } catch (Exception $e) { die('Impossible d\'établir la connexion: ' . $e->getMessage()); } //Instancier le compte (Temps: 0.0002 sec) $this->account = new Account(); //Démarrer la session (Temps: 0.0161 sec) $this->session = Session::load(); //Si un utilisateur est défini dans la session, charger le compte associé $userId = $this->session->getVar('userId'); if ($userId !== NULL) { $this->account->loadAccount($userId, $this->session->getVar('logged'), __FILE__, __LINE__); } //Démarrer le système de template (Temps: 0.0008 sec) $this->tpl = new Template($this->account); $this->tpl->set('SKIN_VIRTUAL_PATH', $this->account->getSkinRemoteVirtualPath()); //Chemin root du skin $this->tpl->set('SKIN_ONLINEOFFLINE', $this->account->skinOnlineOffline()); $this->tpl->set('GAME_SESSION_LENGHT', SESSION_TIMEOUT * 60); //Durée en secondes de la session pour le countdown javascript $this->tpl->set('GAME_TIME', fctToGameTime(time())); //Temps affiché dans le jeu $this->tpl->set('GAME_DEVISE', GAME_DEVISE); $this->tpl->set('SITE_CHARSET', SITE_CHARSET); $this->tpl->set('IS_LOGGED', $userId !== NULL ? true : 0); //True si connecté //Trouver le # de la révision SVN $rev = $this->getSvnRevision('revision.txt'); if ($rev !== false) { $this->tpl->set('SITE_REVISION', $rev); } //Charger le contenu demandé $this->tpl->set('PAGE_SOURCE', $this->generatePage()); if (!isset($_GET['popup'])) { //Générer des données de la zone de gauche $this->generateStat(); $this->generateMenu(); //Créer la liste des liens sur les sujets récents du forum if (DB_FORUM_HOST !== NULL) { $arrForumTopic = array(); $LEFTBAR_FORUM = $this->generateForumLink($arrForumTopic); $this->tpl->set('LEFTBAR_FORUM', $LEFTBAR_FORUM); $this->tpl->set('FORUM_RECENT_TOPIC', $arrForumTopic); } $page = $this->account->getSkinRemotePhysicalPath() . 'html/index_full.htm'; } else { $page = $this->account->getSkinRemotePhysicalPath() . 'html/index_lite.htm'; } //Afficher la page global $timerTotal, $memStart; //Afficher la page. $this->tpl->set('QUERY_COUNT', $this->db->getQueryCount()); $this->tpl->set('SQL_GEN_TIME', $this->db->getQueryTime()); $this->tpl->set('MEMORY_USAGE', fctFormatBytes(memory_get_peak_usage())); $this->tpl->set('PAGE_GEN_TIME', round($timerTotal->finish(), 5)); echo $this->tpl->fetch($page, __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $errorUrl1 = '?popup=1&m=Action_Lieu_Guichet'; $errorUrl2 = '?popup=1&m=Action_Lieu_Guichet2'; $errorUrl3 = '?popup=1&m=Action_Lieu_Guichet3historique'; //Vérifier l'état du perso if (!$perso->isAutonome()) { return fctErrorMSG('Votre n\'êtes pas en état d\'effectuer cette action.', $errorUrl1); } //Vérifier si une carte à été sélectionnée if (!isset($_POST['carteid'])) { return fctErrorMSG('Aucune carte sélectionnée.', $errorUrl1); } //Valider si le NIP a été saisi if (!isset($_POST['nip'])) { return fctErrorMSG('Aucun NIP spécifiée.', $errorUrl2, array('carteid' => $_POST['carteid'])); } if (!isset($_POST['trsid'])) { return fctErrorMSG('Transaction invalide (1).', $errorUrl3, array('carteid' => $_POST['carteid'], 'nip' => $_POST['nip'])); } //Créer la carte + compte $query = 'SELECT *' . ' FROM `' . DB_PREFIX . 'banque_cartes`' . ' LEFT JOIN `' . DB_PREFIX . 'banque_comptes` ON (`compte_banque` = `carte_banque` AND `compte_compte` = `carte_compte`)' . ' WHERE `carte_id` = :carteId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':carteId', $_POST['carteid'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; //Valider si la carte existe dans la base de données if ($arr === false) { fctBugReport('Cette carte n\'existe pas', array('perso' => $perso, 'query' => $query), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); } //Créer le compte bancaire $compte = new Member_BanqueCompte($arr); //Créer la carte $carte = $compte->getCarte($_POST['carteid'], $arr); //Valider si la carte est active ou non if (!$carte->isValid()) { return fctErrorMSG('Cette carte à été désactivée.', $errorUrl1); } //Valider le NIP if ($carte->getNip() != $_POST['nip']) { return fctErrorMSG('NIP invalide.', $errorUrl2, array('carteid' => $_POST['carteid'])); } //Charger l'historique des transactions $noCompte = $compte->getNoBanque() . '-' . $compte->getNoCompte(); $query = 'SELECT * ' . ' FROM `' . DB_PREFIX . 'banque_historique`' . ' WHERE `compte`=:noCompte' . ' AND `id`=:id;'; $prep = $db->prepare($query); $prep->bindValue(':noCompte', $noCompte, PDO::PARAM_STR); $prep->bindValue(':id', $_POST['trsid'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; //Valider si la transaction existe dans la base de données if ($arr === false) { return fctErrorMSG('Transaction invalide (2).', $errorUrl3, array('carteid' => $_POST['carteid'], 'nip' => $_POST['nip'])); } //Récolter et formater les informations relative à la transaction $arr['date'] = fctToGameTime($arr['date'], false, true); $arr['solde'] = fctCreditFormat($arr['solde'], true); //Passer les informations au template $tpl->set('CARD_ID', $_POST['carteid']); $tpl->set('NIP', $_POST['nip']); $tpl->set('COMPTE', $compte->getNoBanque() . '-' . $compte->getNoCompte()); //Afficher la page adéquate selon le type de transaction switch ($arr['code']) { case "RETR": $arr['montant'] = fctCreditFormat($arr['retrait']); $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailsdirect.htm', __FILE__, __LINE__); break; case "DPOT": $arr['montant'] = fctCreditFormat($arr['depot']); $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailsdirect.htm', __FILE__, __LINE__); break; case "RTRF": $arr['montant'] = fctCreditFormat($arr['depot']); $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailstransfert.htm', __FILE__, __LINE__); break; case "STRF": $arr['montant'] = fctCreditFormat($arr['retrait']); $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailstransfert.htm', __FILE__, __LINE__); break; default: $tpl->set('TRANSACTION', $arr); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique_detailsnodetails.htm', __FILE__, __LINE__); break; } }
/** * Récupère l'historique des transactions de la boutique du lieu. * L'historique est sous forme de tableau de transactions. Chaque transaction * est représentée par son "id" et son "details". * * Fonctionne pour le lieu actuel. * * @return mixed|null retourne l'historique ou null si aucun historique */ public function getBoutiqueHistorique() { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $transactionType = array('ACH' => 'achat', 'VEN' => 'vente', 'DEP' => 'depot', 'RET' => 'retrait'); $query = 'SELECT * FROM `' . DB_PREFIX . 'boutiques_historiques`' . ' WHERE `boutiqueid` = :boutiqueid' . ' ORDER BY `date` DESC;'; $prep = $db->prepare($query); $prep->bindValue(':boutiqueid', $this->id, PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; if (count($arrAll) != 0) { $result = array(); $i = 0; foreach ($arrAll as $arr) { $result[$i]['id'] = $arr['id']; $result[$i]['details'] = fctToGameTime($arr['date'], true) . ' ' . $transactionType[$arr['transactiontype']] . ' de '; if ($arr['transactiontype'] == 'ACH' || $arr['transactiontype'] == 'VEN') { $result[$i]['details'] .= $arr['itemlist']; if ($arr['marchandage']) { $result[$i]['details'] .= ' avec un rabais'; } else { $result[$i]['details'] .= ' à prix régulier'; } $result[$i]['details'] .= ' : '; if ($arr['moyenpaiement']) { $result[$i]['details'] .= ' par carte bancaire '; } else { $result[$i]['details'] .= ' comptant '; } $result[$i]['details'] .= ' : '; } $result[$i]['details'] .= $arr['prixtotal'] . ' ' . GAME_DEVISE . '.'; $result[$i]['details'] = BBCodes($result[$i]['details']); $i++; } return $result; } return null; }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $errorUrl1 = '?popup=1&m=Action_Lieu_Guichet'; $errorUrl2 = '?popup=1&m=Action_Lieu_Guichet2'; //Vérifier l'état du perso if (!$perso->isAutonome()) { return fctErrorMSG('Votre n\'êtes pas en état d\'effectuer cette action.', $errorUrl1); } //Vérifier si une carte à été sélectionnée if (!isset($_POST['carteid'])) { return fctErrorMSG('Aucune carte sélectionnée.', $errorUrl1); } //Valider si le NIP a été saisi if (!isset($_POST['nip'])) { return fctErrorMSG('Aucun NIP spécifiée.', $errorUrl2, array('carteid' => $_POST['carteid'])); } //Créer la carte + compte $query = 'SELECT *' . ' FROM `' . DB_PREFIX . 'banque_cartes`' . ' LEFT JOIN `' . DB_PREFIX . 'banque_comptes` ON (`compte_banque` = `carte_banque` AND `compte_compte` = `carte_compte`)' . ' WHERE `carte_id` = :carteId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':carteId', $_POST['carteid'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; //Valider si la carte existe if ($arr === false) { fctBugReport('Cette carte n\'existe pas', array('perso' => $perso, 'query' => $query), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); } //Créer le compte bancaire $compte = new Member_BanqueCompte($arr); //Créer la carte $carte = $compte->getCarte($_POST['carteid'], $arr); //Valider si la carte est active ou non if (!$carte->isValid()) { return fctErrorMSG('Cette carte à été désactivée.', $errorUrl1); } //Valider le NIP if ($carte->getNip() != $_POST['nip']) { return fctErrorMSG('NIP invalide.', $errorUrl2, array('carteid' => $_POST['carteid'])); } //Charger l'historique des transactions $compteNo = $compte->getNoBanque() . '-' . $compte->getNoCompte(); $query = 'SELECT *' . ' FROM `' . DB_PREFIX . 'banque_historique`' . ' WHERE `compte`=:noCompte;'; $prep = $db->prepare($query); $prep->bindValue(':noCompte', $compteNo, PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; //Générer la liste de toutes les transactions et formater les données $historique = array(); foreach ($arrAll as &$arr) { $arr['date'] = fctToGameTime($arr['date']); $arr['retrait'] = fctCreditFormat($arr['retrait'], true); $arr['depot'] = fctCreditFormat($arr['depot'], true); $arr['solde'] = fctCreditFormat($arr['solde'], true); $historique[] = $arr; } //Passer les informations sur l'accès au template $tpl->set('COMPTE', $compte->getNoBanque() . '-' . $compte->getNoCompte()); $tpl->set('CARD_ID', $_POST['carteid']); $tpl->set('NIP', $_POST['nip']); $tpl->set('HISTORIQUE', $historique); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_historique.htm', __FILE__, __LINE__); }