public static function delete($userId) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante //Suppression de tous les perso du compte $query = 'SELECT id' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE userId=:id;'; $prep = $db->prepare($query); $prep->bindValue(':id', $userId, PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $arr = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; foreach ($arr as &$perso) { Mj_Perso_Del::delete($perso['id']); } //suppression du compte $query = 'DELETE FROM ' . DB_PREFIX . 'account' . ' WHERE id=:id' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':id', $userId, PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; }
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']) || !isset($_POST['yes'])) { return fctErrorMSG('Données requises manquantes. (cheat)'); } if ($session->getVar('persoId') == $_GET['id']) { $session->setVar('persoId', NULL); } //Trouver les informations sur le perso / Valider s'il est authorisé à être modifié $query = 'SELECT id' . ' FROM ' . DB_PREFIX . 'perso' . ' WHERE id=:persoId' . ' AND userid=:userId' . ' AND inscription_valide="mod"' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue(':persoId', $_GET['id'], PDO::PARAM_INT); $prep->bindValue(':userId', $account->getId(), 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, ne vous appartiend pas, ou n\'est pas en phase de refus. (cheat)'); } //Apeller la fonction qui gère la suppression de perso. Mj_Perso_Del::delete($_GET['id'], $account->getUser()); //Augmenter 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->executePlus($db, __FILE__, __LINE__); //Retourner le template complété/rempli $tpl->set('PAGE', 'News'); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/redirect.htm', __FILE__, __LINE__); }
private static function doInscription(&$tpl, &$account, &$mj) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $query = 'SELECT p.*, a.email, a.id as aid' . ' FROM ' . DB_PREFIX . 'perso as p' . ' LEFT JOIN ' . DB_PREFIX . 'account as a ON (a.id=p.userId)' . ' WHERE p.inscription_valide="0";'; $prep = $db->prepare($query); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; foreach ($arrAll as &$arrInscr) { //Accepter l'inscription if ($_POST['inscr_' . $arrInscr['id']] == 'ok') { //Activer le perso $query = 'UPDATE ' . DB_PREFIX . 'perso' . ' SET `inscription_valide`="1",' . ' `pa` = `pamax`,' . ' `lieu`=:lieu_depart' . ' WHERE id = :id' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue('id', $arrInscr['id']); $prep->bindValue('lieu_depart', LIEU_DEPART); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; //Ajouter le message d'accueil dans le HE $query = 'SELECT db_param' . ' FROM ' . DB_PREFIX . 'item_db' . ' WHERE db_id=9' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->executePlus($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; Member_He::add('Douanier', $arrInscr['id'], 'msg', stripslashes($arr['db_param'])); //Ajouter&equiper les items de bienvenu $query = 'SELECT db_id, db_resistance' . ' FROM `' . DB_PREFIX . 'item_db`' . ' WHERE `db_id` IN(309, 310, 311);'; $prep = $db->prepare($query); $prep->executePlus($db, __FILE__, __LINE__); $arrAll = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; $query = 'INSERT INTO `' . DB_PREFIX . 'item_inv`' . ' (`inv_id`, `inv_dbid`, `inv_persoid`,' . ' `inv_equip`,`inv_qte`, `inv_resistance`)' . ' VALUES' . ' (' . ' NULL, :db_id, :persoId,' . ' "1", 1, :resistance' . ' );'; $prep = $db->prepare($query); foreach ($arrAll as &$arr) { $prep->bindValue('db_id', $arr['db_id'], PDO::PARAM_INT); $prep->bindValue('persoId', $arrInscr['id'], PDO::PARAM_INT); $prep->bindValue('resistance', $arr['db_resistance'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); } $prep->closeCursor(); $prep = NULL; //Envoie du email : $tpl->set('COMMENTAIRE', $_POST['inscr_commentaire_' . $arrInscr['id']]); $tpl->set('MJ_EMAIL', $mj->getEmail()); $MSG = $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/emailPersoAccepte.htm', __FILE__, __LINE__); mail($arrInscr['email'], "Cybercity 2034", $MSG, "From: robot@cybercity2034.com\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1\n"); } //Refuser l'inscription if ($_POST['inscr_' . $arrInscr['id']] == 'mod') { //Rendre le perso modifiable $query = 'UPDATE ' . DB_PREFIX . 'perso' . ' SET inscription_valide="mod"' . ' WHERE id = :persoId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue('persoId', $arrInscr['id'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; //Ajouter un message dans le HE (qui sera affiché en haut de la page de modification Member_He::add($mj->getNom(), $arrInscr['id'], 'inscription', $_POST['inscr_commentaire_' . $arrInscr['id']]); //Envoie du email : $tpl->set('COMMENTAIRE', $_POST['inscr_commentaire_' . $arrInscr['id']]); $tpl->set('MJ_EMAIL', $mj->getEmail()); $MSG = $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/emailPersoRefuse.htm', __FILE__, __LINE__); mail($arrInscr['email'], "Cybercity 2034", $MSG, "From: robot@cybercity2034.com\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1\n"); } //Supprimer l'inscription if ($_POST['inscr_' . $arrInscr['id']] == 'suppr') { //Supprimer le perso Mj_Perso_Del::delete($arrInscr['id'], $mj->getNom()); //Redonner la chance d'effectuer une inscription $query = 'UPDATE ' . DB_PREFIX . 'account' . ' SET auth_creation_perso= auth_creation_perso+1' . ' WHERE id=:accountId' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue('accountId', $arrInscr['aid'], PDO::PARAM_INT); $prep->executePlus($db, __FILE__, __LINE__); $prep->closeCursor(); $prep = NULL; //Envoie du email : $tpl->set('COMMENTAIRE', $_POST['inscr_commentaire_' . $arrInscr['id']]); $tpl->set('MJ_EMAIL', $mj->getEmail()); $MSG = $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/emailPersoSupprime.htm', __FILE__, __LINE__); mail($arrInscr['email'], "Cybercity 2034", $MSG, "From: robot@cybercity2034.com\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=utf-8\n"); } } }
public static function go(&$account) { $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante $nextnow = mktime(date("H") - INNACTIVITE_TELEPORT_DELAY, date("i"), date("s"), date("m"), date("d"), date("Y")); $delExpir = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - INNACTIVITE_DELETE_DELAY, date("Y")); try { //Trouver les innactifs $query = 'SELECT p.id' . ' FROM ' . DB_PREFIX . 'perso as p, ' . DB_PREFIX . 'account as a' . ' WHERE a.last_conn<:expiration' . ' AND p.userId = a.id' . ' AND p.lieu!=:lieu' . ' AND p.lieu!=:lieuVac' . ' LIMIT 5;'; $prep = $db->prepare($query); $prep->bindValue('expiration', $nextnow, PDO::PARAM_INT); $prep->bindValue('lieu', INNACTIVITE_TELEPORT_LOCATION, PDO::PARAM_STR); $prep->bindValue('lieuVac', INNACTIVITE_VOLUNTARY_LOCATION, PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); $arrPerso = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; if (count($arrPerso) == 0) { return; } //Ne pas essayer de supprimer des perso, on le fera au prochain innactif $query = 'UPDATE ' . DB_PREFIX . 'perso' . ' SET lieu=:lieu' . ' WHERE id=:persoId;'; $prep = $db->prepare($query); foreach ($arrPerso as &$id) { $id = (int) $id[0]; //Téléporter les innactifs $prep->bindValue('lieu', INNACTIVITE_TELEPORT_LOCATION, PDO::PARAM_STR); $prep->bindValue('persoId', $id, PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); Member_He::add('System', $id, 'innact', 'Votre personnage a été téléporté pour inactivité.'); } $prep->closeCursor(); $prep = NULL; } catch (Exception $e) { fctBugReport('Erreur', $e->getMessage(), __FILE__, __LINE__); } try { //Trouver les trop innactifs (les supprimer) $query = 'SELECT p.id, p.nom, a.email' . ' FROM ' . DB_PREFIX . 'perso as p, ' . DB_PREFIX . 'account as a' . ' WHERE a.last_conn<:expiration' . ' AND p.userId = a.id' . ' AND p.lieu != :lieuVac' . ' LIMIT 1;'; $prep = $db->prepare($query); $prep->bindValue('expiration', $delExpir, PDO::PARAM_INT); $prep->bindValue('lieuVac', INNACTIVITE_VOLUNTARY_LOCATION, PDO::PARAM_STR); $prep->execute($db, __FILE__, __LINE__); $arrPerso = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; if (count($arrPerso) == 0) { return; } //Ne pas essayer de supprimer des perso, on le fera au prochain innactif foreach ($arrPerso as &$arr) { //Apeller la fonction qui gère la suppression de perso. Mj_Perso_Del::delete($arr['id'], 'system'); $tpl = new Template($account); //Envoyer un email de bye bye $tpl->set('PERSO_NOM', stripslashes($arr['nom'])); $MSG = $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Visitor/innactivite_email.htm', __FILE__, __LINE__); $ret = @mail($arr['email'], "Cybercity 2034 - Suppression", $MSG, "From: robot@cybercity2034.com\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=utf-8\n"); } } catch (Exception $e) { fctBugReport('Erreur', $e->getMessage(), __FILE__, __LINE__); } }